You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2019/06/07 07:43:40 UTC
[kudu] branch master updated: fuzz-itest: assorted cleanup
This is an automated email from the ASF dual-hosted git repository.
adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 0deeafe fuzz-itest: assorted cleanup
0deeafe is described below
commit 0deeafee3a66422d0242e0e3e7d60020a011802a
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Wed Jun 5 17:50:48 2019 -0700
fuzz-itest: assorted cleanup
No functional changes here, though this does change the textual
representation of a fuzz-itest op.
Change-Id: I1792f4f2d83403c9ae57acb29190246d5f036e69
Reviewed-on: http://gerrit.cloudera.org:8080/13532
Reviewed-by: Mike Percy <mp...@apache.org>
Tested-by: Kudu Jenkins
---
src/kudu/integration-tests/fuzz-itest.cc | 258 +++++++++++++++++--------------
1 file changed, 142 insertions(+), 116 deletions(-)
diff --git a/src/kudu/integration-tests/fuzz-itest.cc b/src/kudu/integration-tests/fuzz-itest.cc
index c33b971..dbc0ee4 100644
--- a/src/kudu/integration-tests/fuzz-itest.cc
+++ b/src/kudu/integration-tests/fuzz-itest.cc
@@ -71,6 +71,33 @@ DECLARE_bool(enable_maintenance_manager);
DECLARE_bool(scanner_allow_snapshot_scans_with_logical_timestamps);
DECLARE_bool(use_hybrid_clock);
+using boost::optional;
+using kudu::client::KuduClient;
+using kudu::client::KuduClientBuilder;
+using kudu::client::KuduDelete;
+using kudu::client::KuduPredicate;
+using kudu::client::KuduScanBatch;
+using kudu::client::KuduScanner;
+using kudu::client::KuduSchema;
+using kudu::client::KuduSession;
+using kudu::client::KuduTable;
+using kudu::client::KuduTableCreator;
+using kudu::client::KuduUpdate;
+using kudu::client::KuduValue;
+using kudu::client::KuduWriteOperation;
+using kudu::client::sp::shared_ptr;
+using kudu::cluster::InternalMiniCluster;
+using kudu::cluster::InternalMiniClusterOptions;
+using std::list;
+using std::map;
+using std::string;
+using std::vector;
+using std::unique_ptr;
+using strings::Substitute;
+
+namespace kudu {
+namespace tablet {
+
// The type of operation in a sequence of operations generated by
// the fuzz test.
enum TestOpType {
@@ -90,40 +117,8 @@ enum TestOpType {
TEST_SCAN_AT_TIMESTAMP,
TEST_NUM_OP_TYPES // max value for enum
};
-MAKE_ENUM_LIMITS(TestOpType, TEST_INSERT, TEST_NUM_OP_TYPES);
const char* kTableName = "table";
-
-namespace kudu {
-
-using boost::optional;
-using client::KuduClient;
-using client::KuduClientBuilder;
-using client::KuduDelete;
-using client::KuduPredicate;
-using client::KuduScanBatch;
-using client::KuduScanner;
-using client::KuduSchema;
-using client::KuduSchemaBuilder;
-using client::KuduSession;
-using client::KuduTable;
-using client::KuduTableCreator;
-using client::KuduUpdate;
-using client::KuduUpsert;
-using client::KuduValue;
-using client::KuduWriteOperation;
-using client::sp::shared_ptr;
-using cluster::InternalMiniCluster;
-using cluster::InternalMiniClusterOptions;
-using std::list;
-using std::map;
-using std::string;
-using std::vector;
-using std::unique_ptr;
-using strings::Substitute;
-
-namespace tablet {
-
const char* TestOpType_names[] = {
"TEST_INSERT",
"TEST_INSERT_PK_ONLY",
@@ -143,6 +138,11 @@ const char* TestOpType_names[] = {
// An operation in a fuzz-test sequence.
struct TestOp {
+ // NOLINTNEXTLINE(google-explicit-constructor)
+ TestOp(TestOpType t, int v = 0) // NOLINT(runtime/explicit)
+ : type(t),
+ val(v) {}
+
// The op to run.
TestOpType type;
@@ -152,7 +152,27 @@ struct TestOp {
int val;
string ToString() const {
- return strings::Substitute("{$0, $1}", TestOpType_names[type], val);
+ switch (type) {
+ case TEST_FLUSH_OPS:
+ case TEST_FLUSH_TABLET:
+ case TEST_COMPACT_TABLET:
+ case TEST_FLUSH_DELTAS:
+ case TEST_MAJOR_COMPACT_DELTAS:
+ case TEST_MINOR_COMPACT_DELTAS:
+ case TEST_RESTART_TS:
+ return strings::Substitute("{$0}", TestOpType_names[type]);
+ case TEST_INSERT:
+ case TEST_INSERT_PK_ONLY:
+ case TEST_UPSERT:
+ case TEST_UPSERT_PK_ONLY:
+ case TEST_UPDATE:
+ case TEST_DELETE:
+ case TEST_SCAN_AT_TIMESTAMP:
+ return strings::Substitute("{$0, $1}", TestOpType_names[type], val);
+ default:
+ LOG(FATAL) << "Invalid op type: " << type;
+ }
+ __builtin_unreachable();
}
};
@@ -477,6 +497,7 @@ TestOpType PickOpAtRandom(TestOpSets sets) {
default:
LOG(FATAL) << "Unknown TestOpSets type: " << sets;
}
+ __builtin_unreachable();
}
bool IsMutation(const TestOpType& op) {
@@ -517,14 +538,14 @@ void GenerateTestCase(vector<TestOp>* ops, int len, TestOpSets sets = ALL) {
case TEST_INSERT:
case TEST_INSERT_PK_ONLY:
if (exists[row_key]) continue;
- ops->push_back({r, row_key});
+ ops->emplace_back(r, row_key);
exists[row_key] = true;
ops_pending = true;
data_in_mrs = true;
break;
case TEST_UPSERT:
case TEST_UPSERT_PK_ONLY:
- ops->push_back({r, row_key});
+ ops->emplace_back(r, row_key);
exists[row_key] = true;
ops_pending = true;
// If the row doesn't currently exist, this will act like an insert
@@ -539,7 +560,7 @@ void GenerateTestCase(vector<TestOp>* ops, int len, TestOpSets sets = ALL) {
break;
case TEST_UPDATE:
if (!exists[row_key]) continue;
- ops->push_back({TEST_UPDATE, row_key});
+ ops->emplace_back(TEST_UPDATE, row_key);
ops_pending = true;
if (!data_in_mrs) {
data_in_dms = true;
@@ -547,7 +568,7 @@ void GenerateTestCase(vector<TestOp>* ops, int len, TestOpSets sets = ALL) {
break;
case TEST_DELETE:
if (!exists[row_key]) continue;
- ops->push_back({TEST_DELETE, row_key});
+ ops->emplace_back(TEST_DELETE, row_key);
ops_pending = true;
exists[row_key] = false;
if (!data_in_mrs) {
@@ -556,7 +577,7 @@ void GenerateTestCase(vector<TestOp>* ops, int len, TestOpSets sets = ALL) {
break;
case TEST_FLUSH_OPS:
if (ops_pending) {
- ops->push_back({TEST_FLUSH_OPS, 0});
+ ops->emplace_back(TEST_FLUSH_OPS);
ops_pending = false;
op_timestamps++;
}
@@ -564,10 +585,10 @@ void GenerateTestCase(vector<TestOp>* ops, int len, TestOpSets sets = ALL) {
case TEST_FLUSH_TABLET:
if (data_in_mrs) {
if (ops_pending) {
- ops->push_back({TEST_FLUSH_OPS, 0});
+ ops->emplace_back(TEST_FLUSH_OPS);
ops_pending = false;
}
- ops->push_back({TEST_FLUSH_TABLET, 0});
+ ops->emplace_back(TEST_FLUSH_TABLET);
data_in_mrs = false;
worth_compacting = true;
}
@@ -575,38 +596,38 @@ void GenerateTestCase(vector<TestOp>* ops, int len, TestOpSets sets = ALL) {
case TEST_COMPACT_TABLET:
if (worth_compacting) {
if (ops_pending) {
- ops->push_back({TEST_FLUSH_OPS, 0});
+ ops->emplace_back(TEST_FLUSH_OPS);
ops_pending = false;
}
- ops->push_back({TEST_COMPACT_TABLET, 0});
+ ops->emplace_back(TEST_COMPACT_TABLET);
worth_compacting = false;
}
break;
case TEST_FLUSH_DELTAS:
if (data_in_dms) {
if (ops_pending) {
- ops->push_back({TEST_FLUSH_OPS, 0});
+ ops->emplace_back(TEST_FLUSH_OPS);
ops_pending = false;
}
- ops->push_back({TEST_FLUSH_DELTAS, 0});
+ ops->emplace_back(TEST_FLUSH_DELTAS);
data_in_dms = false;
}
break;
case TEST_MAJOR_COMPACT_DELTAS:
- ops->push_back({TEST_MAJOR_COMPACT_DELTAS, 0});
+ ops->emplace_back(TEST_MAJOR_COMPACT_DELTAS);
break;
case TEST_MINOR_COMPACT_DELTAS:
- ops->push_back({TEST_MINOR_COMPACT_DELTAS, 0});
+ ops->emplace_back(TEST_MINOR_COMPACT_DELTAS);
break;
case TEST_RESTART_TS:
- ops->push_back({TEST_RESTART_TS, 0});
+ ops->emplace_back(TEST_RESTART_TS);
break;
case TEST_SCAN_AT_TIMESTAMP: {
int timestamp = 1;
if (op_timestamps > 0) {
timestamp = (rand() % op_timestamps) + 1;
}
- ops->push_back({TEST_SCAN_AT_TIMESTAMP, timestamp});
+ ops->emplace_back(TEST_SCAN_AT_TIMESTAMP, timestamp);
break;
}
default:
@@ -764,14 +785,14 @@ TEST_F(FuzzTest, TestFuzz1) {
vector<TestOp> test_ops = {
// Get an inserted row in a DRS.
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
// DELETE in DMS, INSERT in MRS and flush again.
{TEST_DELETE, 0},
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
// State:
// RowSet RowSet(0):
@@ -779,7 +800,7 @@ TEST_F(FuzzTest, TestFuzz1) {
// RowSet RowSet(1):
// (int32 key=1, int32 val=NULL) Undos: [@2(DELETE)] Redos: []
- {TEST_COMPACT_TABLET, 0},
+ {TEST_COMPACT_TABLET},
};
RunFuzzCase(test_ops);
}
@@ -790,8 +811,8 @@ TEST_F(FuzzTest, TestFuzz2) {
vector<TestOp> test_ops = {
{TEST_INSERT, 0},
{TEST_DELETE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
// (int32 key=1, int32 val=NULL)
// Undo Mutations: [@1(DELETE)]
// Redo Mutations: [@1(DELETE)]
@@ -799,20 +820,20 @@ TEST_F(FuzzTest, TestFuzz2) {
{TEST_INSERT, 0},
{TEST_DELETE, 0},
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
// (int32 key=1, int32 val=NULL)
// Undo Mutations: [@2(DELETE)]
// Redo Mutations: []
- {TEST_COMPACT_TABLET, 0},
+ {TEST_COMPACT_TABLET},
// Output Row: (int32 key=1, int32 val=NULL)
// Undo Mutations: [@1(DELETE)]
// Redo Mutations: [@1(DELETE)]
{TEST_DELETE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_COMPACT_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_COMPACT_TABLET},
};
RunFuzzCase(test_ops);
}
@@ -822,8 +843,8 @@ TEST_F(FuzzTest, TestFuzz3) {
CreateTabletAndStartClusterWithSchema(CreateKeyValueTestSchema());
vector<TestOp> test_ops = {
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
// Output Row: (int32 key=1, int32 val=NULL)
// Undo Mutations: [@1(DELETE)]
// Redo Mutations: []
@@ -833,8 +854,8 @@ TEST_F(FuzzTest, TestFuzz3) {
{TEST_INSERT, 0},
{TEST_DELETE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
// (int32 key=1, int32 val=NULL)
// Undo Mutations: [@2(DELETE)]
// Redo Mutations: [@2(DELETE)]
@@ -847,7 +868,7 @@ TEST_F(FuzzTest, TestFuzz3) {
// Undo Mutations: [@1(DELETE)]
// Redo Mutations: [@2(DELETE)]
- {TEST_COMPACT_TABLET, 0},
+ {TEST_COMPACT_TABLET},
};
RunFuzzCase(test_ops);
}
@@ -857,29 +878,29 @@ TEST_F(FuzzTest, TestFuzz4) {
CreateTabletAndStartClusterWithSchema(CreateKeyValueTestSchema());
vector<TestOp> test_ops = {
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_COMPACT_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_COMPACT_TABLET},
{TEST_DELETE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_COMPACT_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_COMPACT_TABLET},
{TEST_INSERT, 0},
{TEST_UPDATE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_DELETE, 0},
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_UPDATE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_UPDATE, 0},
{TEST_DELETE, 0},
{TEST_INSERT, 0},
{TEST_DELETE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
- {TEST_COMPACT_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
+ {TEST_COMPACT_TABLET},
};
RunFuzzCase(test_ops);
}
@@ -889,7 +910,7 @@ TEST_F(FuzzTest, TestFuzz5) {
CreateTabletAndStartClusterWithSchema(CreateKeyValueTestSchema());
vector<TestOp> test_ops = {
{TEST_UPSERT_PK_ONLY, 1},
- {TEST_FLUSH_OPS, 0},
+ {TEST_FLUSH_OPS},
{TEST_INSERT, 0},
{TEST_SCAN_AT_TIMESTAMP, 5},
};
@@ -905,22 +926,22 @@ TEST_F(FuzzTest, TestFuzzWithRestarts1) {
CreateTabletAndStartClusterWithSchema(CreateKeyValueTestSchema());
RunFuzzCase({
{TEST_INSERT, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_UPDATE, 1},
- {TEST_RESTART_TS, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_DELTAS, 0},
+ {TEST_RESTART_TS},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_DELTAS},
{TEST_INSERT, 0},
{TEST_DELETE, 1},
{TEST_INSERT, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
- {TEST_RESTART_TS, 0},
- {TEST_MINOR_COMPACT_DELTAS, 0},
- {TEST_COMPACT_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
+ {TEST_RESTART_TS},
+ {TEST_MINOR_COMPACT_DELTAS},
+ {TEST_COMPACT_TABLET},
{TEST_UPDATE, 1},
- {TEST_FLUSH_OPS, 0}
+ {TEST_FLUSH_OPS}
});
}
@@ -932,32 +953,32 @@ TEST_F(FuzzTest, TestFuzzWithRestarts2) {
CreateTabletAndStartClusterWithSchema(CreateKeyValueTestSchema());
RunFuzzCase({
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_DELETE, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_DELTAS, 0},
- {TEST_RESTART_TS, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_DELTAS},
+ {TEST_RESTART_TS},
{TEST_INSERT, 1},
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_DELETE, 0},
{TEST_INSERT, 0},
{TEST_UPDATE, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
- {TEST_FLUSH_DELTAS, 0},
- {TEST_RESTART_TS, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
+ {TEST_FLUSH_DELTAS},
+ {TEST_RESTART_TS},
{TEST_UPDATE, 1},
{TEST_DELETE, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_RESTART_TS, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_RESTART_TS},
{TEST_INSERT, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
- {TEST_RESTART_TS, 0},
- {TEST_COMPACT_TABLET, 0}
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
+ {TEST_RESTART_TS},
+ {TEST_COMPACT_TABLET}
});
}
@@ -968,15 +989,15 @@ TEST_F(FuzzTest, TestUpsertSeq) {
RunFuzzCase({
{TEST_INSERT, 1},
{TEST_UPSERT, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
{TEST_UPSERT, 1},
{TEST_DELETE, 1},
{TEST_UPSERT, 1},
{TEST_INSERT, 0},
- {TEST_FLUSH_OPS, 0},
- {TEST_FLUSH_TABLET, 0},
- {TEST_RESTART_TS, 0},
+ {TEST_FLUSH_OPS},
+ {TEST_FLUSH_TABLET},
+ {TEST_RESTART_TS},
{TEST_UPDATE, 1},
});
}
@@ -987,10 +1008,10 @@ TEST_F(FuzzTest, TestUpsert_PKOnlyOps) {
CreateTabletAndStartClusterWithSchema(CreateKeyValueTestSchema());
RunFuzzCase({
{TEST_INSERT, 1},
- {TEST_FLUSH_OPS, 0},
+ {TEST_FLUSH_OPS},
{TEST_UPSERT_PK_ONLY, 1},
- {TEST_FLUSH_OPS, 0},
- {TEST_RESTART_TS, 0}
+ {TEST_FLUSH_OPS},
+ {TEST_RESTART_TS}
});
}
@@ -1004,9 +1025,14 @@ TEST_F(FuzzTest, TestUpsert_PKOnlySchema) {
{TEST_DELETE, 1},
{TEST_UPSERT_PK_ONLY, 1},
{TEST_UPSERT_PK_ONLY, 1},
- {TEST_FLUSH_OPS, 0}
+ {TEST_FLUSH_OPS}
});
}
} // namespace tablet
} // namespace kudu
+
+// Has to be defined outside of any namespace.
+MAKE_ENUM_LIMITS(kudu::tablet::TestOpType,
+ kudu::tablet::TEST_INSERT,
+ kudu::tablet::TEST_NUM_OP_TYPES);