Simplified Downgrade workload

This commit is contained in:
sfc-gh-tclinkenbeard 2020-07-12 16:06:56 -07:00
parent 369d1be562
commit de2b35f727
1 changed files with 4 additions and 7 deletions

View File

@ -36,15 +36,13 @@ struct DowngradeWorkload : TestWorkload {
numObjects = getOption(options, LiteralStringRef("numOptions"), deterministicRandom()->randomInt(0,100)); numObjects = getOption(options, LiteralStringRef("numOptions"), deterministicRandom()->randomInt(0,100));
} }
template <class Impl>
struct _Struct { struct _Struct {
static constexpr FileIdentifier file_identifier = 2340487; static constexpr FileIdentifier file_identifier = 2340487;
int oldField = 0; int oldField = 0;
}; };
struct OldStruct : public _Struct<OldStruct> { struct OldStruct : public _Struct {
void setFields() { oldField = 1; } void setFields() { oldField = 1; }
bool isSet() const { return oldField == 1; } bool isSet() const { return oldField == 1; }
template <class Archive> template <class Archive>
@ -53,13 +51,12 @@ struct DowngradeWorkload : TestWorkload {
} }
}; };
struct NewStruct : public _Struct<NewStruct> { struct NewStruct : public _Struct {
int newField = 0; int newField = 0;
bool isSet() const { bool isSet() const {
return oldField == 1 && newField == 2; return oldField == 1 && newField == 2;
} }
void setFields() { void setFields() {
oldField = 1; oldField = 1;
newField = 2; newField = 2;
@ -74,8 +71,8 @@ struct DowngradeWorkload : TestWorkload {
ACTOR static Future<Void> writeOld(Database cx, int numObjects, Key key) { ACTOR static Future<Void> writeOld(Database cx, int numObjects, Key key) {
BinaryWriter writer(IncludeVersion(currentProtocolVersion)); BinaryWriter writer(IncludeVersion(currentProtocolVersion));
std::vector<OldStruct> data(numObjects); std::vector<OldStruct> data(numObjects);
for (auto& oldStruct : data) { for (auto& oldObject : data) {
oldStruct.setFields(); oldObject.setFields();
} }
writer << data; writer << data;
state Value value = writer.toValue(); state Value value = writer.toValue();