add version guard and add network option to testConfig

This commit is contained in:
Jon Fu 2022-09-14 13:15:24 -07:00
parent 0f78f748f9
commit a7956f42a4
8 changed files with 82 additions and 8 deletions

View File

@ -290,6 +290,22 @@ if(NOT WIN32)
@LOG_DIR@ @LOG_DIR@
) )
add_fdbclient_test(
NAME fdb_c_api_tests_local_only
DISABLE_LOG_DUMP
COMMAND ${CMAKE_SOURCE_DIR}/bindings/c/test/apitester/run_c_api_tests.py
--cluster-file
@CLUSTER_FILE@
--tester-binary
$<TARGET_FILE:fdb_c_api_tester>
--test-dir
${CMAKE_SOURCE_DIR}/bindings/c/test/apitester/local_tests
--tmp-dir
@TMP_DIR@
--log-dir
@LOG_DIR@
)
add_fdbclient_test( add_fdbclient_test(
NAME fdb_c_api_tests_blob_granule NAME fdb_c_api_tests_blob_granule
DISABLE_LOG_DUMP DISABLE_LOG_DUMP

View File

@ -0,0 +1,28 @@
[[test]]
title = 'API Correctness Single Threaded'
minClients = 1
maxClients = 3
minDatabases = 1
maxDatabases = 3
multiThreaded = false
[[test.workload]]
name = 'ApiCorrectness'
minKeyLength = 1
maxKeyLength = 64
minValueLength = 1
maxValueLength = 1000
maxKeysPerTransaction = 50
initialSize = 100
numRandomOperations = 100
readExistingKeysRatio = 0.9
[[test.workload]]
name = 'AtomicOpsCorrectness'
initialSize = 0
numRandomOperations = 100
[[test.workload]]
name = 'WatchAndWait'
initialSize = 0
numRandomOperations = 10

View File

@ -2456,6 +2456,9 @@ void MultiVersionApi::setNetworkOptionInternal(FDBNetworkOptions::Option option,
} else if (option == FDBNetworkOptions::DISABLE_CLIENT_BYPASS) { } else if (option == FDBNetworkOptions::DISABLE_CLIENT_BYPASS) {
MutexHolder holder(lock); MutexHolder holder(lock);
ASSERT(!value.present() && !networkStartSetup); ASSERT(!value.present() && !networkStartSetup);
if (bypassMultiClientApi) {
throw invalid_option();
}
disableBypass = true; disableBypass = true;
bypassMultiClientApi = false; bypassMultiClientApi = false;
forwardOption = true; forwardOption = true;

View File

@ -2496,12 +2496,13 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
} }
break; break;
} }
case FDBNetworkOptions::DISABLE_CLIENT_BYPASS:
networkOptions.disableBypass = true;
break;
case FDBNetworkOptions::EXTERNAL_CLIENT: case FDBNetworkOptions::EXTERNAL_CLIENT:
networkOptions.primaryClient = false; networkOptions.primaryClient = false;
break; break;
case FDBNetworkOptions::DISABLE_CLIENT_BYPASS:
validateOptionValueNotPresent(value);
networkOptions.disableBypass = true;
break;
default: default:
break; break;
} }
@ -6671,6 +6672,9 @@ void Transaction::setOption(FDBTransactionOptions::Option option, Optional<Strin
case FDBTransactionOptions::USE_GRV_CACHE: case FDBTransactionOptions::USE_GRV_CACHE:
validateOptionValueNotPresent(value); validateOptionValueNotPresent(value);
if (apiVersionAtLeast(720) && !networkOptions.disableBypass) {
throw invalid_option();
}
if (trState->numErrors == 0) { if (trState->numErrors == 0) {
trState->options.useGrvCache = true; trState->options.useGrvCache = true;
} }
@ -8768,7 +8772,6 @@ void sharedStateDelRef(DatabaseSharedState* ssPtr) {
} }
Future<DatabaseSharedState*> DatabaseContext::initSharedState() { Future<DatabaseSharedState*> DatabaseContext::initSharedState() {
ASSERT(networkOptions.disableBypass);
ASSERT(!sharedStatePtr); // Don't re-initialize shared state if a pointer already exists ASSERT(!sharedStatePtr); // Don't re-initialize shared state if a pointer already exists
DatabaseSharedState* newState = new DatabaseSharedState(); DatabaseSharedState* newState = new DatabaseSharedState();
// Increment refcount by 1 on creation to account for the one held in MultiVersionApi map // Increment refcount by 1 on creation to account for the one held in MultiVersionApi map
@ -8780,7 +8783,6 @@ Future<DatabaseSharedState*> DatabaseContext::initSharedState() {
} }
void DatabaseContext::setSharedState(DatabaseSharedState* p) { void DatabaseContext::setSharedState(DatabaseSharedState* p) {
ASSERT(networkOptions.disableBypass);
ASSERT(p->protocolVersion == currentProtocolVersion()); ASSERT(p->protocolVersion == currentProtocolVersion());
sharedStatePtr = p; sharedStatePtr = p;
sharedStatePtr->refCount++; sharedStatePtr->refCount++;

View File

@ -127,7 +127,7 @@ description is not currently required but encouraged.
<Option name="enable_run_loop_profiling" code="71" <Option name="enable_run_loop_profiling" code="71"
description="Enables debugging feature to perform run loop profiling. Requires trace logging to be enabled. WARNING: this feature is not recommended for use in production." /> description="Enables debugging feature to perform run loop profiling. Requires trace logging to be enabled. WARNING: this feature is not recommended for use in production." />
<Option name="disable_client_bypass" code="72" <Option name="disable_client_bypass" code="72"
description="This option makes it so that the multi-version API cannot be bypassed on the primary client."/> description="Prevents the multi-version client API from being disabled, even if no external clients are configured. This option is required to use GRV caching."/>
<Option name="client_buggify_enable" code="80" <Option name="client_buggify_enable" code="80"
description="Enable client buggify - will make requests randomly fail (intended for client testing)" /> description="Enable client buggify - will make requests randomly fail (intended for client testing)" />
<Option name="client_buggify_disable" code="81" <Option name="client_buggify_disable" code="81"
@ -305,7 +305,7 @@ description is not currently required but encouraged.
<Option name="bypass_unreadable" code="1100" <Option name="bypass_unreadable" code="1100"
description="Allows ``get`` operations to read from sections of keyspace that have become unreadable because of versionstamp operations. These reads will view versionstamp operations as if they were set operations that did not fill in the versionstamp." /> description="Allows ``get`` operations to read from sections of keyspace that have become unreadable because of versionstamp operations. These reads will view versionstamp operations as if they were set operations that did not fill in the versionstamp." />
<Option name="use_grv_cache" code="1101" <Option name="use_grv_cache" code="1101"
description="Allows this transaction to use cached GRV from the database context. Defaults to off. Upon first usage, starts a background updater to periodically update the cache to avoid stale read versions." /> description="Allows this transaction to use cached GRV from the database context. Defaults to off. Upon first usage, starts a background updater to periodically update the cache to avoid stale read versions. The disable_client_bypass option must also be set." />
<Option name="skip_grv_cache" code="1102" <Option name="skip_grv_cache" code="1102"
description="Specifically instruct this transaction to NOT use cached GRV. Primarily used for the read version cache's background updater to avoid attempting to read a cached entry in specific situations." description="Specifically instruct this transaction to NOT use cached GRV. Primarily used for the read version cache's background updater to avoid attempting to read a cached entry in specific situations."
hidden="true"/> hidden="true"/>

View File

@ -274,6 +274,9 @@ class TestConfig {
if (attrib == "disableEncryption") { if (attrib == "disableEncryption") {
disableEncryption = strcmp(value.c_str(), "true") == 0; disableEncryption = strcmp(value.c_str(), "true") == 0;
} }
if (attrib == "disableClientBypass") {
disableClientBypass = strcmp(value.c_str(), "true") == 0;
}
if (attrib == "restartInfoLocation") { if (attrib == "restartInfoLocation") {
isFirstTestInRestart = true; isFirstTestInRestart = true;
} }
@ -334,6 +337,8 @@ public:
// Set the maximum TLog version that can be selected for a test // Set the maximum TLog version that can be selected for a test
// Refer to FDBTypes.h::TLogVersion. Defaults to the maximum supported version. // Refer to FDBTypes.h::TLogVersion. Defaults to the maximum supported version.
int maxTLogVersion = TLogVersion::MAX_SUPPORTED; int maxTLogVersion = TLogVersion::MAX_SUPPORTED;
// Disable bypassing multi-version client API. Required for use_grv_cache
bool disableClientBypass = false;
// Set true to simplify simulation configs for easier debugging // Set true to simplify simulation configs for easier debugging
bool simpleConfig = false; bool simpleConfig = false;
int extraMachineCountDC = 0; int extraMachineCountDC = 0;
@ -393,6 +398,7 @@ public:
.add("disableHostname", &disableHostname) .add("disableHostname", &disableHostname)
.add("disableRemoteKVS", &disableRemoteKVS) .add("disableRemoteKVS", &disableRemoteKVS)
.add("disableEncryption", &disableEncryption) .add("disableEncryption", &disableEncryption)
.add("disableClientBypass", &disableClientBypass)
.add("simpleConfig", &simpleConfig) .add("simpleConfig", &simpleConfig)
.add("generateFearless", &generateFearless) .add("generateFearless", &generateFearless)
.add("datacenters", &datacenters) .add("datacenters", &datacenters)
@ -1150,6 +1156,10 @@ ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActor
g_knobs.setKnob("enable_blob_granule_encryption", KnobValueRef::create(bool{ false })); g_knobs.setKnob("enable_blob_granule_encryption", KnobValueRef::create(bool{ false }));
TraceEvent(SevDebug, "DisableEncryption"); TraceEvent(SevDebug, "DisableEncryption");
} }
if (testConfig.disableClientBypass) {
setNetworkOption(FDBNetworkOptions::DISABLE_CLIENT_BYPASS);
TraceEvent(SevDebug, "DisableClientBypass");
}
*pConnString = conn; *pConnString = conn;
*pTesterCount = testerCount; *pTesterCount = testerCount;
bool usingSSL = conn.toString().find(":tls") != std::string::npos || listenersPerProcess > 1; bool usingSSL = conn.toString().find(":tls") != std::string::npos || listenersPerProcess > 1;
@ -1934,6 +1944,10 @@ void setupSimulatedSystem(std::vector<Future<Void>>* systemActors,
g_knobs.setKnob("enable_blob_granule_encryption", KnobValueRef::create(bool{ false })); g_knobs.setKnob("enable_blob_granule_encryption", KnobValueRef::create(bool{ false }));
TraceEvent(SevDebug, "DisableEncryption"); TraceEvent(SevDebug, "DisableEncryption");
} }
if (testConfig.disableClientBypass) {
setNetworkOption(FDBNetworkOptions::DISABLE_CLIENT_BYPASS);
TraceEvent(SevDebug, "DisableClientBypass");
}
auto configDBType = testConfig.getConfigDBType(); auto configDBType = testConfig.getConfigDBType();
for (auto kv : startingConfigJSON) { for (auto kv : startingConfigJSON) {
if ("tss_storage_engine" == kv.first) { if ("tss_storage_engine" == kv.first) {

View File

@ -1184,7 +1184,15 @@ std::map<std::string, std::function<void(const std::string&)>> testSpecGlobalKey
{ "disableRemoteKVS", { "disableRemoteKVS",
[](const std::string& value) { TraceEvent("TestParserTest").detail("ParsedRemoteKVS", ""); } }, [](const std::string& value) { TraceEvent("TestParserTest").detail("ParsedRemoteKVS", ""); } },
{ "disableEncryption", { "disableEncryption",
[](const std::string& value) { TraceEvent("TestParserTest").detail("ParsedRemoteKVS", ""); } } [](const std::string& value) { TraceEvent("TestParserTest").detail("ParsedRemoteKVS", ""); } },
{ "disableClientBypass",
[](const std::string& value) {
if (value == "true") {
setNetworkOption(FDBNetworkOptions::DISABLE_CLIENT_BYPASS);
}
// else { } It is disabled by default for tester
TraceEvent("TestParserTest").detail("ParsedDisableClientBypass", "");
} }
}; };
std::map<std::string, std::function<void(const std::string& value, TestSpec* spec)>> testSpecTestKeys = { std::map<std::string, std::function<void(const std::string& value, TestSpec* spec)>> testSpecTestKeys = {

View File

@ -1,3 +1,6 @@
[configuration]
disableClientBypass=true
[[test]] [[test]]
testTitle = 'SingleClientCausalConsistencyTest' testTitle = 'SingleClientCausalConsistencyTest'