2021-05-14 02:22:25 +08:00
|
|
|
/*
|
|
|
|
* ConfigBroadcaster.actor.cpp
|
|
|
|
*
|
|
|
|
* 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-05-14 02:22:25 +08:00
|
|
|
#include "fdbserver/ConfigBroadcaster.h"
|
2021-05-15 14:02:40 +08:00
|
|
|
#include "fdbserver/IConfigDatabaseNode.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
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2021-05-16 11:38:41 +08:00
|
|
|
Key encodeConfigKey(Optional<KeyRef> configClass, KeyRef knobName) {
|
2021-05-14 02:22:25 +08:00
|
|
|
Tuple tuple;
|
2021-05-15 10:34:21 +08:00
|
|
|
if (configClass.present()) {
|
|
|
|
tuple.append(configClass.get());
|
|
|
|
} else {
|
|
|
|
tuple.appendNull();
|
|
|
|
}
|
2021-05-14 02:22:25 +08:00
|
|
|
tuple << knobName;
|
2021-05-16 11:38:41 +08:00
|
|
|
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,
|
|
|
|
Optional<ValueRef> knobValue) {
|
|
|
|
auto mutation = ConfigMutationRef::createConfigMutation(encodeConfigKey(configClass, knobName), knobValue);
|
|
|
|
versionedMutations.emplace_back_deep(versionedMutations.arena(), version, mutation);
|
2021-05-14 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2021-05-16 11:38:41 +08:00
|
|
|
Value longToValue(int64_t v) {
|
|
|
|
auto s = format("%ld", v);
|
2021-05-15 06:05:33 +08:00
|
|
|
return StringRef(reinterpret_cast<uint8_t const*>(s.c_str()), s.size());
|
|
|
|
}
|
|
|
|
|
2021-05-18 06:31:03 +08:00
|
|
|
Future<Void> addTestClearMutation(IConfigTransaction& tr, Optional<KeyRef> configClass) {
|
2021-05-16 11:38:41 +08:00
|
|
|
tr.fullReset();
|
2021-05-17 14:14:46 +08:00
|
|
|
auto configKey = encodeConfigKey(configClass, "test_long"_sr);
|
|
|
|
tr.clear(configKey);
|
2021-05-16 11:38:41 +08:00
|
|
|
return tr.commit();
|
2021-05-14 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2021-05-18 06:31:03 +08:00
|
|
|
Future<Void> addTestSetMutation(IConfigTransaction& tr, Optional<KeyRef> configClass, int64_t value) {
|
2021-05-16 11:38:41 +08:00
|
|
|
tr.fullReset();
|
2021-05-17 14:14:46 +08:00
|
|
|
auto configKey = encodeConfigKey(configClass, "test_long"_sr);
|
2021-05-16 11:38:41 +08:00
|
|
|
tr.set(configKey, longToValue(value));
|
|
|
|
return tr.commit();
|
2021-05-14 03:55:33 +08:00
|
|
|
}
|
|
|
|
|
2021-05-16 11:38:41 +08:00
|
|
|
template <class WriteTo>
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> addTestClearMutation(WriteTo& writeTo, Optional<KeyRef> configKey, Version version) {
|
2021-05-16 11:38:41 +08:00
|
|
|
Standalone<VectorRef<VersionedConfigMutationRef>> versionedMutations;
|
2021-05-17 14:14:46 +08:00
|
|
|
appendVersionedMutation(versionedMutations, version, configKey, "test_long"_sr, {});
|
2021-05-16 11:38:41 +08:00
|
|
|
return writeTo.addVersionedMutations(versionedMutations, version);
|
2021-05-14 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2021-05-16 11:38:41 +08:00
|
|
|
template <class WriteTo>
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> addTestSetMutation(WriteTo& writeTo, Optional<KeyRef> configClass, int64_t value, Version version) {
|
2021-05-16 11:38:41 +08:00
|
|
|
Standalone<VectorRef<VersionedConfigMutationRef>> versionedMutations;
|
2021-05-17 14:14:46 +08:00
|
|
|
appendVersionedMutation(versionedMutations, version, configClass, "test_long"_sr, longToValue(value));
|
2021-05-16 11:38:41 +08:00
|
|
|
return writeTo.addVersionedMutations(versionedMutations, version);
|
2021-05-14 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2021-05-18 06:31:03 +08:00
|
|
|
ACTOR Future<Void> checkImmediate(IConfigTransaction* tr, Optional<KeyRef> configClass, Optional<int64_t> expected) {
|
2021-05-16 11:38:41 +08:00
|
|
|
tr->fullReset();
|
2021-05-17 14:14:46 +08:00
|
|
|
state Key configKey = encodeConfigKey(configClass, "test_long"_sr);
|
|
|
|
state Optional<Value> value = wait(tr->get(configKey));
|
2021-05-16 11:38:41 +08:00
|
|
|
if (expected.present()) {
|
2021-05-17 14:14:46 +08:00
|
|
|
ASSERT(value.get() == longToValue(expected.get()));
|
2021-05-16 11:38:41 +08:00
|
|
|
} else {
|
2021-05-17 14:14:46 +08:00
|
|
|
ASSERT(!value.present());
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
2021-05-15 06:37:14 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-18 06:31:03 +08:00
|
|
|
Future<Void> checkImmediate(IConfigTransaction& tr, Optional<KeyRef> configClass, Optional<int64_t> expected) {
|
|
|
|
return checkImmediate(&tr, configClass, expected);
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
void checkImmediate(LocalConfiguration const& localConfiguration, Optional<int64_t> expected) {
|
|
|
|
if (expected.present()) {
|
|
|
|
ASSERT_EQ(localConfiguration.getTestKnobs().TEST_LONG, expected.get());
|
2021-05-16 11:38:41 +08:00
|
|
|
} else {
|
2021-05-17 14:14:46 +08:00
|
|
|
ASSERT_EQ(localConfiguration.getTestKnobs().TEST_LONG, 0);
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
2021-05-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
ACTOR Future<Void> checkEventually(LocalConfiguration const* localConfiguration, Optional<int64_t> expected) {
|
|
|
|
loop {
|
|
|
|
if (localConfiguration->getTestKnobs().TEST_LONG == (expected.present() ? expected.get() : 0)) {
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
wait(delayJittered(0.1));
|
|
|
|
}
|
2021-05-15 06:37:14 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
class LocalConfigEnvironment {
|
|
|
|
LocalConfiguration localConfiguration;
|
2021-05-17 08:25:41 +08:00
|
|
|
UID id;
|
2021-05-17 14:14:46 +08:00
|
|
|
Version lastWrittenVersion{ 0 };
|
2021-05-17 05:36:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
LocalConfigEnvironment(std::string const& configPath, std::map<Key, Value> const& manualKnobOverrides)
|
2021-05-17 08:25:41 +08:00
|
|
|
: localConfiguration(configPath, manualKnobOverrides), id(deterministicRandom()->randomUniqueID()) {}
|
|
|
|
Future<Void> setup() { return localConfiguration.initialize("./", id); }
|
|
|
|
Future<Void> restart(std::string const& newConfigPath) {
|
|
|
|
localConfiguration = LocalConfiguration(newConfigPath, {});
|
|
|
|
return setup();
|
|
|
|
}
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> getError() const { return Never(); }
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) {
|
|
|
|
return addTestClearMutation(localConfiguration, configClass, ++lastWrittenVersion);
|
|
|
|
}
|
|
|
|
Future<Void> set(Optional<KeyRef> configClass, int64_t value) {
|
|
|
|
return addTestSetMutation(localConfiguration, configClass, value, ++lastWrittenVersion);
|
2021-05-17 05:36:52 +08:00
|
|
|
}
|
2021-05-17 14:14:46 +08:00
|
|
|
void check(Optional<int64_t> value) const { checkImmediate(localConfiguration, value); }
|
2021-05-17 05:36:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class BroadcasterToLocalConfigEnvironment {
|
|
|
|
class DummyConfigSource {
|
|
|
|
ConfigFollowerInterface cfi;
|
|
|
|
ACTOR static Future<Void> serve(DummyConfigSource* self) {
|
|
|
|
loop {
|
|
|
|
choose {
|
|
|
|
when(ConfigFollowerGetVersionRequest req = waitNext(self->cfi.getVersion.getFuture())) {
|
|
|
|
req.reply.send(0);
|
|
|
|
}
|
|
|
|
when(ConfigFollowerGetSnapshotRequest req = waitNext(self->cfi.getSnapshot.getFuture())) {
|
|
|
|
req.reply.send(ConfigFollowerGetSnapshotReply{});
|
|
|
|
}
|
2021-05-14 15:41:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-17 05:36:52 +08:00
|
|
|
public:
|
|
|
|
Future<Void> serve() { return serve(this); }
|
|
|
|
ConfigFollowerInterface const& getInterface() { return cfi; }
|
|
|
|
} dummyConfigSource;
|
|
|
|
ConfigBroadcaster broadcaster;
|
|
|
|
Reference<AsyncVar<ConfigFollowerInterface>> cfi;
|
|
|
|
LocalConfiguration localConfiguration;
|
2021-05-17 14:14:46 +08:00
|
|
|
Version lastWrittenVersion{ 0 };
|
|
|
|
Future<Void> broadcastServer;
|
2021-05-17 05:36:52 +08:00
|
|
|
ActorCollection actors{ false };
|
|
|
|
|
|
|
|
ACTOR static Future<Void> setup(BroadcasterToLocalConfigEnvironment* self) {
|
|
|
|
wait(self->localConfiguration.initialize("./", deterministicRandom()->randomUniqueID()));
|
|
|
|
self->actors.add(self->dummyConfigSource.serve());
|
2021-05-17 14:14:46 +08:00
|
|
|
self->broadcastServer = self->broadcaster.serve(self->cfi->get());
|
2021-05-17 05:36:52 +08:00
|
|
|
self->actors.add(
|
|
|
|
self->localConfiguration.consume(IDependentAsyncVar<ConfigFollowerInterface>::create(self->cfi)));
|
|
|
|
return Void();
|
2021-05-14 15:41:02 +08:00
|
|
|
}
|
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
ACTOR static Future<Void> compact(BroadcasterToLocalConfigEnvironment* self) {
|
|
|
|
ConfigFollowerGetVersionReply reply =
|
|
|
|
wait(self->cfi->get().getVersion.getReply(ConfigFollowerGetVersionRequest{}));
|
|
|
|
wait(self->cfi->get().compact.getReply(ConfigFollowerCompactRequest{ reply.version }));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-14 15:41:02 +08:00
|
|
|
public:
|
2021-05-17 14:14:46 +08:00
|
|
|
BroadcasterToLocalConfigEnvironment(std::string const& configPath)
|
2021-05-18 06:31:03 +08:00
|
|
|
: broadcaster(dummyConfigSource.getInterface()), cfi(makeReference<AsyncVar<ConfigFollowerInterface>>()),
|
|
|
|
localConfiguration(configPath, {}) {}
|
2021-05-17 05:36:52 +08:00
|
|
|
|
|
|
|
Future<Void> setup() { return setup(this); }
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> set(Optional<KeyRef> configClass, int64_t value) {
|
|
|
|
return addTestSetMutation(localConfiguration, configClass, value, ++lastWrittenVersion);
|
|
|
|
}
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) {
|
|
|
|
return addTestClearMutation(localConfiguration, configClass, ++lastWrittenVersion);
|
2021-05-17 05:36:52 +08:00
|
|
|
}
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> check(Optional<int64_t> value) const { return checkEventually(&localConfiguration, value); }
|
|
|
|
void changeBroadcaster() {
|
|
|
|
cfi->set(ConfigFollowerInterface());
|
2021-05-18 06:31:03 +08:00
|
|
|
broadcaster = ConfigBroadcaster(dummyConfigSource.getInterface());
|
2021-05-17 14:14:46 +08:00
|
|
|
broadcastServer = broadcaster.serve(cfi->get());
|
|
|
|
}
|
2021-05-17 15:52:24 +08:00
|
|
|
Future<Void> compact() { return compact(this); }
|
2021-05-17 14:14:46 +08:00
|
|
|
|
|
|
|
Future<Void> getError() const { return actors.getResult() || broadcastServer; }
|
2021-05-14 15:41:02 +08:00
|
|
|
};
|
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
class TransactionEnvironment {
|
|
|
|
ConfigTransactionInterface cti;
|
2021-05-18 06:31:03 +08:00
|
|
|
Reference<IConfigTransaction> tr;
|
2021-05-17 15:52:24 +08:00
|
|
|
Reference<IConfigDatabaseNode> node;
|
|
|
|
Future<Void> server;
|
|
|
|
UID id;
|
2021-05-15 01:38:01 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
ACTOR static Future<Void> setup(TransactionEnvironment* self) {
|
2021-05-17 15:52:24 +08:00
|
|
|
wait(self->node->initialize("./", self->id));
|
|
|
|
self->server = self->node->serve(self->cti);
|
2021-05-17 05:36:52 +08:00
|
|
|
return Void();
|
|
|
|
}
|
2021-05-15 04:30:04 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
public:
|
2021-05-17 15:52:24 +08:00
|
|
|
TransactionEnvironment()
|
2021-05-18 06:31:03 +08:00
|
|
|
: tr(IConfigTransaction::createSimple(cti)), node(IConfigDatabaseNode::createSimple()),
|
|
|
|
id(deterministicRandom()->randomUniqueID()) {}
|
2021-05-15 14:02:40 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
Future<Void> setup() { return setup(this); }
|
2021-05-16 11:38:41 +08:00
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
Future<Void> restart() {
|
2021-05-18 04:02:55 +08:00
|
|
|
server.cancel();
|
2021-05-18 05:15:30 +08:00
|
|
|
node = IConfigDatabaseNode::createSimple();
|
2021-05-17 15:52:24 +08:00
|
|
|
return setup();
|
|
|
|
}
|
|
|
|
|
2021-05-18 06:31:03 +08:00
|
|
|
Future<Void> set(Optional<KeyRef> configClass, int64_t value) {
|
|
|
|
return addTestSetMutation(*tr, configClass, value);
|
|
|
|
}
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) { return addTestClearMutation(*tr, configClass); }
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> check(Optional<KeyRef> configClass, Optional<int64_t> expected) {
|
2021-05-18 06:31:03 +08:00
|
|
|
return checkImmediate(*tr, configClass, expected);
|
2021-05-16 11:38:41 +08:00
|
|
|
}
|
2021-05-17 15:52:24 +08:00
|
|
|
Future<Void> getError() const { return server; }
|
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 {
|
|
|
|
ConfigTransactionInterface cti;
|
|
|
|
Reference<AsyncVar<ConfigFollowerInterface>> cfi;
|
2021-05-18 06:31:03 +08:00
|
|
|
Reference<IConfigTransaction> tr;
|
2021-05-17 15:52:24 +08:00
|
|
|
Reference<IConfigDatabaseNode> node;
|
|
|
|
UID nodeID;
|
|
|
|
Future<Void> ctiServer;
|
|
|
|
Future<Void> cfiServer;
|
2021-05-17 05:36:52 +08:00
|
|
|
LocalConfiguration localConfiguration;
|
2021-05-17 15:52:24 +08:00
|
|
|
Future<Void> consumer;
|
2021-05-17 05:36:52 +08:00
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
ACTOR static Future<Void> setup(TransactionToLocalConfigEnvironment* self) {
|
2021-05-17 05:36:52 +08:00
|
|
|
wait(self->localConfiguration.initialize("./", deterministicRandom()->randomUniqueID()));
|
2021-05-17 15:52:24 +08:00
|
|
|
wait(setupNode(self));
|
|
|
|
self->consumer =
|
|
|
|
self->localConfiguration.consume(IDependentAsyncVar<ConfigFollowerInterface>::create(self->cfi));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTOR static Future<Void> setupNode(TransactionToLocalConfigEnvironment* self) {
|
|
|
|
wait(self->node->initialize("./", self->nodeID));
|
|
|
|
self->ctiServer = self->node->serve(self->cti);
|
|
|
|
self->cfiServer = self->node->serve(self->cfi->get());
|
2021-05-17 05:36:52 +08:00
|
|
|
return Void();
|
|
|
|
}
|
2021-05-16 11:38:41 +08:00
|
|
|
|
2021-05-17 05:36:52 +08:00
|
|
|
public:
|
2021-05-17 14:14:46 +08:00
|
|
|
TransactionToLocalConfigEnvironment(std::string const& configPath)
|
2021-05-18 06:31:03 +08:00
|
|
|
: cfi(makeReference<AsyncVar<ConfigFollowerInterface>>()), tr(IConfigTransaction::createSimple(cti)),
|
|
|
|
node(IConfigDatabaseNode::createSimple()), nodeID(deterministicRandom()->randomUniqueID()),
|
|
|
|
localConfiguration(configPath, {}) {}
|
2021-05-17 05:36:52 +08:00
|
|
|
|
|
|
|
Future<Void> setup() { return setup(this); }
|
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
Future<Void> restartNode() {
|
|
|
|
cfiServer.cancel();
|
|
|
|
ctiServer.cancel();
|
2021-05-18 05:15:30 +08:00
|
|
|
node = IConfigDatabaseNode::createSimple();
|
2021-05-17 15:52:24 +08:00
|
|
|
return setupNode(this);
|
|
|
|
}
|
|
|
|
|
2021-05-18 06:31:03 +08:00
|
|
|
Future<Void> set(Optional<KeyRef> configClass, int64_t value) {
|
|
|
|
return addTestSetMutation(*tr, configClass, value);
|
|
|
|
}
|
|
|
|
Future<Void> clear(Optional<KeyRef> configClass) { return addTestClearMutation(*tr, configClass); }
|
2021-05-17 14:14:46 +08:00
|
|
|
Future<Void> check(Optional<int64_t> value) { return checkEventually(&localConfiguration, value); }
|
2021-05-17 15:52:24 +08:00
|
|
|
Future<Void> getError() const { return ctiServer || cfiServer || consumer; }
|
2021-05-17 05:36:52 +08:00
|
|
|
};
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
template <class Env, class... Args>
|
|
|
|
Future<Void> set(Env& env, Args&&... args) {
|
|
|
|
return waitOrError(env.set(std::forward<Args>(args)...), env.getError());
|
|
|
|
}
|
|
|
|
template <class Env, class... Args>
|
|
|
|
Future<Void> clear(Env& env, Args&&... args) {
|
|
|
|
return waitOrError(env.clear(std::forward<Args>(args)...), env.getError());
|
|
|
|
}
|
|
|
|
template <class Env, class... Args>
|
|
|
|
Future<Void> check(Env& env, Args&&... args) {
|
|
|
|
return waitOrError(env.check(std::forward<Args>(args)...), env.getError());
|
|
|
|
}
|
2021-05-17 05:36:52 +08:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Set") {
|
2021-05-17 14:14:46 +08:00
|
|
|
state LocalConfigEnvironment env("class-A", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
env.check(1);
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Restart") {
|
|
|
|
state LocalConfigEnvironment env("class-A/class-B", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(env.restart("class-A/class-B"));
|
|
|
|
env.check(1);
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/RestartFresh") {
|
|
|
|
state LocalConfigEnvironment env("class-A/class-B", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(env.restart("class-B/class-A"));
|
|
|
|
env.check(Optional<int64_t>{});
|
2021-05-16 11:38:41 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Clear") {
|
2021-05-17 14:14:46 +08:00
|
|
|
state LocalConfigEnvironment env("class-A", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(clear(env, "class-A"_sr));
|
|
|
|
env.check(Optional<int64_t>{});
|
2021-05-17 05:36:52 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/GlobalSet") {
|
|
|
|
state LocalConfigEnvironment env("class-A", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(set(env, Optional<KeyRef>{}, 10));
|
|
|
|
env.check(10);
|
2021-05-17 05:36:52 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/ConflictingOverrides") {
|
|
|
|
state LocalConfigEnvironment env("class-A/class-B", {});
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(set(env, "class-B"_sr, 10));
|
|
|
|
env.check(10);
|
2021-05-16 11:38:41 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/LocalConfiguration/Manual") {
|
|
|
|
state LocalConfigEnvironment env("class-A", { { "test_long"_sr, "1000"_sr } });
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
env.check(1000);
|
2021-05-16 11:38:41 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Set") {
|
2021-05-17 14:14:46 +08:00
|
|
|
state BroadcasterToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(check(env, 1));
|
2021-05-16 11:38:41 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Clear") {
|
2021-05-17 14:14:46 +08:00
|
|
|
state BroadcasterToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(clear(env, "class-A"_sr));
|
|
|
|
wait(check(env, Optional<int64_t>{}));
|
2021-05-17 05:36:52 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Ignore") {
|
|
|
|
state BroadcasterToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-B"_sr, 1));
|
|
|
|
choose {
|
|
|
|
when(wait(delay(5))) {}
|
|
|
|
when(wait(check(env, 1))) { ASSERT(false); }
|
|
|
|
}
|
2021-05-16 11:38:41 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/GlobalSet") {
|
|
|
|
state BroadcasterToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(set(env, Optional<KeyRef>{}, 10));
|
|
|
|
wait(check(env, 10));
|
2021-05-16 11:38:41 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/ChangeBroadcaster") {
|
|
|
|
state BroadcasterToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(check(env, 1));
|
|
|
|
env.changeBroadcaster();
|
|
|
|
wait(set(env, "class-A"_sr, 2));
|
|
|
|
wait(check(env, 2));
|
2021-05-15 14:02:40 +08:00
|
|
|
return Void();
|
|
|
|
}
|
2021-05-16 13:28:12 +08:00
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/BroadcasterToLocalConfig/Compact") {
|
|
|
|
state BroadcasterToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(env.compact());
|
|
|
|
wait(check(env, 1));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:28:12 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/Set") {
|
2021-05-17 14:14:46 +08:00
|
|
|
state TransactionToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(check(env, 1));
|
2021-05-16 13:28:12 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/Clear") {
|
2021-05-17 14:14:46 +08:00
|
|
|
state TransactionToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(clear(env, "class-A"_sr));
|
|
|
|
wait(check(env, Optional<int64_t>{}));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/GlobalSet") {
|
|
|
|
state TransactionToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(set(env, Optional<KeyRef>{}, 10));
|
|
|
|
wait(check(env, 10));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 15:52:24 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/TransactionToLocalConfig/RestartNode") {
|
|
|
|
state TransactionToLocalConfigEnvironment env("class-A");
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(env.restartNode());
|
|
|
|
wait(check(env, 1));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-05-17 14:14:46 +08:00
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/Set") {
|
|
|
|
state TransactionEnvironment env;
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(check(env, "class-A"_sr, 1));
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/Clear") {
|
|
|
|
state TransactionEnvironment env;
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(clear(env, "class-A"_sr));
|
|
|
|
wait(check(env, "class-A"_sr, Optional<int64_t>{}));
|
2021-05-16 13:28:12 +08:00
|
|
|
return Void();
|
|
|
|
}
|
2021-05-17 15:52:24 +08:00
|
|
|
|
|
|
|
TEST_CASE("/fdbserver/ConfigDB/Transaction/Restart") {
|
|
|
|
state TransactionEnvironment env;
|
|
|
|
wait(env.setup());
|
|
|
|
wait(set(env, "class-A"_sr, 1));
|
|
|
|
wait(env.restart());
|
|
|
|
wait(check(env, "class-A"_sr, 1));
|
|
|
|
return Void();
|
|
|
|
}
|