Fix HighContentionPrefixAllocatorWorkload and make untrusted argument to workload factory type safe

This commit is contained in:
Markus Pilman 2022-10-14 09:51:49 -06:00
parent fb1390ef3d
commit 180238076c
5 changed files with 10 additions and 6 deletions

View File

@ -231,13 +231,16 @@ struct IWorkloadFactory : ReferenceCounted<IWorkloadFactory> {
virtual Reference<TestWorkload> create(WorkloadContext const& wcx) = 0;
};
FDB_DECLARE_BOOLEAN_PARAM(UntrustedMode);
template <class Workload>
struct WorkloadFactory : IWorkloadFactory {
static_assert(std::is_convertible_v<decltype(Workload::NAME), std::string>,
"Each workload must have a Workload::NAME member");
using WorkloadType = TestWorkloadImpl<Workload>;
bool runInUntrustedClient;
WorkloadFactory(bool runInUntrustedClient = false) : runInUntrustedClient(runInUntrustedClient) {
WorkloadFactory(UntrustedMode runInUntrustedClient = UntrustedMode::False)
: runInUntrustedClient(runInUntrustedClient) {
factories()[WorkloadType::NAME] = Reference<IWorkloadFactory>::addRef(this);
}
Reference<TestWorkload> create(WorkloadContext const& wcx) override {

View File

@ -46,6 +46,8 @@
#include "fdbserver/WorkerInterface.actor.h"
#include "flow/actorcompiler.h" // This must be the last #include.
FDB_DEFINE_BOOLEAN_PARAM(UntrustedMode);
WorkloadContext::WorkloadContext() {}
WorkloadContext::WorkloadContext(const WorkloadContext& r)

View File

@ -328,5 +328,5 @@ struct CycleWorkload : TestWorkload, CycleMembers<MultiTenancy> {
}
};
WorkloadFactory<CycleWorkload<false>> CycleWorkloadFactory(false);
WorkloadFactory<CycleWorkload<true>> TenantCycleWorkloadFactory(true);
WorkloadFactory<CycleWorkload<false>> CycleWorkloadFactory(UntrustedMode::False);
WorkloadFactory<CycleWorkload<true>> TenantCycleWorkloadFactory(UntrustedMode::True);

View File

@ -154,5 +154,4 @@ struct HighContentionPrefixAllocatorWorkload : TestWorkload {
void getMetrics(std::vector<PerfMetric>& m) override {}
};
WorkloadFactory<HighContentionPrefixAllocatorWorkload> HighContentionPrefixAllocatorWorkload(
HighContentionPrefixAllocatorWorkload::NAME);
WorkloadFactory<HighContentionPrefixAllocatorWorkload> HighContentionPrefixAllocatorWorkload;

View File

@ -141,4 +141,4 @@ struct PrivateEndpoints : TestWorkload {
} // namespace
WorkloadFactory<PrivateEndpoints> PrivateEndpointsFactory(true);
WorkloadFactory<PrivateEndpoints> PrivateEndpointsFactory(UntrustedMode::True);