Add IKnobCollection::clearTestKnobs to fix unit tests

This commit is contained in:
sfc-gh-tclinkenbeard 2021-08-19 16:18:44 -07:00
parent b6c669be23
commit 0fcca0eb60
4 changed files with 9 additions and 0 deletions

View File

@ -54,6 +54,7 @@ public:
virtual ClientKnobs const& getClientKnobs() const = 0;
virtual ServerKnobs const& getServerKnobs() const = 0;
virtual class TestKnobs const& getTestKnobs() const = 0;
virtual void clearTestKnobs() {}
virtual Optional<KnobValue> tryParseKnobValue(std::string const& knobName, std::string const& knobValue) const = 0;
KnobValue parseKnobValue(std::string const& knobName, std::string const& knobValue) const;
static KnobValue parseKnobValue(std::string const& knobName, std::string const& knobValue, Type);

View File

@ -35,6 +35,10 @@ void TestKnobCollection::reset(Randomize randomize, IsSimulated isSimulated) {
testKnobs.reset();
}
void TestKnobCollection::clearTestKnobs() {
testKnobs.reset();
}
Optional<KnobValue> TestKnobCollection::tryParseKnobValue(std::string const& knobName,
std::string const& knobValue) const {
auto result = serverKnobCollection.tryParseKnobValue(knobName, knobValue);

View File

@ -52,6 +52,7 @@ public:
ClientKnobs const& getClientKnobs() const override { return serverKnobCollection.getClientKnobs(); }
ServerKnobs const& getServerKnobs() const override { return serverKnobCollection.getServerKnobs(); }
TestKnobs const& getTestKnobs() const override { return testKnobs; }
void clearTestKnobs() override;
Optional<KnobValue> tryParseKnobValue(std::string const& knobName, std::string const& knobValue) const override;
bool trySetKnob(std::string const& knobName, KnobValueRef const& knobValue) override;
};

View File

@ -227,6 +227,9 @@ class LocalConfigurationImpl {
void updateInMemoryState(Version lastSeenVersion) {
this->lastSeenVersion = lastSeenVersion;
if (g_network->isSimulated()) {
getKnobs().clearTestKnobs();
}
configKnobOverrides.update(getKnobs());
manualKnobOverrides.update(getKnobs());
// FIXME: Reinitialize in order to update dependent knobs?