| 929 | } |
| 930 | |
| 931 | int testReplication() { |
| 932 | const char* testTotalEnv = getenv("REPLICATION_TESTTOTAL"); |
| 933 | const char* debugLevelEnv = getenv("REPLICATION_DEBUGLEVEL"); |
| 934 | const char* policyTotalEnv = getenv("REPLICATION_POLICYTOTAL"); |
| 935 | const char* policyIndexEnv = getenv("REPLICATION_POLICYINDEX"); |
| 936 | const char* reportCacheEnv = getenv("REPLICATION_REPORTCACHE"); |
| 937 | const char* stopOnErrorEnv = getenv("REPLICATION_STOPONERROR"); |
| 938 | const char* skipTotalEnv = getenv("REPLICATION_SKIPTOTAL"); |
| 939 | const char* validateEnv = getenv("REPLICATION_VALIDATE"); |
| 940 | const char* findBestEnv = getenv("REPLICATION_FINDBEST"); |
| 941 | const char* rateSampleEnv = getenv("REPLICATION_RATESAMPLE"); |
| 942 | const char* policySampleEnv = getenv("REPLICATION_POLICYSAMPLE"); |
| 943 | const char* policyMinEnv = getenv("REPLICATION_POLICYEXTRA"); |
| 944 | int totalTests = testTotalEnv ? atoi(testTotalEnv) : 10000; |
| 945 | int skipTotal = skipTotalEnv ? atoi(skipTotalEnv) : 0; |
| 946 | int findBest = findBestEnv ? atoi(findBestEnv) : 0; |
| 947 | int policyIndexStatic = policyIndexEnv ? atoi(policyIndexEnv) : -1; |
| 948 | int policyTotal = policyTotalEnv ? atoi(policyTotalEnv) : 100; |
| 949 | bool stopOnError = stopOnErrorEnv ? (atoi(stopOnErrorEnv) > 0) : false; |
| 950 | bool validate = validateEnv ? (atoi(validateEnv) > 0) : true; |
| 951 | int rateSample = rateSampleEnv ? atoi(rateSampleEnv) : 1000; |
| 952 | int policySample = policySampleEnv ? atoi(policySampleEnv) : 100; |
| 953 | int policyMin = policyMinEnv ? atoi(policyMinEnv) : 2; |
| 954 | int policyIndex, testCounter, alsoSize, debugBackup, maxAlsoSize; |
| 955 | std::vector<repTestType> serverIndexes; |
| 956 | Reference<LocalitySet> testServers; |
| 957 | std::vector<Reference<IReplicationPolicy>> policies; |
| 958 | std::vector<LocalityEntry> alsoServers, bestSet; |
| 959 | int totalErrors = 0; |
| 960 | |
| 961 | if (debugLevelEnv) |
| 962 | g_replicationdebug = atoi(debugLevelEnv); |
| 963 | debugBackup = g_replicationdebug; |
| 964 | |
| 965 | testServers = createTestLocalityMap(serverIndexes, |
| 966 | deterministicRandom()->randomInt(1, 5), |
| 967 | deterministicRandom()->randomInt(1, 6), |
| 968 | deterministicRandom()->randomInt(1, 10), |
| 969 | deterministicRandom()->randomInt(1, 10), |
| 970 | deterministicRandom()->randomInt(0, 4), |
| 971 | deterministicRandom()->randomInt(1, 5)); |
| 972 | maxAlsoSize = testServers->size() / deterministicRandom()->randomInt(2, 20); |
| 973 | |
| 974 | if (g_replicationdebug >= 0) |
| 975 | printf("Running %d Replication test\n", totalTests); |
| 976 | |
| 977 | if ((!policyIndexEnv) || (policyIndexStatic >= 0)) { |
| 978 | policies = getStaticPolicies(); |
| 979 | } else { |
| 980 | if (g_replicationdebug > 0) |
| 981 | printf("Creating %3d random policies.\n", policyTotal); |
| 982 | policies.reserve(policyTotal); |
| 983 | for (auto i = 0; i < policyTotal; i++) { |
| 984 | if (g_replicationdebug > 0) |
| 985 | printf(" (%3d) ", i + 1); |
| 986 | policies.push_back(randomAcrossPolicy(*testServers)); |
| 987 | } |
| 988 | } |
no test coverage detected