Merge pull request #8233 from sfc-gh-mpilman/features/disable-failure-injection-for-workload

All workloads to disable some failures
This commit is contained in:
Trevor Clinkenbeard 2022-09-20 16:17:35 -07:00 committed by GitHub
commit 3b5117ca92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 7 deletions

View File

@ -75,6 +75,7 @@ struct TestWorkload : NonCopyable, WorkloadContext, ReferenceCounted<TestWorkloa
virtual ~TestWorkload(){};
virtual Future<Void> initialized() { return Void(); }
virtual std::string description() const = 0;
virtual void disableFailureInjectionWorkloads(std::set<std::string>& out) const;
virtual Future<Void> setup(Database const& cx) { return Void(); }
virtual Future<Void> start(Database const& cx) = 0;
virtual Future<bool> check(Database const& cx) = 0;

View File

@ -384,19 +384,21 @@ void CompoundWorkload::addFailureInjection(WorkloadRequest& work) {
if (!work.runFailureWorkloads || !FLOW_KNOBS->ENABLE_SIMULATION_IMPROVEMENTS) {
return;
}
// Some common workloads won't work with failure injection workloads
// Some workloads won't work with some failure injection workloads
std::set<std::string> disabledWorkloads;
for (auto const& w : workloads) {
auto desc = w->description();
if (desc == "ChangeConfig") {
return;
} else if (desc == "SaveAndKill") {
return;
}
w->disableFailureInjectionWorkloads(disabledWorkloads);
}
if (disabledWorkloads.count("all") > 0) {
return;
}
auto& factories = IFailureInjectorFactory::factories();
DeterministicRandom random(sharedRandomNumber);
for (auto& factory : factories) {
auto workload = factory->create(*this);
if (disabledWorkloads.count(workload->description()) > 0) {
continue;
}
while (workload->add(random, work, *this)) {
failureInjection.push_back(workload);
workload = factory->create(*this);
@ -419,6 +421,8 @@ void CompoundWorkload::getMetrics(std::vector<PerfMetric>&) {
ASSERT(false);
}
void TestWorkload::disableFailureInjectionWorkloads(std::set<std::string>& out) const {}
FailureInjectionWorkload::FailureInjectionWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {}
bool FailureInjectionWorkload::add(DeterministicRandom& random,

View File

@ -49,6 +49,8 @@ struct ChangeConfigWorkload : TestWorkload {
std::string description() const override { return "ChangeConfig"; }
void disableFailureInjectionWorkloads(std::set<std::string>& out) const override { out.insert("all"); }
Future<Void> start(Database const& cx) override {
if (this->clientId != 0)
return Void();

View File

@ -45,6 +45,7 @@ struct SaveAndKillWorkload : TestWorkload {
}
std::string description() const override { return "SaveAndKillWorkload"; }
void disableFailureInjectionWorkloads(std::set<std::string>& out) const override { out.insert("all"); }
Future<Void> setup(Database const& cx) override {
g_simulator->disableSwapsToAll();
return Void();