2021-05-14 02:22:25 +08:00
|
|
|
/*
|
2021-06-03 13:14:58 +08:00
|
|
|
* ConfigDatabaseUnitTests.actor.cpp
|
2021-05-14 02:22:25 +08:00
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fdbclient/CoordinationInterface.h"
|
2021-05-18 06:31:03 +08:00
|
|
|
#include "fdbclient/IConfigTransaction.h"
|
2021-06-10 11:50:00 +08:00
|
|
|
#include "fdbclient/TestKnobCollection.h"
|
2021-05-14 02:22:25 +08:00
|
|
|
#include "fdbserver/ConfigBroadcaster.h"
|
2021-07-19 09:25:06 +08:00
|
|
|
#include "fdbserver/ConfigNode.h"
|
2021-05-14 02:22:25 +08:00
|
|
|
#include "fdbserver/LocalConfiguration.h"
|
|
|
|
#include "fdbclient/Tuple.h"
|
|
|
|
#include "flow/UnitTest.h"
|
|
|
|
#include "flow/actorcompiler.h" // must be last include
|
|
|
|
|
2021-08-06 09:50:11 +08:00
|
|
|
/*
|
2021-05-14 02:22:25 +08:00
|
|
|
namespace {
|
|
|
|
|
2021-05-16 11:38:41 +08:00
|
|
|
Key encodeConfigKey(Optional<KeyRef> configClass, KeyRef knobName) {
|
2021-08-06 09:50:23 +08:00
|
|
|
Tuple tuple;
|
|
|
|
if (configClass.present()) {
|
|
|
|
tuple.append(configClass.get());
|
|
|
|
} else {
|
|
|
|
tuple.appendNull();
|
|
|
|
}
|
|
|
|
tuple << knobName;
|
|
|
|
return tuple.pack();
|
2021-05-14 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2021-05-16 11:38:41 +08:00
|
|
|
void appendVersionedMutation(Standalone<VectorRef<VersionedConfigMutationRef>>& versionedMutations,
|
|
|
|
Version version,
|
|
|
|
Optional<KeyRef> configClass,
|
|
|
|
KeyRef knobName,
|
2021-06-03 12:36:34 +08:00
|
|
|
Optional<KnobValueRef> knobValue) {
|
2021-08-06 09:50:23 +08:00
|
|
|
auto configKey = ConfigKeyRef(configClass, knobName);
|
|
|
|
auto mutation = ConfigMutationRef(configKey, knobValue);
|
|
|
|
versionedMutations.emplace_back_deep(versionedMutations.arena(), version, mutation);
|
2021-05-14 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2021-05-24 03:34:10 +08:00
|
|
|
class WriteToTransactionEnvironment {
|
2021-08-06 09:50:23 +08:00
|
|
|
std::string dataDir;
|
|
|
|
ConfigTransactionInterface cti;
|
|
|
|
ConfigFollowerInterface cfi;
|
|
|
|
Reference<ConfigNode> node;
|
|
|
|
Future<Void> ctiServer;
|
|
|
|
Future<Void> cfiServer;
|
|
|
|
Version lastWrittenVersion{ 0 };
|
|
|
|
|
|
|
|
static Value longToValue(int64_t v) {
|
|
|
|
auto s = format("%ld", v);
|
|
|
|
return StringRef(reinterpret_cast<uint8_t const*>(s.c_str()), s.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Void> set(WriteToTransactionEnvironment* self,
|
|
|
|
Optional<KeyRef> configClass,
|
|
|
|
int64_t value,
|
|
|
|
KeyRef knobName) {
|
|
|
|
state Reference<IConfigTransaction> tr = IConfigTransaction::createTestSimple(self->cti);
|
|
|
|
auto configKey = encodeConfigKey(configClass, knobName);
|
|
|
|
tr->set(configKey, longToValue(value));
|
|
|
|
wait(tr->commit());
|
|
|
|
self->lastWrittenVersion = tr->getCommittedVersion();
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Void> clear(WriteToTransactionEnvironment* self, Optional<KeyRef> configClass) {
|
|
|
|
state Reference<IConfigTransaction> tr = IConfigTransaction::createTestSimple(self->cti);
|
|
|
|
auto configKey = encodeConfigKey(configClass, "test_long"_sr);
|
|
|
|
tr->clear(configKey);
|
|
|
|
wait(tr->commit());
|
|
|
|
self->lastWrittenVersion = tr->getCommittedVersion();
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
ctiServer = node->serve(cti);
|
|
|
|
cfiServer = node->serve(cfi);
|
|
|
|
}
|
2021-05-14 02:22:25 +08:00
|
|
|
|
2021-05-24 09:01:50 +08:00
|
|
|
public:
|
2021-08-06 09:50:23 +08:00
|
|
|
WriteToTransactionEnvironment(std::string const& dataDir)
|
|
|
|
: dataDir(dataDir), node(makeReference<ConfigNode>(dataDir)) {
|
|
|
|
platform::eraseDirectoryRecursive(dataDir);
|
|
|
|
setup();
|
|
|
|
}
|
2021-05-14 02:22:25 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> set(Optional<KeyRef> configClass, int64_t value, KeyRef knobName = "test_long"_sr) {
|
|
|
|
return set(this, configClass, value, knobName);
|
|
|
|
}
|
2021-05-24 03:34:10 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) { return clear(this, configClass); }
|
2021-05-24 03:34:10 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> compact() { return cfi.compact.getReply(ConfigFollowerCompactRequest{ lastWrittenVersion }); }
|
2021-05-24 07:44:06 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
void restartNode() {
|
|
|
|
cfiServer.cancel();
|
|
|
|
ctiServer.cancel();
|
|
|
|
node = makeReference<ConfigNode>(dataDir);
|
|
|
|
setup();
|
|
|
|
}
|
2021-05-15 06:37:14 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
ConfigTransactionInterface getTransactionInterface() const { return cti; }
|
2021-05-18 06:31:03 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
ConfigFollowerInterface getFollowerInterface() const { return cfi; }
|
2021-05-24 03:34:10 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> getError() const { return cfiServer || ctiServer; }
|
2021-05-24 03:34:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ReadFromLocalConfigEnvironment {
|
2021-08-06 09:50:23 +08:00
|
|
|
UID id;
|
|
|
|
std::string dataDir;
|
|
|
|
LocalConfiguration localConfiguration;
|
|
|
|
Reference<IAsyncListener<ConfigBroadcastFollowerInterface> const> cbfi;
|
|
|
|
Future<Void> consumer;
|
|
|
|
|
|
|
|
ACTOR static Future<Void> checkEventually(LocalConfiguration const* localConfiguration,
|
|
|
|
Optional<int64_t> expected) {
|
|
|
|
state double lastMismatchTime = now();
|
|
|
|
loop {
|
|
|
|
if (localConfiguration->getTestKnobs().TEST_LONG == expected.orDefault(0)) {
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
if (now() > lastMismatchTime + 1.0) {
|
|
|
|
TraceEvent(SevWarn, "CheckEventuallyStillChecking")
|
|
|
|
.detail("Expected", expected.present() ? expected.get() : 0)
|
|
|
|
.detail("TestLong", localConfiguration->getTestKnobs().TEST_LONG);
|
|
|
|
lastMismatchTime = now();
|
|
|
|
}
|
|
|
|
wait(delayJittered(0.1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Void> setup(ReadFromLocalConfigEnvironment* self) {
|
|
|
|
wait(self->localConfiguration.initialize());
|
|
|
|
if (self->cbfi) {
|
|
|
|
self->consumer = self->localConfiguration.consume(self->cbfi);
|
|
|
|
}
|
|
|
|
return Void();
|
|
|
|
}
|
2021-05-24 03:34:10 +08:00
|
|
|
|
|
|
|
public:
|
2021-08-06 09:50:23 +08:00
|
|
|
ReadFromLocalConfigEnvironment(std::string const& dataDir,
|
|
|
|
std::string const& configPath,
|
|
|
|
std::map<std::string, std::string> const& manualKnobOverrides)
|
|
|
|
: dataDir(dataDir), localConfiguration(dataDir, configPath, manualKnobOverrides, IsTest::True),
|
|
|
|
consumer(Never()) {}
|
|
|
|
|
|
|
|
Future<Void> setup() { return setup(this); }
|
|
|
|
|
|
|
|
Future<Void> restartLocalConfig(std::string const& newConfigPath) {
|
|
|
|
localConfiguration = LocalConfiguration(dataDir, newConfigPath, {}, IsTest::True);
|
|
|
|
return setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void connectToBroadcaster(Reference<IAsyncListener<ConfigBroadcastFollowerInterface> const> const& cbfi) {
|
|
|
|
ASSERT(!this->cbfi);
|
|
|
|
this->cbfi = cbfi;
|
|
|
|
consumer = localConfiguration.consume(cbfi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkImmediate(Optional<int64_t> expected) const {
|
|
|
|
if (expected.present()) {
|
|
|
|
ASSERT_EQ(localConfiguration.getTestKnobs().TEST_LONG, expected.get());
|
|
|
|
} else {
|
|
|
|
ASSERT_EQ(localConfiguration.getTestKnobs().TEST_LONG, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Void> checkEventually(Optional<int64_t> expected) const {
|
|
|
|
return checkEventually(&localConfiguration, expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalConfiguration& getMutableLocalConfiguration() { return localConfiguration; }
|
|
|
|
|
|
|
|
Future<Void> getError() const { return consumer; }
|
2021-05-24 03:34:10 +08:00
|
|
|
};
|
2021-05-15 06:37:14 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
class LocalConfigEnvironment {
|
2021-08-06 09:50:23 +08:00
|
|
|
ReadFromLocalConfigEnvironment readFrom;
|
|
|
|
Version lastWrittenVersion{ 0 };
|
2021-05-17 05:36:52 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> addMutation(Optional<KeyRef> configClass, Optional<KnobValueRef> value) {
|
|
|
|
Standalone<VectorRef<VersionedConfigMutationRef>> versionedMutations;
|
|
|
|
appendVersionedMutation(versionedMutations, ++lastWrittenVersion, configClass, "test_long"_sr, value);
|
|
|
|
return readFrom.getMutableLocalConfiguration().addChanges(versionedMutations, lastWrittenVersion);
|
|
|
|
}
|
2021-05-24 03:34:10 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
public:
|
2021-08-06 09:50:23 +08:00
|
|
|
LocalConfigEnvironment(std::string const& dataDir,
|
|
|
|
std::string const& configPath,
|
|
|
|
std::map<std::string, std::string> const& manualKnobOverrides = {})
|
|
|
|
: readFrom(dataDir, configPath, manualKnobOverrides) {}
|
|
|
|
Future<Void> setup() { return readFrom.setup(); }
|
|
|
|
Future<Void> restartLocalConfig(std::string const& newConfigPath) {
|
|
|
|
return readFrom.restartLocalConfig(newConfigPath);
|
|
|
|
}
|
|
|
|
Future<Void> getError() const { return Never(); }
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) { return addMutation(configClass, {}); }
|
|
|
|
Future<Void> set(Optional<KeyRef> configClass, int64_t value) {
|
|
|
|
auto knobValue = KnobValueRef::create(value);
|
|
|
|
return addMutation(configClass, knobValue.contents());
|
|
|
|
}
|
|
|
|
void check(Optional<int64_t> value) const { return readFrom.checkImmediate(value); }
|
2021-05-17 05:36:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class BroadcasterToLocalConfigEnvironment {
|
2021-08-06 09:50:23 +08:00
|
|
|
ReadFromLocalConfigEnvironment readFrom;
|
|
|
|
Reference<AsyncVar<ConfigBroadcastFollowerInterface>> cbfi;
|
|
|
|
ConfigBroadcaster broadcaster;
|
|
|
|
Version lastWrittenVersion{ 0 };
|
|
|
|
Future<Void> broadcastServer;
|
|
|
|
|
|
|
|
ACTOR static Future<Void> setup(BroadcasterToLocalConfigEnvironment* self) {
|
|
|
|
wait(self->readFrom.setup());
|
|
|
|
self->readFrom.connectToBroadcaster(IAsyncListener<ConfigBroadcastFollowerInterface>::create(self->cbfi));
|
|
|
|
self->broadcastServer = self->broadcaster.serve(self->cbfi->get());
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
void addMutation(Optional<KeyRef> configClass, KnobValueRef value) {
|
|
|
|
Standalone<VectorRef<VersionedConfigMutationRef>> versionedMutations;
|
|
|
|
appendVersionedMutation(versionedMutations, ++lastWrittenVersion, configClass, "test_long"_sr, value);
|
|
|
|
broadcaster.applyChanges(versionedMutations, lastWrittenVersion, {});
|
|
|
|
}
|
2021-05-14 15:41:02 +08:00
|
|
|
|
|
|
|
public:
|
2021-08-06 09:50:23 +08:00
|
|
|
BroadcasterToLocalConfigEnvironment(std::string const& dataDir, std::string const& configPath)
|
|
|
|
: readFrom(dataDir, configPath, {}), cbfi(makeReference<AsyncVar<ConfigBroadcastFollowerInterface>>()),
|
|
|
|
broadcaster(ConfigFollowerInterface{}) {}
|
2021-05-17 05:36:52 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> setup() { return setup(this); }
|
2021-05-17 05:36:52 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
void set(Optional<KeyRef> configClass, int64_t value) {
|
|
|
|
auto knobValue = KnobValueRef::create(value);
|
|
|
|
addMutation(configClass, knobValue.contents());
|
|
|
|
}
|
2021-05-19 12:29:40 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
void clear(Optional<KeyRef> configClass) { addMutation(configClass, {}); }
|
2021-05-19 12:29:40 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> check(Optional<int64_t> value) const { return readFrom.checkEventually(value); }
|
2021-05-19 12:29:40 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
void changeBroadcaster() {
|
|
|
|
broadcastServer.cancel();
|
|
|
|
cbfi->set(ConfigBroadcastFollowerInterface{});
|
|
|
|
broadcastServer = broadcaster.serve(cbfi->get());
|
|
|
|
}
|
2021-05-19 12:29:40 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> restartLocalConfig(std::string const& newConfigPath) {
|
|
|
|
return readFrom.restartLocalConfig(newConfigPath);
|
|
|
|
}
|
2021-05-19 12:29:40 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
void compact() { broadcaster.compact(lastWrittenVersion); }
|
2021-05-17 14:14:46 +08:00
|
|
|
|
2021-08-06 09:50:23 +08:00
|
|
|
Future<Void> getError() const { return readFrom.getError() || broadcastServer; }
|
2021-05-14 15:41:02 +08:00
|
|
|
};
|
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
class TransactionEnvironment {
|
2021-08-06 09:50:23 +08:00
|
|
|
WriteToTransactionEnvironment writeTo;
|
|
|
|
|
|
|
|
ACTOR static Future<Void> check(TransactionEnvironment* self,
|
|
|
|
Optional<KeyRef> configClass,
|
|
|
|
Optional<int64_t> expected) {
|
|
|
|
state Reference<IConfigTransaction> tr =
|
|
|
|
IConfigTransaction::createTestSimple(self->writeTo.getTransactionInterface());
|
|
|
|
state Key configKey = encodeConfigKey(configClass, "test_long"_sr);
|
|
|
|
state Optional<Value> value = wait(tr->get(configKey));
|
|
|
|
if (expected.present()) {
|
|
|
|
ASSERT_EQ(BinaryReader::fromStringRef<int64_t>(value.get(), Unversioned()), expected.get());
|
|
|
|
} else {
|
|
|
|
ASSERT(!value.present());
|
|
|
|
}
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Standalone<VectorRef<KeyRef>>> getConfigClasses(TransactionEnvironment* self) {
|
|
|
|
state Reference<IConfigTransaction> tr =
|
|
|
|
IConfigTransaction::createTestSimple(self->writeTo.getTransactionInterface());
|
|
|
|
state KeySelector begin = firstGreaterOrEqual(configClassKeys.begin);
|
|
|
|
state KeySelector end = firstGreaterOrEqual(configClassKeys.end);
|
|
|
|
RangeResult range = wait(tr->getRange(begin, end, 1000));
|
|
|
|
Standalone<VectorRef<KeyRef>> result;
|
|
|
|
for (const auto& kv : range) {
|
|
|
|
result.push_back_deep(result.arena(), kv.key);
|
|
|
|
ASSERT(kv.value == ""_sr);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Standalone<VectorRef<KeyRef>>> getKnobNames(TransactionEnvironment* self,
|
|
|
|
Optional<KeyRef> configClass) {
|
|
|
|
state Reference<IConfigTransaction> tr =
|
|
|
|
IConfigTransaction::createTestSimple(self->writeTo.getTransactionInterface());
|
|
|
|
state KeyRange keys = globalConfigKnobKeys;
|
|
|
|
if (configClass.present()) {
|
|
|
|
keys = singleKeyRange(configClass.get().withPrefix(configKnobKeys.begin));
|
|
|
|
}
|
|
|
|
KeySelector begin = firstGreaterOrEqual(keys.begin);
|
|
|
|
KeySelector end = firstGreaterOrEqual(keys.end);
|
|
|
|
RangeResult range = wait(tr->getRange(begin, end, 1000));
|
|
|
|
Standalone<VectorRef<KeyRef>> result;
|
|
|
|
for (const auto& kv : range) {
|
|
|
|
result.push_back_deep(result.arena(), kv.key);
|
|
|
|
ASSERT(kv.value == ""_sr);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Void> badRangeRead(TransactionEnvironment* self) {
|
|
|
|
state Reference<IConfigTransaction> tr =
|
|
|
|
IConfigTransaction::createTestSimple(self->writeTo.getTransactionInterface());
|
|
|
|
KeySelector begin = firstGreaterOrEqual(normalKeys.begin);
|
|
|
|
KeySelector end = firstGreaterOrEqual(normalKeys.end);
|
|
|
|
wait(success(tr->getRange(begin, end, 1000)));
|
|
|
|
return Void();
|
|
|
|
}
|
2021-05-29 18:58:18 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
public:
|
2021-08-06 09:50:23 +08:00
|
|
|
TransactionEnvironment(std::string const& dataDir) : writeTo(dataDir) {}
|
|
|
|
|
|
|
|
Future<Void> setup() { return Void(); }
|
|
|
|
|
|
|
|
void restartNode() { writeTo.restartNode(); }
|
|
|
|
template <class T>
|
|
|
|
Future<Void> set(Optional<KeyRef> configClass, T value, KeyRef knobName = "test_long"_sr) {
|
|
|
|
return writeTo.set(configClass, value, knobName);
|
|
|
|
}
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) { return writeTo.clear(configClass); }
|
|
|
|
Future<Void> check(Optional<KeyRef> configClass, Optional<int64_t> expected) {
|
|
|
|
return check(this, configClass, expected);
|
|
|
|
}
|
|
|
|
Future<Void> badRangeRead() { return badRangeRead(this); }
|
|
|
|
|
|
|
|
Future<Standalone<VectorRef<KeyRef>>> getConfigClasses() { return getConfigClasses(this); }
|
|
|
|
Future<Standalone<VectorRef<KeyRef>>> getKnobNames(Optional<KeyRef> configClass) {
|
|
|
|
return getKnobNames(this, configClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Void> compact() { return writeTo.compact(); }
|
|
|
|
Future<Void> getError() const { return writeTo.getError(); }
|
2021-05-17 05:36:52 +08:00
|
|
|
};
|
2021-05-16 11:38:41 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
class TransactionToLocalConfigEnvironment {
|
2021-08-06 09:50:23 +08:00
|
|
|
WriteToTransactionEnvironment writeTo;
|
|
|
|
ReadFromLocalConfigEnvironment readFrom;
|
|
|
|
Reference<AsyncVar<ConfigBroadcastFollowerInterface>> cbfi;
|
|
|
|
ConfigBroadcaster broadcaster;
|
|
|
|
Future<Void> broadcastServer;
|
|
|
|
|
|
|
|
ACTOR static Future<Void> setup(TransactionToLocalConfigEnvironment* self) {
|
|
|
|
wait(self->readFrom.setup());
|
|
|
|
self->readFrom.connectToBroadcaster(IAsyncListener<ConfigBroadcastFollowerInterface>::create(self->cbfi));
|
|
|
|
self->broadcastServer = self->broadcaster.serve(self->cbfi->get());
|
|
|
|
return Void();
|
|
|
|
}
|
2021-05-16 11:38:41 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
public:
|
2021-08-06 09:50:23 +08:00
|
|
|
TransactionToLocalConfigEnvironment(std::string const& dataDir, std::string const& configPath)
|
|
|
|
: writeTo(dataDir), readFrom(dataDir, configPath, {}),
|
|
|
|
cbfi(makeReference<AsyncVar<ConfigBroadcastFollowerInterface>>()), broadcaster(writeTo.getFollowerInterface()) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Void> setup() { return setup(this); }
|
|
|
|
|
|
|
|
void restartNode() { writeTo.restartNode(); }
|
|
|
|
|
|
|
|
void changeBroadcaster() {
|
|
|
|
broadcastServer.cancel();
|
|
|
|
cbfi->set(ConfigBroadcastFollowerInterface{});
|
|
|
|
broadcastServer = broadcaster.serve(cbfi->get());
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Void> restartLocalConfig(std::string const& newConfigPath) {
|
|
|
|
return readFrom.restartLocalConfig(newConfigPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Void> compact() { return writeTo.compact(); }
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
Future<Void> set(Optional<KeyRef> configClass, T const& value) {
|
|
|
|
return writeTo.set(configClass, value);
|
|
|
|
}
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) { return writeTo.clear(configClass); }
|
|
|
|
Future<Void> check(Optional<int64_t> value) const { return readFrom.checkEventually(value); }
|
|
|
|
Future<Void> getError() const { return writeTo.getError() || readFrom.getError() || broadcastServer; }
|
2021-05-17 05:36:52 +08:00
|
|
|
};
|
|
|
|
|
2021-06-11 08:14:37 +08:00
|
|
|
// These functions give a common interface to all environments, to improve code reuse
|
2021-05-17 14:14:46 +08:00
|
|
|
template <class Env, class... Args>
|
|
|
|
Future<Void> set(Env& env, Args&&... args) {
|
2021-08-06 09:50:23 +08:00
|
|
|
return waitOrError(env.set(std::forward<Args>(args)...), env.getError());
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
2021-05-23 15:41:15 +08:00
|
|
|
template <class... Args>
|
|
|
|
Future<Void> set(BroadcasterToLocalConfigEnvironment& env, Args&&... args) {
|
2021-08-06 09:50:23 +08:00
|
|
|
env.set(std::forward<Args>(args)...);
|
|
|
|
return Void();
|
2021-05-23 15:41:15 +08:00
|
|
|
}
|
2021-05-17 14:14:46 +08:00
|
|
|
template <class Env, class... Args>
|
|
|
|
Future<Void> clear(Env& env, Args&&... args) {
|
2021-08-06 09:50:23 +08:00
|
|
|
return waitOrError(env.clear(std::forward<Args>(args)...), env.getError());
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
2021-05-23 15:41:15 +08:00
|
|
|
template <class... Args>
|
|
|
|
Future<Void> clear(BroadcasterToLocalConfigEnvironment& env, Args&&... args) {
|
2021-08-06 09:50:23 +08:00
|
|
|
env.clear(std::forward<Args>(args)...);
|
|
|
|
return Void();
|
2021-05-23 15:41:15 +08:00
|
|
|
}
|
2021-05-17 14:14:46 +08:00
|
|
|
template <class Env, class... Args>
|
|
|
|
Future<Void> check(Env& env, Args&&... args) {
|
2021-08-06 09:50:23 +08:00
|
|
|
return waitOrError(env.check(std::forward<Args>(args)...), env.getError());
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
2021-05-19 14:50:01 +08:00
|
|
|
template <class... Args>
|
|
|
|
Future<Void> check(LocalConfigEnvironment& env, Args&&... args) {
|
2021-08-06 09:50:23 +08:00
|
|
|
env.check(std::forward<Args>(args)...);
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
2021-05-24 07:44:06 +08:00
|
|
|
template <class Env>
|
|
|
|
Future<Void> compact(Env& env) {
|
2021-08-06 09:50:23 +08:00
|
|
|
return waitOrError(env.compact(), env.getError());
|
2021-05-24 07:44:06 +08:00
|
|
|
}
|
|
|
|
Future<Void> compact(BroadcasterToLocalConfigEnvironment& env) {
|
2021-08-06 09:50:23 +08:00
|
|
|
env.compact();
|
|
|
|
return Void();
|
2021-05-24 07:44:06 +08:00
|
|
|
}
|
2021-05-17 05:36:52 +08:00
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testRestartLocalConfig(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
wait(env.restartLocalConfig("class-A"));
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
wait(set(env, "class-A"_sr, 2));
|
|
|
|
wait(check(env, int64_t{ 2 }));
|
|
|
|
return Void();
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testRestartLocalConfigAndChangeClass(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
wait(env.restartLocalConfig("class-B"));
|
|
|
|
wait(check(env, int64_t{ 0 }));
|
|
|
|
wait(set(env, "class-B"_sr, int64_t{ 2 }));
|
|
|
|
wait(check(env, int64_t{ 2 }));
|
|
|
|
return Void();
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testSet(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
return Void();
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testClear(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(clear(env, "class-A"_sr));
|
|
|
|
wait(check(env, Optional<int64_t>{}));
|
|
|
|
return Void();
|
2021-05-17 05:36:52 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testGlobalSet(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, Optional<KeyRef>{}, int64_t{ 1 }));
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 10 }));
|
|
|
|
wait(check(env, int64_t{ 10 }));
|
|
|
|
return Void();
|
2021-05-17 05:36:52 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testIgnore(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-B"_sr, int64_t{ 1 }));
|
|
|
|
choose {
|
|
|
|
when(wait(delay(5))) {}
|
|
|
|
when(wait(check(env, int64_t{ 1 }))) { ASSERT(false); }
|
|
|
|
}
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testCompact(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(compact(env));
|
|
|
|
wait(check(env, 1));
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 2 }));
|
|
|
|
wait(check(env, 2));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR template <class Env>
|
2021-06-07 02:25:58 +08:00
|
|
|
Future<Void> testChangeBroadcaster(UnitTestParameters params) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state Env env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
env.changeBroadcaster();
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 2 }));
|
|
|
|
wait(check(env, int64_t{ 2 }));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
2021-05-29 18:58:18 +08:00
|
|
|
bool matches(Standalone<VectorRef<KeyRef>> const& vec, std::set<Key> const& compareTo) {
|
2021-08-06 09:50:23 +08:00
|
|
|
std::set<Key> s;
|
|
|
|
for (const auto& value : vec) {
|
|
|
|
s.insert(value);
|
|
|
|
}
|
|
|
|
return (s == compareTo);
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
2021-06-07 02:25:58 +08:00
|
|
|
ACTOR Future<Void> testGetConfigClasses(UnitTestParameters params, bool doCompact) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(set(env, "class-B"_sr, int64_t{ 1 }));
|
|
|
|
if (doCompact) {
|
|
|
|
wait(compact(env));
|
|
|
|
}
|
|
|
|
Standalone<VectorRef<KeyRef>> configClasses = wait(env.getConfigClasses());
|
|
|
|
ASSERT(matches(configClasses, { "class-A"_sr, "class-B"_sr }));
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
2021-06-07 02:25:58 +08:00
|
|
|
ACTOR Future<Void> testGetKnobs(UnitTestParameters params, bool global, bool doCompact) {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
state Optional<Key> configClass;
|
|
|
|
if (!global) {
|
|
|
|
configClass = "class-A"_sr;
|
|
|
|
}
|
|
|
|
wait(set(env, configClass.castTo<KeyRef>(), int64_t{ 1 }, "test_long"_sr));
|
|
|
|
wait(set(env, configClass.castTo<KeyRef>(), int{ 2 }, "test_int"_sr));
|
|
|
|
wait(set(env, "class-B"_sr, double{ 3.0 }, "test_double"_sr)); // ignored
|
|
|
|
if (doCompact) {
|
|
|
|
wait(compact(env));
|
|
|
|
}
|
|
|
|
Standalone<VectorRef<KeyRef>> knobNames =
|
|
|
|
wait(waitOrError(env.getKnobNames(configClass.castTo<KeyRef>()), env.getError()));
|
|
|
|
ASSERT(matches(knobNames, { "test_long"_sr, "test_int"_sr }));
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Set") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testSet<LocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Restart") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testRestartLocalConfig<LocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/RestartFresh") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testRestartLocalConfigAndChangeClass<LocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Clear") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testClear<LocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/GlobalSet") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGlobalSet<LocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/ConflictingOverrides") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state LocalConfigEnvironment env(params.getDataDir(), "class-A/class-B", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(set(env, "class-B"_sr, int64_t{ 10 }));
|
|
|
|
env.check(10);
|
|
|
|
return Void();
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Manual") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state LocalConfigEnvironment env(params.getDataDir(), "class-A", { { "test_long", "1000" } });
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
env.check(1000);
|
|
|
|
return Void();
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Set") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testSet<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Clear") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testClear<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-17 05:36:52 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Ignore") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testIgnore<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/GlobalSet") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGlobalSet<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
|
|
|
|
2021-05-30 01:57:10 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/ChangeBroadcaster") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testChangeBroadcaster<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-30 01:57:10 +08:00
|
|
|
}
|
2021-05-16 13:28:12 +08:00
|
|
|
|
2021-05-19 12:29:40 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/RestartLocalConfig") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testRestartLocalConfig<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 12:29:40 +08:00
|
|
|
}
|
|
|
|
|
2021-05-30 01:57:10 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/RestartLocalConfigAndChangeClass") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testRestartLocalConfigAndChangeClass<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-30 01:57:10 +08:00
|
|
|
}
|
2021-05-19 12:29:40 +08:00
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Compact") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testCompact<BroadcasterToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-17 15:52:24 +08:00
|
|
|
}
|
|
|
|
|
2021-05-16 13:28:12 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/Set") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testSet<TransactionToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-16 13:28:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/Clear") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testClear<TransactionToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/GlobalSet") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGlobalSet<TransactionToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/RestartNode") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionToLocalConfigEnvironment env(params.getDataDir(), "class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
env.restartNode();
|
|
|
|
wait(check(env, int64_t{ 1 }));
|
|
|
|
return Void();
|
2021-05-17 15:52:24 +08:00
|
|
|
}
|
|
|
|
|
2021-05-19 14:50:01 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/ChangeBroadcaster") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testChangeBroadcaster<TransactionToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/RestartLocalConfigAndChangeClass") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testRestartLocalConfigAndChangeClass<TransactionToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-19 14:50:01 +08:00
|
|
|
}
|
|
|
|
|
2021-05-24 07:44:06 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/CompactNode") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testCompact<TransactionToLocalConfigEnvironment>(params));
|
|
|
|
return Void();
|
2021-05-24 07:44:06 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/Set") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(check(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
return Void();
|
2021-05-17 14:14:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/Clear") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(clear(env, "class-A"_sr));
|
|
|
|
wait(check(env, "class-A"_sr, Optional<int64_t>{}));
|
|
|
|
return Void();
|
2021-05-16 13:28:12 +08:00
|
|
|
}
|
2021-05-17 15:52:24 +08:00
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/Restart") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
env.restartNode();
|
|
|
|
wait(check(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
return Void();
|
2021-05-17 15:52:24 +08:00
|
|
|
}
|
2021-05-24 07:44:06 +08:00
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/CompactNode") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(compact(env));
|
|
|
|
wait(check(env, "class-A"_sr, int64_t{ 1 }));
|
|
|
|
wait(set(env, "class-A"_sr, int64_t{ 2 }));
|
|
|
|
wait(check(env, "class-A"_sr, int64_t{ 2 }));
|
|
|
|
return Void();
|
2021-05-24 07:44:06 +08:00
|
|
|
}
|
2021-05-29 18:58:18 +08:00
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/GetConfigClasses") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGetConfigClasses(params, false));
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/CompactThenGetConfigClasses") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGetConfigClasses(params, true));
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/GetKnobs") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGetKnobs(params, false, false));
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/CompactThenGetKnobs") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGetKnobs(params, false, true));
|
|
|
|
return Void();
|
2021-05-29 19:31:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/GetGlobalKnobs") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGetKnobs(params, true, false));
|
|
|
|
return Void();
|
2021-05-29 19:31:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/CompactThenGetGlobalKnobs") {
|
2021-08-06 09:50:23 +08:00
|
|
|
wait(testGetKnobs(params, true, true));
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/BadRangeRead") {
|
2021-08-06 09:50:23 +08:00
|
|
|
state TransactionEnvironment env(params.getDataDir());
|
|
|
|
try {
|
|
|
|
wait(env.badRangeRead() || env.getError());
|
|
|
|
ASSERT(false);
|
|
|
|
} catch (Error& e) {
|
|
|
|
ASSERT_EQ(e.code(), error_code_invalid_config_db_range_read);
|
|
|
|
}
|
|
|
|
return Void();
|
2021-05-29 18:58:18 +08:00
|
|
|
}
|
2021-08-06 09:50:11 +08:00
|
|
|
*/
|