diff --git a/script/validators/source_validator.py b/script/validators/source_validator.py index 331bdc7c688..3eaa651d8fc 100755 --- a/script/validators/source_validator.py +++ b/script/validators/source_validator.py @@ -66,6 +66,8 @@ "src/codegen/util/cc_hash_table.cpp" ] +TEST_CASE_PATT = re.compile(r'TEST_F\(([a-zA-Z]+), ([a-zA-Z]+)\)') + ## ============================================== ## UTILITY FUNCTION DEFINITIONS ## ============================================== @@ -202,6 +204,39 @@ def check_includes(file_path): return file_status +def check_tests(file_path): + """Checks test source files for correct class and method naming.""" + # check class naming + class_status = True # For reporting class names. + test_status = True # For reporting test cases. + line_num = 0 + with open(file_path, "r") as file: + for line in file: + line_num += 1 + if line.startswith('class '): + class_name = line.split(' ')[1] + if not class_name.endswith('Tests'): + if class_status: + LOG.info("Invalid class name in %s", file_path) + class_status = False + LOG.info("Line %s: %s", line_num, line.strip()) + + else: + # Check test case names. + case_found = TEST_CASE_PATT.match(line) + if case_found and not case_found.groups()[1].endswith('Test'): + if test_status: + LOG.info("Invalid test name in %s", file_path) + test_status = False + LOG.info("Line %s: %s", line_num, line.strip()) + + if not class_status: + LOG.info("Test class names should end with 'Tests' suffix.") + if not test_status: + LOG.info("Test case names should end with 'Test' suffix.") + + return class_status and test_status + VALIDATORS = [ check_common_patterns, check_includes, @@ -224,6 +259,11 @@ def validate_file(file_path): if not validator(file_path): file_status = False + relative_path = os.path.relpath(file_path, start=PELOTON_DIR) + if relative_path.startswith('/test/') and relative_path.endswith('.cpp'): + if not relative_path.endswith('_util.cpp'): + file_status = check_tests(file_path) + return file_status diff --git a/test/binder/binder_test.cpp b/test/binder/binder_test.cpp index b5b266c21cf..6164548b7f6 100644 --- a/test/binder/binder_test.cpp +++ b/test/binder/binder_test.cpp @@ -37,9 +37,9 @@ using std::vector; namespace peloton { namespace test { -class BinderCorrectnessTest : public PelotonTest { +class BinderCorrectnessTests : public PelotonTests { virtual void SetUp() override { - PelotonTest::SetUp(); + PelotonTests::SetUp(); catalog::Catalog::GetInstance(); // NOTE: Catalog::GetInstance()->Bootstrap(), you can only call it once! TestingExecutorUtil::InitializeDatabase(DEFAULT_DB_NAME); @@ -47,7 +47,7 @@ class BinderCorrectnessTest : public PelotonTest { virtual void TearDown() override { TestingExecutorUtil::DeleteDatabase(DEFAULT_DB_NAME); - PelotonTest::TearDown(); + PelotonTests::TearDown(); } }; @@ -101,7 +101,7 @@ void SetupTables(std::string database_name) { } } -TEST_F(BinderCorrectnessTest, SelectStatementTest) { +TEST_F(BinderCorrectnessTests, SelectStatementTest) { std::string default_database_name = "test_db"; SetupTables(default_database_name); auto &parser = parser::PostgresParser::GetInstance(); @@ -127,14 +127,14 @@ TEST_F(BinderCorrectnessTest, SelectStatementTest) { oid_t db_oid = catalog_ptr->GetDatabaseWithName(default_database_name, txn)->GetOid(); - oid_t tableA_oid = catalog_ptr - ->GetTableWithName(default_database_name, - DEFAULT_SCHEMA_NAME, "a", txn) - ->GetOid(); - oid_t tableB_oid = catalog_ptr - ->GetTableWithName(default_database_name, - DEFAULT_SCHEMA_NAME, "b", txn) - ->GetOid(); + oid_t tableA_oid = + catalog_ptr->GetTableWithName(default_database_name, DEFAULT_SCHEMA_NAME, + "a", txn) + ->GetOid(); + oid_t tableB_oid = + catalog_ptr->GetTableWithName(default_database_name, DEFAULT_SCHEMA_NAME, + "b", txn) + ->GetOid(); txn_manager.CommitTransaction(txn); // Check select_list @@ -250,7 +250,7 @@ TEST_F(BinderCorrectnessTest, SelectStatementTest) { // instead of TupleValueExpression to represent column. We can only add this // test after UpdateStatement is changed -TEST_F(BinderCorrectnessTest, DeleteStatementTest) { +TEST_F(BinderCorrectnessTests, DeleteStatementTest) { std::string default_database_name = "test_db"; SetupTables(default_database_name); auto &parser = parser::PostgresParser::GetInstance(); @@ -260,10 +260,10 @@ TEST_F(BinderCorrectnessTest, DeleteStatementTest) { auto txn = txn_manager.BeginTransaction(); oid_t db_oid = catalog_ptr->GetDatabaseWithName(default_database_name, txn)->GetOid(); - oid_t tableB_oid = catalog_ptr - ->GetTableWithName(default_database_name, - DEFAULT_SCHEMA_NAME, "b", txn) - ->GetOid(); + oid_t tableB_oid = + catalog_ptr->GetTableWithName(default_database_name, DEFAULT_SCHEMA_NAME, + "b", txn) + ->GetOid(); string deleteSQL = "DELETE FROM b WHERE 1 = b1 AND b2 = 'str'"; unique_ptr binder( @@ -292,7 +292,7 @@ TEST_F(BinderCorrectnessTest, DeleteStatementTest) { txn_manager.CommitTransaction(txn); } -TEST_F(BinderCorrectnessTest, BindDepthTest) { +TEST_F(BinderCorrectnessTests, BindDepthTest) { std::string default_database_name = "test_db"; SetupTables(default_database_name); auto &parser = parser::PostgresParser::GetInstance(); @@ -382,7 +382,7 @@ TEST_F(BinderCorrectnessTest, BindDepthTest) { txn_manager.CommitTransaction(txn); } -TEST_F(BinderCorrectnessTest, FunctionExpressionTest) { +TEST_F(BinderCorrectnessTests, FunctionExpressionTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); diff --git a/test/brain/query_clusterer_test.cpp b/test/brain/query_clusterer_test.cpp index 5e51d8350a4..92742b86849 100644 --- a/test/brain/query_clusterer_test.cpp +++ b/test/brain/query_clusterer_test.cpp @@ -52,7 +52,7 @@ bool ClusterCorrectness(std::set clusters, return check; } -class QueryClustererTests : public PelotonTest {}; +class QueryClustererTests : public PelotonTests {}; TEST_F(QueryClustererTests, ClusterTest) { int num_features = 5; diff --git a/test/brain/query_logger_test.cpp b/test/brain/query_logger_test.cpp index c3affa7fd40..01ef1696d70 100644 --- a/test/brain/query_logger_test.cpp +++ b/test/brain/query_logger_test.cpp @@ -19,7 +19,7 @@ namespace peloton { namespace test { -class QueryLoggerTests : public PelotonTest { +class QueryLoggerTests : public PelotonTests { protected: void SetUp() override { settings::SettingsManager::SetBool(settings::SettingId::brain, true); diff --git a/test/brain/tensorflow_test.cpp b/test/brain/tensorflow_test.cpp index c0c659f5bb9..2391301e8d2 100644 --- a/test/brain/tensorflow_test.cpp +++ b/test/brain/tensorflow_test.cpp @@ -26,7 +26,7 @@ namespace test { // Tensorflow Tests //===--------------------------------------------------------------------===// -class TensorflowTests : public PelotonTest {}; +class TensorflowTests : public PelotonTests {}; TEST_F(TensorflowTests, BasicTFTest) { // Check that the tensorflow library imports and prints version info correctly @@ -46,8 +46,8 @@ TEST_F(TensorflowTests, SineWavePredictionTest) { int NUM_WAVES = 3; matrix_eig data = matrix_eig::Zero(NUM_SAMPLES, NUM_WAVES); for (int i = 0; i < NUM_WAVES; i++) { - data.col(i).setLinSpaced(NUM_SAMPLES, NUM_SAMPLES * i, - NUM_SAMPLES * (i + 1) - 1); + data.col(i) + .setLinSpaced(NUM_SAMPLES, NUM_SAMPLES * i, NUM_SAMPLES * (i + 1) - 1); data.col(i) = data.col(i).array().sin(); } diff --git a/test/catalog/catalog_test.cpp b/test/catalog/catalog_test.cpp index 36af866b958..4236bca0444 100644 --- a/test/catalog/catalog_test.cpp +++ b/test/catalog/catalog_test.cpp @@ -33,9 +33,9 @@ namespace test { // Catalog Tests //===--------------------------------------------------------------------===// -class CatalogTests : public PelotonTest {}; +class CatalogTests : public PelotonTests {}; -TEST_F(CatalogTests, BootstrappingCatalog) { +TEST_F(CatalogTests, BootstrappingCatalogTest) { auto catalog = catalog::Catalog::GetInstance(); catalog->Bootstrap(); EXPECT_EQ(1, storage::StorageManager::GetInstance()->GetDatabaseCount()); @@ -52,7 +52,7 @@ TEST_F(CatalogTests, BootstrappingCatalog) { EXPECT_NE(nullptr, db_metric_table); } // -TEST_F(CatalogTests, CreatingDatabase) { +TEST_F(CatalogTests, CreatingDatabaseTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase("emp_db", txn); @@ -62,7 +62,7 @@ TEST_F(CatalogTests, CreatingDatabase) { txn_manager.CommitTransaction(txn); } -TEST_F(CatalogTests, CreatingTable) { +TEST_F(CatalogTests, CreatingTableTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); auto id_column = catalog::Column( @@ -120,7 +120,7 @@ TEST_F(CatalogTests, CreatingTable) { txn_manager.CommitTransaction(txn); } -TEST_F(CatalogTests, TableObject) { +TEST_F(CatalogTests, TableObjectTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -168,7 +168,7 @@ TEST_F(CatalogTests, TableObject) { txn_manager.CommitTransaction(txn); } -TEST_F(CatalogTests, TestingNamespace) { +TEST_F(CatalogTests, ingNamespaceTest) { EXPECT_EQ(ResultType::SUCCESS, TestingSQLUtil::ExecuteSQLQuery("begin;")); // create namespaces emp_ns0 and emp_ns1 EXPECT_EQ(ResultType::SUCCESS, TestingSQLUtil::ExecuteSQLQuery( @@ -231,7 +231,7 @@ TEST_F(CatalogTests, TestingNamespace) { EXPECT_EQ(ResultType::ABORTED, TestingSQLUtil::ExecuteSQLQuery("commit;")); } -TEST_F(CatalogTests, DroppingTable) { +TEST_F(CatalogTests, DroppingTableTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); auto catalog = catalog::Catalog::GetInstance(); @@ -293,7 +293,7 @@ TEST_F(CatalogTests, DroppingTable) { txn_manager.CommitTransaction(txn); } -TEST_F(CatalogTests, DroppingDatabase) { +TEST_F(CatalogTests, DroppingDatabaseTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName("emp_db", txn); @@ -304,7 +304,7 @@ TEST_F(CatalogTests, DroppingDatabase) { txn_manager.CommitTransaction(txn); } -TEST_F(CatalogTests, DroppingCatalog) { +TEST_F(CatalogTests, DroppingCatalogTest) { auto catalog = catalog::Catalog::GetInstance(); EXPECT_NE(nullptr, catalog); } diff --git a/test/catalog/constraints_test.cpp b/test/catalog/constraints_test.cpp index dfd8b015a81..5a9d5fe3115 100644 --- a/test/catalog/constraints_test.cpp +++ b/test/catalog/constraints_test.cpp @@ -38,7 +38,7 @@ namespace test { // Constraints Tests //===--------------------------------------------------------------------===// -class ConstraintsTests : public PelotonTest {}; +class ConstraintsTests : public PelotonTests {}; #ifdef CONSTRAINT_NOTNULL_TEST TEST_F(ConstraintsTests, NOTNULLTest) { @@ -112,7 +112,7 @@ TEST_F(ConstraintsTests, NOTNULLTest) { #endif #ifdef CONSTRAINT_DEFAULT_TEST -TEST_F(ConstraintsTests, DEFAULTTEST) { +TEST_F(ConstraintsTests, DEFAULTTESTTest) { // Set all of the columns to be NOT NULL std::vector> constraints; for (int i = 0; i < CONSTRAINTS_NUM_COLS; i++) { diff --git a/test/catalog/manager_test.cpp b/test/catalog/manager_test.cpp index 7b5ec2161ac..e2008a3dcc1 100644 --- a/test/catalog/manager_test.cpp +++ b/test/catalog/manager_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "catalog/manager.h" @@ -27,10 +26,9 @@ namespace test { // Manager Tests //===--------------------------------------------------------------------===// -class ManagerTests : public PelotonTest {}; +class ManagerTests : public PelotonTests {}; void AddTileGroup(UNUSED_ATTRIBUTE uint64_t thread_id) { - // TILES std::vector tile_column_names; std::vector> column_names; @@ -42,8 +40,9 @@ void AddTileGroup(UNUSED_ATTRIBUTE uint64_t thread_id) { std::vector columns; // SCHEMA - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); columns.push_back(column1); std::unique_ptr schema1(new catalog::Schema(columns)); diff --git a/test/catalog/tuple_schema_test.cpp b/test/catalog/tuple_schema_test.cpp index 4da8e445aa2..318291251a2 100644 --- a/test/catalog/tuple_schema_test.cpp +++ b/test/catalog/tuple_schema_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "catalog/schema.h" @@ -22,17 +21,20 @@ namespace test { // Tuple Schema Tests //===--------------------------------------------------------------------===// -class TupleSchemaTests : public PelotonTest {}; +class TupleSchemaTests : public PelotonTests {}; TEST_F(TupleSchemaTests, ColumnInfoTest) { std::vector columns; - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); columns.push_back(column1); columns.push_back(column2); @@ -43,17 +45,20 @@ TEST_F(TupleSchemaTests, ColumnInfoTest) { } /* - * TupleSchemaFilteringTest() - Tests FilterSchema() which uses a set + * TupleSchemaFilteringTests() - Tests FilterSchema() which uses a set */ TEST_F(TupleSchemaTests, TupleSchemaFilteringTest) { std::vector columns; - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); catalog::Column column4(type::TypeId::VARCHAR, 24, "D", false); columns.push_back(column1); @@ -70,54 +75,60 @@ TEST_F(TupleSchemaTests, TupleSchemaFilteringTest) { /////////////////////////////////////////////////////////////////// // Tests basic filterng /////////////////////////////////////////////////////////////////// - + std::vector subset{0, 2}; - std::unique_ptr schema3_p(catalog::Schema::FilterSchema(&schema2, subset)); + std::unique_ptr schema3_p( + catalog::Schema::FilterSchema(&schema2, subset)); LOG_INFO("%s", schema3_p->GetInfo().c_str()); EXPECT_NE(schema1, (*schema3_p)); - + /////////////////////////////////////////////////////////////////// // Tests out of order filtering (should not affected by order) /////////////////////////////////////////////////////////////////// - + subset = {2, 0}; - std::unique_ptr schema4_p(catalog::Schema::FilterSchema(&schema2, subset)); + std::unique_ptr schema4_p( + catalog::Schema::FilterSchema(&schema2, subset)); LOG_INFO("%s", schema4_p->GetInfo().c_str()); EXPECT_EQ((*schema4_p), (*schema3_p)); - + /////////////////////////////////////////////////////////////////// // Tests duplicated indices & out of bound indices /////////////////////////////////////////////////////////////////// - + subset = {666, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 2, 100, 101}; - - std::unique_ptr schema5_p(catalog::Schema::FilterSchema(&schema2, subset)); + + std::unique_ptr schema5_p( + catalog::Schema::FilterSchema(&schema2, subset)); LOG_INFO("%s", schema5_p->GetInfo().c_str()); EXPECT_EQ(schema5_p->GetColumnCount(), 2); EXPECT_EQ((*schema5_p), (*schema4_p)); - + /////////////////////////////////////////////////////////////////// // All tests finished ///////////////////////////////////////////////////////////////////./t - + return; } /* - * TupleSchemaCopyTest() - Tests CopySchema() which uses a list of indices + * TupleSchemaCopyTests() - Tests CopySchema() which uses a list of indices */ TEST_F(TupleSchemaTests, TupleSchemaCopyTest) { std::vector columns; - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); catalog::Column column4(type::TypeId::VARCHAR, 24, "D", false); columns.push_back(column1); @@ -132,7 +143,8 @@ TEST_F(TupleSchemaTests, TupleSchemaCopyTest) { /////////////////////////////////////////////////////////////////// std::vector subset{0, 2}; - std::unique_ptr schema3_p(catalog::Schema::CopySchema(&schema1, subset)); + std::unique_ptr schema3_p( + catalog::Schema::CopySchema(&schema1, subset)); LOG_INFO("%s", schema3_p->GetInfo().c_str()); EXPECT_NE(schema1, (*schema3_p)); @@ -142,7 +154,8 @@ TEST_F(TupleSchemaTests, TupleSchemaCopyTest) { /////////////////////////////////////////////////////////////////// subset = {2, 0}; - std::unique_ptr schema4_p(catalog::Schema::CopySchema(&schema1, subset)); + std::unique_ptr schema4_p( + catalog::Schema::CopySchema(&schema1, subset)); LOG_INFO("%s", schema4_p->GetInfo().c_str()); EXPECT_NE((*schema4_p), (*schema3_p)); @@ -153,7 +166,8 @@ TEST_F(TupleSchemaTests, TupleSchemaCopyTest) { subset = {0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 2, 1}; - std::unique_ptr schema5_p(catalog::Schema::CopySchema(&schema1, subset)); + std::unique_ptr schema5_p( + catalog::Schema::CopySchema(&schema1, subset)); LOG_INFO("%s", schema5_p->GetInfo().c_str()); EXPECT_EQ(schema5_p->GetColumnCount(), subset.size()); diff --git a/test/codegen/block_nested_loop_join_translator_test.cpp b/test/codegen/block_nested_loop_join_translator_test.cpp index 2c416f025a8..59d8afa196f 100644 --- a/test/codegen/block_nested_loop_join_translator_test.cpp +++ b/test/codegen/block_nested_loop_join_translator_test.cpp @@ -21,9 +21,9 @@ namespace peloton { namespace test { -class BlockNestedLoopJoinTranslatorTest : public PelotonCodeGenTest { +class BlockNestedLoopJoinTranslatorTests : public PelotonCodeGenTests { public: - BlockNestedLoopJoinTranslatorTest() : PelotonCodeGenTest() { + BlockNestedLoopJoinTranslatorTests() : PelotonCodeGenTests() { // Load the test table uint32_t num_rows = 10; LoadTestTable(LeftTableId(), 2 * num_rows); @@ -59,17 +59,15 @@ class BlockNestedLoopJoinTranslatorTest : public PelotonCodeGenTest { type::Value GetCol(const AbstractTuple &t, JoinOutputColPos p); }; -void BlockNestedLoopJoinTranslatorTest::PerformTest( +void BlockNestedLoopJoinTranslatorTests::PerformTest( ExpressionPtr &&predicate, const std::vector &left_join_cols, const std::vector &right_join_cols, std::vector &results) { // Output all columns - DirectMapList direct_map_list = {{0, std::make_pair(0, 0)}, - {1, std::make_pair(0, 1)}, - {2, std::make_pair(0, 2)}, - {3, std::make_pair(1, 0)}, - {4, std::make_pair(1, 1)}, - {5, std::make_pair(1, 2)}}; + DirectMapList direct_map_list = { + {0, std::make_pair(0, 0)}, {1, std::make_pair(0, 1)}, + {2, std::make_pair(0, 2)}, {3, std::make_pair(1, 0)}, + {4, std::make_pair(1, 1)}, {5, std::make_pair(1, 2)}}; std::unique_ptr projection{ new planner::ProjectInfo(TargetList{}, std::move(direct_map_list))}; @@ -104,12 +102,12 @@ void BlockNestedLoopJoinTranslatorTest::PerformTest( results = buffer.GetOutputTuples(); } -type::Value BlockNestedLoopJoinTranslatorTest::GetCol(const AbstractTuple &t, - JoinOutputColPos p) { +type::Value BlockNestedLoopJoinTranslatorTests::GetCol(const AbstractTuple &t, + JoinOutputColPos p) { return t.GetValue(static_cast(p)); } -TEST_F(BlockNestedLoopJoinTranslatorTest, SingleColumnEqualityJoin) { +TEST_F(BlockNestedLoopJoinTranslatorTests, SingleColumnEqualityJoinTest) { { LOG_INFO( "Testing: " @@ -172,7 +170,7 @@ TEST_F(BlockNestedLoopJoinTranslatorTest, SingleColumnEqualityJoin) { } } -TEST_F(BlockNestedLoopJoinTranslatorTest, NonEqualityJoin) { +TEST_F(BlockNestedLoopJoinTranslatorTests, NonEqualityJoinTest) { // The left and right input tables have the same schema and data distribution. // The test table has four columns: A, B, D, E. The values in column B, D, E // are 1, 2, and 3 more than the values in the A column, respectively. Values diff --git a/test/codegen/bloom_filter_test.cpp b/test/codegen/bloom_filter_test.cpp index ec632255dc9..69531e1ee25 100644 --- a/test/codegen/bloom_filter_test.cpp +++ b/test/codegen/bloom_filter_test.cpp @@ -36,9 +36,9 @@ namespace peloton { namespace test { -class BloomFilterCodegenTest : public PelotonTest { +class BloomFilterCodegenTests : public PelotonTests { public: - BloomFilterCodegenTest() { + BloomFilterCodegenTests() { // Create test db auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -46,7 +46,7 @@ class BloomFilterCodegenTest : public PelotonTest { txn_manager.CommitTransaction(txn); } - ~BloomFilterCodegenTest() { + ~BloomFilterCodegenTests() { // Drop test db auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -70,7 +70,7 @@ class BloomFilterCodegenTest : public PelotonTest { const std::string table2_name = "test2"; }; -TEST_F(BloomFilterCodegenTest, FalsePositiveRateTest) { +TEST_F(BloomFilterCodegenTests, FalsePositiveRateTest) { codegen::CodeContext code_context; codegen::CodeGen codegen(code_context); @@ -167,7 +167,7 @@ TEST_F(BloomFilterCodegenTest, FalsePositiveRateTest) { ASSERT_TRUE(code_context.Compile()); - typedef void (*ftype)(codegen::util::BloomFilter * bloom_filter, int *, int, + typedef void (*ftype)(codegen::util::BloomFilter *bloom_filter, int *, int, int *); ftype f = (ftype)code_context.GetRawFunctionPointer(func.GetFunction()); @@ -190,7 +190,7 @@ TEST_F(BloomFilterCodegenTest, FalsePositiveRateTest) { // Testing whether bloom filter can improve the performance of hash join // when the hash table is bigger than L3 cache and selectivity is low -TEST_F(BloomFilterCodegenTest, PerformanceTest) { +TEST_F(BloomFilterCodegenTests, PerformanceTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto *catalog = catalog::Catalog::GetInstance(); auto *txn = txn_manager.BeginTransaction(); @@ -276,11 +276,9 @@ TEST_F(BloomFilterCodegenTest, PerformanceTest) { txn_manager.CommitTransaction(txn); } -double BloomFilterCodegenTest::ExecuteJoin(std::string query, - concurrency::TransactionContext *txn, - int num_iter, - unsigned inner_table_cardinality, - bool enable_bloom_filter) { +double BloomFilterCodegenTests::ExecuteJoin( + std::string query, concurrency::TransactionContext *txn, int num_iter, + unsigned inner_table_cardinality, bool enable_bloom_filter) { std::unique_ptr optimizer( new optimizer::Optimizer()); double total_runtime = 0; @@ -310,8 +308,8 @@ double BloomFilterCodegenTest::ExecuteJoin(std::string query, *plan, executor_context->GetParams().GetQueryParametersMap(), consumer); // Run - PelotonCodeGenTest::ExecuteSync(*compiled_query, - std::move(executor_context), consumer); + PelotonCodeGenTests::ExecuteSync(*compiled_query, + std::move(executor_context), consumer); LOG_INFO("Execution Time: %0.0f ms", stats.plan_ms); total_runtime += stats.plan_ms; @@ -321,8 +319,9 @@ double BloomFilterCodegenTest::ExecuteJoin(std::string query, // Create a table where all the columns are BIGINT and each tuple has desired // tuple size -void BloomFilterCodegenTest::CreateTable(std::string table_name, int tuple_size, - concurrency::TransactionContext *txn) { +void BloomFilterCodegenTests::CreateTable( + std::string table_name, int tuple_size, + concurrency::TransactionContext *txn) { int curr_size = 0; size_t bigint_size = type::Type::GetTypeSize(type::TypeId::BIGINT); std::vector cols; @@ -339,9 +338,9 @@ void BloomFilterCodegenTest::CreateTable(std::string table_name, int tuple_size, } // Insert a tuple to specific table -void BloomFilterCodegenTest::InsertTuple(const std::vector &vals, - storage::DataTable *table, - concurrency::TransactionContext *txn) { +void BloomFilterCodegenTests::InsertTuple( + const std::vector &vals, storage::DataTable *table, + concurrency::TransactionContext *txn) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); storage::Tuple tuple{table->GetSchema(), true}; for (unsigned i = 0; i < vals.size(); i++) { diff --git a/test/codegen/case_translator_test.cpp b/test/codegen/case_translator_test.cpp index 9f3a5816896..2f8e24b826a 100644 --- a/test/codegen/case_translator_test.cpp +++ b/test/codegen/case_translator_test.cpp @@ -25,9 +25,9 @@ namespace peloton { namespace test { -class CaseTranslatorTest : public PelotonCodeGenTest { +class CaseTranslatorTests : public PelotonCodeGenTests { public: - CaseTranslatorTest() : PelotonCodeGenTest(), num_rows_to_insert(64) { + CaseTranslatorTests() : PelotonCodeGenTests(), num_rows_to_insert(64) { // Load test table LoadTestTable(TestTableId(), num_rows_to_insert); } @@ -40,7 +40,7 @@ class CaseTranslatorTest : public PelotonCodeGenTest { uint32_t num_rows_to_insert = 64; }; -TEST_F(CaseTranslatorTest, SimpleCase) { +TEST_F(CaseTranslatorTests, SimpleCaseTest) { // // SELECT a, case when a=10 then 1 when else 0 FROM table; // @@ -89,26 +89,21 @@ TEST_F(CaseTranslatorTest, SimpleCase) { const auto &results = buffer.GetOutputTuples(); EXPECT_EQ(NumRowsInTestTable(), results.size()); EXPECT_TRUE(results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(0)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(0)) == CmpBool::CmpTrue); EXPECT_TRUE(results[0].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(0)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(0)) == CmpBool::CmpTrue); EXPECT_TRUE(results[1].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(10)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(10)) == CmpBool::CmpTrue); EXPECT_TRUE(results[1].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(1)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(1)) == CmpBool::CmpTrue); for (uint32_t i = 2; i < NumRowsInTestTable(); i++) { EXPECT_TRUE(results[i].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(0)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(0)) == CmpBool::CmpTrue); } } -TEST_F(CaseTranslatorTest, SimpleCaseMoreWhen) { +TEST_F(CaseTranslatorTests, SimpleCaseMoreWhenTest) { // // SELECT a, case when a=10 then 1 when a=20 then 2 else 0 FROM table; // @@ -159,23 +154,17 @@ TEST_F(CaseTranslatorTest, SimpleCaseMoreWhen) { const auto &results = buffer.GetOutputTuples(); EXPECT_EQ(NumRowsInTestTable(), results.size()); EXPECT_TRUE(results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(0)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(0)) == CmpBool::CmpTrue); EXPECT_TRUE(results[0].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(0)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(0)) == CmpBool::CmpTrue); EXPECT_TRUE(results[1].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(10)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(10)) == CmpBool::CmpTrue); EXPECT_TRUE(results[1].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(1)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(1)) == CmpBool::CmpTrue); EXPECT_TRUE(results[2].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(20)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(20)) == CmpBool::CmpTrue); EXPECT_TRUE(results[2].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(2)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(2)) == CmpBool::CmpTrue); } } // namespace test diff --git a/test/codegen/delete_translator_test.cpp b/test/codegen/delete_translator_test.cpp index 4bef9b3e7e3..18b2539d829 100644 --- a/test/codegen/delete_translator_test.cpp +++ b/test/codegen/delete_translator_test.cpp @@ -23,9 +23,9 @@ namespace peloton { namespace test { -class DeleteTranslatorTest : public PelotonCodeGenTest { +class DeleteTranslatorTests : public PelotonCodeGenTests { public: - DeleteTranslatorTest() : PelotonCodeGenTest() {} + DeleteTranslatorTests() : PelotonCodeGenTests() {} size_t GetCurrentTableSize(oid_t table_id) { planner::SeqScanPlan scan{&GetTestTable(table_id), nullptr, {0, 1}}; @@ -47,7 +47,7 @@ class DeleteTranslatorTest : public PelotonCodeGenTest { uint32_t num_rows_to_insert = 64; }; -TEST_F(DeleteTranslatorTest, DeleteAllTuples) { +TEST_F(DeleteTranslatorTests, DeleteAllTuplesTest) { // // DELETE FROM table; // @@ -72,7 +72,7 @@ TEST_F(DeleteTranslatorTest, DeleteAllTuples) { EXPECT_EQ(0, GetCurrentTableSize(TestTableId1())); } -TEST_F(DeleteTranslatorTest, DeleteWithSimplePredicate) { +TEST_F(DeleteTranslatorTests, DeleteWithSimplePredicateTest) { // // DELETE FROM table where a >= 40; // @@ -104,7 +104,7 @@ TEST_F(DeleteTranslatorTest, DeleteWithSimplePredicate) { EXPECT_EQ(4, GetCurrentTableSize(TestTableId2())); } -TEST_F(DeleteTranslatorTest, DeleteWithCompositePredicate) { +TEST_F(DeleteTranslatorTests, DeleteWithCompositePredicateTest) { // // DELETE FROM table where a >= 20 and b = 21; // @@ -144,7 +144,7 @@ TEST_F(DeleteTranslatorTest, DeleteWithCompositePredicate) { EXPECT_EQ(NumRowsInTestTable() - 1, GetCurrentTableSize(TestTableId3())); } -TEST_F(DeleteTranslatorTest, DeleteWithModuloPredicate) { +TEST_F(DeleteTranslatorTests, DeleteWithModuloPredicateTest) { // // DELETE FROM table where a = b % 1; // diff --git a/test/codegen/function_builder_test.cpp b/test/codegen/function_builder_test.cpp index 1822e384f72..04e43e479c2 100644 --- a/test/codegen/function_builder_test.cpp +++ b/test/codegen/function_builder_test.cpp @@ -18,9 +18,9 @@ namespace peloton { namespace test { -class FunctionBuilderTest : public PelotonTest {}; +class FunctionBuilderTests : public PelotonTests {}; -TEST_F(FunctionBuilderTest, ConstructSingleFunction) { +TEST_F(FunctionBuilderTests, ConstructSingleFunctionTest) { // Generate a function like so: // define @test() { // ret i32 44; @@ -31,18 +31,16 @@ TEST_F(FunctionBuilderTest, ConstructSingleFunction) { codegen::CodeContext code_context; codegen::CodeGen cg{code_context}; codegen::FunctionBuilder func{code_context, "test", cg.Int32Type(), {}}; - { - func.ReturnAndFinish(cg.Const32(magic_num)); - } + { func.ReturnAndFinish(cg.Const32(magic_num)); } ASSERT_TRUE(code_context.Compile()); typedef int (*func_t)(void); - func_t fn = (func_t) code_context.GetRawFunctionPointer(func.GetFunction()); + func_t fn = (func_t)code_context.GetRawFunctionPointer(func.GetFunction()); ASSERT_EQ(fn(), magic_num); } -TEST_F(FunctionBuilderTest, ConstructNestedFunction) { +TEST_F(FunctionBuilderTests, ConstructNestedFunctionTest) { // In this test, we want to construct the following scenario: // define void @test(i32 %a) { // %tmp = mul i32 %a, i32 44 @@ -83,7 +81,7 @@ TEST_F(FunctionBuilderTest, ConstructNestedFunction) { ASSERT_TRUE(code_context.Compile()); typedef int (*func_t)(uint32_t); - func_t fn = (func_t) code_context.GetRawFunctionPointer(main.GetFunction()); + func_t fn = (func_t)code_context.GetRawFunctionPointer(main.GetFunction()); ASSERT_EQ(fn(1), 44); } diff --git a/test/codegen/group_by_translator_test.cpp b/test/codegen/group_by_translator_test.cpp index 7d3e813c491..41a6f03c807 100644 --- a/test/codegen/group_by_translator_test.cpp +++ b/test/codegen/group_by_translator_test.cpp @@ -25,9 +25,9 @@ namespace peloton { namespace test { -class GroupByTranslatorTest : public PelotonCodeGenTest { +class GroupByTranslatorTests : public PelotonCodeGenTests { public: - GroupByTranslatorTest() : PelotonCodeGenTest() { + GroupByTranslatorTests() : PelotonCodeGenTests() { uint32_t num_rows = 10; LoadTestTable(TestTableId(), num_rows); } @@ -35,7 +35,7 @@ class GroupByTranslatorTest : public PelotonCodeGenTest { oid_t TestTableId() const { return test_table_oids[0]; } }; -TEST_F(GroupByTranslatorTest, SingleColumnGrouping) { +TEST_F(GroupByTranslatorTests, SingleColumnGroupingTest) { // // SELECT a, count(*) FROM table GROUP BY a; // @@ -90,12 +90,11 @@ TEST_F(GroupByTranslatorTest, SingleColumnGrouping) { // Each group should have a count of one (since the grouping column is unique) type::Value const_one = type::ValueFactory::GetIntegerValue(1); for (const auto &tuple : results) { - EXPECT_TRUE(tuple.GetValue(1).CompareEquals(const_one) == - CmpBool::CmpTrue); + EXPECT_TRUE(tuple.GetValue(1).CompareEquals(const_one) == CmpBool::CmpTrue); } } -TEST_F(GroupByTranslatorTest, MultiColumnGrouping) { +TEST_F(GroupByTranslatorTests, MultiColumnGroupingTest) { // // SELECT a, b, count(*) FROM table GROUP BY a, b; // @@ -156,7 +155,7 @@ TEST_F(GroupByTranslatorTest, MultiColumnGrouping) { } } -TEST_F(GroupByTranslatorTest, AverageAggregation) { +TEST_F(GroupByTranslatorTests, AverageAggregationTest) { // // SELECT a, avg(b) FROM table GROUP BY a; // @@ -208,7 +207,7 @@ TEST_F(GroupByTranslatorTest, AverageAggregation) { EXPECT_EQ(10, results.size()); } -TEST_F(GroupByTranslatorTest, AggregationWithOutputPredicate) { +TEST_F(GroupByTranslatorTests, AggregationWithOutputPredicateTest) { // // SELECT a, avg(b) as x FROM table GROUP BY a WHERE x > 50; // @@ -239,9 +238,8 @@ TEST_F(GroupByTranslatorTest, AggregationWithOutputPredicate) { new expression::TupleValueExpression(type::TypeId::DECIMAL, 0, 1); auto *const_50 = new expression::ConstantValueExpression( type::ValueFactory::GetDecimalValue(50.0)); - ExpressionPtr x_gt_50{ - new expression::ComparisonExpression(ExpressionType::COMPARE_GREATERTHAN, - x_exp, const_50)}; + ExpressionPtr x_gt_50{new expression::ComparisonExpression( + ExpressionType::COMPARE_GREATERTHAN, x_exp, const_50)}; // 6) Finally, the aggregation node std::unique_ptr agg_plan{new planner::AggregatePlan( @@ -269,7 +267,7 @@ TEST_F(GroupByTranslatorTest, AggregationWithOutputPredicate) { EXPECT_EQ(5, results.size()); } -TEST_F(GroupByTranslatorTest, AggregationWithInputPredciate) { +TEST_F(GroupByTranslatorTests, AggregationWithInputPredciateTest) { // // SELECT a, avg(b) as x FROM table GROUP BY a WHERE a > 50; // @@ -329,7 +327,7 @@ TEST_F(GroupByTranslatorTest, AggregationWithInputPredciate) { EXPECT_EQ(4, results.size()); } -TEST_F(GroupByTranslatorTest, SingleCountStar) { +TEST_F(GroupByTranslatorTests, SingleCountStarTest) { // // SELECT count(*) FROM table; // @@ -380,11 +378,10 @@ TEST_F(GroupByTranslatorTest, SingleCountStar) { const auto &results = buffer.GetOutputTuples(); EXPECT_EQ(1, results.size()); EXPECT_TRUE(results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(10)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(10)) == CmpBool::CmpTrue); } -TEST_F(GroupByTranslatorTest, MinAndMax) { +TEST_F(GroupByTranslatorTests, MinAndMaxTest) { // // SELECT MAX(a), MIN(b) FROM table; // @@ -445,14 +442,12 @@ TEST_F(GroupByTranslatorTest, MinAndMax) { // maximum row ID is equal to # inserted - 1. Therefore: // MAX(a) = (# inserted - 1) * 10 = (10 - 1) * 10 = 9 * 10 = 90 EXPECT_TRUE(results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetBigIntValue(90)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(90)) == CmpBool::CmpTrue); // The values of 'b' are equal to the (zero-indexed) row ID * 10 + 1. The // minimum row ID is 0. Therefore: MIN(b) = 0 * 10 + 1 = 1 EXPECT_TRUE(results[0].GetValue(1).CompareEquals( - type::ValueFactory::GetBigIntValue(1)) == - CmpBool::CmpTrue); + type::ValueFactory::GetBigIntValue(1)) == CmpBool::CmpTrue); } } // namespace test diff --git a/test/codegen/hash_join_translator_test.cpp b/test/codegen/hash_join_translator_test.cpp index e29fbd83e60..fadaccea607 100644 --- a/test/codegen/hash_join_translator_test.cpp +++ b/test/codegen/hash_join_translator_test.cpp @@ -25,9 +25,9 @@ namespace peloton { namespace test { -class HashJoinTranslatorTest : public PelotonCodeGenTest { +class HashJoinTranslatorTests : public PelotonCodeGenTests { public: - HashJoinTranslatorTest() : PelotonCodeGenTest() { + HashJoinTranslatorTests() : PelotonCodeGenTests() { // Load the test table uint32_t num_rows = 10; LoadTestTable(LeftTableId(), 2 * num_rows); @@ -47,7 +47,7 @@ class HashJoinTranslatorTest : public PelotonCodeGenTest { } }; -TEST_F(HashJoinTranslatorTest, SingleHashJoinColumnTest) { +TEST_F(HashJoinTranslatorTests, SingleHashJoinColumnTest) { // // SELECT // left_table.a, right_table.a, left_table.b, right_table.c, diff --git a/test/codegen/if_test.cpp b/test/codegen/if_test.cpp index 4c198cea2d3..9bb96e6ac1a 100644 --- a/test/codegen/if_test.cpp +++ b/test/codegen/if_test.cpp @@ -23,9 +23,9 @@ namespace peloton { namespace test { -class IfTest : public PelotonTest {}; +class IfTests : public PelotonTests {}; -TEST_F(IfTest, TestIfOnly) { +TEST_F(IfTests, IfOnlyTest) { const std::string func_name = "TestIfOnly"; // Generate a function like so: @@ -74,7 +74,7 @@ TEST_F(IfTest, TestIfOnly) { EXPECT_EQ(f(2000), 0); } -TEST_F(IfTest, TestIfInsideLoop) { +TEST_F(IfTests, IfInsideLoopTest) { const std::string func_name = "TestIfInsideLoop"; codegen::CodeContext code_context; codegen::CodeGen cg{code_context}; @@ -136,7 +136,7 @@ TEST_F(IfTest, TestIfInsideLoop) { ASSERT_EQ(5, f(10)); } -TEST_F(IfTest, BreakTest) { +TEST_F(IfTests, BreakTest) { const std::string func_name = "TestBreakLoop"; codegen::CodeContext code_context; codegen::CodeGen cg{code_context}; @@ -185,7 +185,7 @@ TEST_F(IfTest, BreakTest) { ASSERT_EQ(5, f(7)); } -TEST_F(IfTest, ComplexNestedIf) { +TEST_F(IfTests, ComplexNestedIfTest) { const std::string func_name = "TestIfOnly"; // Generate a function like so: diff --git a/test/codegen/insert_translator_test.cpp b/test/codegen/insert_translator_test.cpp index 8d2534d2324..6806b9c6dbc 100644 --- a/test/codegen/insert_translator_test.cpp +++ b/test/codegen/insert_translator_test.cpp @@ -22,15 +22,15 @@ namespace peloton { namespace test { -class InsertTranslatorTest : public PelotonCodeGenTest { +class InsertTranslatorTests : public PelotonCodeGenTests { public: - InsertTranslatorTest() : PelotonCodeGenTest() {} + InsertTranslatorTests() : PelotonCodeGenTests() {} oid_t TestTableId1() { return test_table_oids[0]; } oid_t TestTableId2() { return test_table_oids[1]; } }; // Insert one tuple -TEST_F(InsertTranslatorTest, InsertOneTuple) { +TEST_F(InsertTranslatorTests, InsertOneTupleTest) { // Check the pre-condition auto table = &GetTestTable(TestTableId1()); auto num_tuples = table->GetTupleCount(); @@ -89,18 +89,18 @@ TEST_F(InsertTranslatorTest, InsertOneTuple) { auto &results_table1 = buffer_table1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(0))); + type::ValueFactory::GetIntegerValue(0))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetDecimalValue(2))); + type::ValueFactory::GetDecimalValue(2))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(3).CompareEquals( type::ValueFactory::GetVarcharValue("Tuple1"))); } // Insert all tuples from table2 into table1. -TEST_F(InsertTranslatorTest, InsertScanTranslator) { +TEST_F(InsertTranslatorTests, InsertScanTranslatorTest) { auto table1 = &GetTestTable(TestTableId1()); auto table2 = &GetTestTable(TestTableId2()); @@ -148,26 +148,25 @@ TEST_F(InsertTranslatorTest, InsertScanTranslator) { auto &results_table1 = buffer_table1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(0))); + type::ValueFactory::GetIntegerValue(0))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(2))); + type::ValueFactory::GetIntegerValue(2))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("3"))); + type::ValueFactory::GetVarcharValue("3"))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(90))); + type::ValueFactory::GetIntegerValue(90))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(91))); + type::ValueFactory::GetIntegerValue(91))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(92))); - EXPECT_EQ(CmpBool::CmpTrue, - results_table1[9].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("93"))); + type::ValueFactory::GetIntegerValue(92))); + EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("93"))); } // Insert all tuples from table2 into table1 with null values. -TEST_F(InsertTranslatorTest, InsertScanTranslatorWithNull) { +TEST_F(InsertTranslatorTests, InsertScanTranslatorWithNullTest) { auto table1 = &GetTestTable(TestTableId1()); auto table2 = &GetTestTable(TestTableId2()); @@ -216,24 +215,23 @@ TEST_F(InsertTranslatorTest, InsertScanTranslatorWithNull) { auto &results_table1 = buffer_table1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(0))); + type::ValueFactory::GetIntegerValue(0))); EXPECT_TRUE(results_table1[0].GetValue(1).IsNull()); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(2))); + type::ValueFactory::GetIntegerValue(2))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("3"))); + type::ValueFactory::GetVarcharValue("3"))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(90))); + type::ValueFactory::GetIntegerValue(90))); EXPECT_TRUE(results_table1[9].GetValue(1).IsNull()); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(92))); - EXPECT_EQ(CmpBool::CmpTrue, - results_table1[9].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("93"))); + type::ValueFactory::GetIntegerValue(92))); + EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("93"))); } // Insert a tuple from table2 with column order changed, into table1. -TEST_F(InsertTranslatorTest, InsertScanColumnTranslator) { +TEST_F(InsertTranslatorTests, InsertScanColumnTranslatorTest) { auto table1 = &GetTestTable(TestTableId1()); auto table2 = &GetTestTable(TestTableId2()); @@ -281,22 +279,21 @@ TEST_F(InsertTranslatorTest, InsertScanColumnTranslator) { auto &results_table1 = buffer_table1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(0))); + type::ValueFactory::GetIntegerValue(0))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(2))); + type::ValueFactory::GetIntegerValue(2))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("3"))); + type::ValueFactory::GetVarcharValue("3"))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(91))); + type::ValueFactory::GetIntegerValue(91))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(90))); + type::ValueFactory::GetIntegerValue(90))); EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(92))); - EXPECT_EQ(CmpBool::CmpTrue, - results_table1[9].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("93"))); + type::ValueFactory::GetIntegerValue(92))); + EXPECT_EQ(CmpBool::CmpTrue, results_table1[9].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("93"))); } } // namespace test diff --git a/test/codegen/oa_hash_table_test.cpp b/test/codegen/oa_hash_table_test.cpp index 7bec398c5aa..395533ebf45 100644 --- a/test/codegen/oa_hash_table_test.cpp +++ b/test/codegen/oa_hash_table_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class OAHashTableTest : public PelotonTest { +class OAHashTableTests : public PelotonTests { public: // The key and value object we store in the hash table struct Key { @@ -42,12 +42,12 @@ class OAHashTableTest : public PelotonTest { bool operator!=(const Value &rhs) const { return !(rhs == *this); } }; - OAHashTableTest() { + OAHashTableTests() { PELOTON_MEMSET(raw_hash_table, 1, sizeof(raw_hash_table)); GetHashTable().Init(sizeof(Key), sizeof(Value)); } - ~OAHashTableTest() { + ~OAHashTableTests() { // Clean up GetHashTable().Destroy(); } @@ -78,7 +78,7 @@ class OAHashTableTest : public PelotonTest { int8_t raw_hash_table[sizeof(codegen::util::OAHashTable)]; }; -TEST_F(OAHashTableTest, CanInsertKeyValuePairs) { +TEST_F(OAHashTableTests, CanInsertKeyValuePairsTest) { Value v = {3, 4, 5, 6}; uint32_t to_insert = 50000; @@ -100,7 +100,7 @@ TEST_F(OAHashTableTest, CanInsertKeyValuePairs) { EXPECT_EQ(to_insert, GetHashTable().NumOccupiedBuckets()); } -TEST_F(OAHashTableTest, CanIterate) { +TEST_F(OAHashTableTests, CanIterateTest) { Value v = {3, 4, 5, 6}; uint32_t to_insert = 50000; @@ -130,8 +130,8 @@ TEST_F(OAHashTableTest, CanIterate) { i = 0; uint32_t dup_count = 0; - for (auto iter = hashtable.begin(), end = hashtable.end(); - iter != end; ++iter) { + for (auto iter = hashtable.begin(), end = hashtable.end(); iter != end; + ++iter) { const Key *iter_key = reinterpret_cast(iter.Key()); if (*iter_key == key_dup) { dup_count++; @@ -145,9 +145,9 @@ TEST_F(OAHashTableTest, CanIterate) { EXPECT_EQ(3, dup_count); } -TEST_F(OAHashTableTest, CanCodegenProbeOrInsert) {} +TEST_F(OAHashTableTests, CanCodegenProbeOrInsertTest) {} -TEST_F(OAHashTableTest, MicroBenchmark) { +TEST_F(OAHashTableTests, MicroBenchmarkTest) { uint32_t num_runs = 10; std::vector keys; @@ -205,7 +205,7 @@ TEST_F(OAHashTableTest, MicroBenchmark) { } LOG_INFO("Avg OA_HT: %.2lf, Avg std::unordered_map: %.2lf", - avg_oaht / (double)num_runs, avg_map / (double)num_runs); + avg_oaht / (double)num_runs, avg_map / (double)num_runs); } } // namespace test diff --git a/test/codegen/order_by_translator_test.cpp b/test/codegen/order_by_translator_test.cpp index b8c13f08563..b0c04afa827 100644 --- a/test/codegen/order_by_translator_test.cpp +++ b/test/codegen/order_by_translator_test.cpp @@ -20,14 +20,14 @@ namespace peloton { namespace test { -class OrderByTranslatorTest : public PelotonCodeGenTest { +class OrderByTranslatorTests : public PelotonCodeGenTests { public: - OrderByTranslatorTest() : PelotonCodeGenTest() {} + OrderByTranslatorTests() : PelotonCodeGenTests() {} oid_t TestTableId() { return test_table_oids[0]; } }; -TEST_F(OrderByTranslatorTest, SingleIntColAscTest) { +TEST_F(OrderByTranslatorTests, SingleIntColAscTest) { // // SELECT * FROM test_table ORDER BY a; // @@ -64,7 +64,7 @@ TEST_F(OrderByTranslatorTest, SingleIntColAscTest) { })); } -TEST_F(OrderByTranslatorTest, SingleIntColDescTest) { +TEST_F(OrderByTranslatorTests, SingleIntColDescTest) { // // SELECT * FROM test_table ORDER BY a DESC; // @@ -101,7 +101,7 @@ TEST_F(OrderByTranslatorTest, SingleIntColDescTest) { })); } -TEST_F(OrderByTranslatorTest, MultiIntColAscTest) { +TEST_F(OrderByTranslatorTests, MultiIntColAscTest) { // // SELECT * FROM test_table ORDER BY b, a ASC; // @@ -134,8 +134,7 @@ TEST_F(OrderByTranslatorTest, MultiIntColAscTest) { EXPECT_TRUE(std::is_sorted( results.begin(), results.end(), [](const codegen::WrappedTuple &t1, const codegen::WrappedTuple &t2) { - if (t1.GetValue(1).CompareEquals(t2.GetValue(0)) == - CmpBool::CmpTrue) { + if (t1.GetValue(1).CompareEquals(t2.GetValue(0)) == CmpBool::CmpTrue) { // t1.b == t2.b => t1.a <= t2.a return t1.GetValue(0).CompareLessThanEquals(t2.GetValue(0)) == CmpBool::CmpTrue; @@ -147,7 +146,7 @@ TEST_F(OrderByTranslatorTest, MultiIntColAscTest) { })); } -TEST_F(OrderByTranslatorTest, MultiIntColMixedTest) { +TEST_F(OrderByTranslatorTests, MultiIntColMixedTest) { // // SELECT * FROM test_table ORDER BY b DESC a ASC; // @@ -180,8 +179,7 @@ TEST_F(OrderByTranslatorTest, MultiIntColMixedTest) { EXPECT_TRUE(std::is_sorted( results.begin(), results.end(), [](const codegen::WrappedTuple &t1, const codegen::WrappedTuple &t2) { - if (t1.GetValue(1).CompareEquals(t2.GetValue(1)) == - CmpBool::CmpTrue) { + if (t1.GetValue(1).CompareEquals(t2.GetValue(1)) == CmpBool::CmpTrue) { // t1.b == t2.b => t1.a <= t2.a return t1.GetValue(0).CompareLessThanEquals(t2.GetValue(0)) == CmpBool::CmpTrue; diff --git a/test/codegen/parameterization_test.cpp b/test/codegen/parameterization_test.cpp index df4801a25d4..8f9b2255d7d 100644 --- a/test/codegen/parameterization_test.cpp +++ b/test/codegen/parameterization_test.cpp @@ -24,9 +24,9 @@ namespace peloton { namespace test { -class ParameterizationTest : public PelotonCodeGenTest { +class ParameterizationTests : public PelotonCodeGenTests { public: - ParameterizationTest() : PelotonCodeGenTest(), num_rows_to_insert(64) { + ParameterizationTests() : PelotonCodeGenTests(), num_rows_to_insert(64) { // Load test table LoadTestTable(TestTableId(), num_rows_to_insert); } @@ -42,7 +42,7 @@ class ParameterizationTest : public PelotonCodeGenTest { // Tests whether parameterization works for varchar type in Constant Value Expr // (1) Query with a varchar constant // (2) Query with a different varchar on the previously cached compiled query -TEST_F(ParameterizationTest, ConstParameterVarchar) { +TEST_F(ParameterizationTests, ConstParameterVarcharTest) { // SELECT d FROM table where d != ""; auto *d_col_exp = new expression::TupleValueExpression(type::TypeId::VARCHAR, 0, 3); @@ -94,7 +94,7 @@ TEST_F(ParameterizationTest, ConstParameterVarchar) { // (3) Query with a const parameter with the same value // The last query attemts to see whether query with a const paraemeter is // distinct from (2) -TEST_F(ParameterizationTest, ParamParameterVarchar) { +TEST_F(ParameterizationTests, ParamParameterVarcharTest) { // SELECT d FROM table where d != ?, with ? = ""; auto *d_col_exp = new expression::TupleValueExpression(type::TypeId::VARCHAR, 0, 3); @@ -170,7 +170,7 @@ TEST_F(ParameterizationTest, ParamParameterVarchar) { // Tests whether parameterization works for conjuction with Const Value Exprs // (1) Query with const integer parameters // (2) Query with differnt consts on the previously cached compiled query -TEST_F(ParameterizationTest, ConstParameterWithConjunction) { +TEST_F(ParameterizationTests, ConstParameterWithConjunctionTest) { // SELECT a, b, c FROM table where a >= 20 and b = 21; auto *a_col_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); @@ -202,11 +202,11 @@ TEST_F(ParameterizationTest, ConstParameterWithConjunction) { const auto &results = buffer.GetOutputTuples(); ASSERT_EQ(1, results.size()); EXPECT_EQ(CmpBool::CmpTrue, results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(20))); + type::ValueFactory::GetIntegerValue(20))); EXPECT_EQ(CmpBool::CmpTrue, results[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(21))); + type::ValueFactory::GetIntegerValue(21))); EXPECT_EQ(CmpBool::CmpTrue, results[0].GetValue(2).CompareEquals( - type::ValueFactory::GetDecimalValue(22))); + type::ValueFactory::GetDecimalValue(22))); // SELECT a, b, c FROM table where a >= 30 and b = 31; auto *a_col_exp_2 = @@ -239,11 +239,11 @@ TEST_F(ParameterizationTest, ConstParameterWithConjunction) { const auto &results_2 = buffer_2.GetOutputTuples(); ASSERT_EQ(1, results_2.size()); EXPECT_EQ(CmpBool::CmpTrue, results_2[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(30))); + type::ValueFactory::GetIntegerValue(30))); EXPECT_EQ(CmpBool::CmpTrue, results_2[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(31))); + type::ValueFactory::GetIntegerValue(31))); EXPECT_EQ(CmpBool::CmpTrue, results_2[0].GetValue(2).CompareEquals( - type::ValueFactory::GetDecimalValue(32))); + type::ValueFactory::GetDecimalValue(32))); EXPECT_TRUE(cached); // SELECT a, b, c FROM table where a >= 30 and b = null; @@ -283,7 +283,7 @@ TEST_F(ParameterizationTest, ConstParameterWithConjunction) { // (1) Query with param parameters // (2) Query with different param values on the previously cached compiled query // (2) Query with the same plan, but with a param value changed to a contant -TEST_F(ParameterizationTest, ParamParameterWithConjunction) { +TEST_F(ParameterizationTests, ParamParameterWithConjunctionTest) { // SELECT a, b, c FROM table where a >= 20 and d != ""; auto *a_col_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); @@ -317,9 +317,9 @@ TEST_F(ParameterizationTest, ParamParameterWithConjunction) { const auto &results = buffer.GetOutputTuples(); ASSERT_EQ(NumRowsInTestTable() - 2, results.size()); EXPECT_EQ(CmpBool::CmpTrue, results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(20))); + type::ValueFactory::GetIntegerValue(20))); EXPECT_EQ(CmpBool::CmpFalse, results[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue(""))); + type::ValueFactory::GetVarcharValue(""))); EXPECT_FALSE(cached); // SELECT a, b, c FROM table where a >= 30 and d != "empty"; @@ -355,7 +355,7 @@ TEST_F(ParameterizationTest, ParamParameterWithConjunction) { const auto &results_2 = buffer_2.GetOutputTuples(); ASSERT_EQ(NumRowsInTestTable() - 3, results_2.size()); EXPECT_EQ(CmpBool::CmpTrue, results_2[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(30))); + type::ValueFactory::GetIntegerValue(30))); EXPECT_EQ(CmpBool::CmpFalse, results_2[0].GetValue(3).CompareEquals( type::ValueFactory::GetVarcharValue("empty"))); @@ -394,7 +394,7 @@ TEST_F(ParameterizationTest, ParamParameterWithConjunction) { const auto &results_3 = buffer_3.GetOutputTuples(); ASSERT_EQ(NumRowsInTestTable() - 3, results_3.size()); EXPECT_EQ(CmpBool::CmpTrue, results_3[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(30))); + type::ValueFactory::GetIntegerValue(30))); EXPECT_EQ(CmpBool::CmpFalse, results_3[0].GetValue(3).CompareEquals( type::ValueFactory::GetVarcharValue("empty"))); @@ -433,7 +433,7 @@ TEST_F(ParameterizationTest, ParamParameterWithConjunction) { const auto &results_4 = buffer_4.GetOutputTuples(); ASSERT_EQ(NumRowsInTestTable() - 3, results_3.size()); EXPECT_EQ(CmpBool::CmpTrue, results_4[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(30))); + type::ValueFactory::GetIntegerValue(30))); EXPECT_EQ(CmpBool::CmpFalse, results_4[0].GetValue(3).CompareEquals( type::ValueFactory::GetVarcharValue("empty"))); @@ -443,7 +443,7 @@ TEST_F(ParameterizationTest, ParamParameterWithConjunction) { // (1) Check to use a Parameter Value Expression // (2) Set a different value on the cached query // (3) Query a similar one, but with a different operator expression -TEST_F(ParameterizationTest, ParamParameterWithOperators) { +TEST_F(ParameterizationTests, ParamParameterWithOperatorsTest) { // (1) Check to use a Parameter Value Expression // SELECT a, b FROM table where b = a + ?; // b = a + ? @@ -537,7 +537,7 @@ TEST_F(ParameterizationTest, ParamParameterWithOperators) { EXPECT_FALSE(cached); } -TEST_F(ParameterizationTest, ParamParameterWithOperatersLeftHand) { +TEST_F(ParameterizationTests, ParamParameterWithOperatersLeftHandTest) { // SELECT a, b, c FROM table where a * 1 = a * b; auto *a_lhs_col_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); diff --git a/test/codegen/query_cache_test.cpp b/test/codegen/query_cache_test.cpp index 125517dc9fe..524c41f09fa 100644 --- a/test/codegen/query_cache_test.cpp +++ b/test/codegen/query_cache_test.cpp @@ -29,9 +29,9 @@ namespace peloton { namespace test { -class QueryCacheTest : public PelotonCodeGenTest { +class QueryCacheTests : public PelotonCodeGenTests { public: - QueryCacheTest() : PelotonCodeGenTest(), num_rows_to_insert(64) { + QueryCacheTests() : PelotonCodeGenTests(), num_rows_to_insert(64) { // Load test table LoadTestTable(TestTableId(), num_rows_to_insert); LoadTestTable(RightTableId(), 4 * num_rows_to_insert); @@ -44,7 +44,7 @@ class QueryCacheTest : public PelotonCodeGenTest { std::shared_ptr GetSeqScanPlan() { auto *a_col_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); - auto *const_40_exp = PelotonCodeGenTest::ConstIntExpr(40).release(); + auto *const_40_exp = PelotonCodeGenTests::ConstIntExpr(40).release(); auto *a_gt_40 = new expression::ComparisonExpression( ExpressionType::COMPARE_GREATERTHANOREQUALTO, a_col_exp, const_40_exp); return std::shared_ptr(new planner::SeqScanPlan( @@ -55,13 +55,13 @@ class QueryCacheTest : public PelotonCodeGenTest { std::shared_ptr GetSeqScanPlanWithPredicate() { auto *a_col_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); - auto *const_20_exp = PelotonCodeGenTest::ConstIntExpr(20).release(); + auto *const_20_exp = PelotonCodeGenTests::ConstIntExpr(20).release(); auto *a_gt_20 = new expression::ComparisonExpression( ExpressionType::COMPARE_GREATERTHANOREQUALTO, a_col_exp, const_20_exp); auto *b_col_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 1); - auto *const_21_exp = PelotonCodeGenTest::ConstIntExpr(21).release(); + auto *const_21_exp = PelotonCodeGenTests::ConstIntExpr(21).release(); auto *b_eq_21 = new expression::ComparisonExpression( ExpressionType::COMPARE_EQUAL, b_col_exp, const_21_exp); @@ -207,7 +207,7 @@ class QueryCacheTest : public PelotonCodeGenTest { uint32_t num_rows_to_insert = 64; }; -TEST_F(QueryCacheTest, SimpleCache) { +TEST_F(QueryCacheTests, SimpleCacheTest) { int CACHE_USED_BY_CATALOG = codegen::QueryCache::Instance().GetCount(); // SELECT b FROM table where a >= 40; @@ -253,7 +253,7 @@ TEST_F(QueryCacheTest, SimpleCache) { EXPECT_EQ(0, codegen::QueryCache::Instance().GetCount()); } -TEST_F(QueryCacheTest, CacheSeqScanPlan) { +TEST_F(QueryCacheTests, CacheSeqScanPlanTest) { int CACHE_USED_BY_CATALOG = codegen::QueryCache::Instance().GetCount(); // SELECT a, b, c FROM table where a >= 20 and b = 21; @@ -305,7 +305,7 @@ TEST_F(QueryCacheTest, CacheSeqScanPlan) { EXPECT_EQ(0, codegen::QueryCache::Instance().GetCount()); } -TEST_F(QueryCacheTest, CacheHashJoinPlan) { +TEST_F(QueryCacheTests, CacheHashJoinPlanTest) { int CACHE_USED_BY_CATALOG = codegen::QueryCache::Instance().GetCount(); auto hj_plan1 = GetHashJoinPlan(); @@ -366,7 +366,7 @@ TEST_F(QueryCacheTest, CacheHashJoinPlan) { EXPECT_EQ(0, codegen::QueryCache::Instance().GetCount()); } -TEST_F(QueryCacheTest, CacheOrderByPlan) { +TEST_F(QueryCacheTests, CacheOrderByPlanTest) { int CACHE_USED_BY_CATALOG = codegen::QueryCache::Instance().GetCount(); // plan 1, 2: SELECT * FROM test_table ORDER BY b DESC a ASC; @@ -447,7 +447,7 @@ TEST_F(QueryCacheTest, CacheOrderByPlan) { EXPECT_EQ(0, codegen::QueryCache::Instance().GetCount()); } -TEST_F(QueryCacheTest, CacheAggregatePlan) { +TEST_F(QueryCacheTests, CacheAggregatePlanTest) { int CACHE_USED_BY_CATALOG = codegen::QueryCache::Instance().GetCount(); auto agg_plan1 = GetAggregatePlan(); @@ -499,7 +499,7 @@ TEST_F(QueryCacheTest, CacheAggregatePlan) { EXPECT_FALSE(found); } -TEST_F(QueryCacheTest, CacheNestedLoopJoinPlan) { +TEST_F(QueryCacheTests, CacheNestedLoopJoinPlanTest) { int CACHE_USED_BY_CATALOG = codegen::QueryCache::Instance().GetCount(); auto nlj_plan_1 = GetBlockNestedLoopJoinPlan(); @@ -545,7 +545,7 @@ TEST_F(QueryCacheTest, CacheNestedLoopJoinPlan) { EXPECT_FALSE(found); } -TEST_F(QueryCacheTest, PerformanceBenchmark) { +TEST_F(QueryCacheTests, PerformanceBenchmarkTest) { codegen::QueryCache::Instance().Clear(); Timer> timer1, timer2; diff --git a/test/codegen/sorter_test.cpp b/test/codegen/sorter_test.cpp index 055e2c7a583..3789b122d07 100644 --- a/test/codegen/sorter_test.cpp +++ b/test/codegen/sorter_test.cpp @@ -34,14 +34,14 @@ static int CompareTuplesForAscending(const char *a, const char *b) { return at->col_b - bt->col_b; } -class SorterTest : public PelotonTest { +class SorterTests : public PelotonTests { public: - SorterTest() { + SorterTests() { // Init sorter.Init(CompareTuplesForAscending, sizeof(TestTuple)); } - ~SorterTest() { + ~SorterTests() { // Clean up sorter.Destroy(); } @@ -93,12 +93,12 @@ class SorterTest : public PelotonTest { codegen::util::Sorter sorter; }; -TEST_F(SorterTest, CanSortTuples) { +TEST_F(SorterTests, CanSortTuplesTest) { // Test sorting 10 TestSort(10); } -TEST_F(SorterTest, BenchmarkSorter) { +TEST_F(SorterTests, BenchmarkSorterTest) { // Test sorting 5 million input tuples TestSort(5000000); } diff --git a/test/codegen/table_scan_translator_test.cpp b/test/codegen/table_scan_translator_test.cpp index 99fda04bb2b..fea4743706d 100644 --- a/test/codegen/table_scan_translator_test.cpp +++ b/test/codegen/table_scan_translator_test.cpp @@ -25,11 +25,11 @@ namespace peloton { namespace test { -class TableScanTranslatorTest : public PelotonCodeGenTest { +class TableScanTranslatorTests : public PelotonCodeGenTests { std::string all_cols_table_name = "crazy_table"; public: - TableScanTranslatorTest() : PelotonCodeGenTest(), num_rows_to_insert(64) { + TableScanTranslatorTests() : PelotonCodeGenTests(), num_rows_to_insert(64) { // Load test table LoadTestTable(TestTableId(), num_rows_to_insert); @@ -143,7 +143,7 @@ class TableScanTranslatorTest : public PelotonCodeGenTest { storage::DataTable *all_cols_table = nullptr; }; -TEST_F(TableScanTranslatorTest, AllColumnsScan) { +TEST_F(TableScanTranslatorTests, AllColumnsScanTest) { // // SELECT a, b, c FROM table; // @@ -166,7 +166,7 @@ TEST_F(TableScanTranslatorTest, AllColumnsScan) { EXPECT_EQ(NumRowsInTestTable(), results.size()); } -TEST_F(TableScanTranslatorTest, AllColumnsScanWithNulls) { +TEST_F(TableScanTranslatorTests, AllColumnsScanWithNullsTest) { // // SELECT * FROM crazy_table; // @@ -195,12 +195,12 @@ TEST_F(TableScanTranslatorTest, AllColumnsScanWithNulls) { auto &tuple = buffer.GetOutputTuples()[0]; for (uint32_t i = 0; i < all_col_ids.size(); i++) { auto col_val = tuple.GetValue(i); - EXPECT_TRUE(col_val.IsNull()) - << "Result value: " << col_val.ToString() << ", expected NULL"; + EXPECT_TRUE(col_val.IsNull()) << "Result value: " << col_val.ToString() + << ", expected NULL"; } } -TEST_F(TableScanTranslatorTest, SimplePredicate) { +TEST_F(TableScanTranslatorTests, SimplePredicateTest) { // // SELECT a, b, c FROM table where a >= 20; // @@ -228,7 +228,7 @@ TEST_F(TableScanTranslatorTest, SimplePredicate) { EXPECT_EQ(NumRowsInTestTable() - 2, results.size()); } -TEST_F(TableScanTranslatorTest, SimplePredicateWithNull) { +TEST_F(TableScanTranslatorTests, SimplePredicateWithNullTest) { // Insert 10 null rows const bool insert_nulls = true; LoadTestTable(TestTableId(), 10, insert_nulls); @@ -272,7 +272,7 @@ TEST_F(TableScanTranslatorTest, SimplePredicateWithNull) { type::ValueFactory::GetIntegerValue(11))); } -TEST_F(TableScanTranslatorTest, PredicateOnNonOutputColumn) { +TEST_F(TableScanTranslatorTests, PredicateOnNonOutputColumnTest) { // // SELECT b FROM table where a >= 40; // @@ -300,7 +300,7 @@ TEST_F(TableScanTranslatorTest, PredicateOnNonOutputColumn) { EXPECT_EQ(NumRowsInTestTable() - 4, results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithConjunctionPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithConjunctionPredicateTest) { // // SELECT a, b, c FROM table where a >= 20 and b = 21; // @@ -341,7 +341,7 @@ TEST_F(TableScanTranslatorTest, ScanWithConjunctionPredicate) { type::ValueFactory::GetIntegerValue(21))); } -TEST_F(TableScanTranslatorTest, ScanWithAddPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithAddPredicateTest) { // // SELECT a, b FROM table where b = a + 1; // @@ -381,7 +381,7 @@ TEST_F(TableScanTranslatorTest, ScanWithAddPredicate) { EXPECT_EQ(NumRowsInTestTable(), results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithAddColumnsPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithAddColumnsPredicateTest) { // // SELECT a, b FROM table where b = a + b; // @@ -422,7 +422,7 @@ TEST_F(TableScanTranslatorTest, ScanWithAddColumnsPredicate) { EXPECT_EQ(1, results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithSubtractPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithSubtractPredicateTest) { // // SELECT a, b FROM table where a = b - 1; // @@ -462,7 +462,7 @@ TEST_F(TableScanTranslatorTest, ScanWithSubtractPredicate) { EXPECT_EQ(NumRowsInTestTable(), results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithSubtractColumnsPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithSubtractColumnsPredicateTest) { // // SELECT a, b FROM table where b = b - a; // @@ -503,7 +503,7 @@ TEST_F(TableScanTranslatorTest, ScanWithSubtractColumnsPredicate) { EXPECT_EQ(1, results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithDividePredicate) { +TEST_F(TableScanTranslatorTests, ScanWithDividePredicateTest) { // // SELECT a, b, c FROM table where a = a / 2; // @@ -544,7 +544,7 @@ TEST_F(TableScanTranslatorTest, ScanWithDividePredicate) { EXPECT_EQ(1, results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithMultiplyPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithMultiplyPredicateTest) { // // SELECT a, b, c FROM table where a = a *b; // @@ -585,7 +585,7 @@ TEST_F(TableScanTranslatorTest, ScanWithMultiplyPredicate) { EXPECT_EQ(1, results.size()); } -TEST_F(TableScanTranslatorTest, ScanWithModuloPredicate) { +TEST_F(TableScanTranslatorTests, ScanWithModuloPredicateTest) { // // SELECT a, b, c FROM table where a = b % 1; // @@ -629,7 +629,7 @@ TEST_F(TableScanTranslatorTest, ScanWithModuloPredicate) { type::ValueFactory::GetIntegerValue(1))); } -TEST_F(TableScanTranslatorTest, ScanRowLayout) { +TEST_F(TableScanTranslatorTests, ScanRowLayoutTest) { // // Creates a table with LayoutType::ROW and // invokes the TableScanTranslator @@ -643,7 +643,7 @@ TEST_F(TableScanTranslatorTest, ScanRowLayout) { ScanLayoutTable(tuples_per_tilegroup, tilegroup_count, column_count); } -TEST_F(TableScanTranslatorTest, ScanColumnLayout) { +TEST_F(TableScanTranslatorTests, ScanColumnLayoutTest) { // // Creates a table with LayoutType::COLUMN and // invokes the TableScanTranslator @@ -657,7 +657,7 @@ TEST_F(TableScanTranslatorTest, ScanColumnLayout) { ScanLayoutTable(tuples_per_tilegroup, tilegroup_count, column_count); } -TEST_F(TableScanTranslatorTest, MultiLayoutScan) { +TEST_F(TableScanTranslatorTests, MultiLayoutScanTest) { // // Creates a table with LayoutType::ROW // Sets the default_layout_ as LayoutType::COLUMN diff --git a/test/codegen/testing_codegen_util.cpp b/test/codegen/testing_codegen_util.cpp index ff05144978b..aa8188b23f1 100644 --- a/test/codegen/testing_codegen_util.cpp +++ b/test/codegen/testing_codegen_util.cpp @@ -32,8 +32,8 @@ namespace test { // PELOTON CODEGEN TEST //===----------------------------------------------------------------------===// -PelotonCodeGenTest::PelotonCodeGenTest(oid_t tuples_per_tilegroup, - peloton::LayoutType layout_type) { +PelotonCodeGenTests::PelotonCodeGenTests(oid_t tuples_per_tilegroup, + peloton::LayoutType layout_type) { auto *catalog = catalog::Catalog::GetInstance(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -48,7 +48,7 @@ PelotonCodeGenTest::PelotonCodeGenTest(oid_t tuples_per_tilegroup, layout_table = nullptr; } -PelotonCodeGenTest::~PelotonCodeGenTest() { +PelotonCodeGenTests::~PelotonCodeGenTests() { auto *catalog = catalog::Catalog::GetInstance(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -58,7 +58,7 @@ PelotonCodeGenTest::~PelotonCodeGenTest() { codegen::QueryCache::Instance().Clear(); } -catalog::Column PelotonCodeGenTest::GetTestColumn(uint32_t col_id) const { +catalog::Column PelotonCodeGenTests::GetTestColumn(uint32_t col_id) const { PELOTON_ASSERT(col_id < 4); static const uint64_t int_size = type::Type::GetTypeSize(type::TypeId::INTEGER); @@ -81,7 +81,7 @@ catalog::Column PelotonCodeGenTest::GetTestColumn(uint32_t col_id) const { } // Create the test schema for all the tables -std::unique_ptr PelotonCodeGenTest::CreateTestSchema( +std::unique_ptr PelotonCodeGenTests::CreateTestSchema( bool add_primary) const { // Create the columns std::vector cols = {GetTestColumn(0), GetTestColumn(1), @@ -104,19 +104,18 @@ std::unique_ptr PelotonCodeGenTest::CreateTestSchema( } // Create all the test tables, but don't load any data -void PelotonCodeGenTest::CreateTestTables(concurrency::TransactionContext *txn, - oid_t tuples_per_tilegroup, - peloton::LayoutType layout_type) { +void PelotonCodeGenTests::CreateTestTables(concurrency::TransactionContext *txn, + oid_t tuples_per_tilegroup, + peloton::LayoutType layout_type) { auto *catalog = catalog::Catalog::GetInstance(); for (int i = 0; i < 4; i++) { auto table_schema = CreateTestSchema(); catalog->CreateTable(test_db_name, DEFAULT_SCHEMA_NAME, test_table_names[i], std::move(table_schema), txn, false, tuples_per_tilegroup, layout_type); - test_table_oids.push_back(catalog - ->GetTableObject(test_db_name, - DEFAULT_SCHEMA_NAME, - test_table_names[i], txn) + test_table_oids.push_back(catalog->GetTableObject(test_db_name, + DEFAULT_SCHEMA_NAME, + test_table_names[i], txn) ->GetTableOid()); } for (int i = 4; i < 5; i++) { @@ -124,16 +123,15 @@ void PelotonCodeGenTest::CreateTestTables(concurrency::TransactionContext *txn, catalog->CreateTable(test_db_name, DEFAULT_SCHEMA_NAME, test_table_names[i], std::move(table_schema), txn, false, tuples_per_tilegroup, layout_type); - test_table_oids.push_back(catalog - ->GetTableObject(test_db_name, - DEFAULT_SCHEMA_NAME, - test_table_names[i], txn) + test_table_oids.push_back(catalog->GetTableObject(test_db_name, + DEFAULT_SCHEMA_NAME, + test_table_names[i], txn) ->GetTableOid()); } } -void PelotonCodeGenTest::LoadTestTable(oid_t table_id, uint32_t num_rows, - bool insert_nulls) { +void PelotonCodeGenTests::LoadTestTable(oid_t table_id, uint32_t num_rows, + bool insert_nulls) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto *txn = txn_manager.BeginTransaction(); @@ -178,7 +176,7 @@ void PelotonCodeGenTest::LoadTestTable(oid_t table_id, uint32_t num_rows, txn_manager.CommitTransaction(txn); } -void PelotonCodeGenTest::CreateAndLoadTableWithLayout( +void PelotonCodeGenTests::CreateAndLoadTableWithLayout( peloton::LayoutType layout_type, uint32_t tuples_per_tilegroup, uint32_t tile_group_count, uint32_t column_count, bool is_inlined) { uint32_t tuple_count = tuples_per_tilegroup * tile_group_count; @@ -252,7 +250,7 @@ void PelotonCodeGenTest::CreateAndLoadTableWithLayout( txn_manager.CommitTransaction(txn); } -void PelotonCodeGenTest::ExecuteSync( +void PelotonCodeGenTests::ExecuteSync( codegen::Query &query, std::unique_ptr executor_context, codegen::QueryResultConsumer &consumer) { @@ -270,7 +268,7 @@ void PelotonCodeGenTest::ExecuteSync( cond.wait(lock, [&] { return finished; }); } -codegen::QueryCompiler::CompileStats PelotonCodeGenTest::CompileAndExecute( +codegen::QueryCompiler::CompileStats PelotonCodeGenTests::CompileAndExecute( planner::AbstractPlan &plan, codegen::QueryResultConsumer &consumer) { codegen::QueryParameters parameters(plan, {}); @@ -295,7 +293,8 @@ codegen::QueryCompiler::CompileStats PelotonCodeGenTest::CompileAndExecute( return stats; } -codegen::QueryCompiler::CompileStats PelotonCodeGenTest::CompileAndExecuteCache( +codegen::QueryCompiler::CompileStats +PelotonCodeGenTests::CompileAndExecuteCache( std::shared_ptr plan, codegen::QueryResultConsumer &consumer, bool &cached, std::vector params) { @@ -328,72 +327,72 @@ codegen::QueryCompiler::CompileStats PelotonCodeGenTest::CompileAndExecuteCache( return stats; } -ExpressionPtr PelotonCodeGenTest::ConstIntExpr(int64_t val) { +ExpressionPtr PelotonCodeGenTests::ConstIntExpr(int64_t val) { auto *expr = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(val)); return ExpressionPtr{expr}; } -ExpressionPtr PelotonCodeGenTest::ConstDecimalExpr(double val) { +ExpressionPtr PelotonCodeGenTests::ConstDecimalExpr(double val) { auto *expr = new expression::ConstantValueExpression( type::ValueFactory::GetDecimalValue(val)); return ExpressionPtr{expr}; } -ExpressionPtr PelotonCodeGenTest::ColRefExpr(type::TypeId type, - uint32_t col_id) { +ExpressionPtr PelotonCodeGenTests::ColRefExpr(type::TypeId type, + uint32_t col_id) { auto *expr = new expression::TupleValueExpression(type, 0, col_id); return ExpressionPtr{expr}; } -ExpressionPtr PelotonCodeGenTest::ColRefExpr(type::TypeId type, bool left, - uint32_t col_id) { +ExpressionPtr PelotonCodeGenTests::ColRefExpr(type::TypeId type, bool left, + uint32_t col_id) { return ExpressionPtr{ new expression::TupleValueExpression(type, !left, col_id)}; } -ExpressionPtr PelotonCodeGenTest::CmpExpr(ExpressionType cmp_type, - ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::CmpExpr(ExpressionType cmp_type, + ExpressionPtr &&left, + ExpressionPtr &&right) { auto *expr = new expression::ComparisonExpression(cmp_type, left.release(), right.release()); return ExpressionPtr{expr}; } -ExpressionPtr PelotonCodeGenTest::CmpLtExpr(ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::CmpLtExpr(ExpressionPtr &&left, + ExpressionPtr &&right) { return CmpExpr(ExpressionType::COMPARE_LESSTHAN, std::move(left), std::move(right)); } -ExpressionPtr PelotonCodeGenTest::CmpLteExpr(ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::CmpLteExpr(ExpressionPtr &&left, + ExpressionPtr &&right) { return CmpExpr(ExpressionType::COMPARE_LESSTHANOREQUALTO, std::move(left), std::move(right)); } -ExpressionPtr PelotonCodeGenTest::CmpGtExpr(ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::CmpGtExpr(ExpressionPtr &&left, + ExpressionPtr &&right) { return CmpExpr(ExpressionType::COMPARE_GREATERTHAN, std::move(left), std::move(right)); } -ExpressionPtr PelotonCodeGenTest::CmpGteExpr(ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::CmpGteExpr(ExpressionPtr &&left, + ExpressionPtr &&right) { return CmpExpr(ExpressionType::COMPARE_GREATERTHANOREQUALTO, std::move(left), std::move(right)); } -ExpressionPtr PelotonCodeGenTest::CmpEqExpr(ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::CmpEqExpr(ExpressionPtr &&left, + ExpressionPtr &&right) { return CmpExpr(ExpressionType::COMPARE_EQUAL, std::move(left), std::move(right)); } -ExpressionPtr PelotonCodeGenTest::OpExpr(ExpressionType op_type, - type::TypeId type, - ExpressionPtr &&left, - ExpressionPtr &&right) { +ExpressionPtr PelotonCodeGenTests::OpExpr(ExpressionType op_type, + type::TypeId type, + ExpressionPtr &&left, + ExpressionPtr &&right) { switch (op_type) { case ExpressionType::OPERATOR_PLUS: case ExpressionType::OPERATOR_MINUS: diff --git a/test/codegen/type_integrity_test.cpp b/test/codegen/type_integrity_test.cpp index 0b3b5224016..03e928491c2 100644 --- a/test/codegen/type_integrity_test.cpp +++ b/test/codegen/type_integrity_test.cpp @@ -30,9 +30,9 @@ namespace peloton { namespace test { -class TypeIntegrityTest : public PelotonCodeGenTest {}; +class TypeIntegrityTests : public PelotonCodeGenTests {}; -TEST_F(TypeIntegrityTest, ImplicitCastTest) { +TEST_F(TypeIntegrityTests, ImplicitCastTest) { struct ImplicitCastTestCase { codegen::type::Type source_type; std::vector target_types; @@ -104,7 +104,7 @@ TEST_F(TypeIntegrityTest, ImplicitCastTest) { // This test performs checks that comparisons between every possible pair of // (the most important) input types are possible through potentially implicitly // casting the inputs. -TEST_F(TypeIntegrityTest, ComparisonWithImplicitCastTest) { +TEST_F(TypeIntegrityTests, ComparisonWithImplicitCastTest) { const std::vector types_to_test = { codegen::type::Boolean::Instance(), codegen::type::TinyInt::Instance(), @@ -146,7 +146,7 @@ TEST_F(TypeIntegrityTest, ComparisonWithImplicitCastTest) { } // TODO: This test only does math ops. We need a generic way to test binary ops. -TEST_F(TypeIntegrityTest, MathOpWithImplicitCastTest) { +TEST_F(TypeIntegrityTests, MathOpWithImplicitCastTest) { const auto binary_ops = {OperatorId::Add, OperatorId::Sub, OperatorId::Mul, OperatorId::Div, OperatorId::Mod}; diff --git a/test/codegen/update_translator_test.cpp b/test/codegen/update_translator_test.cpp index b14f4506384..2a53afe6ae3 100644 --- a/test/codegen/update_translator_test.cpp +++ b/test/codegen/update_translator_test.cpp @@ -31,9 +31,9 @@ namespace peloton { namespace test { -class UpdateTranslatorTest : public PelotonCodeGenTest { +class UpdateTranslatorTests : public PelotonCodeGenTests { public: - UpdateTranslatorTest() : PelotonCodeGenTest() {} + UpdateTranslatorTests() : PelotonCodeGenTests() {} oid_t TestTableId1() { return test_table_oids[0]; } oid_t TestTableId2() { return test_table_oids[1]; } @@ -44,7 +44,7 @@ class UpdateTranslatorTest : public PelotonCodeGenTest { uint32_t num_rows_to_insert = 10; }; -TEST_F(UpdateTranslatorTest, UpdateColumnsWithAConstant) { +TEST_F(UpdateTranslatorTests, UpdateColumnsWithAConstantTest) { LoadTestTable(TestTableId1(), NumRowsInTestTable()); // SET a = 1; @@ -114,25 +114,24 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithAConstant) { auto &results_1 = buffer_1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(2))); + type::ValueFactory::GetIntegerValue(2))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("3"))); + type::ValueFactory::GetVarcharValue("3"))); EXPECT_EQ(CmpBool::CmpTrue, results_1[9].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_1[9].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(91))); + type::ValueFactory::GetIntegerValue(91))); EXPECT_EQ(CmpBool::CmpTrue, results_1[9].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(92))); - EXPECT_EQ(CmpBool::CmpTrue, - results_1[9].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("93"))); + type::ValueFactory::GetIntegerValue(92))); + EXPECT_EQ(CmpBool::CmpTrue, results_1[9].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("93"))); } -TEST_F(UpdateTranslatorTest, UpdateColumnsWithAConstantAndPredicate) { +TEST_F(UpdateTranslatorTests, UpdateColumnsWithAConstantAndPredicateTest) { LoadTestTable(TestTableId2(), NumRowsInTestTable()); // SET a = 1; @@ -207,17 +206,16 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithAConstantAndPredicate) { auto &results_1 = buffer_1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(40))); + type::ValueFactory::GetIntegerValue(40))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(49))); + type::ValueFactory::GetIntegerValue(49))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(42))); - EXPECT_EQ(CmpBool::CmpTrue, - results_1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("43"))); + type::ValueFactory::GetIntegerValue(42))); + EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("43"))); } -TEST_F(UpdateTranslatorTest, UpdateColumnsWithAnOperatorExpression) { +TEST_F(UpdateTranslatorTests, UpdateColumnsWithAnOperatorExpressionTest) { LoadTestTable(TestTableId2(), NumRowsInTestTable()); // SET a = 1; @@ -299,17 +297,17 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithAnOperatorExpression) { auto &results_1 = buffer_1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(40))); + type::ValueFactory::GetIntegerValue(40))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(49))); + type::ValueFactory::GetIntegerValue(49))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(42))); - EXPECT_EQ(CmpBool::CmpTrue, - results_1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("43"))); + type::ValueFactory::GetIntegerValue(42))); + EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("43"))); } -TEST_F(UpdateTranslatorTest, UpdateColumnsWithAnOperatorExpressionComplex) { +TEST_F(UpdateTranslatorTests, + UpdateColumnsWithAnOperatorExpressionComplexTest) { LoadTestTable(TestTableId2(), NumRowsInTestTable()); // SET a = 1; @@ -401,17 +399,16 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithAnOperatorExpressionComplex) { auto &results_1 = buffer_1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(41))); + type::ValueFactory::GetIntegerValue(41))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(81))); + type::ValueFactory::GetIntegerValue(81))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(42))); - EXPECT_EQ(CmpBool::CmpTrue, - results_1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("43"))); + type::ValueFactory::GetIntegerValue(42))); + EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("43"))); } -TEST_F(UpdateTranslatorTest, UpdateColumnsWithAConstantPrimary) { +TEST_F(UpdateTranslatorTests, UpdateColumnsWithAConstantPrimaryTest) { LoadTestTable(TestTableId5(), NumRowsInTestTable()); // SET a = 1; @@ -486,17 +483,16 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithAConstantPrimary) { auto &results_5 = buffer_5.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_5[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(1))); + type::ValueFactory::GetIntegerValue(1))); EXPECT_EQ(CmpBool::CmpTrue, results_5[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(11))); + type::ValueFactory::GetIntegerValue(11))); EXPECT_EQ(CmpBool::CmpTrue, results_5[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(12))); - EXPECT_EQ(CmpBool::CmpTrue, - results_5[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("13"))); + type::ValueFactory::GetIntegerValue(12))); + EXPECT_EQ(CmpBool::CmpTrue, results_5[0].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("13"))); } -TEST_F(UpdateTranslatorTest, UpdateColumnsWithCast) { +TEST_F(UpdateTranslatorTests, UpdateColumnsWithCastTest) { LoadTestTable(TestTableId1(), NumRowsInTestTable()); // SET a = 1; @@ -570,14 +566,13 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithCast) { auto &results_1 = buffer_1.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(10))); + type::ValueFactory::GetIntegerValue(10))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(11))); + type::ValueFactory::GetIntegerValue(11))); EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(2))); - EXPECT_EQ(CmpBool::CmpTrue, - results_1[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("13"))); + type::ValueFactory::GetIntegerValue(2))); + EXPECT_EQ(CmpBool::CmpTrue, results_1[0].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("13"))); // Get the scan plan without a predicate with four columns ExpressionPtr a_eq_10_2 = @@ -641,14 +636,13 @@ TEST_F(UpdateTranslatorTest, UpdateColumnsWithCast) { auto &results_3 = buffer_3.GetOutputTuples(); EXPECT_EQ(CmpBool::CmpTrue, results_3[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(10))); + type::ValueFactory::GetIntegerValue(10))); EXPECT_EQ(CmpBool::CmpTrue, results_3[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(11))); + type::ValueFactory::GetIntegerValue(11))); EXPECT_EQ(CmpBool::CmpTrue, results_3[0].GetValue(2).CompareEquals( - type::ValueFactory::GetIntegerValue(3))); - EXPECT_EQ(CmpBool::CmpTrue, - results_3[0].GetValue(3).CompareEquals( - type::ValueFactory::GetVarcharValue("13"))); + type::ValueFactory::GetIntegerValue(3))); + EXPECT_EQ(CmpBool::CmpTrue, results_3[0].GetValue(3).CompareEquals( + type::ValueFactory::GetVarcharValue("13"))); } } // namespace test diff --git a/test/codegen/value_integrity_test.cpp b/test/codegen/value_integrity_test.cpp index 551e3956e75..bdaba48c111 100644 --- a/test/codegen/value_integrity_test.cpp +++ b/test/codegen/value_integrity_test.cpp @@ -21,7 +21,7 @@ namespace peloton { namespace test { -class ValueIntegrityTest : public PelotonCodeGenTest {}; +class ValueIntegrityTests : public PelotonCodeGenTests {}; // This test sets up a function taking a single argument. The body of the // function divides a constant value with the value of the argument. After @@ -138,7 +138,7 @@ void OverflowTest(const codegen::type::Type &data_type, ExpressionType op) { EXPECT_THROW(f(2), std::overflow_error); } -TEST_F(ValueIntegrityTest, IntegerOverflow) { +TEST_F(ValueIntegrityTests, IntegerOverflowTest) { auto overflowable_ops = {ExpressionType::OPERATOR_MINUS, ExpressionType::OPERATOR_PLUS, ExpressionType::OPERATOR_MULTIPLY}; @@ -150,7 +150,7 @@ TEST_F(ValueIntegrityTest, IntegerOverflow) { } } -TEST_F(ValueIntegrityTest, IntegerDivideByZero) { +TEST_F(ValueIntegrityTests, IntegerDivideByZeroTest) { auto div0_ops = {ExpressionType::OPERATOR_DIVIDE, ExpressionType::OPERATOR_MOD}; for (auto op : div0_ops) { diff --git a/test/codegen/zone_map_scan_test.cpp b/test/codegen/zone_map_scan_test.cpp index f3b24ac7e53..668b9adca0f 100644 --- a/test/codegen/zone_map_scan_test.cpp +++ b/test/codegen/zone_map_scan_test.cpp @@ -25,12 +25,12 @@ namespace peloton { namespace test { -class ZoneMapScanTest : public PelotonCodeGenTest { +class ZoneMapScanTests : public PelotonCodeGenTests { std::string all_cols_table_name = "skipping_table"; public: - ZoneMapScanTest() - : PelotonCodeGenTest(TEST_TUPLES_PER_TILEGROUP), num_rows_to_insert(20) { + ZoneMapScanTests() + : PelotonCodeGenTests(TEST_TUPLES_PER_TILEGROUP), num_rows_to_insert(20) { // Load test table LoadTestTable(TestTableId(), num_rows_to_insert); @@ -67,7 +67,7 @@ class ZoneMapScanTest : public PelotonCodeGenTest { uint32_t num_rows_to_insert = 100; }; -TEST_F(ZoneMapScanTest, ScanNoPredicates) { +TEST_F(ZoneMapScanTests, ScanNoPredicatesTest) { // SELECT a, b, c FROM table; // 1) Setup the scan plan node planner::SeqScanPlan scan{&GetTestTable(TestTableId()), nullptr, {0, 1, 2}}; @@ -81,7 +81,7 @@ TEST_F(ZoneMapScanTest, ScanNoPredicates) { EXPECT_EQ(NumRowsInTestTable(), results.size()); } -TEST_F(ZoneMapScanTest, SimplePredicate) { +TEST_F(ZoneMapScanTests, SimplePredicateTest) { // SELECT a, b, c FROM table where a >= 20; // 1) Setup the predicate ExpressionPtr a_gt_20 = @@ -101,7 +101,7 @@ TEST_F(ZoneMapScanTest, SimplePredicate) { EXPECT_EQ(NumRowsInTestTable() - 2, results.size()); } -TEST_F(ZoneMapScanTest, PredicateOnNonOutputColumn) { +TEST_F(ZoneMapScanTests, PredicateOnNonOutputColumnTest) { // SELECT b FROM table where a >= 40; // 1) Setup the predicate ExpressionPtr a_gt_40 = @@ -121,7 +121,7 @@ TEST_F(ZoneMapScanTest, PredicateOnNonOutputColumn) { EXPECT_EQ(NumRowsInTestTable() - 4, results.size()); } -TEST_F(ZoneMapScanTest, ScanwithConjunctionPredicate) { +TEST_F(ZoneMapScanTests, ScanwithConjunctionPredicateTest) { // SELECT a, b, c FROM table where a >= 20 and b = 21; // 1) Construct the components of the predicate // a >= 20 @@ -146,9 +146,9 @@ TEST_F(ZoneMapScanTest, ScanwithConjunctionPredicate) { const auto &results = buffer.GetOutputTuples(); ASSERT_EQ(1, results.size()); EXPECT_EQ(CmpBool::CmpTrue, results[0].GetValue(0).CompareEquals( - type::ValueFactory::GetIntegerValue(20))); + type::ValueFactory::GetIntegerValue(20))); EXPECT_EQ(CmpBool::CmpTrue, results[0].GetValue(1).CompareEquals( - type::ValueFactory::GetIntegerValue(21))); + type::ValueFactory::GetIntegerValue(21))); } } } \ No newline at end of file diff --git a/test/common/cache_test.cpp b/test/common/cache_test.cpp index 334fc64867a..0d5deaab40d 100644 --- a/test/common/cache_test.cpp +++ b/test/common/cache_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "common/cache.h" @@ -27,7 +26,7 @@ namespace test { // Cache Test //===--------------------------------------------------------------------===// -class CacheTests : public PelotonTest {}; +class CacheTests : public PelotonTests {}; #define CACHE_SIZE 5 @@ -43,7 +42,7 @@ static void fill( * Test basic functionality * */ -TEST_F(CacheTests, Basic) { +TEST_F(CacheTests, BasicTest) { Cache cache(CACHE_SIZE, 1); EXPECT_EQ(0, cache.size()); @@ -54,7 +53,7 @@ TEST_F(CacheTests, Basic) { * Test find operation * */ -TEST_F(CacheTests, Find) { +TEST_F(CacheTests, FindTest) { Cache cache(CACHE_SIZE, 1); // EXPECT_EQ(cache.end(), cache.find(1)); @@ -64,7 +63,7 @@ TEST_F(CacheTests, Find) { * Test insert operation * */ -TEST_F(CacheTests, Insert) { +TEST_F(CacheTests, InsertTest) { Cache cache(CACHE_SIZE, 1); std::vector > plans; @@ -91,12 +90,11 @@ TEST_F(CacheTests, Insert) { EXPECT_EQ(statement_cache_.size(), 1); } - /** * Test insert operation with default threshold * */ -TEST_F(CacheTests, InsertThreshold) { +TEST_F(CacheTests, InsertThresholdTest) { // Default insert threshold is 3, i.e. it will not be inserted // until 3 attempts are detected. Cache cache(CACHE_SIZE); @@ -122,7 +120,7 @@ TEST_F(CacheTests, InsertThreshold) { /** * Test iterator function */ -TEST_F(CacheTests, Iterator) { +TEST_F(CacheTests, IteratorTest) { Cache cache(CACHE_SIZE, 1); std::vector > plans; @@ -149,7 +147,7 @@ TEST_F(CacheTests, Iterator) { * Try to insert 2 times of the capacity of the cache * The cache should keep the most recent half */ -TEST_F(CacheTests, EvictionByInsert) { +TEST_F(CacheTests, EvictionByInsertTest) { Cache cache(CACHE_SIZE, 1); std::vector > plans; @@ -181,7 +179,7 @@ TEST_F(CacheTests, EvictionByInsert) { * The cache should keep the most recent half */ /* TODO: Fix this test -TEST_F(CacheTest, EvictionWithAccessing) { +TEST_F(CacheTests, EvictionWithAccessingTest) { Cache cache(CACHE_SIZE, 1); std::vector > plans; @@ -255,7 +253,7 @@ TEST_F(CacheTest, EvictionWithAccessing) { * Try to insert 2 times of the capacity of the cache * The cache should keep the most recent half */ -TEST_F(CacheTests, Updating) { +TEST_F(CacheTests, UpdatingTest) { Cache cache(CACHE_SIZE, 1); std::vector > plans; diff --git a/test/common/container_tuple_test.cpp b/test/common/container_tuple_test.cpp index 54794a5ddd2..91442d524ab 100644 --- a/test/common/container_tuple_test.cpp +++ b/test/common/container_tuple_test.cpp @@ -23,9 +23,9 @@ namespace peloton { namespace test { -class ContainerTupleTests : public PelotonTest {}; +class ContainerTupleTests : public PelotonTests {}; -TEST_F(ContainerTupleTests, VectorValue) { +TEST_F(ContainerTupleTests, VectorValueTest) { std::vector values; values.push_back(type::ValueFactory::GetIntegerValue(11)); values.push_back(type::ValueFactory::GetIntegerValue(22)); @@ -37,11 +37,12 @@ TEST_F(ContainerTupleTests, VectorValue) { for (size_t i = 0; i < values.size(); i++) { LOG_INFO("%s", ctuple.GetValue(i).GetInfo().c_str()); - EXPECT_TRUE(values[i].CompareEquals(ctuple.GetValue(i)) == CmpBool::CmpTrue); + EXPECT_TRUE(values[i].CompareEquals(ctuple.GetValue(i)) == + CmpBool::CmpTrue); } } -TEST_F(ContainerTupleTests, GetInfo) { +TEST_F(ContainerTupleTests, GetInfoTest) { catalog::Column a_col{type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), "a"}; catalog::Column b_col{type::TypeId::BIGINT, diff --git a/test/common/cuckoo_map_test.cpp b/test/common/cuckoo_map_test.cpp index 2ac31db4c8c..e43f1d6213c 100644 --- a/test/common/cuckoo_map_test.cpp +++ b/test/common/cuckoo_map_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/container/cuckoo_map.h" #include "common/harness.h" @@ -22,7 +21,7 @@ namespace test { // Cuckoo Map Test //===--------------------------------------------------------------------===// -class CuckooMapTests : public PelotonTest {}; +class CuckooMapTests : public PelotonTests {}; // Test basic functionality TEST_F(CuckooMapTests, BasicTest) { @@ -95,7 +94,7 @@ TEST_F(CuckooMapTests, IteratorTest) { typedef std::shared_ptr value_type; CuckooMap map; - + { size_t const element_count = 3; for (size_t element = 0; element < element_count; ++element) { diff --git a/test/common/harness.cpp b/test/common/harness.cpp index deff8069c25..ba6f9616bf2 100644 --- a/test/common/harness.cpp +++ b/test/common/harness.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "type/ephemeral_pool.h" @@ -23,7 +22,7 @@ namespace test { /** * @brief Return the singleton testing harness instance */ -TestingHarness& TestingHarness::GetInstance() { +TestingHarness &TestingHarness::GetInstance() { static TestingHarness testing_harness; return testing_harness; } @@ -44,7 +43,7 @@ uint64_t TestingHarness::GetThreadId() { } txn_id_t TestingHarness::GetNextTransactionId() { - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); txn_id_t txn_id = txn->GetTransactionId(); txn_manager.CommitTransaction(txn); @@ -52,7 +51,7 @@ txn_id_t TestingHarness::GetNextTransactionId() { return txn_id; } -type::AbstractPool* TestingHarness::GetTestingPool() { +type::AbstractPool *TestingHarness::GetTestingPool() { // return pool return pool_.get(); } diff --git a/test/common/internal_types_test.cpp b/test/common/internal_types_test.cpp index c9782514fc6..2f5b61fca29 100644 --- a/test/common/internal_types_test.cpp +++ b/test/common/internal_types_test.cpp @@ -24,7 +24,7 @@ namespace test { // Internal Types Test //===--------------------------------------------------------------------===// -class InternalTypesTests : public PelotonTest {}; +class InternalTypesTests : public PelotonTests {}; TEST_F(InternalTypesTests, DatePartTypeTest) { std::vector list = { @@ -104,11 +104,13 @@ TEST_F(InternalTypesTests, BackendTypeTest) { TEST_F(InternalTypesTests, TypeIdTest) { std::vector list = { - type::TypeId::INVALID, type::TypeId::PARAMETER_OFFSET, - type::TypeId::BOOLEAN, type::TypeId::TINYINT, type::TypeId::SMALLINT, - type::TypeId::INTEGER, type::TypeId::BIGINT, type::TypeId::DECIMAL, - type::TypeId::TIMESTAMP, type::TypeId::DATE, type::TypeId::VARCHAR, - type::TypeId::VARBINARY, type::TypeId::ARRAY, type::TypeId::UDT}; + type::TypeId::INVALID, type::TypeId::PARAMETER_OFFSET, + type::TypeId::BOOLEAN, type::TypeId::TINYINT, + type::TypeId::SMALLINT, type::TypeId::INTEGER, + type::TypeId::BIGINT, type::TypeId::DECIMAL, + type::TypeId::TIMESTAMP, type::TypeId::DATE, + type::TypeId::VARCHAR, type::TypeId::VARBINARY, + type::TypeId::ARRAY, type::TypeId::UDT}; // Make sure that ToString and FromString work for (auto val : list) { @@ -164,31 +166,54 @@ TEST_F(InternalTypesTests, StatementTypeTest) { TEST_F(InternalTypesTests, ExpressionTypeTest) { std::vector list = { - ExpressionType::INVALID, ExpressionType::OPERATOR_PLUS, - ExpressionType::OPERATOR_MINUS, ExpressionType::OPERATOR_MULTIPLY, - ExpressionType::OPERATOR_DIVIDE, ExpressionType::OPERATOR_CONCAT, - ExpressionType::OPERATOR_MOD, ExpressionType::OPERATOR_CAST, - ExpressionType::OPERATOR_NOT, ExpressionType::OPERATOR_IS_NULL, - ExpressionType::OPERATOR_EXISTS, ExpressionType::OPERATOR_UNARY_MINUS, - ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_NOTEQUAL, - ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_GREATERTHAN, + ExpressionType::INVALID, + ExpressionType::OPERATOR_PLUS, + ExpressionType::OPERATOR_MINUS, + ExpressionType::OPERATOR_MULTIPLY, + ExpressionType::OPERATOR_DIVIDE, + ExpressionType::OPERATOR_CONCAT, + ExpressionType::OPERATOR_MOD, + ExpressionType::OPERATOR_CAST, + ExpressionType::OPERATOR_NOT, + ExpressionType::OPERATOR_IS_NULL, + ExpressionType::OPERATOR_EXISTS, + ExpressionType::OPERATOR_UNARY_MINUS, + ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_NOTEQUAL, + ExpressionType::COMPARE_LESSTHAN, + ExpressionType::COMPARE_GREATERTHAN, ExpressionType::COMPARE_LESSTHANOREQUALTO, ExpressionType::COMPARE_GREATERTHANOREQUALTO, - ExpressionType::COMPARE_LIKE, ExpressionType::COMPARE_NOTLIKE, - ExpressionType::COMPARE_IN, ExpressionType::COMPARE_DISTINCT_FROM, - ExpressionType::CONJUNCTION_AND, ExpressionType::CONJUNCTION_OR, - ExpressionType::VALUE_CONSTANT, ExpressionType::VALUE_PARAMETER, - ExpressionType::VALUE_TUPLE, ExpressionType::VALUE_TUPLE_ADDRESS, - ExpressionType::VALUE_NULL, ExpressionType::VALUE_VECTOR, - ExpressionType::VALUE_SCALAR, ExpressionType::AGGREGATE_COUNT, - ExpressionType::AGGREGATE_COUNT_STAR, ExpressionType::AGGREGATE_SUM, - ExpressionType::AGGREGATE_MIN, ExpressionType::AGGREGATE_MAX, - ExpressionType::AGGREGATE_AVG, ExpressionType::FUNCTION, - ExpressionType::HASH_RANGE, ExpressionType::OPERATOR_CASE_EXPR, - ExpressionType::OPERATOR_NULLIF, ExpressionType::OPERATOR_COALESCE, - ExpressionType::ROW_SUBQUERY, ExpressionType::SELECT_SUBQUERY, - ExpressionType::STAR, ExpressionType::PLACEHOLDER, - ExpressionType::COLUMN_REF, ExpressionType::FUNCTION_REF, + ExpressionType::COMPARE_LIKE, + ExpressionType::COMPARE_NOTLIKE, + ExpressionType::COMPARE_IN, + ExpressionType::COMPARE_DISTINCT_FROM, + ExpressionType::CONJUNCTION_AND, + ExpressionType::CONJUNCTION_OR, + ExpressionType::VALUE_CONSTANT, + ExpressionType::VALUE_PARAMETER, + ExpressionType::VALUE_TUPLE, + ExpressionType::VALUE_TUPLE_ADDRESS, + ExpressionType::VALUE_NULL, + ExpressionType::VALUE_VECTOR, + ExpressionType::VALUE_SCALAR, + ExpressionType::AGGREGATE_COUNT, + ExpressionType::AGGREGATE_COUNT_STAR, + ExpressionType::AGGREGATE_SUM, + ExpressionType::AGGREGATE_MIN, + ExpressionType::AGGREGATE_MAX, + ExpressionType::AGGREGATE_AVG, + ExpressionType::FUNCTION, + ExpressionType::HASH_RANGE, + ExpressionType::OPERATOR_CASE_EXPR, + ExpressionType::OPERATOR_NULLIF, + ExpressionType::OPERATOR_COALESCE, + ExpressionType::ROW_SUBQUERY, + ExpressionType::SELECT_SUBQUERY, + ExpressionType::STAR, + ExpressionType::PLACEHOLDER, + ExpressionType::COLUMN_REF, + ExpressionType::FUNCTION_REF, ExpressionType::CAST}; // Make sure that ToString and FromString work @@ -316,16 +341,20 @@ TEST_F(InternalTypesTests, JoinTypeTest) { TEST_F(InternalTypesTests, PlanNodeTypeTest) { std::vector list = { - PlanNodeType::INVALID, PlanNodeType::SEQSCAN, PlanNodeType::INDEXSCAN, - PlanNodeType::NESTLOOP, PlanNodeType::NESTLOOPINDEX, - PlanNodeType::MERGEJOIN, PlanNodeType::HASHJOIN, PlanNodeType::UPDATE, - PlanNodeType::INSERT, PlanNodeType::DELETE, PlanNodeType::DROP, - PlanNodeType::CREATE, PlanNodeType::SEND, PlanNodeType::RECEIVE, - PlanNodeType::PRINT, PlanNodeType::AGGREGATE, PlanNodeType::UNION, - PlanNodeType::ORDERBY, PlanNodeType::PROJECTION, - PlanNodeType::MATERIALIZE, PlanNodeType::LIMIT, PlanNodeType::DISTINCT, - PlanNodeType::SETOP, PlanNodeType::APPEND, PlanNodeType::AGGREGATE_V2, - PlanNodeType::HASH, PlanNodeType::RESULT, PlanNodeType::COPY, + PlanNodeType::INVALID, PlanNodeType::SEQSCAN, + PlanNodeType::INDEXSCAN, PlanNodeType::NESTLOOP, + PlanNodeType::NESTLOOPINDEX, PlanNodeType::MERGEJOIN, + PlanNodeType::HASHJOIN, PlanNodeType::UPDATE, + PlanNodeType::INSERT, PlanNodeType::DELETE, + PlanNodeType::DROP, PlanNodeType::CREATE, + PlanNodeType::SEND, PlanNodeType::RECEIVE, + PlanNodeType::PRINT, PlanNodeType::AGGREGATE, + PlanNodeType::UNION, PlanNodeType::ORDERBY, + PlanNodeType::PROJECTION, PlanNodeType::MATERIALIZE, + PlanNodeType::LIMIT, PlanNodeType::DISTINCT, + PlanNodeType::SETOP, PlanNodeType::APPEND, + PlanNodeType::AGGREGATE_V2, PlanNodeType::HASH, + PlanNodeType::RESULT, PlanNodeType::COPY, PlanNodeType::MOCK}; // Make sure that ToString and FromString work @@ -433,9 +462,8 @@ TEST_F(InternalTypesTests, ConstraintTypeTest) { } TEST_F(InternalTypesTests, LoggingTypeTest) { - std::vector list = { - LoggingType::INVALID, LoggingType::OFF, LoggingType::ON - }; + std::vector list = {LoggingType::INVALID, LoggingType::OFF, + LoggingType::ON}; // Make sure that ToString and FromString work for (auto val : list) { @@ -458,9 +486,9 @@ TEST_F(InternalTypesTests, LoggingTypeTest) { } TEST_F(InternalTypesTests, CheckpointingTypeTest) { - std::vector list = { - CheckpointingType::INVALID, CheckpointingType::OFF, CheckpointingType::ON - }; + std::vector list = {CheckpointingType::INVALID, + CheckpointingType::OFF, + CheckpointingType::ON}; // Make sure that ToString and FromString work for (auto val : list) { @@ -484,9 +512,9 @@ TEST_F(InternalTypesTests, CheckpointingTypeTest) { } TEST_F(InternalTypesTests, GarbageCollectionTypeTest) { - std::vector list = { - GarbageCollectionType::INVALID, GarbageCollectionType::OFF, GarbageCollectionType::ON - }; + std::vector list = {GarbageCollectionType::INVALID, + GarbageCollectionType::OFF, + GarbageCollectionType::ON}; // Make sure that ToString and FromString work for (auto val : list) { @@ -511,10 +539,8 @@ TEST_F(InternalTypesTests, GarbageCollectionTypeTest) { } TEST_F(InternalTypesTests, ProtocolTypeTest) { - std::vector list = { - ProtocolType::INVALID, - ProtocolType::TIMESTAMP_ORDERING - }; + std::vector list = {ProtocolType::INVALID, + ProtocolType::TIMESTAMP_ORDERING}; // Make sure that ToString and FromString work for (auto val : list) { @@ -537,10 +563,8 @@ TEST_F(InternalTypesTests, ProtocolTypeTest) { } TEST_F(InternalTypesTests, EpochTypeTest) { - std::vector list = { - EpochType::INVALID, - EpochType::DECENTRALIZED_EPOCH - }; + std::vector list = {EpochType::INVALID, + EpochType::DECENTRALIZED_EPOCH}; // Make sure that ToString and FromString work for (auto val : list) { @@ -615,11 +639,9 @@ TEST_F(InternalTypesTests, VisibilityTypeTest) { } TEST_F(InternalTypesTests, VisibilityIdTypeTest) { - std::vector list = { - VisibilityIdType::INVALID, - VisibilityIdType::READ_ID, - VisibilityIdType::COMMIT_ID - }; + std::vector list = {VisibilityIdType::INVALID, + VisibilityIdType::READ_ID, + VisibilityIdType::COMMIT_ID}; // Make sure that ToString and FromString work for (auto val : list) { @@ -990,10 +1012,14 @@ TEST_F(InternalTypesTests, SetOpTypeTest) { TEST_F(InternalTypesTests, LogRecordTypeTest) { std::vector list = { - LogRecordType::INVALID, LogRecordType::TRANSACTION_BEGIN, - LogRecordType::TRANSACTION_COMMIT, LogRecordType::TUPLE_INSERT, - LogRecordType::TUPLE_DELETE, LogRecordType::TUPLE_UPDATE, - LogRecordType::EPOCH_BEGIN, LogRecordType::EPOCH_END, + LogRecordType::INVALID, + LogRecordType::TRANSACTION_BEGIN, + LogRecordType::TRANSACTION_COMMIT, + LogRecordType::TUPLE_INSERT, + LogRecordType::TUPLE_DELETE, + LogRecordType::TUPLE_UPDATE, + LogRecordType::EPOCH_BEGIN, + LogRecordType::EPOCH_END, }; // Make sure that ToString and FromString work @@ -1046,7 +1072,7 @@ TEST_F(InternalTypesTests, PropertyTypeTest) { TEST_F(InternalTypesTests, EntityTypeTest) { std::vector list = { EntityType::INVALID, EntityType::TABLE, EntityType::SCHEMA, - EntityType::INDEX, EntityType::VIEW, EntityType::PREPARED_STATEMENT, + EntityType::INDEX, EntityType::VIEW, EntityType::PREPARED_STATEMENT, }; // Make sure that ToString and FromString work @@ -1102,28 +1128,17 @@ TEST_F(InternalTypesTests, PostgresValueTypeTest) { // Note that we are not testing BOOLEAN here because it is an alias // for TINYINT. So we won't get back the correct string representation. std::vector list = { - PostgresValueType::INVALID, - PostgresValueType::TINYINT, - PostgresValueType::SMALLINT, - PostgresValueType::INTEGER, - PostgresValueType::VARBINARY, - PostgresValueType::BIGINT, - PostgresValueType::REAL, - PostgresValueType::DOUBLE, - PostgresValueType::TEXT, - PostgresValueType::BPCHAR, - PostgresValueType::BPCHAR2, - PostgresValueType::VARCHAR, - PostgresValueType::VARCHAR2, - PostgresValueType::DATE, - PostgresValueType::TIMESTAMPS, - PostgresValueType::TIMESTAMPS2, - PostgresValueType::TEXT_ARRAY, - PostgresValueType::INT2_ARRAY, - PostgresValueType::INT4_ARRAY, - PostgresValueType::OID_ARRAY, - PostgresValueType::FLOADT4_ARRAY, - PostgresValueType::DECIMAL, + PostgresValueType::INVALID, PostgresValueType::TINYINT, + PostgresValueType::SMALLINT, PostgresValueType::INTEGER, + PostgresValueType::VARBINARY, PostgresValueType::BIGINT, + PostgresValueType::REAL, PostgresValueType::DOUBLE, + PostgresValueType::TEXT, PostgresValueType::BPCHAR, + PostgresValueType::BPCHAR2, PostgresValueType::VARCHAR, + PostgresValueType::VARCHAR2, PostgresValueType::DATE, + PostgresValueType::TIMESTAMPS, PostgresValueType::TIMESTAMPS2, + PostgresValueType::TEXT_ARRAY, PostgresValueType::INT2_ARRAY, + PostgresValueType::INT4_ARRAY, PostgresValueType::OID_ARRAY, + PostgresValueType::FLOADT4_ARRAY, PostgresValueType::DECIMAL, }; // Make sure that ToString and FromString work @@ -1142,7 +1157,8 @@ TEST_F(InternalTypesTests, PostgresValueTypeTest) { // Then make sure that we can't cast garbage std::string invalid("Never Trust The Terrier"); EXPECT_THROW(peloton::StringToPostgresValueType(invalid), peloton::Exception); - EXPECT_THROW(peloton::PostgresValueTypeToString(static_cast(-99999)), + EXPECT_THROW(peloton::PostgresValueTypeToString( + static_cast(-99999)), peloton::Exception); } diff --git a/test/common/lock_free_array_test.cpp b/test/common/lock_free_array_test.cpp index c8b9f3cea68..76595b54ea9 100644 --- a/test/common/lock_free_array_test.cpp +++ b/test/common/lock_free_array_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/container/lock_free_array.h" #include "common/harness.h" @@ -22,18 +21,17 @@ namespace test { // LockFreeArray Test //===--------------------------------------------------------------------===// -class LockFreeArrayTests : public PelotonTest {}; +class LockFreeArrayTests : public PelotonTests {}; // Test basic functionality TEST_F(LockFreeArrayTests, BasicTest) { - - typedef uint32_t value_type; + typedef uint32_t value_type; { LockFreeArray array; size_t const element_count = 3; - for (size_t element = 0; element < element_count; ++element ) { + for (size_t element = 0; element < element_count; ++element) { auto status = array.Append(element); EXPECT_TRUE(status); } @@ -41,19 +39,17 @@ TEST_F(LockFreeArrayTests, BasicTest) { auto array_size = array.GetSize(); EXPECT_EQ(array_size, element_count); } - } //// Test shared pointers -TEST_F(LockFreeArrayTests, SharedPointerTest1) { - +TEST_F(LockFreeArrayTests, SharedPointer1Test) { typedef std::shared_ptr value_type; { LockFreeArray array; size_t const element_count = 3; - for (size_t element = 0; element < element_count; ++element ) { + for (size_t element = 0; element < element_count; ++element) { std::shared_ptr entry(new oid_t); auto status = array.Append(entry); EXPECT_TRUE(status); @@ -62,29 +58,25 @@ TEST_F(LockFreeArrayTests, SharedPointerTest1) { auto array_size = array.GetSize(); EXPECT_EQ(array_size, element_count); } - } -TEST_F(LockFreeArrayTests, SharedPointerTest2) { - +TEST_F(LockFreeArrayTests, SharedPointer2Test) { typedef std::shared_ptr value_type; { LockFreeArray array; - std::thread t0([&] { size_t const element_count = 10000; - for (size_t element = 0; element < element_count; ++element ) { + for (size_t element = 0; element < element_count; ++element) { std::shared_ptr entry(new oid_t); auto status = array.Append(entry); EXPECT_TRUE(status); } }); - size_t const element_count = 10000; - for (size_t element = 0; element < element_count; ++element ) { + for (size_t element = 0; element < element_count; ++element) { std::shared_ptr entry(new oid_t); auto status = array.Append(entry); EXPECT_TRUE(status); @@ -92,10 +84,7 @@ TEST_F(LockFreeArrayTests, SharedPointerTest2) { t0.join(); auto array_size = array.GetSize(); - EXPECT_EQ(array_size, element_count*2); - - - + EXPECT_EQ(array_size, element_count * 2); } } diff --git a/test/common/logger_test.cpp b/test/common/logger_test.cpp index 85e6bfd8825..98e0a6fb8a0 100644 --- a/test/common/logger_test.cpp +++ b/test/common/logger_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "common/logger.h" @@ -21,7 +20,7 @@ namespace test { // Logger Tests //===--------------------------------------------------------------------===// -class LoggerTests : public PelotonTest {}; +class LoggerTests : public PelotonTests {}; TEST_F(LoggerTests, BasicTest) { LOG_TRACE("trace message"); diff --git a/test/common/statement_cache_manager_test.cpp b/test/common/statement_cache_manager_test.cpp index 3a71bba2c22..1ba581b024d 100644 --- a/test/common/statement_cache_manager_test.cpp +++ b/test/common/statement_cache_manager_test.cpp @@ -19,7 +19,7 @@ namespace peloton { namespace test { // Tests for both statement cache -class StatementCacheTests : public PelotonTest {}; +class StatementCacheTests : public PelotonTests {}; TEST_F(StatementCacheTests, InvalidateOneTest) { // Register the statement cache to the statement cache manager diff --git a/test/common/statement_cache_test.cpp b/test/common/statement_cache_test.cpp index 430bcc7884f..169d86b8e85 100644 --- a/test/common/statement_cache_test.cpp +++ b/test/common/statement_cache_test.cpp @@ -18,7 +18,7 @@ namespace peloton { namespace test { // Tests for both statement cache -class StatementCacheTests : public PelotonTest {}; +class StatementCacheTests : public PelotonTests {}; // Test statementCache add and get statement TEST_F(StatementCacheTests, AddGetTest) { @@ -101,6 +101,5 @@ TEST_F(StatementCacheTests, DisableTableTest) { } } - } // namespace test } // namespace peloton diff --git a/test/common/thread_pool_test.cpp b/test/common/thread_pool_test.cpp index 3b4b5c395ea..ffa35aa00e1 100644 --- a/test/common/thread_pool_test.cpp +++ b/test/common/thread_pool_test.cpp @@ -20,7 +20,7 @@ namespace test { // Thread Pool Test //===--------------------------------------------------------------------===// -class ThreadPoolTests : public PelotonTest {}; +class ThreadPoolTests : public PelotonTests {}; TEST_F(ThreadPoolTests, BasicTest) { ThreadPool thread_pool; @@ -34,31 +34,26 @@ TEST_F(ThreadPoolTests, BasicTest) { int var4 = 4; int var5 = 5; thread_pool.SubmitTask([](int *var, std::atomic *counter) { - *var = *var + *var; - counter->fetch_add(1); - }, - &var1, &counter); + *var = *var + *var; + counter->fetch_add(1); + }, &var1, &counter); thread_pool.SubmitTask([](int *var, std::atomic *counter) { - *var = *var - *var; - counter->fetch_add(1); - }, - &var2, &counter); + *var = *var - *var; + counter->fetch_add(1); + }, &var2, &counter); thread_pool.SubmitTask([](int *var, std::atomic *counter) { - *var = *var * *var; - counter->fetch_add(1); - }, - &var3, &counter); + *var = *var * *var; + counter->fetch_add(1); + }, &var3, &counter); thread_pool.SubmitTask([](int *var, std::atomic *counter) { - *var = *var / *var; - counter->fetch_add(1); - }, - &var4, &counter); + *var = *var / *var; + counter->fetch_add(1); + }, &var4, &counter); thread_pool.SubmitDedicatedTask([](int *var, std::atomic *counter) { - *var = *var / *var; - counter->fetch_add(1); - }, - &var5, &counter); + *var = *var / *var; + counter->fetch_add(1); + }, &var5, &counter); // Wait for all the test to finish while (counter.load() != 5) { diff --git a/test/concurrency/anomaly_test.cpp b/test/concurrency/anomaly_test.cpp index f8c080f7434..4eeb328b681 100644 --- a/test/concurrency/anomaly_test.cpp +++ b/test/concurrency/anomaly_test.cpp @@ -19,44 +19,38 @@ namespace test { //===--------------------------------------------------------------------===// // Anomaly Tests //===--------------------------------------------------------------------===// -// These test cases are based on the paper: +// These test cases are based on the paper: // -- "A Critique of ANSI SQL Isolation Levels" -class AnomalyTests : public PelotonTest {}; +class AnomalyTests : public PelotonTests {}; static std::vector PROTOCOL_TYPES = { - ProtocolType::TIMESTAMP_ORDERING -}; + ProtocolType::TIMESTAMP_ORDERING}; static std::vector ISOLATION_LEVEL_TYPES = { - IsolationLevelType::SERIALIZABLE, - IsolationLevelType::SNAPSHOT, - IsolationLevelType::REPEATABLE_READS, - IsolationLevelType::READ_COMMITTED -}; + IsolationLevelType::SERIALIZABLE, IsolationLevelType::SNAPSHOT, + IsolationLevelType::REPEATABLE_READS, IsolationLevelType::READ_COMMITTED}; static std::vector CONFLICT_AVOIDANCE_TYPES = { - // ConflictAvoidanceType::WAIT, - ConflictAvoidanceType::ABORT -}; - + // ConflictAvoidanceType::WAIT, + ConflictAvoidanceType::ABORT}; // Dirty write: -// TransactionContext T1 modifies a data item. Another transaction T2 then further +// TransactionContext T1 modifies a data item. Another transaction T2 then +// further // modifies that data item before T1 performs a COMMIT or ROLLBACK. -// If T1 or T2 then performs a ROLLBACK, it is unclear what the correct +// If T1 or T2 then performs a ROLLBACK, it is unclear what the correct // data value should be. // for all isolation levels, dirty write must never happen. -void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, - const IsolationLevelType isolation, +void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, + const IsolationLevelType isolation, const ConflictAvoidanceType conflict) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 updates (0, ?) to (0, 2) @@ -81,18 +75,18 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (isolation == IsolationLevelType::SNAPSHOT) { EXPECT_EQ(0, scheduler.schedules[2].results[0]); } else { - EXPECT_EQ(2, scheduler.schedules[2].results[0]); + EXPECT_EQ(2, scheduler.schedules[2].results[0]); } } if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); - EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - + EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); + if (isolation == IsolationLevelType::SNAPSHOT) { EXPECT_EQ(0, scheduler.schedules[2].results[0]); } else { - EXPECT_EQ(1, scheduler.schedules[2].results[0]); + EXPECT_EQ(1, scheduler.schedules[2].results[0]); } } @@ -101,8 +95,7 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 updates (0, ?) to (0, 2) @@ -125,20 +118,20 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); if (isolation == IsolationLevelType::SNAPSHOT) { - EXPECT_EQ(0, scheduler.schedules[2].results[0]); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } else { - EXPECT_EQ(1, scheduler.schedules[2].results[0]); + EXPECT_EQ(1, scheduler.schedules[2].results[0]); } } if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); - EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - + EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); + if (isolation == IsolationLevelType::SNAPSHOT) { EXPECT_EQ(0, scheduler.schedules[2].results[0]); } else { - EXPECT_EQ(1, scheduler.schedules[2].results[0]); + EXPECT_EQ(1, scheduler.schedules[2].results[0]); } } @@ -147,8 +140,7 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 updates (0, ?) to (0, 2) @@ -175,8 +167,8 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::ABORTED); - EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - + EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } @@ -185,8 +177,7 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 updates (0, ?) to (0, 2) @@ -213,19 +204,17 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::ABORTED); - EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - + EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } schedules.clear(); } - { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 updates (0, ?) to (0, 2) @@ -252,19 +241,17 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::ABORTED); - EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - + EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } schedules.clear(); } - { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 updates (0, ?) to (0, 2) @@ -291,8 +278,8 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::ABORTED); - EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - + EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } @@ -300,24 +287,22 @@ void DirtyWriteTest(const ProtocolType protocol UNUSED_ATTRIBUTE, } } - // Dirty read: // TransactionContext T1 modifies a data item. Another transaction T2 then reads // that data item before T1 performs a COMMIT or ROLLBACK. // If T1 then performs a ROLLBACK, T2 has read a data item that was never // committed and so never really existed. -// for all isolation levels except READ_UNCOMMITTED, +// for all isolation levels except READ_UNCOMMITTED, // dirty read must never happen. -void DirtyReadTest(const ProtocolType protocol UNUSED_ATTRIBUTE, - const IsolationLevelType isolation, +void DirtyReadTest(const ProtocolType protocol UNUSED_ATTRIBUTE, + const IsolationLevelType isolation, const ConflictAvoidanceType conflict) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 reads (0, ?) @@ -345,14 +330,13 @@ void DirtyReadTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (conflict == ConflictAvoidanceType::ABORT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); - if (isolation == IsolationLevelType::SNAPSHOT) { EXPECT_TRUE(schedules[1].txn_result == ResultType::SUCCESS); EXPECT_EQ(0, scheduler.schedules[1].results[0]); EXPECT_EQ(0, scheduler.schedules[2].results[0]); } else { EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - EXPECT_EQ(1, scheduler.schedules[2].results[0]); + EXPECT_EQ(1, scheduler.schedules[2].results[0]); } } @@ -361,8 +345,7 @@ void DirtyReadTest(const ProtocolType protocol UNUSED_ATTRIBUTE, { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 updates (0, ?) to (0, 1) // T1 reads (0, ?) @@ -385,7 +368,6 @@ void DirtyReadTest(const ProtocolType protocol UNUSED_ATTRIBUTE, EXPECT_TRUE(schedules[1].txn_result == ResultType::SUCCESS); EXPECT_EQ(0, scheduler.schedules[2].results[0]); - } if (conflict == ConflictAvoidanceType::ABORT) { @@ -393,37 +375,34 @@ void DirtyReadTest(const ProtocolType protocol UNUSED_ATTRIBUTE, if (isolation == IsolationLevelType::SNAPSHOT) { EXPECT_TRUE(schedules[1].txn_result == ResultType::SUCCESS); - EXPECT_EQ(0, scheduler.schedules[1].results[0]); - EXPECT_EQ(0, scheduler.schedules[2].results[0]); + EXPECT_EQ(0, scheduler.schedules[1].results[0]); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } else { EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); - EXPECT_EQ(0, scheduler.schedules[2].results[0]); + EXPECT_EQ(0, scheduler.schedules[2].results[0]); } } schedules.clear(); } - } - // Fuzzy read: // TransactionContext T1 reads a data item. Another transaction T2 then modifies // or deletes that data item and commits. If T1 then attempts to reread // the data item, it receives a modified value or discovers that the data // item has been deleted. -// for all isolation levels except READ_UNCOMMITTED and READ_COMMITTED, +// for all isolation levels except READ_UNCOMMITTED and READ_COMMITTED, // dirty read must never happen. -void FuzzyReadTest(const ProtocolType protocol, - const IsolationLevelType isolation UNUSED_ATTRIBUTE, +void FuzzyReadTest(const ProtocolType protocol, + const IsolationLevelType isolation UNUSED_ATTRIBUTE, const ConflictAvoidanceType conflict) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T0 obtains a smaller timestamp. @@ -445,12 +424,10 @@ void FuzzyReadTest(const ProtocolType protocol, scheduler.Run(); auto &schedules = scheduler.schedules; - if (protocol == ProtocolType::TIMESTAMP_ORDERING) { if (conflict == ConflictAvoidanceType::ABORT) { - if (isolation != IsolationLevelType::READ_COMMITTED && + if (isolation != IsolationLevelType::READ_COMMITTED && isolation != IsolationLevelType::SNAPSHOT) { - EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); EXPECT_TRUE(schedules[1].txn_result == ResultType::SUCCESS); @@ -465,11 +442,9 @@ void FuzzyReadTest(const ProtocolType protocol, schedules.clear(); } - { concurrency::EpochManagerFactory::GetInstance().Reset(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); TransactionScheduler scheduler(3, table, &txn_manager); // T1 obtains a smaller timestamp. @@ -495,9 +470,8 @@ void FuzzyReadTest(const ProtocolType protocol, if (protocol == ProtocolType::TIMESTAMP_ORDERING) { if (conflict == ConflictAvoidanceType::ABORT) { - if (isolation == IsolationLevelType::SERIALIZABLE || + if (isolation == IsolationLevelType::SERIALIZABLE || isolation == IsolationLevelType::REPEATABLE_READS) { - EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); EXPECT_TRUE(schedules[1].txn_result == ResultType::ABORTED); @@ -506,9 +480,7 @@ void FuzzyReadTest(const ProtocolType protocol, EXPECT_EQ(0, scheduler.schedules[1].results[0]); EXPECT_EQ(0, scheduler.schedules[2].results[0]); - } - else if (isolation == IsolationLevelType::SNAPSHOT) { - + } else if (isolation == IsolationLevelType::SNAPSHOT) { EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); EXPECT_TRUE(schedules[1].txn_result == ResultType::SUCCESS); @@ -518,10 +490,8 @@ void FuzzyReadTest(const ProtocolType protocol, EXPECT_EQ(0, scheduler.schedules[1].results[0]); // TODO: double check! - EXPECT_EQ(0, scheduler.schedules[2].results[0]); - } - else if (isolation == IsolationLevelType::READ_COMMITTED) { - + EXPECT_EQ(0, scheduler.schedules[2].results[0]); + } else if (isolation == IsolationLevelType::READ_COMMITTED) { EXPECT_TRUE(schedules[0].txn_result == ResultType::SUCCESS); EXPECT_TRUE(schedules[1].txn_result == ResultType::SUCCESS); @@ -529,7 +499,7 @@ void FuzzyReadTest(const ProtocolType protocol, EXPECT_EQ(1, scheduler.schedules[0].results[1]); EXPECT_EQ(0, scheduler.schedules[1].results[0]); - EXPECT_EQ(1, scheduler.schedules[2].results[0]); + EXPECT_EQ(1, scheduler.schedules[2].results[0]); } } } @@ -538,7 +508,7 @@ void FuzzyReadTest(const ProtocolType protocol, } // { - // storage::DataTable *table = + // storage::DataTable *table = // TestingTransactionUtil::CreateTable(); // TransactionScheduler scheduler(2, table, &txn_manager); @@ -564,10 +534,9 @@ void FuzzyReadTest(const ProtocolType protocol, // } } -void PhantomTest() { +void PhantomTests() { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); { TransactionScheduler scheduler(2, table, &txn_manager); @@ -608,10 +577,9 @@ void PhantomTest() { } // Can't pass this test! -void WriteSkewTest() { +void WriteSkewTests() { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); { // Prepare @@ -619,8 +587,7 @@ void WriteSkewTest() { scheduler.Txn(0).Update(1, 1); scheduler.Txn(0).Commit(); scheduler.Run(); - EXPECT_EQ(ResultType::SUCCESS, - scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); } { // the database has tuple (0, 0), (1, 1) @@ -642,8 +609,7 @@ void WriteSkewTest() { scheduler.Run(); - EXPECT_EQ(ResultType::SUCCESS, - scheduler.schedules[2].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[2].txn_result); // Can't all success if (ResultType::SUCCESS == scheduler.schedules[0].txn_result && ResultType::SUCCESS == scheduler.schedules[1].txn_result) { @@ -653,10 +619,9 @@ void WriteSkewTest() { } } -void ReadSkewTest() { +void ReadSkewTests() { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); { TransactionScheduler scheduler(2, table, &txn_manager); scheduler.Txn(0).Read(0); @@ -681,8 +646,7 @@ void ReadSkewTest() { // transaction). void SIAnomalyTest1() { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); int current_batch_key = 10000; { TransactionScheduler scheduler(1, table, &txn_manager); @@ -691,8 +655,7 @@ void SIAnomalyTest1() { scheduler.Txn(0).Update(100, 1); scheduler.Txn(0).Commit(); scheduler.Run(); - EXPECT_EQ(ResultType::SUCCESS, - scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); } { TransactionScheduler scheduler(4, table, &txn_manager); @@ -722,19 +685,21 @@ void SIAnomalyTest1() { TEST_F(AnomalyTests, SerializableTest) { for (auto protocol_type : PROTOCOL_TYPES) { - for (auto isolation_level_type: ISOLATION_LEVEL_TYPES) { + for (auto isolation_level_type : ISOLATION_LEVEL_TYPES) { for (auto conflict_avoidance_type : CONFLICT_AVOIDANCE_TYPES) { concurrency::TransactionManagerFactory::Configure( protocol_type, isolation_level_type, conflict_avoidance_type); - DirtyWriteTest(protocol_type, isolation_level_type, conflict_avoidance_type); - DirtyReadTest(protocol_type, isolation_level_type, conflict_avoidance_type); - FuzzyReadTest(protocol_type, isolation_level_type, conflict_avoidance_type); - // // WriteSkewTest(); + DirtyWriteTest(protocol_type, isolation_level_type, + conflict_avoidance_type); + DirtyReadTest(protocol_type, isolation_level_type, + conflict_avoidance_type); + FuzzyReadTest(protocol_type, isolation_level_type, + conflict_avoidance_type); + // // WriteSkewTests(); // ReadSkewTest(isolation_level_type, conflict_avoidance_type); // PhantomTest(isolation_level_type, conflict_avoidance_type); // SIAnomalyTest1(isolation_level_type, conflict_avoidance_type); - } } } @@ -747,16 +712,15 @@ TEST_F(AnomalyTests, StressTest) { srand(15721); for (auto protocol_type : PROTOCOL_TYPES) { concurrency::TransactionManagerFactory::Configure( - protocol_type, - IsolationLevelType::SERIALIZABLE, + protocol_type, IsolationLevelType::SERIALIZABLE, ConflictAvoidanceType::ABORT); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - - EXPECT_EQ(IsolationLevelType::SERIALIZABLE, txn_manager.GetIsolationLevel()); - storage::DataTable *table = - TestingTransactionUtil::CreateTable(num_key); + EXPECT_EQ(IsolationLevelType::SERIALIZABLE, + txn_manager.GetIsolationLevel()); + + storage::DataTable *table = TestingTransactionUtil::CreateTable(num_key); TransactionScheduler scheduler(num_txn, table, &txn_manager); scheduler.SetConcurrent(true); @@ -787,8 +751,7 @@ TEST_F(AnomalyTests, StressTest) { scheduler2.Txn(0).Commit(); scheduler2.Run(); - EXPECT_EQ(ResultType::SUCCESS, - scheduler2.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler2.schedules[0].txn_result); // The sum should be zero int sum = 0; for (auto result : scheduler2.schedules[0].results) { diff --git a/test/concurrency/decentralized_epoch_manager_test.cpp b/test/concurrency/decentralized_epoch_manager_test.cpp index 2652ccec1a2..d701c8c50f2 100644 --- a/test/concurrency/decentralized_epoch_manager_test.cpp +++ b/test/concurrency/decentralized_epoch_manager_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "concurrency/epoch_manager_factory.h" #include "concurrency/testing_transaction_util.h" #include "common/harness.h" @@ -22,15 +21,13 @@ namespace test { // TransactionContext Tests //===--------------------------------------------------------------------===// -class DecentralizedEpochManagerTests : public PelotonTest {}; - +class DecentralizedEpochManagerTests : public PelotonTests {}; TEST_F(DecentralizedEpochManagerTests, Test) { concurrency::EpochManagerFactory::Configure(EpochType::DECENTRALIZED_EPOCH); EXPECT_TRUE(true); } - TEST_F(DecentralizedEpochManagerTests, SingleThreadTest) { auto &epoch_manager = concurrency::EpochManagerFactory::GetInstance(); epoch_manager.Reset(); @@ -59,7 +56,7 @@ TEST_F(DecentralizedEpochManagerTests, SingleThreadTest) { tail_epoch_id = epoch_manager.GetExpiredEpochId(); EXPECT_EQ(1, tail_epoch_id); - + epoch_manager.ExitEpoch(0, epoch_id); epoch_manager.SetCurrentEpochId(4); @@ -72,9 +69,7 @@ TEST_F(DecentralizedEpochManagerTests, SingleThreadTest) { epoch_manager.DeregisterThread(0); } - TEST_F(DecentralizedEpochManagerTests, MultipleThreadsTest) { - auto &epoch_manager = concurrency::EpochManagerFactory::GetInstance(); epoch_manager.Reset(); @@ -86,7 +81,7 @@ TEST_F(DecentralizedEpochManagerTests, MultipleThreadsTest) { epoch_manager.RegisterThread(1); - epoch_manager.RegisterThread(2); // this is an idle thread. + epoch_manager.RegisterThread(2); // this is an idle thread. epoch_manager.SetCurrentEpochId(2); @@ -111,7 +106,7 @@ TEST_F(DecentralizedEpochManagerTests, MultipleThreadsTest) { tail_epoch_id = epoch_manager.GetExpiredEpochId(); EXPECT_EQ(1, tail_epoch_id); - + epoch_manager.ExitEpoch(0, epoch_id1); epoch_manager.SetCurrentEpochId(5); @@ -127,7 +122,6 @@ TEST_F(DecentralizedEpochManagerTests, MultipleThreadsTest) { EXPECT_EQ(4, tail_epoch_id); - // deregister two threads. epoch_manager.DeregisterThread(0); @@ -136,7 +130,5 @@ TEST_F(DecentralizedEpochManagerTests, MultipleThreadsTest) { epoch_manager.DeregisterThread(2); } - } // namespace test } // namespace peloton - diff --git a/test/concurrency/local_epoch_test.cpp b/test/concurrency/local_epoch_test.cpp index 2a951c5367d..b2346b0a399 100644 --- a/test/concurrency/local_epoch_test.cpp +++ b/test/concurrency/local_epoch_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "concurrency/local_epoch.h" #include "common/harness.h" @@ -21,12 +20,11 @@ namespace test { // TransactionContext Tests //===--------------------------------------------------------------------===// -class LocalEpochTests : public PelotonTest {}; - +class LocalEpochTests : public PelotonTests {}; TEST_F(LocalEpochTests, EpochCompareTest) { concurrency::EpochCompare comp; - + std::shared_ptr epoch0(new concurrency::Epoch(10, 20)); std::shared_ptr epoch1(new concurrency::Epoch(10, 20)); bool rt = comp(epoch0, epoch1); @@ -38,24 +36,23 @@ TEST_F(LocalEpochTests, EpochCompareTest) { EXPECT_FALSE(rt); } - TEST_F(LocalEpochTests, TransactionTest) { concurrency::LocalEpoch local_epoch(0); - + // a transaction enters epoch 10 bool rt = local_epoch.EnterEpoch(10, TimestampType::READ); EXPECT_TRUE(rt); uint64_t max_eid = local_epoch.GetExpiredEpochId(11); EXPECT_EQ(max_eid, 9); - + // a transaction enters epoch 15 rt = local_epoch.EnterEpoch(15, TimestampType::READ); EXPECT_TRUE(rt); - + max_eid = local_epoch.GetExpiredEpochId(18); EXPECT_EQ(max_eid, 9); - + // now only one transaction left local_epoch.ExitEpoch(10); @@ -69,13 +66,13 @@ TEST_F(LocalEpochTests, TransactionTest) { // a read-only transaction can always succeed. local_epoch.EnterEpoch(12, TimestampType::SNAPSHOT_READ); - + // consequently, the lower bound is dropped. max_eid = local_epoch.GetExpiredEpochId(20); EXPECT_EQ(max_eid, 11); local_epoch.ExitEpoch(12); - + // now the lower bound is returned to 14. max_eid = local_epoch.GetExpiredEpochId(21); EXPECT_EQ(max_eid, 14); @@ -91,7 +88,5 @@ TEST_F(LocalEpochTests, TransactionTest) { EXPECT_EQ(max_eid, 29); } - } // namespace test } // namespace peloton - diff --git a/test/concurrency/multi_granularity_access_test.cpp b/test/concurrency/multi_granularity_access_test.cpp index 1a536cfc4df..198cf0cc6d8 100644 --- a/test/concurrency/multi_granularity_access_test.cpp +++ b/test/concurrency/multi_granularity_access_test.cpp @@ -20,211 +20,208 @@ namespace test { // Multi-Granularity Access Tests //===--------------------------------------------------------------------===// -class MultiGranularityAccessTests : public PelotonTest {}; +class MultiGranularityAccessTests : public PelotonTests {}; static std::vector PROTOCOL_TYPES = { - ProtocolType::TIMESTAMP_ORDERING -}; + ProtocolType::TIMESTAMP_ORDERING}; TEST_F(MultiGranularityAccessTests, SingleTransactionTest) { - for (auto protocol_type : PROTOCOL_TYPES) { - concurrency::TransactionManagerFactory::Configure(protocol_type); - auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - storage::DataTable *table = TestingTransactionUtil::CreateTable(); - - // update, update, update, update, read - { - TransactionScheduler scheduler(1, table, &txn_manager); - scheduler.Txn(0).Update(0, 1, true); - scheduler.Txn(0).Update(0, 2, true); - scheduler.Txn(0).Update(0, 3, true); - scheduler.Txn(0).Update(0, 4, true); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Commit(); - - scheduler.Run(); - - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); - EXPECT_EQ(4, scheduler.schedules[0].results[0]); - } + for (auto protocol_type : PROTOCOL_TYPES) { + concurrency::TransactionManagerFactory::Configure(protocol_type); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); + + // update, update, update, update, read + { + TransactionScheduler scheduler(1, table, &txn_manager); + scheduler.Txn(0).Update(0, 1, true); + scheduler.Txn(0).Update(0, 2, true); + scheduler.Txn(0).Update(0, 3, true); + scheduler.Txn(0).Update(0, 4, true); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Commit(); + + scheduler.Run(); + + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); + EXPECT_EQ(4, scheduler.schedules[0].results[0]); + } // delete not exist, delete exist, read deleted, update deleted, // read deleted, insert back, update inserted, read newly updated, // delete inserted, read deleted - { - TransactionScheduler scheduler(1, table, &txn_manager); - scheduler.Txn(0).Delete(100, true); - scheduler.Txn(0).Delete(0, true); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Update(0, 1, true); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Insert(0, 2); - scheduler.Txn(0).Update(0, 3, true); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Delete(0, true); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Commit(); - - scheduler.Run(); - - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); - EXPECT_EQ(-1, scheduler.schedules[0].results[0]); - EXPECT_EQ(-1, scheduler.schedules[0].results[1]); - EXPECT_EQ(3, scheduler.schedules[0].results[2]); - EXPECT_EQ(-1, scheduler.schedules[0].results[3]); - LOG_INFO("FINISH THIS"); - } - - // insert, delete inserted, read deleted, insert again, delete again - // read deleted, insert again, read inserted, update inserted, read - // updated - { - TransactionScheduler scheduler(1, table, &txn_manager); - - scheduler.Txn(0).Insert(1000, 0); - scheduler.Txn(0).Delete(1000, true); - scheduler.Txn(0).Read(1000, true); - scheduler.Txn(0).Insert(1000, 1); - scheduler.Txn(0).Delete(1000, true); - scheduler.Txn(0).Read(1000, true); - scheduler.Txn(0).Insert(1000, 2); - scheduler.Txn(0).Read(1000, true); - scheduler.Txn(0).Update(1000, 3, true); - scheduler.Txn(0).Read(1000, true); - scheduler.Txn(0).Commit(); - - scheduler.Run(); - - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); - EXPECT_EQ(-1, scheduler.schedules[0].results[0]); - EXPECT_EQ(-1, scheduler.schedules[0].results[1]); - EXPECT_EQ(2, scheduler.schedules[0].results[2]); - EXPECT_EQ(3, scheduler.schedules[0].results[3]); - } - - } + { + TransactionScheduler scheduler(1, table, &txn_manager); + scheduler.Txn(0).Delete(100, true); + scheduler.Txn(0).Delete(0, true); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Update(0, 1, true); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Insert(0, 2); + scheduler.Txn(0).Update(0, 3, true); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Delete(0, true); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Commit(); + + scheduler.Run(); + + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); + EXPECT_EQ(-1, scheduler.schedules[0].results[0]); + EXPECT_EQ(-1, scheduler.schedules[0].results[1]); + EXPECT_EQ(3, scheduler.schedules[0].results[2]); + EXPECT_EQ(-1, scheduler.schedules[0].results[3]); + LOG_INFO("FINISH THIS"); + } + + // insert, delete inserted, read deleted, insert again, delete again + // read deleted, insert again, read inserted, update inserted, read + // updated + { + TransactionScheduler scheduler(1, table, &txn_manager); + + scheduler.Txn(0).Insert(1000, 0); + scheduler.Txn(0).Delete(1000, true); + scheduler.Txn(0).Read(1000, true); + scheduler.Txn(0).Insert(1000, 1); + scheduler.Txn(0).Delete(1000, true); + scheduler.Txn(0).Read(1000, true); + scheduler.Txn(0).Insert(1000, 2); + scheduler.Txn(0).Read(1000, true); + scheduler.Txn(0).Update(1000, 3, true); + scheduler.Txn(0).Read(1000, true); + scheduler.Txn(0).Commit(); + + scheduler.Run(); + + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); + EXPECT_EQ(-1, scheduler.schedules[0].results[0]); + EXPECT_EQ(-1, scheduler.schedules[0].results[1]); + EXPECT_EQ(2, scheduler.schedules[0].results[2]); + EXPECT_EQ(3, scheduler.schedules[0].results[3]); + } + } } TEST_F(MultiGranularityAccessTests, MultiTransactionTest) { - for (auto protocol_type : PROTOCOL_TYPES) { - concurrency::TransactionManagerFactory::Configure(protocol_type); - auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); - storage::DataTable *table = TestingTransactionUtil::CreateTable(); - // Txn 0: scan + select for update - // Txn 1: scan - // Txn 1: commit (should failed for timestamp ordering cc) - // Txn 2: Scan + select for update - // Txn 2: commit (should failed) - // Txn 0: commit (success) - { - TransactionScheduler scheduler(3, table, &txn_manager); - scheduler.Txn(0).Scan(0, true); - scheduler.Txn(1).Scan(0); - scheduler.Txn(1).Commit(); - scheduler.Txn(2).Scan(0, true); - scheduler.Txn(0).Commit(); - scheduler.Txn(2).Commit(); - - scheduler.Run(); - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); - EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[1].txn_result); - EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[2].txn_result); - - EXPECT_EQ(10, scheduler.schedules[0].results.size()); - } - - // Txn 0: scan + select for update - // Txn 0: abort - // Txn 1: Scan + select for update - // Txn 1: commit (should success) - { - TransactionScheduler scheduler(2, table, &txn_manager); - scheduler.Txn(0).Scan(0, true); - scheduler.Txn(0).Abort(); - scheduler.Txn(1).Scan(0, true); - scheduler.Txn(1).Commit(); - - scheduler.Run(); - EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[0].txn_result); - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); - - EXPECT_EQ(10, scheduler.schedules[1].results.size()); - } - - // Txn 0: read + select for update - // Txn 0: abort - // Txn 1: read + select for update - // Txn 1: commit (should success) - { - TransactionScheduler scheduler(2, table, &txn_manager); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Abort(); - scheduler.Txn(1).Read(0, true); - scheduler.Txn(1).Commit(); - - scheduler.Run(); - EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[0].txn_result); - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); - - EXPECT_EQ(1, scheduler.schedules[1].results.size()); - } - - // read, read, read, read, update, read, read not exist - // another txn read - { - TransactionScheduler scheduler(2, table, &txn_manager); - scheduler.Txn(0).Read(0); - scheduler.Txn(0).Read(0, true); - scheduler.Txn(0).Read(0); - scheduler.Txn(0).Read(0); - scheduler.Txn(0).Update(0, 1); - scheduler.Txn(0).Read(0); - scheduler.Txn(0).Read(100, true); - scheduler.Txn(0).Commit(); - scheduler.Txn(1).Read(0, true); - scheduler.Txn(1).Commit(); - - scheduler.Run(); - - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); - EXPECT_EQ(0, scheduler.schedules[0].results[0]); - EXPECT_EQ(0, scheduler.schedules[0].results[1]); - EXPECT_EQ(0, scheduler.schedules[0].results[2]); - EXPECT_EQ(0, scheduler.schedules[0].results[3]); - EXPECT_EQ(1, scheduler.schedules[0].results[4]); - EXPECT_EQ(-1, scheduler.schedules[0].results[5]); - EXPECT_EQ(1, scheduler.schedules[1].results[0]); - } - - - { - // Test commit/abort protocol when part of the read-own tuples get updated. - TransactionScheduler scheduler(3, table, &txn_manager); - scheduler.Txn(0).Read(3, true); - scheduler.Txn(0).Read(4, true); - scheduler.Txn(0).Update(3, 1); - scheduler.Txn(0).Abort(); - scheduler.Txn(1).Read(3, true); - scheduler.Txn(1).Read(4, true); - scheduler.Txn(1).Update(3, 2); - scheduler.Txn(1).Commit(); - scheduler.Txn(2).Read(3); - scheduler.Txn(2).Read(4); - scheduler.Txn(2).Commit(); - - scheduler.Run(); - EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[0].txn_result); - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); - EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[2].txn_result); - - EXPECT_EQ(0, scheduler.schedules[1].results[0]); - EXPECT_EQ(0, scheduler.schedules[1].results[1]); - EXPECT_EQ(2, scheduler.schedules[2].results[0]); - EXPECT_EQ(0, scheduler.schedules[2].results[1]); - } - - } + for (auto protocol_type : PROTOCOL_TYPES) { + concurrency::TransactionManagerFactory::Configure(protocol_type); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + storage::DataTable *table = TestingTransactionUtil::CreateTable(); + // Txn 0: scan + select for update + // Txn 1: scan + // Txn 1: commit (should failed for timestamp ordering cc) + // Txn 2: Scan + select for update + // Txn 2: commit (should failed) + // Txn 0: commit (success) + { + TransactionScheduler scheduler(3, table, &txn_manager); + scheduler.Txn(0).Scan(0, true); + scheduler.Txn(1).Scan(0); + scheduler.Txn(1).Commit(); + scheduler.Txn(2).Scan(0, true); + scheduler.Txn(0).Commit(); + scheduler.Txn(2).Commit(); + + scheduler.Run(); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[1].txn_result); + EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[2].txn_result); + + EXPECT_EQ(10, scheduler.schedules[0].results.size()); + } + + // Txn 0: scan + select for update + // Txn 0: abort + // Txn 1: Scan + select for update + // Txn 1: commit (should success) + { + TransactionScheduler scheduler(2, table, &txn_manager); + scheduler.Txn(0).Scan(0, true); + scheduler.Txn(0).Abort(); + scheduler.Txn(1).Scan(0, true); + scheduler.Txn(1).Commit(); + + scheduler.Run(); + EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); + + EXPECT_EQ(10, scheduler.schedules[1].results.size()); + } + + // Txn 0: read + select for update + // Txn 0: abort + // Txn 1: read + select for update + // Txn 1: commit (should success) + { + TransactionScheduler scheduler(2, table, &txn_manager); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Abort(); + scheduler.Txn(1).Read(0, true); + scheduler.Txn(1).Commit(); + + scheduler.Run(); + EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); + + EXPECT_EQ(1, scheduler.schedules[1].results.size()); + } + + // read, read, read, read, update, read, read not exist + // another txn read + { + TransactionScheduler scheduler(2, table, &txn_manager); + scheduler.Txn(0).Read(0); + scheduler.Txn(0).Read(0, true); + scheduler.Txn(0).Read(0); + scheduler.Txn(0).Read(0); + scheduler.Txn(0).Update(0, 1); + scheduler.Txn(0).Read(0); + scheduler.Txn(0).Read(100, true); + scheduler.Txn(0).Commit(); + scheduler.Txn(1).Read(0, true); + scheduler.Txn(1).Commit(); + + scheduler.Run(); + + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); + EXPECT_EQ(0, scheduler.schedules[0].results[0]); + EXPECT_EQ(0, scheduler.schedules[0].results[1]); + EXPECT_EQ(0, scheduler.schedules[0].results[2]); + EXPECT_EQ(0, scheduler.schedules[0].results[3]); + EXPECT_EQ(1, scheduler.schedules[0].results[4]); + EXPECT_EQ(-1, scheduler.schedules[0].results[5]); + EXPECT_EQ(1, scheduler.schedules[1].results[0]); + } + + { + // Test commit/abort protocol when part of the read-own tuples get + // updated. + TransactionScheduler scheduler(3, table, &txn_manager); + scheduler.Txn(0).Read(3, true); + scheduler.Txn(0).Read(4, true); + scheduler.Txn(0).Update(3, 1); + scheduler.Txn(0).Abort(); + scheduler.Txn(1).Read(3, true); + scheduler.Txn(1).Read(4, true); + scheduler.Txn(1).Update(3, 2); + scheduler.Txn(1).Commit(); + scheduler.Txn(2).Read(3); + scheduler.Txn(2).Read(4); + scheduler.Txn(2).Commit(); + + scheduler.Run(); + EXPECT_EQ(ResultType::ABORTED, scheduler.schedules[0].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[1].txn_result); + EXPECT_EQ(ResultType::SUCCESS, scheduler.schedules[2].txn_result); + + EXPECT_EQ(0, scheduler.schedules[1].results[0]); + EXPECT_EQ(0, scheduler.schedules[1].results[1]); + EXPECT_EQ(2, scheduler.schedules[2].results[0]); + EXPECT_EQ(0, scheduler.schedules[2].results[1]); + } + } } } // namespace test diff --git a/test/concurrency/mvcc_test.cpp b/test/concurrency/mvcc_test.cpp index 7532f2b6a31..c9ec457e01c 100644 --- a/test/concurrency/mvcc_test.cpp +++ b/test/concurrency/mvcc_test.cpp @@ -23,7 +23,7 @@ namespace test { // TransactionContext Tests //===--------------------------------------------------------------------===// -class MVCCTests : public PelotonTest {}; +class MVCCTests : public PelotonTests {}; static std::vector PROTOCOL_TYPES = { ProtocolType::TIMESTAMP_ORDERING}; @@ -33,7 +33,8 @@ TEST_F(MVCCTests, SingleThreadVersionChainTest) { for (auto protocol : PROTOCOL_TYPES) { concurrency::TransactionManagerFactory::Configure( - protocol, IsolationLevelType::SERIALIZABLE, ConflictAvoidanceType::ABORT); + protocol, IsolationLevelType::SERIALIZABLE, + ConflictAvoidanceType::ABORT); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); storage::DataTable *table = TestingTransactionUtil::CreateTable(); @@ -95,7 +96,8 @@ TEST_F(MVCCTests, AbortVersionChainTest) { for (auto protocol : PROTOCOL_TYPES) { concurrency::TransactionManagerFactory::Configure( - protocol, IsolationLevelType::SERIALIZABLE, ConflictAvoidanceType::ABORT); + protocol, IsolationLevelType::SERIALIZABLE, + ConflictAvoidanceType::ABORT); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); storage::DataTable *table = TestingTransactionUtil::CreateTable(); @@ -127,7 +129,8 @@ TEST_F(MVCCTests, VersionChainTest) { for (auto protocol : PROTOCOL_TYPES) { LOG_INFO("Validating %d", static_cast(protocol)); concurrency::TransactionManagerFactory::Configure( - protocol, IsolationLevelType::SERIALIZABLE, ConflictAvoidanceType::ABORT); + protocol, IsolationLevelType::SERIALIZABLE, + ConflictAvoidanceType::ABORT); const int num_txn = 2; // 5 const int scale = 1; // 20 diff --git a/test/concurrency/serializable_transaction_test.cpp b/test/concurrency/serializable_transaction_test.cpp index 2c352c0db7d..b42323b4f69 100644 --- a/test/concurrency/serializable_transaction_test.cpp +++ b/test/concurrency/serializable_transaction_test.cpp @@ -20,7 +20,7 @@ namespace test { // Serializable TransactionContext Tests //===--------------------------------------------------------------------===// -class SerializableTransactionTests : public PelotonTest {}; +class SerializableTransactionTests : public PelotonTests {}; static std::vector PROTOCOL_TYPES = { ProtocolType::TIMESTAMP_ORDERING diff --git a/test/concurrency/timestamp_ordering_transaction_manager_test.cpp b/test/concurrency/timestamp_ordering_transaction_manager_test.cpp index 7b4247efd98..b10f8413cc5 100644 --- a/test/concurrency/timestamp_ordering_transaction_manager_test.cpp +++ b/test/concurrency/timestamp_ordering_transaction_manager_test.cpp @@ -4,13 +4,13 @@ // // timestamp_ordering_transaction_manager_test.cpp // -// Identification: test/concurrency/timestamp_ordering_transaction_manager_test.cpp +// Identification: +// test/concurrency/timestamp_ordering_transaction_manager_test.cpp // // Copyright (c) 2015-16, Carnegie Mellon University Database Group // //===----------------------------------------------------------------------===// - #include "concurrency/testing_transaction_util.h" #include "common/harness.h" @@ -22,10 +22,11 @@ namespace test { // TransactionContext Tests //===--------------------------------------------------------------------===// -class TimestampOrderingTransactionManagerTests : public PelotonTest {}; +class TimestampOrderingTransactionManagerTests : public PelotonTests {}; TEST_F(TimestampOrderingTransactionManagerTests, Test) { - concurrency::TransactionManagerFactory::Configure(ProtocolType::TIMESTAMP_ORDERING); + concurrency::TransactionManagerFactory::Configure( + ProtocolType::TIMESTAMP_ORDERING); EXPECT_TRUE(true); } diff --git a/test/executor/aggregate_test.cpp b/test/executor/aggregate_test.cpp index 1c3ea4ee3c0..3acf1d1b7eb 100644 --- a/test/executor/aggregate_test.cpp +++ b/test/executor/aggregate_test.cpp @@ -38,20 +38,20 @@ using ::testing::Return; namespace peloton { namespace test { -class AggregateTests : public PelotonTest {}; +class AggregateTests : public PelotonTests {}; TEST_F(AggregateTests, SortedDistinctTest) { // SELECT d, a, b, c FROM table GROUP BY a, b, c, d; const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - false, true, txn); + false, true, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -124,8 +124,7 @@ TEST_F(AggregateTests, SortedDistinctTest) { ASSERT_TRUE(result_tile->GetTupleCount() > 0); type::Value val = (result_tile->GetValue(0, 2)); - CmpBool cmp = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(1))); + CmpBool cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(1))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); val = (result_tile->GetValue(0, 3)); cmp = (val.CompareEquals(type::ValueFactory::GetDecimalValue(2))); @@ -143,13 +142,13 @@ TEST_F(AggregateTests, SortedSumGroupByTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - false, true, txn); + false, true, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -225,8 +224,7 @@ TEST_F(AggregateTests, SortedSumGroupByTest) { std::unique_ptr result_tile(executor.GetOutput()); EXPECT_TRUE(result_tile.get() != nullptr); type::Value val = (result_tile->GetValue(0, 0)); - CmpBool cmp = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(0))); + CmpBool cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(0))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); val = (result_tile->GetValue(0, 1)); cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(105))); @@ -244,13 +242,13 @@ TEST_F(AggregateTests, SortedSumMaxGroupByTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - false, true, txn); + false, true, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -331,8 +329,7 @@ TEST_F(AggregateTests, SortedSumMaxGroupByTest) { std::unique_ptr result_tile(executor.GetOutput()); EXPECT_TRUE(result_tile.get() != nullptr); type::Value val = (result_tile->GetValue(0, 0)); - CmpBool cmp = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(0))); + CmpBool cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(0))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); val = (result_tile->GetValue(0, 1)); cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(105))); @@ -350,13 +347,13 @@ TEST_F(AggregateTests, MinMaxTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -452,8 +449,7 @@ TEST_F(AggregateTests, MinMaxTest) { std::unique_ptr result_tile(executor.GetOutput()); EXPECT_TRUE(result_tile.get() != nullptr); type::Value val = (result_tile->GetValue(0, 0)); - CmpBool cmp = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(1))); + CmpBool cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(1))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); val = (result_tile->GetValue(0, 1)); cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(91))); @@ -471,13 +467,13 @@ TEST_F(AggregateTests, HashDistinctTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - true, true, - txn); // let it be random + true, true, + txn); // let it be random txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -560,12 +556,12 @@ TEST_F(AggregateTests, HashSumGroupByTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - true, true, txn); + true, true, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -648,13 +644,13 @@ TEST_F(AggregateTests, HashCountDistinctGroupByTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - true, true, txn); + true, true, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -737,10 +733,8 @@ TEST_F(AggregateTests, HashCountDistinctGroupByTest) { std::unique_ptr result_tile(executor.GetOutput()); EXPECT_TRUE(result_tile.get() != nullptr); type::Value val = (result_tile->GetValue(0, 0)); - CmpBool cmp = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(0))); - CmpBool cmp1 = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(10))); + CmpBool cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(0))); + CmpBool cmp1 = (val.CompareEquals(type::ValueFactory::GetIntegerValue(10))); EXPECT_TRUE(cmp == CmpBool::CmpTrue || cmp1 == CmpBool::CmpTrue); val = (result_tile->GetValue(0, 1)); @@ -757,13 +751,13 @@ TEST_F(AggregateTests, PlainSumCountDistinctTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and wrap it in logical tiles - auto& txn_manager = concurrency::TransactionManagerFactory::GetInstance(); + auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table.get(), 2 * tuple_count, false, - true, true, txn); + true, true, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -852,8 +846,7 @@ TEST_F(AggregateTests, PlainSumCountDistinctTest) { std::unique_ptr result_tile(executor.GetOutput()); EXPECT_TRUE(result_tile.get() != nullptr); type::Value val = (result_tile->GetValue(0, 0)); - CmpBool cmp = - (val.CompareEquals(type::ValueFactory::GetIntegerValue(50))); + CmpBool cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(50))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); val = (result_tile->GetValue(0, 1)); cmp = (val.CompareEquals(type::ValueFactory::GetIntegerValue(10))); diff --git a/test/executor/append_test.cpp b/test/executor/append_test.cpp index 4486a10931c..1893e25ebd6 100644 --- a/test/executor/append_test.cpp +++ b/test/executor/append_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include "executor/testing_executor_util.h" @@ -35,7 +34,7 @@ namespace test { namespace { -class AppendTests : public PelotonTest {}; +class AppendTests : public PelotonTests {}; void RunTest(executor::AppendExecutor &executor, size_t expected_num_tuples) { EXPECT_TRUE(executor.Init()); @@ -85,7 +84,7 @@ TEST_F(AppendTests, AppendTwoTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 10, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr ltile0( diff --git a/test/executor/copy_test.cpp b/test/executor/copy_test.cpp index 77c1c9eecc9..9e86f31b7d0 100644 --- a/test/executor/copy_test.cpp +++ b/test/executor/copy_test.cpp @@ -36,9 +36,9 @@ namespace test { // Copy Tests //===--------------------------------------------------------------------===// -class CopyTests : public PelotonTest {}; +class CopyTests : public PelotonTests {}; -TEST_F(CopyTests, Copying) { +TEST_F(CopyTests, CopyingTest) { auto catalog = catalog::Catalog::GetInstance(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); diff --git a/test/executor/create_index_test.cpp b/test/executor/create_index_test.cpp index 47bbd509307..0cead9b9c4d 100644 --- a/test/executor/create_index_test.cpp +++ b/test/executor/create_index_test.cpp @@ -43,9 +43,9 @@ namespace test { // Catalog Tests //===--------------------------------------------------------------------===// -class CreateIndexTests : public PelotonTest {}; +class CreateIndexTests : public PelotonTests {}; -TEST_F(CreateIndexTests, CreatingIndex) { +TEST_F(CreateIndexTests, CreatingIndexTest) { LOG_INFO("Bootstrapping..."); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); diff --git a/test/executor/create_test.cpp b/test/executor/create_test.cpp index 214f32fa44d..f789be41649 100644 --- a/test/executor/create_test.cpp +++ b/test/executor/create_test.cpp @@ -39,9 +39,9 @@ namespace test { // Catalog Tests //===--------------------------------------------------------------------===// -class CreateTests : public PelotonTest {}; +class CreateTests : public PelotonTests {}; -TEST_F(CreateTests, CreatingDB) { +TEST_F(CreateTests, CreatingDBTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -78,7 +78,7 @@ TEST_F(CreateTests, CreatingDB) { txn_manager.CommitTransaction(txn); } -TEST_F(CreateTests, CreatingTable) { +TEST_F(CreateTests, CreatingTableTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -117,7 +117,7 @@ TEST_F(CreateTests, CreatingTable) { txn_manager.CommitTransaction(txn); } -TEST_F(CreateTests, CreatingUDFs) { +TEST_F(CreateTests, CreatingUDFsTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -222,7 +222,7 @@ TEST_F(CreateTests, CreatingUDFs) { txn_manager.CommitTransaction(txn); } -TEST_F(CreateTests, CreatingTrigger) { +TEST_F(CreateTests, CreatingTriggerTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -352,7 +352,7 @@ TEST_F(CreateTests, CreatingTrigger) { // This test is added because there was a bug for triggers without "when". After // fixing that, // we add this test to avoid problem like that happen in the future. -TEST_F(CreateTests, CreatingTriggerWithoutWhen) { +TEST_F(CreateTests, CreatingTriggerWithoutWhenTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -437,7 +437,7 @@ TEST_F(CreateTests, CreatingTriggerWithoutWhen) { txn_manager.CommitTransaction(txn); } -TEST_F(CreateTests, CreatingTriggerInCatalog) { +TEST_F(CreateTests, CreatingTriggerInCatalogTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); diff --git a/test/executor/delete_test.cpp b/test/executor/delete_test.cpp index 648944c8fe9..2500b4d4400 100644 --- a/test/executor/delete_test.cpp +++ b/test/executor/delete_test.cpp @@ -42,7 +42,7 @@ namespace test { // Catalog Tests //===--------------------------------------------------------------------===// -class DeleteTests : public PelotonTest {}; +class DeleteTests : public PelotonTests {}; void ShowTable(std::string database_name, std::string table_name) { // auto table = @@ -91,7 +91,7 @@ void ShowTable(std::string database_name, std::string table_name) { traffic_cop.CommitQueryHelper(); } -TEST_F(DeleteTests, VariousOperations) { +TEST_F(DeleteTests, VariousOperationsTest) { LOG_INFO("Bootstrapping..."); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); diff --git a/test/executor/drop_test.cpp b/test/executor/drop_test.cpp index d90f06cbcb1..5d6c49f68f4 100644 --- a/test/executor/drop_test.cpp +++ b/test/executor/drop_test.cpp @@ -35,9 +35,9 @@ namespace test { // Catalog Tests //===--------------------------------------------------------------------===// -class DropTests : public PelotonTest {}; +class DropTests : public PelotonTests {}; -TEST_F(DropTests, DroppingDatabase) { +TEST_F(DropTests, DroppingDatabaseTest) { auto catalog = catalog::Catalog::GetInstance(); catalog->Bootstrap(); @@ -73,7 +73,7 @@ TEST_F(DropTests, DroppingDatabase) { txn_manager.CommitTransaction(txn); } -TEST_F(DropTests, DroppingTable) { +TEST_F(DropTests, DroppingTableTest) { auto catalog = catalog::Catalog::GetInstance(); // NOTE: Catalog::GetInstance()->Bootstrap() has been called in previous tests // you can only call it once! @@ -129,7 +129,7 @@ TEST_F(DropTests, DroppingTable) { txn_manager.CommitTransaction(txn); } -TEST_F(DropTests, DroppingTrigger) { +TEST_F(DropTests, DroppingTriggerTest) { auto catalog = catalog::Catalog::GetInstance(); // NOTE: Catalog::GetInstance()->Bootstrap() has been called in previous tests // you can only call it once! @@ -230,7 +230,7 @@ TEST_F(DropTests, DroppingTrigger) { txn_manager.CommitTransaction(txn); } -TEST_F(DropTests, DroppingIndexByName) { +TEST_F(DropTests, DroppingIndexByNameTest) { auto catalog = catalog::Catalog::GetInstance(); // NOTE: Catalog::GetInstance()->Bootstrap() has been called in previous tests // you can only call it once! diff --git a/test/executor/hash_set_op_test.cpp b/test/executor/hash_set_op_test.cpp index a9eb87b2823..97865c2742b 100644 --- a/test/executor/hash_set_op_test.cpp +++ b/test/executor/hash_set_op_test.cpp @@ -32,7 +32,7 @@ using ::testing::Return; namespace peloton { namespace test { -class HashSetOptTests : public PelotonTest {}; +class HashSetOptTests : public PelotonTests {}; namespace { @@ -91,12 +91,12 @@ TEST_F(HashSetOptTests, ExceptTest) { std::unique_ptr data_table1( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table1.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table2( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table2.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); @@ -163,19 +163,19 @@ TEST_F(HashSetOptTests, ExceptAllTest) { std::unique_ptr data_table1( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table1.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table2( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table2.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table3( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table3.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table4( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table4.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); @@ -249,11 +249,11 @@ TEST_F(HashSetOptTests, IntersectTest) { std::unique_ptr data_table1( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table1.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table2( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table2.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); @@ -320,19 +320,19 @@ TEST_F(HashSetOptTests, IntersectAllTest) { std::unique_ptr data_table1( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table1.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table2( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table2.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table3( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table3.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); std::unique_ptr data_table4( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table4.get(), tile_size * 5, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); diff --git a/test/executor/index_scan_test.cpp b/test/executor/index_scan_test.cpp index c22f22bcb89..cc3fe0b4c68 100644 --- a/test/executor/index_scan_test.cpp +++ b/test/executor/index_scan_test.cpp @@ -41,7 +41,7 @@ using ::testing::Return; namespace peloton { namespace test { -class IndexScanTests : public PelotonTest {}; +class IndexScanTests : public PelotonTests {}; // Index scan of table with index predicate. TEST_F(IndexScanTests, IndexPredicateTest) { diff --git a/test/executor/insert_test.cpp b/test/executor/insert_test.cpp index 489b871121d..8f5336bc3f6 100644 --- a/test/executor/insert_test.cpp +++ b/test/executor/insert_test.cpp @@ -31,9 +31,9 @@ namespace test { // Catalog Tests //===--------------------------------------------------------------------===// -class InsertTests : public PelotonTest {}; +class InsertTests : public PelotonTests {}; -TEST_F(InsertTests, InsertRecord) { +TEST_F(InsertTests, InsertRecordTest) { catalog::Catalog::GetInstance(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); diff --git a/test/executor/join_test.cpp b/test/executor/join_test.cpp index f2f78e2c9f2..9c58de96729 100644 --- a/test/executor/join_test.cpp +++ b/test/executor/join_test.cpp @@ -52,7 +52,7 @@ using ::testing::InSequence; namespace peloton { namespace test { -class JoinTests : public PelotonTest {}; +class JoinTests : public PelotonTests {}; std::vector CreateJoinClauses() { std::vector join_clauses; diff --git a/test/executor/limit_test.cpp b/test/executor/limit_test.cpp index ec7992b8380..012c4345c15 100644 --- a/test/executor/limit_test.cpp +++ b/test/executor/limit_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -37,7 +36,7 @@ using ::testing::Return; namespace peloton { namespace test { -class LimitTests : public PelotonTest {}; +class LimitTests : public PelotonTests {}; namespace { @@ -53,7 +52,7 @@ void RunTest(executor::LimitExecutor &executor, size_t expected_num_tiles, EXPECT_EQ(expected_num_tiles, result_tiles.size()); if (result_tiles.size() > 0) { - EXPECT_EQ(expected_first_oid, *(result_tiles[0]->begin())); + EXPECT_EQ(expected_first_oid, *(result_tiles[0]->begin())); } size_t actual_num_tuples_returned = 0; @@ -88,7 +87,7 @@ TEST_F(LimitTests, NonLeafLimitOffsetTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 3, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -129,7 +128,7 @@ TEST_F(LimitTests, NonLeafSkipAllTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 3, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -170,7 +169,7 @@ TEST_F(LimitTests, NonLeafReturnAllTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 3, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -212,7 +211,7 @@ TEST_F(LimitTests, NonLeafHugeLimitTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 3, false, - false, false, txn); + false, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( diff --git a/test/executor/loader_test.cpp b/test/executor/loader_test.cpp index 14b88882ff4..c6698001f31 100644 --- a/test/executor/loader_test.cpp +++ b/test/executor/loader_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -49,7 +48,7 @@ namespace test { // Loader Tests //===--------------------------------------------------------------------===// -class LoaderTests : public PelotonTest {}; +class LoaderTests : public PelotonTests {}; std::atomic loader_tuple_id; @@ -67,8 +66,7 @@ static std::unique_ptr MakeProjectInfoFromTuple( DirectMapList direct_map_list; for (oid_t col_id = START_OID; col_id < tuple->GetColumnCount(); col_id++) { - type::Value value = ( - tuple->GetValue(col_id)); + type::Value value = (tuple->GetValue(col_id)); auto expression = expression::ExpressionUtil::ConstantValueFactory(value); planner::DerivedAttribute attribute{expression}; target_list.emplace_back(col_id, attribute); @@ -131,7 +129,8 @@ TEST_F(LoaderTests, LoadingTest) { auto expected_tile_group_count = 0; - int total_tuple_count = loader_threads_count * tilegroup_count_per_loader * TEST_TUPLES_PER_TILEGROUP; + int total_tuple_count = loader_threads_count * tilegroup_count_per_loader * + TEST_TUPLES_PER_TILEGROUP; int max_cached_tuple_count = TEST_TUPLES_PER_TILEGROUP * storage::DataTable::GetActiveTileGroupCount(); int max_unfill_cached_tuple_count = @@ -147,9 +146,13 @@ TEST_F(LoaderTests, LoadingTest) { max_unfill_cached_tuple_count; } } else { - int filled_tile_group_count = total_tuple_count / max_cached_tuple_count * storage::DataTable::GetActiveTileGroupCount(); - - if (total_tuple_count - filled_tile_group_count * TEST_TUPLES_PER_TILEGROUP - max_unfill_cached_tuple_count <= 0) { + int filled_tile_group_count = total_tuple_count / max_cached_tuple_count * + storage::DataTable::GetActiveTileGroupCount(); + + if (total_tuple_count - + filled_tile_group_count * TEST_TUPLES_PER_TILEGROUP - + max_unfill_cached_tuple_count <= + 0) { expected_tile_group_count = filled_tile_group_count + storage::DataTable::GetActiveTileGroupCount(); } else { diff --git a/test/executor/logical_tile_test.cpp b/test/executor/logical_tile_test.cpp index 0f225e65963..3ac73c83658 100644 --- a/test/executor/logical_tile_test.cpp +++ b/test/executor/logical_tile_test.cpp @@ -31,7 +31,6 @@ #include "common/internal_types.h" #include "type/value_factory.h" - namespace peloton { namespace test { @@ -39,15 +38,16 @@ namespace test { // Logical Tile Tests //===--------------------------------------------------------------------===// -class LogicalTileTests : public PelotonTest {}; +class LogicalTileTests : public PelotonTests {}; TEST_F(LogicalTileTests, TempTableTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; auto pool = TestingHarness::GetInstance().GetTestingPool(); - catalog::Schema *schema = new catalog::Schema( - {TestingExecutorUtil::GetColumnInfo(0), TestingExecutorUtil::GetColumnInfo(1), - TestingExecutorUtil::GetColumnInfo(2)}); + catalog::Schema *schema = + new catalog::Schema({TestingExecutorUtil::GetColumnInfo(0), + TestingExecutorUtil::GetColumnInfo(1), + TestingExecutorUtil::GetColumnInfo(2)}); // Create our TempTable storage::TempTable table(INVALID_OID, schema, true); diff --git a/test/executor/materialization_test.cpp b/test/executor/materialization_test.cpp index 92f569d547f..7bf75d463de 100644 --- a/test/executor/materialization_test.cpp +++ b/test/executor/materialization_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -44,7 +43,7 @@ namespace test { // Materialization Tests //===--------------------------------------------------------------------===// -class MaterializationTests : public PelotonTest {}; +class MaterializationTests : public PelotonTests {}; // "Pass-through" test case. There is nothing to materialize as // there is only one base tile in the logical tile. @@ -65,7 +64,8 @@ TEST_F(MaterializationTests, SingleBaseTileTest) { // Pass through materialization executor. executor::MaterializationExecutor executor(nullptr, nullptr); std::unique_ptr result_logical_tile( - TestingExecutorUtil::ExecuteTile(&executor, source_logical_tile.release())); + TestingExecutorUtil::ExecuteTile(&executor, + source_logical_tile.release())); // Verify that logical tile is only made up of a single base tile. int num_cols = result_logical_tile->GetColumnCount(); @@ -79,8 +79,8 @@ TEST_F(MaterializationTests, SingleBaseTileTest) { for (int i = 0; i < tuple_count; i++) { type::Value val0 = (result_base_tile->GetValue(i, 0)); type::Value val1 = (result_base_tile->GetValue(i, 1)); - CmpBool cmp = (val0.CompareEquals( - type::ValueFactory::GetIntegerValue(TestingExecutorUtil::PopulatedValue(i, 0)))); + CmpBool cmp = (val0.CompareEquals(type::ValueFactory::GetIntegerValue( + TestingExecutorUtil::PopulatedValue(i, 0)))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); cmp = val1.CompareEquals(type::ValueFactory::GetIntegerValue( TestingExecutorUtil::PopulatedValue(i, 1))); @@ -136,7 +136,8 @@ TEST_F(MaterializationTests, TwoBaseTilesWithReorderTest) { // Pass through materialization executor. executor::MaterializationExecutor executor(&node, nullptr); std::unique_ptr result_logical_tile( - TestingExecutorUtil::ExecuteTile(&executor, source_logical_tile.release())); + TestingExecutorUtil::ExecuteTile(&executor, + source_logical_tile.release())); // Verify that logical tile is only made up of a single base tile. int num_cols = result_logical_tile->GetColumnCount(); @@ -152,8 +153,8 @@ TEST_F(MaterializationTests, TwoBaseTilesWithReorderTest) { type::Value val1(result_base_tile->GetValue(i, 1)); type::Value val2(result_base_tile->GetValue(i, 2)); // Output column 2. - CmpBool cmp(val2.CompareEquals( - type::ValueFactory::GetIntegerValue(TestingExecutorUtil::PopulatedValue(i, 0)))); + CmpBool cmp(val2.CompareEquals(type::ValueFactory::GetIntegerValue( + TestingExecutorUtil::PopulatedValue(i, 0)))); EXPECT_TRUE(cmp == CmpBool::CmpTrue); // Output column 1. diff --git a/test/executor/mutate_test.cpp b/test/executor/mutate_test.cpp index 10fcbeec4c9..174af42bb7c 100644 --- a/test/executor/mutate_test.cpp +++ b/test/executor/mutate_test.cpp @@ -57,7 +57,7 @@ namespace test { // Mutator Tests //===--------------------------------------------------------------------===// -class MutateTests : public PelotonTest {}; +class MutateTests : public PelotonTests {}; std::atomic tuple_id; std::atomic delete_tuple_id; @@ -87,8 +87,8 @@ void UpdateTuple(storage::DataTable *table, new executor::ExecutorContext(txn)); // Update - //std::vector update_column_ids = {2}; - //std::vector values; + // std::vector update_column_ids = {2}; + // std::vector values; auto update_val = type::ValueFactory::GetDecimalValue(23.5); TargetList target_list; @@ -182,7 +182,7 @@ void DeleteTuple(storage::DataTable *table, txn_manager.CommitTransaction(txn); } -TEST_F(MutateTests, StressTests) { +TEST_F(MutateTests, StressTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -241,10 +241,10 @@ TEST_F(MutateTests, StressTests) { columns.push_back(TestingExecutorUtil::GetColumnInfo(0)); std::unique_ptr key_schema(new catalog::Schema(columns)); - std::unique_ptr key1(new storage::Tuple(key_schema.get(), - true)); - std::unique_ptr key2(new storage::Tuple(key_schema.get(), - true)); + std::unique_ptr key1( + new storage::Tuple(key_schema.get(), true)); + std::unique_ptr key2( + new storage::Tuple(key_schema.get(), true)); key1->SetValue(0, type::ValueFactory::GetIntegerValue(10), nullptr); key2->SetValue(0, type::ValueFactory::GetIntegerValue(100), nullptr); @@ -255,10 +255,10 @@ TEST_F(MutateTests, StressTests) { columns.push_back(TestingExecutorUtil::GetColumnInfo(1)); key_schema.reset(new catalog::Schema(columns)); - std::unique_ptr key3(new storage::Tuple(key_schema.get(), - true)); - std::unique_ptr key4(new storage::Tuple(key_schema.get(), - true)); + std::unique_ptr key3( + new storage::Tuple(key_schema.get(), true)); + std::unique_ptr key4( + new storage::Tuple(key_schema.get(), true)); key3->SetValue(0, type::ValueFactory::GetIntegerValue(10), nullptr); key3->SetValue(1, type::ValueFactory::GetIntegerValue(11), nullptr); diff --git a/test/executor/order_by_test.cpp b/test/executor/order_by_test.cpp index d22df56045a..1e84251573f 100644 --- a/test/executor/order_by_test.cpp +++ b/test/executor/order_by_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -38,7 +37,7 @@ using ::testing::Return; namespace peloton { namespace test { -class OrderByTests : public PelotonTest {}; +class OrderByTests : public PelotonTests {}; namespace { @@ -98,7 +97,7 @@ TEST_F(OrderByTests, IntAscTest) { TestingExecutorUtil::CreateTable(tile_size)); bool random = true; TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 2, false, - random, false, txn); + random, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -144,7 +143,7 @@ TEST_F(OrderByTests, IntDescTest) { TestingExecutorUtil::CreateTable(tile_size)); bool random = true; TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 2, false, - random, false, txn); + random, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -190,7 +189,7 @@ TEST_F(OrderByTests, StringDescTest) { TestingExecutorUtil::CreateTable(tile_size)); bool random = true; TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 2, false, - random, false, txn); + random, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -236,7 +235,7 @@ TEST_F(OrderByTests, IntAscStringDescTest) { TestingExecutorUtil::CreateTable(tile_size)); bool random = true; TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 2, false, - random, false, txn); + random, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -285,7 +284,7 @@ TEST_F(OrderByTests, StringDescIntAscTest) { TestingExecutorUtil::CreateTable(tile_size)); bool random = true; TestingExecutorUtil::PopulateTable(data_table.get(), tile_size * 2, false, - random, false, txn); + random, false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( diff --git a/test/executor/projection_test.cpp b/test/executor/projection_test.cpp index 994143c90df..3ff528b5d93 100644 --- a/test/executor/projection_test.cpp +++ b/test/executor/projection_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -36,7 +35,7 @@ using ::testing::Return; namespace peloton { namespace test { -class ProjectionTests : public PelotonTest {}; +class ProjectionTests : public PelotonTests {}; void RunTest(executor::ProjectionExecutor &executor, size_t expected_num_tiles) { @@ -66,7 +65,7 @@ TEST_F(ProjectionTests, BasicTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size, false, false, - false, txn); + false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -123,7 +122,7 @@ TEST_F(ProjectionTests, TwoColumnTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size, false, false, - false, txn); + false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -187,7 +186,7 @@ TEST_F(ProjectionTests, BasicTargetTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tile_size)); TestingExecutorUtil::PopulateTable(data_table.get(), tile_size, false, false, - false, txn); + false, txn); txn_manager.CommitTransaction(txn); std::unique_ptr source_logical_tile1( @@ -218,8 +217,8 @@ TEST_F(ProjectionTests, BasicTargetTest) { // target list auto const_val = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(20)); - auto tuple_value_expr = - expression::ExpressionUtil::TupleValueFactory(type::TypeId::INTEGER, 0, 0); + auto tuple_value_expr = expression::ExpressionUtil::TupleValueFactory( + type::TypeId::INTEGER, 0, 0); expression::AbstractExpression *expr = expression::ExpressionUtil::OperatorFactory(ExpressionType::OPERATOR_PLUS, type::TypeId::INTEGER, diff --git a/test/executor/seq_scan_test.cpp b/test/executor/seq_scan_test.cpp index 0649aa38e63..35ba4188ce9 100644 --- a/test/executor/seq_scan_test.cpp +++ b/test/executor/seq_scan_test.cpp @@ -44,7 +44,7 @@ using ::testing::Return; namespace peloton { namespace test { -class SeqScanTests : public PelotonTest {}; +class SeqScanTests : public PelotonTests {}; namespace { diff --git a/test/executor/testing_executor_util.cpp b/test/executor/testing_executor_util.cpp index cd923c11ed8..e85a334a3f6 100644 --- a/test/executor/testing_executor_util.cpp +++ b/test/executor/testing_executor_util.cpp @@ -191,9 +191,9 @@ std::shared_ptr TestingExecutorUtil::CreateTileGroup( * @param table Table to populate with values. * @param num_rows Number of tuples to insert. */ -void TestingExecutorUtil::PopulateTable(storage::DataTable *table, int num_rows, - bool mutate, bool random, bool group_by, - concurrency::TransactionContext *current_txn) { +void TestingExecutorUtil::PopulateTable( + storage::DataTable *table, int num_rows, bool mutate, bool random, + bool group_by, concurrency::TransactionContext *current_txn) { // Random values if (random) std::srand(std::time(nullptr)); diff --git a/test/executor/tile_group_layout_test.cpp b/test/executor/tile_group_layout_test.cpp index c7feee528b3..80dfef3b97b 100644 --- a/test/executor/tile_group_layout_test.cpp +++ b/test/executor/tile_group_layout_test.cpp @@ -58,7 +58,7 @@ namespace test { // Tile Group Layout Tests //===--------------------------------------------------------------------===// -class TileGroupLayoutTests : public PelotonTest {}; +class TileGroupLayoutTests : public PelotonTests {}; void ExecuteTileGroupTest(peloton::LayoutType layout_type) { const int tuples_per_tilegroup_count = 10; @@ -71,9 +71,9 @@ void ExecuteTileGroupTest(peloton::LayoutType layout_type) { std::vector columns; for (oid_t col_itr = 0; col_itr <= col_count; col_itr++) { - auto column = - catalog::Column(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "FIELD" + std::to_string(col_itr), is_inlined); + auto column = catalog::Column( + type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), + "FIELD" + std::to_string(col_itr), is_inlined); columns.push_back(column); } @@ -90,7 +90,8 @@ void ExecuteTileGroupTest(peloton::LayoutType layout_type) { bool is_catalog = false; std::unique_ptr table(storage::TableFactory::GetDataTable( INVALID_OID, INVALID_OID, table_schema, table_name, - tuples_per_tilegroup_count, own_schema, adapt_table, is_catalog, layout_type)); + tuples_per_tilegroup_count, own_schema, adapt_table, is_catalog, + layout_type)); // PRIMARY INDEX if (indexes == true) { @@ -133,7 +134,8 @@ void ExecuteTileGroupTest(peloton::LayoutType layout_type) { storage::Tuple tuple(table_schema, allocate); for (oid_t col_itr = 0; col_itr <= col_count; col_itr++) { - auto value = type::ValueFactory::GetIntegerValue(populate_value + col_itr); + auto value = + type::ValueFactory::GetIntegerValue(populate_value + col_itr); tuple.SetValue(col_itr, value, testing_pool); } @@ -175,9 +177,9 @@ void ExecuteTileGroupTest(peloton::LayoutType layout_type) { std::unordered_map old_to_new_cols; oid_t col_itr = 0; for (auto column_id : column_ids) { - auto column = - catalog::Column(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "FIELD" + std::to_string(column_id), is_inlined); + auto column = catalog::Column( + type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), + "FIELD" + std::to_string(column_id), is_inlined); output_columns.push_back(column); old_to_new_cols[col_itr] = col_itr; @@ -209,11 +211,11 @@ void ExecuteTileGroupTest(peloton::LayoutType layout_type) { txn_manager.CommitTransaction(txn); } -TEST_F(TileGroupLayoutTests, RowLayout) { +TEST_F(TileGroupLayoutTests, RowLayoutTest) { ExecuteTileGroupTest(LayoutType::ROW); } -TEST_F(TileGroupLayoutTests, ColumnLayout) { +TEST_F(TileGroupLayoutTests, ColumnLayoutTest) { ExecuteTileGroupTest(LayoutType::COLUMN); } diff --git a/test/executor/update_test.cpp b/test/executor/update_test.cpp index 04c42162cdc..9a8d1719cda 100644 --- a/test/executor/update_test.cpp +++ b/test/executor/update_test.cpp @@ -60,7 +60,7 @@ namespace test { // Update Tests //===--------------------------------------------------------------------===// -class UpdateTests : public PelotonTest {}; +class UpdateTests : public PelotonTests {}; namespace { @@ -124,7 +124,7 @@ storage::DataTable *CreateTable() { return table.release(); } -TEST_F(UpdateTests, MultiColumnUpdates) { +TEST_F(UpdateTests, MultiColumnUpdatesTest) { // Create table. std::unique_ptr table(CreateTable()); // storage::DataTable* table = CreateTable(); @@ -154,7 +154,7 @@ TEST_F(UpdateTests, MultiColumnUpdates) { // ResultTypeToString(status.m_result).c_str()); } -TEST_F(UpdateTests, UpdatingOld) { +TEST_F(UpdateTests, UpdatingOldTest) { LOG_INFO("Bootstrapping..."); auto catalog = catalog::Catalog::GetInstance(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); diff --git a/test/expression/expression_test.cpp b/test/expression/expression_test.cpp index 85bfcc58979..f5aaa603800 100644 --- a/test/expression/expression_test.cpp +++ b/test/expression/expression_test.cpp @@ -32,7 +32,7 @@ namespace peloton { namespace test { -class ExpressionTests : public PelotonTest {}; +class ExpressionTests : public PelotonTests {}; TEST_F(ExpressionTests, EqualityTest) { // First tree operator_expr(-) -> (tup_expr(A.a), const_expr(2)) @@ -42,8 +42,8 @@ TEST_F(ExpressionTests, EqualityTest) { auto right1 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); std::unique_ptr root1( - new expression::OperatorExpression( - ExpressionType::OPERATOR_MINUS, type::TypeId::INVALID, left1, right1)); + new expression::OperatorExpression(ExpressionType::OPERATOR_MINUS, + type::TypeId::INVALID, left1, right1)); // Second tree operator_expr(-) -> (tup_expr(A.b), const_expr(2)) std::tuple bound_oid2(1, 1, 0); auto left2 = new expression::TupleValueExpression("b", "A"); @@ -51,8 +51,8 @@ TEST_F(ExpressionTests, EqualityTest) { auto right2 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); std::unique_ptr root2( - new expression::OperatorExpression( - ExpressionType::OPERATOR_MINUS, type::TypeId::INVALID, left2, right2)); + new expression::OperatorExpression(ExpressionType::OPERATOR_MINUS, + type::TypeId::INVALID, left2, right2)); EXPECT_TRUE(*root1.get() != *root2.get()); // Third tree operator_expr(-) -> (tup_expr(a.a), const_expr(2)) @@ -61,33 +61,32 @@ TEST_F(ExpressionTests, EqualityTest) { auto right3 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); std::unique_ptr root3( - new expression::OperatorExpression( - ExpressionType::OPERATOR_MINUS, type::TypeId::INVALID, left3, right3)); + new expression::OperatorExpression(ExpressionType::OPERATOR_MINUS, + type::TypeId::INVALID, left3, right3)); EXPECT_TRUE(*root1.get() == *root3.get()); } - TEST_F(ExpressionTests, HashTest) { // First tree operator_expr(-) -> (tup_expr(A.a), const_expr(2)) auto left1 = new expression::TupleValueExpression("a", "A"); - auto oids1 = std::make_tuple(0,0,0); + auto oids1 = std::make_tuple(0, 0, 0); left1->SetBoundOid(oids1); auto right1 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); std::unique_ptr root1( - new expression::OperatorExpression( - ExpressionType::OPERATOR_MINUS, type::TypeId::INVALID, left1, right1)); + new expression::OperatorExpression(ExpressionType::OPERATOR_MINUS, + type::TypeId::INVALID, left1, right1)); LOG_INFO("Hash(tree1)=%ld", root1->Hash()); // Second tree operator_expr(-) -> (tup_expr(A.b), const_expr(2)) auto left2 = new expression::TupleValueExpression("b", "A"); - auto oids2 = std::make_tuple(0,0,1); + auto oids2 = std::make_tuple(0, 0, 1); left2->SetBoundOid(oids2); auto right2 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); std::unique_ptr root2( - new expression::OperatorExpression( - ExpressionType::OPERATOR_MINUS, type::TypeId::INVALID, left2, right2)); + new expression::OperatorExpression(ExpressionType::OPERATOR_MINUS, + type::TypeId::INVALID, left2, right2)); LOG_INFO("Hash(tree2)=%ld", root2->Hash()); EXPECT_NE(root1->Hash(), root2->Hash()); @@ -99,8 +98,8 @@ TEST_F(ExpressionTests, HashTest) { auto right3 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); std::unique_ptr root3( - new expression::OperatorExpression( - ExpressionType::OPERATOR_MINUS, type::TypeId::INVALID, left3, right3)); + new expression::OperatorExpression(ExpressionType::OPERATOR_MINUS, + type::TypeId::INVALID, left3, right3)); LOG_INFO("Hash(tree3)=%ld", root3->Hash()); EXPECT_EQ(root1->Hash(), root3->Hash()); @@ -114,8 +113,8 @@ TEST_F(ExpressionTests, DistinctFromTest) { type::Type::GetTypeSize(type::TypeId::INTEGER), "id", true); catalog::Column column2(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), "value", - true); + type::Type::GetTypeSize(type::TypeId::INTEGER), + "value", true); columns.push_back(column1); columns.push_back(column2); @@ -125,8 +124,10 @@ TEST_F(ExpressionTests, DistinctFromTest) { std::unique_ptr tuple(new storage::Tuple(schema.get(), true)); // Create "id IS DISTINCT FROM value" comparison - auto lexpr = new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); - auto rexpr = new expression::TupleValueExpression(type::TypeId::INTEGER, 1, 1); + auto lexpr = + new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); + auto rexpr = + new expression::TupleValueExpression(type::TypeId::INTEGER, 1, 1); expression::ComparisonExpression expr( StringToExpressionType("COMPARE_DISTINCT_FROM"), lexpr, rexpr); @@ -143,23 +144,23 @@ TEST_F(ExpressionTests, DistinctFromTest) { EXPECT_TRUE(expr.Evaluate(tuple.get(), tuple.get(), nullptr).IsTrue()); // id not NULL, value is NULL, should be true - tuple->SetValue(1, - type::ValueFactory::GetNullValueByType(type::TypeId::INTEGER), pool); + tuple->SetValue( + 1, type::ValueFactory::GetNullValueByType(type::TypeId::INTEGER), pool); EXPECT_TRUE(expr.Evaluate(tuple.get(), tuple.get(), nullptr).IsTrue()); // id is NULL, value not NULL, should be true - tuple->SetValue(0, - type::ValueFactory::GetNullValueByType(type::TypeId::INTEGER), pool); + tuple->SetValue( + 0, type::ValueFactory::GetNullValueByType(type::TypeId::INTEGER), pool); tuple->SetValue(1, type::ValueFactory::GetIntegerValue(10), pool); EXPECT_TRUE(expr.Evaluate(tuple.get(), tuple.get(), nullptr).IsTrue()); // id is NULL, value is NULL, should be false - tuple->SetValue(1, - type::ValueFactory::GetNullValueByType(type::TypeId::INTEGER), pool); + tuple->SetValue( + 1, type::ValueFactory::GetNullValueByType(type::TypeId::INTEGER), pool); EXPECT_TRUE(expr.Evaluate(tuple.get(), tuple.get(), nullptr).IsFalse()); } -TEST_F(ExpressionTests, ExtractDateTests) { +TEST_F(ExpressionTests, ExtractDateTest) { // PAVLO: 2017-01-18 // This will test whether we can invoke the EXTRACT function // correctly. This is different than DateFunctionsTests @@ -217,22 +218,20 @@ TEST_F(ExpressionTests, ExtractDateTests) { // } } -TEST_F(ExpressionTests, SimpleCase) { - +TEST_F(ExpressionTests, SimpleCaseTest) { // CASE WHEN i=1 THEN 2 ELSE 3 END // EXPRESSION - auto tup_val_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, - 0, 0); + auto tup_val_exp = + new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); auto const_val_exp_1 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(1)); auto const_val_exp_2 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(2)); auto const_val_exp_3 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(3)); - auto *when_cond = - new expression::ComparisonExpression(ExpressionType::COMPARE_EQUAL, - tup_val_exp, const_val_exp_1); + auto *when_cond = new expression::ComparisonExpression( + ExpressionType::COMPARE_EQUAL, tup_val_exp, const_val_exp_1); std::vector clauses; clauses.push_back(expression::CaseExpression::WhenClause( @@ -241,18 +240,18 @@ TEST_F(ExpressionTests, SimpleCase) { std::unique_ptr case_expression( new expression::CaseExpression( - type::TypeId::INTEGER, clauses, - expression::CaseExpression::AbsExprPtr(const_val_exp_3))); + type::TypeId::INTEGER, clauses, + expression::CaseExpression::AbsExprPtr(const_val_exp_3))); // TUPLE std::vector columns; catalog::Column column1(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), - "i1", true); + type::Type::GetTypeSize(type::TypeId::INTEGER), "i1", + true); catalog::Column column2(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), - "i2", true); + type::Type::GetTypeSize(type::TypeId::INTEGER), "i2", + true); columns.push_back(column1); columns.push_back(column2); std::unique_ptr schema(new catalog::Schema(columns)); @@ -275,11 +274,10 @@ TEST_F(ExpressionTests, SimpleCase) { } TEST_F(ExpressionTests, SimpleCaseCopyTest) { - // CASE WHEN i=1 THEN 2 ELSE 3 END // EXPRESSION - auto tup_val_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, - 0, 0); + auto tup_val_exp = + new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); auto const_val_exp_1 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(1)); auto const_val_exp_2 = new expression::ConstantValueExpression( @@ -287,9 +285,8 @@ TEST_F(ExpressionTests, SimpleCaseCopyTest) { auto const_val_exp_3 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(3)); - auto *when_cond = - new expression::ComparisonExpression(ExpressionType::COMPARE_EQUAL, - tup_val_exp, const_val_exp_1); + auto *when_cond = new expression::ComparisonExpression( + ExpressionType::COMPARE_EQUAL, tup_val_exp, const_val_exp_1); std::vector clauses; clauses.push_back(expression::CaseExpression::WhenClause( @@ -297,7 +294,8 @@ TEST_F(ExpressionTests, SimpleCaseCopyTest) { expression::CaseExpression::AbsExprPtr(const_val_exp_2))); std::unique_ptr o_case_expression( - new expression::CaseExpression(type::TypeId::INTEGER, clauses, + new expression::CaseExpression( + type::TypeId::INTEGER, clauses, expression::CaseExpression::AbsExprPtr(const_val_exp_3))); std::unique_ptr case_expression( @@ -307,11 +305,11 @@ TEST_F(ExpressionTests, SimpleCaseCopyTest) { std::vector columns; catalog::Column column1(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), - "i1", true); + type::Type::GetTypeSize(type::TypeId::INTEGER), "i1", + true); catalog::Column column2(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), - "i2", true); + type::Type::GetTypeSize(type::TypeId::INTEGER), "i2", + true); columns.push_back(column1); columns.push_back(column2); std::unique_ptr schema(new catalog::Schema(columns)); @@ -333,13 +331,12 @@ TEST_F(ExpressionTests, SimpleCaseCopyTest) { EXPECT_EQ(CmpBool::CmpTrue, expected.CompareEquals(result)); } -TEST_F(ExpressionTests, SimpleCaseWithDefault) { - +TEST_F(ExpressionTests, SimpleCaseWithDefaultTest) { // CASE i WHEN 1 THEN 2 ELSE 3 END // EXPRESSION - auto tup_val_exp = new expression::TupleValueExpression(type::TypeId::INTEGER, - 0, 0); + auto tup_val_exp = + new expression::TupleValueExpression(type::TypeId::INTEGER, 0, 0); auto const_val_exp_1 = new expression::ConstantValueExpression( type::ValueFactory::GetIntegerValue(1)); auto const_val_exp_2 = new expression::ConstantValueExpression( @@ -353,19 +350,20 @@ TEST_F(ExpressionTests, SimpleCaseWithDefault) { expression::CaseExpression::AbsExprPtr(const_val_exp_2))); std::unique_ptr case_expression( - new expression::CaseExpression(type::TypeId::INTEGER, - expression::CaseExpression::AbsExprPtr(tup_val_exp), - clauses, expression::CaseExpression::AbsExprPtr(const_val_exp_3))); + new expression::CaseExpression( + type::TypeId::INTEGER, + expression::CaseExpression::AbsExprPtr(tup_val_exp), clauses, + expression::CaseExpression::AbsExprPtr(const_val_exp_3))); // TUPLE std::vector columns; catalog::Column column1(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), - "i1", true); + type::Type::GetTypeSize(type::TypeId::INTEGER), "i1", + true); catalog::Column column2(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), - "i2", true); + type::Type::GetTypeSize(type::TypeId::INTEGER), "i2", + true); columns.push_back(column1); columns.push_back(column2); std::unique_ptr schema(new catalog::Schema(columns)); diff --git a/test/expression/expression_util_test.cpp b/test/expression/expression_util_test.cpp index daf34e77f14..2e94c9d9803 100644 --- a/test/expression/expression_util_test.cpp +++ b/test/expression/expression_util_test.cpp @@ -30,7 +30,7 @@ namespace peloton { namespace test { -class ExpressionUtilTests : public PelotonTest {}; +class ExpressionUtilTests : public PelotonTests {}; std::string CONSTANT_VALUE_STRING1 = "ABC"; std::string CONSTANT_VALUE_STRING2 = "XYZ"; @@ -103,8 +103,8 @@ TEST_F(ExpressionUtilTests, ExtractJoinColTest) { l_column_ids, r_column_ids; // Table1.a = Table2.b -> nullptr std::unique_ptr ret_expr1( - expression::ExpressionUtil::ExtractJoinColumns( - l_column_ids, r_column_ids, expr3)); + expression::ExpressionUtil::ExtractJoinColumns(l_column_ids, r_column_ids, + expr3)); EXPECT_EQ(nullptr, ret_expr1.get()); EXPECT_EQ(1, l_column_ids.size()); @@ -115,8 +115,8 @@ TEST_F(ExpressionUtilTests, ExtractJoinColTest) { l_column_ids.clear(); r_column_ids.clear(); std::unique_ptr ret_expr2( - expression::ExpressionUtil::ExtractJoinColumns( - l_column_ids, r_column_ids, expr13.get())); + expression::ExpressionUtil::ExtractJoinColumns(l_column_ids, r_column_ids, + expr13.get())); EXPECT_EQ(ExpressionType::COMPARE_LESSTHAN, ret_expr2->GetExpressionType()); EXPECT_EQ(ExpressionType::VALUE_TUPLE, @@ -126,9 +126,11 @@ TEST_F(ExpressionUtilTests, ExtractJoinColTest) { EXPECT_EQ(1, l_column_ids.size()); EXPECT_EQ(1, reinterpret_cast( - l_column_ids[0].get())->GetColumnId()); + l_column_ids[0].get()) + ->GetColumnId()); EXPECT_EQ(0, reinterpret_cast( - r_column_ids[0].get())->GetColumnId()); + r_column_ids[0].get()) + ->GetColumnId()); // Table1.a = Table2.b auto expr14 = expression::ExpressionUtil::TupleValueFactory( @@ -149,18 +151,22 @@ TEST_F(ExpressionUtilTests, ExtractJoinColTest) { l_column_ids.clear(); r_column_ids.clear(); std::unique_ptr ret_expr3( - expression::ExpressionUtil::ExtractJoinColumns( - l_column_ids, r_column_ids, expr18.get())); + expression::ExpressionUtil::ExtractJoinColumns(l_column_ids, r_column_ids, + expr18.get())); EXPECT_EQ(2, l_column_ids.size()); EXPECT_EQ(1, reinterpret_cast( - l_column_ids[0].get())->GetColumnId()); + l_column_ids[0].get()) + ->GetColumnId()); EXPECT_EQ(0, reinterpret_cast( - r_column_ids[0].get())->GetColumnId()); + r_column_ids[0].get()) + ->GetColumnId()); EXPECT_EQ(0, reinterpret_cast( - l_column_ids[1].get())->GetColumnId()); + l_column_ids[1].get()) + ->GetColumnId()); EXPECT_EQ(1, reinterpret_cast( - r_column_ids[1].get())->GetColumnId()); + r_column_ids[1].get()) + ->GetColumnId()); EXPECT_EQ(ExpressionType::COMPARE_EQUAL, ret_expr3->GetExpressionType()); EXPECT_EQ(ExpressionType::VALUE_TUPLE, diff --git a/test/function/decimal_functions_test.cpp b/test/function/decimal_functions_test.cpp index 994523b732f..10e42d4b75a 100644 --- a/test/function/decimal_functions_test.cpp +++ b/test/function/decimal_functions_test.cpp @@ -29,7 +29,7 @@ using ::testing::Return; namespace peloton { namespace test { -class DecimalFunctionsTests : public PelotonTest {}; +class DecimalFunctionsTests : public PelotonTests {}; TEST_F(DecimalFunctionsTests, SqrtTest) { const double column_val = 9.0; @@ -105,7 +105,7 @@ TEST_F(DecimalFunctionsTests, RoundTest) { EXPECT_TRUE(result.IsNull()); } -TEST_F(DecimalFunctionsTests,AbsTestDouble) { +TEST_F(DecimalFunctionsTests, AbsDoubleTest) { std::vector doubleTestInputs = {9.5, -2.5, -4.4, 0.0}; std::vector args; for (double in : doubleTestInputs) { @@ -121,7 +121,7 @@ TEST_F(DecimalFunctionsTests,AbsTestDouble) { EXPECT_TRUE(result.IsNull()); } -TEST_F(DecimalFunctionsTests, AbsTestInt) { +TEST_F(DecimalFunctionsTests, AbsIntTest) { std::vector bigIntTestInputs = {-20, -15, -10, 0, 10, 20}; std::vector intTestInputs = {-20, -15, -10, 0, 10, 20}; std::vector smallIntTestInputs = {-20, -15, -10, 0, 10, 20}; @@ -129,28 +129,28 @@ TEST_F(DecimalFunctionsTests, AbsTestInt) { std::vector args; // Testing Abs with Integer Types - for (int64_t in: bigIntTestInputs) { + for (int64_t in : bigIntTestInputs) { args = {type::ValueFactory::GetBigIntValue(in)}; auto result = function::DecimalFunctions::_Abs(args); EXPECT_FALSE(result.IsNull()); EXPECT_EQ(std::abs(in), result.GetAs()); } - for (int32_t in: intTestInputs) { + for (int32_t in : intTestInputs) { args = {type::ValueFactory::GetIntegerValue(in)}; auto result = function::DecimalFunctions::_Abs(args); EXPECT_FALSE(result.IsNull()); EXPECT_EQ(abs(in), result.GetAs()); } - for (int16_t in: smallIntTestInputs) { + for (int16_t in : smallIntTestInputs) { args = {type::ValueFactory::GetSmallIntValue(in)}; auto result = function::DecimalFunctions::_Abs(args); EXPECT_FALSE(result.IsNull()); EXPECT_EQ(abs(in), result.GetAs()); } - for (int8_t in: tinyIntTestInputs) { + for (int8_t in : tinyIntTestInputs) { args = {type::ValueFactory::GetTinyIntValue(in)}; auto result = function::DecimalFunctions::_Abs(args); EXPECT_FALSE(result.IsNull()); @@ -158,12 +158,12 @@ TEST_F(DecimalFunctionsTests, AbsTestInt) { } } -TEST_F(DecimalFunctionsTests, CeilTestDouble) { - std::vector doubleTestInputs = {-36.0, -35.222, -0.7, -0.5, -0.2, - 0.0, 0.2, 0.5, 0.7, 35.2, 36.0, - 37.2222}; +TEST_F(DecimalFunctionsTests, CeilDoubleTest) { + std::vector doubleTestInputs = {-36.0, -35.222, -0.7, -0.5, + -0.2, 0.0, 0.2, 0.5, + 0.7, 35.2, 36.0, 37.2222}; std::vector args; - for (double in: doubleTestInputs) { + for (double in : doubleTestInputs) { args = {type::ValueFactory::GetDecimalValue(in)}; auto result = function::DecimalFunctions::_Ceil(args); EXPECT_FALSE(result.IsNull()); @@ -175,7 +175,7 @@ TEST_F(DecimalFunctionsTests, CeilTestDouble) { EXPECT_TRUE(result.IsNull()); } -TEST_F(DecimalFunctionsTests, CeilTestInt) { +TEST_F(DecimalFunctionsTests, CeilIntTest) { std::vector bigIntTestInputs = {-20, -15, -10, 0, 10, 20}; std::vector intTestInputs = {-20, -15, -10, 0, 10, 20}; std::vector smallIntTestInputs = {-20, -15, -10, 0, 10, 20}; @@ -183,28 +183,28 @@ TEST_F(DecimalFunctionsTests, CeilTestInt) { std::vector args; // Testing Ceil with Integer Types - for (int64_t in: bigIntTestInputs) { + for (int64_t in : bigIntTestInputs) { args = {type::ValueFactory::GetIntegerValue(in)}; auto result = function::DecimalFunctions::_Ceil(args); EXPECT_FALSE(result.IsNull()); EXPECT_EQ(ceil(in), result.GetAs()); } - for (int in: intTestInputs) { + for (int in : intTestInputs) { args = {type::ValueFactory::GetIntegerValue(in)}; auto result = function::DecimalFunctions::_Ceil(args); EXPECT_FALSE(result.IsNull()); EXPECT_EQ(ceil(in), result.GetAs()); } - for (int in: smallIntTestInputs) { + for (int in : smallIntTestInputs) { args = {type::ValueFactory::GetIntegerValue(in)}; auto result = function::DecimalFunctions::_Ceil(args); EXPECT_FALSE(result.IsNull()); EXPECT_EQ(ceil(in), result.GetAs()); } - for (int in: tinyIntTestInputs) { + for (int in : tinyIntTestInputs) { args = {type::ValueFactory::GetIntegerValue(in)}; auto result = function::DecimalFunctions::_Ceil(args); EXPECT_FALSE(result.IsNull()); diff --git a/test/function/functions_test.cpp b/test/function/functions_test.cpp index 25b56ab5823..acf3af7635b 100644 --- a/test/function/functions_test.cpp +++ b/test/function/functions_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class FunctionsTests : public PelotonTest { +class FunctionsTests : public PelotonTests { public: static type::Value TestFunc( UNUSED_ATTRIBUTE const std::vector &args) { @@ -30,7 +30,7 @@ class FunctionsTests : public PelotonTest { } virtual void SetUp() { - PelotonTest::SetUp(); + PelotonTests::SetUp(); // Bootstrap catalog auto catalog = catalog::Catalog::GetInstance(); catalog->Bootstrap(); diff --git a/test/function/string_functions_test.cpp b/test/function/string_functions_test.cpp index c5557bc89b0..f6bcf38b986 100644 --- a/test/function/string_functions_test.cpp +++ b/test/function/string_functions_test.cpp @@ -26,7 +26,7 @@ using ::testing::Return; namespace peloton { namespace test { -class StringFunctionsTests : public PelotonTest { +class StringFunctionsTests : public PelotonTests { public: StringFunctionsTests() : test_ctx_(nullptr) {} diff --git a/test/function/timestamp_functions_test.cpp b/test/function/timestamp_functions_test.cpp index bfc068708df..03386e67ee7 100644 --- a/test/function/timestamp_functions_test.cpp +++ b/test/function/timestamp_functions_test.cpp @@ -30,7 +30,7 @@ namespace peloton { namespace test { -class TimestampFunctionsTests : public PelotonTest {}; +class TimestampFunctionsTests : public PelotonTests {}; /** * Helper method for TimestampFunctions::DateTrunc diff --git a/test/gc/garbage_collection_test.cpp b/test/gc/garbage_collection_test.cpp index d3b24b878fc..601b13c2452 100644 --- a/test/gc/garbage_collection_test.cpp +++ b/test/gc/garbage_collection_test.cpp @@ -31,7 +31,7 @@ namespace test { // Garbage Collection Tests //===--------------------------------------------------------------------===// -class GarbageCollectionTests : public PelotonTest {}; +class GarbageCollectionTests : public PelotonTests {}; void UpdateTuple(storage::DataTable *table, const int update_num, const int total_num) { diff --git a/test/gc/transaction_level_gc_manager_test.cpp b/test/gc/transaction_level_gc_manager_test.cpp index cef62e0cf73..42a46a688aa 100644 --- a/test/gc/transaction_level_gc_manager_test.cpp +++ b/test/gc/transaction_level_gc_manager_test.cpp @@ -30,7 +30,7 @@ namespace test { // TransactionContext-Level GC Manager Tests //===--------------------------------------------------------------------===// -class TransactionLevelGCManagerTests : public PelotonTest {}; +class TransactionLevelGCManagerTests : public PelotonTests {}; ResultType UpdateTuple(storage::DataTable *table, const int key) { srand(15721); diff --git a/test/include/codegen/testing_codegen_util.h b/test/include/codegen/testing_codegen_util.h index 8234dfb0d2b..4ea76e96bf4 100644 --- a/test/include/codegen/testing_codegen_util.h +++ b/test/include/codegen/testing_codegen_util.h @@ -45,17 +45,17 @@ using ConstPlanPtr = std::unique_ptr; // the codegen components use. Their ID's are available through the oid_t // enumeration. //===----------------------------------------------------------------------===// -class PelotonCodeGenTest : public PelotonTest { +class PelotonCodeGenTests : public PelotonTests { public: std::string test_db_name = "peloton_codegen"; std::vector test_table_names = {"table1", "table2", "table3", "table4", "table5"}; std::vector test_table_oids; - PelotonCodeGenTest(oid_t tuples_per_tilegroup = DEFAULT_TUPLES_PER_TILEGROUP, - peloton::LayoutType layout_type = LayoutType::ROW); + PelotonCodeGenTests(oid_t tuples_per_tilegroup = DEFAULT_TUPLES_PER_TILEGROUP, + peloton::LayoutType layout_type = LayoutType::ROW); - virtual ~PelotonCodeGenTest(); + virtual ~PelotonCodeGenTests(); // Get the test database storage::Database &GetDatabase() const { return *test_db; } diff --git a/test/include/common/harness.h b/test/include/common/harness.h index 7be32f83164..2282d83b808 100644 --- a/test/include/common/harness.h +++ b/test/include/common/harness.h @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #pragma once #include @@ -33,7 +32,7 @@ namespace peloton { -namespace type{ +namespace type { class AbstractPool; } @@ -102,19 +101,15 @@ void LaunchParallelTest(uint64_t num_threads, Args &&... args) { //===--------------------------------------------------------------------===// // All tests inherit from this class -class PelotonTest : public ::testing::Test { +class PelotonTests : public ::testing::Test { protected: - virtual void SetUp() { - // turn off gc under test mode gc::GCManagerFactory::GetInstance().StopGC(); gc::GCManagerFactory::Configure(0); - } virtual void TearDown() { - // shutdown protocol buf library google::protobuf::ShutdownProtobufLibrary(); diff --git a/test/include/executor/mock_executor.h b/test/include/executor/mock_executor.h index 510df7eec9a..1085ab8299a 100644 --- a/test/include/executor/mock_executor.h +++ b/test/include/executor/mock_executor.h @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #pragma once #include "gmock/gmock.h" diff --git a/test/include/executor/testing_join_util.h b/test/include/executor/testing_join_util.h index 9f03785d439..18d2fdd1a03 100644 --- a/test/include/executor/testing_join_util.h +++ b/test/include/executor/testing_join_util.h @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #pragma once #include diff --git a/test/include/logging/testing_logging_util.h b/test/include/logging/testing_logging_util.h index c2e3eb2c4b6..c6e857c70ba 100644 --- a/test/include/logging/testing_logging_util.h +++ b/test/include/logging/testing_logging_util.h @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "logging/log_manager.h" diff --git a/test/index/art_index_test.cpp b/test/index/art_index_test.cpp index 2e9348bd2c7..ec8cdcd834c 100644 --- a/test/index/art_index_test.cpp +++ b/test/index/art_index_test.cpp @@ -67,7 +67,7 @@ class ArtIndexForTest : public index::ArtIndex { }; // The base test class -class ArtIndexTests : public PelotonTest { +class ArtIndexTests : public PelotonTests { public: ArtIndexTests() : index_(CreateTestIndex()) { GenerateTestInput(1); } diff --git a/test/index/bwtree_index_test.cpp b/test/index/bwtree_index_test.cpp old mode 100755 new mode 100644 index 3be9d9abe6c..6fa7dc84d23 --- a/test/index/bwtree_index_test.cpp +++ b/test/index/bwtree_index_test.cpp @@ -23,7 +23,7 @@ namespace test { // BwTree Index Tests //===--------------------------------------------------------------------===// -class BwTreeIndexTests : public PelotonTest {}; +class BwTreeIndexTests : public PelotonTests {}; TEST_F(BwTreeIndexTests, BasicTest) { TestingIndexUtil::BasicTest(IndexType::BWTREE); @@ -49,7 +49,7 @@ TEST_F(BwTreeIndexTests, MultiThreadedInsertTest) { TestingIndexUtil::MultiThreadedInsertTest(IndexType::BWTREE); } -//TEST_F(BwTreeIndexTests, UniqueKeyMultiThreadedTest) { +// TEST_F(BwTreeIndexTests, UniqueKeyMultiThreadedTest) { // TestingIndexUtil::UniqueKeyMultiThreadedTest(IndexType::BWTREE); //} @@ -61,7 +61,7 @@ TEST_F(BwTreeIndexTests, NonUniqueKeyMultiThreadedStressTest) { TestingIndexUtil::NonUniqueKeyMultiThreadedStressTest(IndexType::BWTREE); } -TEST_F(BwTreeIndexTests, NonUniqueKeyMultiThreadedStressTest2) { +TEST_F(BwTreeIndexTests, NonUniqueKeyMultiThreadedStress2Test) { TestingIndexUtil::NonUniqueKeyMultiThreadedStressTest2(IndexType::BWTREE); } diff --git a/test/index/hybrid_index_test.cpp b/test/index/hybrid_index_test.cpp index 2467882b91a..e48f1ac14cf 100644 --- a/test/index/hybrid_index_test.cpp +++ b/test/index/hybrid_index_test.cpp @@ -52,7 +52,7 @@ namespace peloton { namespace test { namespace hybrid_index_test { -class HybridIndexTests : public PelotonTest {}; +class HybridIndexTests : public PelotonTests {}; static double projectivity = 1.0; static size_t column_count = 4; diff --git a/test/index/index_intskey_test.cpp b/test/index/index_intskey_test.cpp index 98bd5536cdd..1de4d47ad8d 100644 --- a/test/index/index_intskey_test.cpp +++ b/test/index/index_intskey_test.cpp @@ -27,7 +27,7 @@ namespace test { // Index IntsKey Tests //===--------------------------------------------------------------------===// -class IndexIntsKeyTests : public PelotonTest {}; +class IndexIntsKeyTests : public PelotonTests {}; catalog::Schema *key_schema = nullptr; std::unique_ptr tuple_schema(nullptr); @@ -104,8 +104,7 @@ void IndexIntsKeyTestHelper(IndexType index_type, #endif for (int i = 0; i < NUM_TUPLES; i++) { - std::shared_ptr key( - new storage::Tuple(key_schema, true)); + std::shared_ptr key(new storage::Tuple(key_schema, true)); std::shared_ptr item(new ItemPointer(i, i * i)); for (int col_idx = 0; col_idx < (int)col_types.size(); col_idx++) { @@ -224,8 +223,7 @@ TEST_F(IndexIntsKeyTests, IndexIntsKeyTest) { for (type::TypeId type1 : types) { for (type::TypeId type2 : types) { for (type::TypeId type3 : types) { - std::vector col_types = {type0, type1, type2, - type3}; + std::vector col_types = {type0, type1, type2, type3}; IndexIntsKeyTestHelper(index_type, col_types); } } diff --git a/test/index/index_util_test.cpp b/test/index/index_util_test.cpp index 9133fa74172..444f68cfa71 100644 --- a/test/index/index_util_test.cpp +++ b/test/index/index_util_test.cpp @@ -1,434 +1,432 @@ -//===----------------------------------------------------------------------===// -// -// PelotonDB -// -// index_test.cpp -// -// Identification: test/index/index_util_test.cpp -// -// Copyright (c) 2015-16, Carnegie Mellon University Database Group -// -//===----------------------------------------------------------------------===// - -#include "common/harness.h" -#include "gtest/gtest.h" - -#include "common/logger.h" -#include "common/platform.h" -#include "index/index_factory.h" -#include "index/index_util.h" -#include "index/scan_optimizer.h" -#include "storage/tuple.h" - -namespace peloton { -namespace test { - -using namespace index; -using namespace storage; - -class IndexUtilTests : public PelotonTest {}; - -/* - * BuildIndex() - Builds an index with 4 columns - * - * The index has 4 columns as tuple key (A, B, C, D), and three of them - * are indexed: - * - * tuple key: 0 1 2 3 - * index key: 3 0 1 (i.e. the 1st column of index key is the 3rd column of - * tuple key) - */ - -// These two are here since the IndexMetadata object does not claim -// ownership for the two schema objects so they will be not destroyed -// automatically -// -// Put them here to avoid Valgrind warning -static std::unique_ptr tuple_schema = nullptr; - -static index::Index *BuildIndex() { - // Build tuple and key schema - std::vector tuple_column_list{}; - std::vector index_column_list{}; - - // The following key are both in index key and tuple key and they are - // indexed - // The size of the key is: - // integer 4 * 3 = total 12 - - catalog::Column column0(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), "A", - true); - - catalog::Column column1(type::TypeId::VARCHAR, 1024, "B", false); - - // The following twoc constitutes tuple schema but does not appear in index - - catalog::Column column2(type::TypeId::DECIMAL, - type::Type::GetTypeSize(type::TypeId::DECIMAL), "C", - true); - - catalog::Column column3(type::TypeId::INTEGER, - type::Type::GetTypeSize(type::TypeId::INTEGER), "D", - true); - - // Use all four columns to build tuple schema - - tuple_column_list.push_back(column0); - tuple_column_list.push_back(column1); - tuple_column_list.push_back(column2); - tuple_column_list.push_back(column3); - - if (tuple_schema == nullptr) { - tuple_schema.reset(new catalog::Schema(tuple_column_list)); - } - - // Use column 3, 0, 1 to build index key - - index_column_list.push_back(column3); - index_column_list.push_back(column0); - index_column_list.push_back(column1); - - // This will be copied into the key schema as well as into the IndexMetadata - // object to identify indexed columns - std::vector key_attrs = {3, 0, 1}; - - // key schame also needs the mapping relation from index key to tuple key - auto key_schema = new catalog::Schema(index_column_list); - key_schema->SetIndexedColumns(key_attrs); - - // Build index metadata - // - // NOTE: Since here we use a relatively small key (size = 12) - // so index_test is only testing with a certain kind of key - // (most likely, GenericKey) - // - // For testing IntsKey and TupleKey we need more test cases - index::IndexMetadata *index_metadata = new index::IndexMetadata( - "index_util_test", 88888, // Index oid - INVALID_OID, INVALID_OID, IndexType::BWTREE, - IndexConstraintType::DEFAULT, tuple_schema.get(), key_schema, key_attrs, - true); // unique_keys - - // Build index - index::Index *index = index::IndexFactory::GetIndex(index_metadata); - - // Actually this will never be hit since if index creation fails an exception - // would be raised (maybe out of memory would result in a nullptr? Anyway - // leave it here) - EXPECT_TRUE(index != NULL); - - return index; -} - -/* - * FindValueIndexTest() - Tests whether the index util correctly recognizes - * point query - * - * The index configuration is as follows: - * - * tuple key: 0 1 2 3 - * index_key: 3 0 1 - */ -TEST_F(IndexUtilTests, FindValueIndexTest) { - std::unique_ptr index_p(BuildIndex()); - bool ret; - - std::vector> value_index_list{}; - - // Test basic - - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {3, 0, 1}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_TRUE(ret); - value_index_list.clear(); - - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {1, 0, 3}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_TRUE(ret); - value_index_list.clear(); - - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {0, 1, 3}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_TRUE(ret); - value_index_list.clear(); - - // Test whether reconizes if only two columns are matched - - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {0, 1}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_FALSE(ret); - value_index_list.clear(); - - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {3, 0}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_FALSE(ret); - value_index_list.clear(); - - // Test empty - - ret = IndexUtil::FindValueIndex(index_p->GetMetadata(), {}, {}, value_index_list); - EXPECT_FALSE(ret); - value_index_list.clear(); - - // Test redundant conditions - - // This should return false, since the < already defines a lower bound - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {0, 3, 3, 0, 3, 1}, - {ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_FALSE(ret); - value_index_list.clear(); - - // This should return true - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {0, 3, 3, 0, 3, 1}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_LESSTHAN, - ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_TRUE(ret); - value_index_list.clear(); - - // Test duplicated conditions on a single column - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {3, 3, 3}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_EQUAL}, - value_index_list); - EXPECT_FALSE(ret); - value_index_list.clear(); - - // The last test should logically be classified as point query - // but our procedure does not give positive result to reduce - // the complexity - ret = IndexUtil::FindValueIndex( - index_p->GetMetadata(), {3, 0, 1, 0}, - {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_LESSTHANOREQUALTO, - ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_GREATERTHANOREQUALTO}, - value_index_list); - EXPECT_FALSE(ret); - value_index_list.clear(); - - return; -} - -/* - * ConstructBoundaryKeyTest() - Tests ConstructBoundaryKey() function for - * conjunctions - */ -TEST_F(IndexUtilTests, ConstructBoundaryKeyTest) { - std::unique_ptr index_p(BuildIndex()); - - // This is the output variable - std::vector> value_index_list{}; - - std::vector value_list{}; - std::vector tuple_column_id_list{}; - std::vector expr_list{}; - - value_list = { - type::ValueFactory::GetIntegerValue(100).Copy(), - type::ValueFactory::GetIntegerValue(200).Copy(), - type::ValueFactory::GetIntegerValue(50).Copy(), - }; - - tuple_column_id_list = {3, 3, 0}; - - expr_list = { - ExpressionType::COMPARE_GREATERTHAN, - ExpressionType::COMPARE_LESSTHANOREQUALTO, - ExpressionType::COMPARE_GREATERTHANOREQUALTO, - }; - - IndexScanPredicate isp{}; - - isp.AddConjunctionScanPredicate(index_p.get(), value_list, - tuple_column_id_list, expr_list); - - const std::vector &cl = isp.GetConjunctionList(); - - // First check the conjunction has been pushed into the scan predicate object - EXPECT_EQ(cl.size(), 1UL); - - // Then make sure all values have been bound (i.e. no free variable) - EXPECT_EQ(cl[0].GetBindingCount(), 0UL); - - // Check whether the entire predicate is full index scan (should not be) - EXPECT_FALSE(isp.IsFullIndexScan()); - - // Then check the conjunction predicate - EXPECT_FALSE(cl[0].IsFullIndexScan()); - - // Then check whether the conjunction predicate is a point query - EXPECT_FALSE(cl[0].IsPointQuery()); - - LOG_INFO("Low key = %s", cl[0].GetLowKey()->GetInfo().c_str()); - LOG_INFO("High key = %s", cl[0].GetHighKey()->GetInfo().c_str()); - - /////////////////////////////////////////////////////////////////// - // Test the case where there is no optimization that could be done - // - // The condition means first index column does not equal 100 - /////////////////////////////////////////////////////////////////// - - value_list = { - type::ValueFactory::GetIntegerValue(100).Copy(), - }; - - tuple_column_id_list = { - 3, - }; - - expr_list = { - ExpressionType::COMPARE_NOTEQUAL, - }; - - isp.AddConjunctionScanPredicate(index_p.get(), value_list, - tuple_column_id_list, expr_list); - - const std::vector &cl2 = isp.GetConjunctionList(); - - EXPECT_EQ(cl2.size(), 2UL); - EXPECT_EQ(cl2[1].GetBindingCount(), 0UL); - EXPECT_TRUE(isp.IsFullIndexScan()); - EXPECT_TRUE(cl2[1].IsFullIndexScan()); - EXPECT_FALSE(cl2[1].IsPointQuery()); - - /////////////////////////////////////////////////////////////////// - // Test point query and query key - // - // Index key = <100, 50, "Peloton!"> - /////////////////////////////////////////////////////////////////// - - IndexScanPredicate isp2{}; - - value_list = { - type::ValueFactory::GetIntegerValue(100).Copy(), - type::ValueFactory::GetVarcharValue("Peloton!").Copy(), - type::ValueFactory::GetIntegerValue(50).Copy(), - }; - - tuple_column_id_list = {3, 1, 0}; - - expr_list = { - ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, - ExpressionType::COMPARE_EQUAL, - }; - - isp2.AddConjunctionScanPredicate(index_p.get(), value_list, - tuple_column_id_list, expr_list); - - const std::vector &cl3 = isp2.GetConjunctionList(); - - EXPECT_EQ(cl3.size(), 1UL); - EXPECT_EQ(cl3[0].GetBindingCount(), 0UL); - EXPECT_FALSE(isp2.IsFullIndexScan()); - EXPECT_FALSE(cl3[0].IsFullIndexScan()); - EXPECT_TRUE(cl3[0].IsPointQuery()); - - LOG_INFO("Point query key = %s", - cl3[0].GetPointQueryKey()->GetInfo().c_str()); - - /////////////////////////////////////////////////////////////////// - // End of all test cases - /////////////////////////////////////////////////////////////////// - - return; -} - -/* - * BindKeyTest() - Tests binding values onto keys that are not bound - */ -TEST_F(IndexUtilTests, BindKeyTest) { - std::unique_ptr index_p(BuildIndex()); - - // This is the output variable - std::vector> value_index_list{}; - - std::vector value_list{}; - std::vector tuple_column_id_list{}; - std::vector expr_list{}; - - value_list = { - type::ValueFactory::GetParameterOffsetValue(2).Copy(), - type::ValueFactory::GetParameterOffsetValue(0).Copy(), - type::ValueFactory::GetParameterOffsetValue(1).Copy(), - }; - - tuple_column_id_list = {3, 3, 0}; - - expr_list = { - ExpressionType::COMPARE_GREATERTHAN, - ExpressionType::COMPARE_LESSTHANOREQUALTO, - ExpressionType::COMPARE_GREATERTHANOREQUALTO, - }; - - IndexScanPredicate isp{}; - - isp.AddConjunctionScanPredicate(index_p.get(), value_list, - tuple_column_id_list, expr_list); - - const std::vector &cl = isp.GetConjunctionList(); - - /////////////////////////////////////////////////////////////////// - // Test bind for range query - /////////////////////////////////////////////////////////////////// - - // Basic check to avoid surprise in later tests - EXPECT_EQ(cl.size(), 1); - EXPECT_FALSE(cl[0].IsPointQuery()); - EXPECT_FALSE(isp.IsFullIndexScan()); - - // There are three unbound values - EXPECT_EQ(cl[0].GetBindingCount(), 3); - - // At this time low key and high key should be binded - // (Note that the type should be also INT but the value is likely to be 0) - LOG_INFO("Low key (NOT BINDED) = %s", cl[0].GetLowKey()->GetInfo().c_str()); - LOG_INFO("High key (NOT BINDED) = %s", cl[0].GetHighKey()->GetInfo().c_str()); - - // Bind real value - type::Value val1 = ( - type::ValueFactory::GetIntegerValue(100).Copy()); - type::Value val2 = ( - type::ValueFactory::GetIntegerValue(200).Copy()); - type::Value val3 = ( - type::ValueFactory::GetIntegerValue(300).Copy()); - isp.LateBindValues(index_p.get(), {val1, val2, val3}); - - // This is important - Since binding does not change the number of - // binding points, and their information is preserved for next - // binding - EXPECT_EQ(cl[0].GetBindingCount(), 3); - - // At this time low key and high key should be binded - LOG_INFO("Low key = %s", cl[0].GetLowKey()->GetInfo().c_str()); - LOG_INFO("High key = %s", cl[0].GetHighKey()->GetInfo().c_str()); - - /////////////////////////////////////////////////////////////////// - // End of all tests - /////////////////////////////////////////////////////////////////// - - return; -} - -} // namespace test -} // namespace peloton +//===----------------------------------------------------------------------===// +// +// PelotonDB +// +// index_test.cpp +// +// Identification: test/index/index_util_test.cpp +// +// Copyright (c) 2015-16, Carnegie Mellon University Database Group +// +//===----------------------------------------------------------------------===// + +#include "common/harness.h" +#include "gtest/gtest.h" + +#include "common/logger.h" +#include "common/platform.h" +#include "index/index_factory.h" +#include "index/index_util.h" +#include "index/scan_optimizer.h" +#include "storage/tuple.h" + +namespace peloton { +namespace test { + +using namespace index; +using namespace storage; + +class IndexUtilTests : public PelotonTests {}; + +/* + * BuildIndex() - Builds an index with 4 columns + * + * The index has 4 columns as tuple key (A, B, C, D), and three of them + * are indexed: + * + * tuple key: 0 1 2 3 + * index key: 3 0 1 (i.e. the 1st column of index key is the 3rd column of + * tuple key) + */ + +// These two are here since the IndexMetadata object does not claim +// ownership for the two schema objects so they will be not destroyed +// automatically +// +// Put them here to avoid Valgrind warning +static std::unique_ptr tuple_schema = nullptr; + +static index::Index *BuildIndex() { + // Build tuple and key schema + std::vector tuple_column_list{}; + std::vector index_column_list{}; + + // The following key are both in index key and tuple key and they are + // indexed + // The size of the key is: + // integer 4 * 3 = total 12 + + catalog::Column column0(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + + catalog::Column column1(type::TypeId::VARCHAR, 1024, "B", false); + + // The following twoc constitutes tuple schema but does not appear in index + + catalog::Column column2(type::TypeId::DECIMAL, + type::Type::GetTypeSize(type::TypeId::DECIMAL), "C", + true); + + catalog::Column column3(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "D", + true); + + // Use all four columns to build tuple schema + + tuple_column_list.push_back(column0); + tuple_column_list.push_back(column1); + tuple_column_list.push_back(column2); + tuple_column_list.push_back(column3); + + if (tuple_schema == nullptr) { + tuple_schema.reset(new catalog::Schema(tuple_column_list)); + } + + // Use column 3, 0, 1 to build index key + + index_column_list.push_back(column3); + index_column_list.push_back(column0); + index_column_list.push_back(column1); + + // This will be copied into the key schema as well as into the IndexMetadata + // object to identify indexed columns + std::vector key_attrs = {3, 0, 1}; + + // key schame also needs the mapping relation from index key to tuple key + auto key_schema = new catalog::Schema(index_column_list); + key_schema->SetIndexedColumns(key_attrs); + + // Build index metadata + // + // NOTE: Since here we use a relatively small key (size = 12) + // so index_test is only testing with a certain kind of key + // (most likely, GenericKey) + // + // For testing IntsKey and TupleKey we need more test cases + index::IndexMetadata *index_metadata = new index::IndexMetadata( + "index_util_test", 88888, // Index oid + INVALID_OID, INVALID_OID, IndexType::BWTREE, IndexConstraintType::DEFAULT, + tuple_schema.get(), key_schema, key_attrs, + true); // unique_keys + + // Build index + index::Index *index = index::IndexFactory::GetIndex(index_metadata); + + // Actually this will never be hit since if index creation fails an exception + // would be raised (maybe out of memory would result in a nullptr? Anyway + // leave it here) + EXPECT_TRUE(index != NULL); + + return index; +} + +/* + * FindValueIndexTests() - Tests whether the index util correctly recognizes + * point query + * + * The index configuration is as follows: + * + * tuple key: 0 1 2 3 + * index_key: 3 0 1 + */ +TEST_F(IndexUtilTests, FindValueIndexTest) { + std::unique_ptr index_p(BuildIndex()); + bool ret; + + std::vector> value_index_list{}; + + // Test basic + + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {3, 0, 1}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_TRUE(ret); + value_index_list.clear(); + + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {1, 0, 3}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_TRUE(ret); + value_index_list.clear(); + + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {0, 1, 3}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_TRUE(ret); + value_index_list.clear(); + + // Test whether reconizes if only two columns are matched + + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {0, 1}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_FALSE(ret); + value_index_list.clear(); + + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {3, 0}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_FALSE(ret); + value_index_list.clear(); + + // Test empty + + ret = IndexUtil::FindValueIndex(index_p->GetMetadata(), {}, {}, + value_index_list); + EXPECT_FALSE(ret); + value_index_list.clear(); + + // Test redundant conditions + + // This should return false, since the < already defines a lower bound + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {0, 3, 3, 0, 3, 1}, + {ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_FALSE(ret); + value_index_list.clear(); + + // This should return true + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {0, 3, 3, 0, 3, 1}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_LESSTHAN, ExpressionType::COMPARE_LESSTHAN, + ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_TRUE(ret); + value_index_list.clear(); + + // Test duplicated conditions on a single column + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {3, 3, 3}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_EQUAL}, + value_index_list); + EXPECT_FALSE(ret); + value_index_list.clear(); + + // The last test should logically be classified as point query + // but our procedure does not give positive result to reduce + // the complexity + ret = IndexUtil::FindValueIndex( + index_p->GetMetadata(), {3, 0, 1, 0}, + {ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_LESSTHANOREQUALTO, + ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_GREATERTHANOREQUALTO}, + value_index_list); + EXPECT_FALSE(ret); + value_index_list.clear(); + + return; +} + +/* + * ConstructBoundaryKeyTests() - Tests ConstructBoundaryKey() function for + * conjunctions + */ +TEST_F(IndexUtilTests, ConstructBoundaryKeyTest) { + std::unique_ptr index_p(BuildIndex()); + + // This is the output variable + std::vector> value_index_list{}; + + std::vector value_list{}; + std::vector tuple_column_id_list{}; + std::vector expr_list{}; + + value_list = { + type::ValueFactory::GetIntegerValue(100).Copy(), + type::ValueFactory::GetIntegerValue(200).Copy(), + type::ValueFactory::GetIntegerValue(50).Copy(), + }; + + tuple_column_id_list = {3, 3, 0}; + + expr_list = { + ExpressionType::COMPARE_GREATERTHAN, + ExpressionType::COMPARE_LESSTHANOREQUALTO, + ExpressionType::COMPARE_GREATERTHANOREQUALTO, + }; + + IndexScanPredicate isp{}; + + isp.AddConjunctionScanPredicate(index_p.get(), value_list, + tuple_column_id_list, expr_list); + + const std::vector &cl = isp.GetConjunctionList(); + + // First check the conjunction has been pushed into the scan predicate object + EXPECT_EQ(cl.size(), 1UL); + + // Then make sure all values have been bound (i.e. no free variable) + EXPECT_EQ(cl[0].GetBindingCount(), 0UL); + + // Check whether the entire predicate is full index scan (should not be) + EXPECT_FALSE(isp.IsFullIndexScan()); + + // Then check the conjunction predicate + EXPECT_FALSE(cl[0].IsFullIndexScan()); + + // Then check whether the conjunction predicate is a point query + EXPECT_FALSE(cl[0].IsPointQuery()); + + LOG_INFO("Low key = %s", cl[0].GetLowKey()->GetInfo().c_str()); + LOG_INFO("High key = %s", cl[0].GetHighKey()->GetInfo().c_str()); + + /////////////////////////////////////////////////////////////////// + // Test the case where there is no optimization that could be done + // + // The condition means first index column does not equal 100 + /////////////////////////////////////////////////////////////////// + + value_list = { + type::ValueFactory::GetIntegerValue(100).Copy(), + }; + + tuple_column_id_list = { + 3, + }; + + expr_list = { + ExpressionType::COMPARE_NOTEQUAL, + }; + + isp.AddConjunctionScanPredicate(index_p.get(), value_list, + tuple_column_id_list, expr_list); + + const std::vector &cl2 = isp.GetConjunctionList(); + + EXPECT_EQ(cl2.size(), 2UL); + EXPECT_EQ(cl2[1].GetBindingCount(), 0UL); + EXPECT_TRUE(isp.IsFullIndexScan()); + EXPECT_TRUE(cl2[1].IsFullIndexScan()); + EXPECT_FALSE(cl2[1].IsPointQuery()); + + /////////////////////////////////////////////////////////////////// + // Test point query and query key + // + // Index key = <100, 50, "Peloton!"> + /////////////////////////////////////////////////////////////////// + + IndexScanPredicate isp2{}; + + value_list = { + type::ValueFactory::GetIntegerValue(100).Copy(), + type::ValueFactory::GetVarcharValue("Peloton!").Copy(), + type::ValueFactory::GetIntegerValue(50).Copy(), + }; + + tuple_column_id_list = {3, 1, 0}; + + expr_list = { + ExpressionType::COMPARE_EQUAL, ExpressionType::COMPARE_EQUAL, + ExpressionType::COMPARE_EQUAL, + }; + + isp2.AddConjunctionScanPredicate(index_p.get(), value_list, + tuple_column_id_list, expr_list); + + const std::vector &cl3 = isp2.GetConjunctionList(); + + EXPECT_EQ(cl3.size(), 1UL); + EXPECT_EQ(cl3[0].GetBindingCount(), 0UL); + EXPECT_FALSE(isp2.IsFullIndexScan()); + EXPECT_FALSE(cl3[0].IsFullIndexScan()); + EXPECT_TRUE(cl3[0].IsPointQuery()); + + LOG_INFO("Point query key = %s", + cl3[0].GetPointQueryKey()->GetInfo().c_str()); + + /////////////////////////////////////////////////////////////////// + // End of all test cases + /////////////////////////////////////////////////////////////////// + + return; +} + +/* + * BindKeyTests() - Tests binding values onto keys that are not bound + */ +TEST_F(IndexUtilTests, BindKeyTest) { + std::unique_ptr index_p(BuildIndex()); + + // This is the output variable + std::vector> value_index_list{}; + + std::vector value_list{}; + std::vector tuple_column_id_list{}; + std::vector expr_list{}; + + value_list = { + type::ValueFactory::GetParameterOffsetValue(2).Copy(), + type::ValueFactory::GetParameterOffsetValue(0).Copy(), + type::ValueFactory::GetParameterOffsetValue(1).Copy(), + }; + + tuple_column_id_list = {3, 3, 0}; + + expr_list = { + ExpressionType::COMPARE_GREATERTHAN, + ExpressionType::COMPARE_LESSTHANOREQUALTO, + ExpressionType::COMPARE_GREATERTHANOREQUALTO, + }; + + IndexScanPredicate isp{}; + + isp.AddConjunctionScanPredicate(index_p.get(), value_list, + tuple_column_id_list, expr_list); + + const std::vector &cl = isp.GetConjunctionList(); + + /////////////////////////////////////////////////////////////////// + // Test bind for range query + /////////////////////////////////////////////////////////////////// + + // Basic check to avoid surprise in later tests + EXPECT_EQ(cl.size(), 1); + EXPECT_FALSE(cl[0].IsPointQuery()); + EXPECT_FALSE(isp.IsFullIndexScan()); + + // There are three unbound values + EXPECT_EQ(cl[0].GetBindingCount(), 3); + + // At this time low key and high key should be binded + // (Note that the type should be also INT but the value is likely to be 0) + LOG_INFO("Low key (NOT BINDED) = %s", cl[0].GetLowKey()->GetInfo().c_str()); + LOG_INFO("High key (NOT BINDED) = %s", cl[0].GetHighKey()->GetInfo().c_str()); + + // Bind real value + type::Value val1 = (type::ValueFactory::GetIntegerValue(100).Copy()); + type::Value val2 = (type::ValueFactory::GetIntegerValue(200).Copy()); + type::Value val3 = (type::ValueFactory::GetIntegerValue(300).Copy()); + isp.LateBindValues(index_p.get(), {val1, val2, val3}); + + // This is important - Since binding does not change the number of + // binding points, and their information is preserved for next + // binding + EXPECT_EQ(cl[0].GetBindingCount(), 3); + + // At this time low key and high key should be binded + LOG_INFO("Low key = %s", cl[0].GetLowKey()->GetInfo().c_str()); + LOG_INFO("High key = %s", cl[0].GetHighKey()->GetInfo().c_str()); + + /////////////////////////////////////////////////////////////////// + // End of all tests + /////////////////////////////////////////////////////////////////// + + return; +} + +} // namespace test +} // namespace peloton diff --git a/test/index/skiplist_index_test.cpp b/test/index/skiplist_index_test.cpp index 1b8c4864f5f..4a231e77925 100644 --- a/test/index/skiplist_index_test.cpp +++ b/test/index/skiplist_index_test.cpp @@ -23,46 +23,46 @@ namespace test { // SkipList Index Tests //===--------------------------------------------------------------------===// -class SkipListIndexTests : public PelotonTest {}; +class SkipListIndexTests : public PelotonTests {}; TEST_F(SkipListIndexTests, BasicTest) { // TestingIndexUtil::BasicTest(IndexType::SKIPLIST); - EXPECT_EQ(2, 1+1); + EXPECT_EQ(2, 1 + 1); } -//TEST_F(SkipListIndexTests, MultiMapInsertTest) { +// TEST_F(SkipListIndexTests, MultiMapInsertTest) { // TestingIndexUtil::MultiMapInsertTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, UniqueKeyInsertTest) { +// TEST_F(SkipListIndexTests, UniqueKeyInsertTest) { // TestingIndexUtil::UniqueKeyInsertTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, UniqueKeyDeleteTest) { +// TEST_F(SkipListIndexTests, UniqueKeyDeleteTest) { // TestingIndexUtil::UniqueKeyDeleteTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, NonUniqueKeyDeleteTest) { +// TEST_F(SkipListIndexTests, NonUniqueKeyDeleteTest) { // TestingIndexUtil::NonUniqueKeyDeleteTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, MultiThreadedInsertTest) { +// TEST_F(SkipListIndexTests, MultiThreadedInsertTest) { // TestingIndexUtil::MultiThreadedInsertTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, UniqueKeyMultiThreadedTest) { +// TEST_F(SkipListIndexTests, UniqueKeyMultiThreadedTest) { // TestingIndexUtil::UniqueKeyMultiThreadedTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, NonUniqueKeyMultiThreadedTest) { +// TEST_F(SkipListIndexTests, NonUniqueKeyMultiThreadedTest) { // TestingIndexUtil::NonUniqueKeyMultiThreadedTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, NonUniqueKeyMultiThreadedStressTest) { +// TEST_F(SkipListIndexTests, NonUniqueKeyMultiThreadedStressTest) { // TestingIndexUtil::NonUniqueKeyMultiThreadedStressTest(IndexType::SKIPLIST); //} // -//TEST_F(SkipListIndexTests, NonUniqueKeyMultiThreadedStressTest2) { +// TEST_F(SkipListIndexTests, NonUniqueKeyMultiThreadedStressTest2) { // TestingIndexUtil::NonUniqueKeyMultiThreadedStressTest2(IndexType::SKIPLIST); //} diff --git a/test/index/testing_index_util.cpp b/test/index/testing_index_util.cpp old mode 100755 new mode 100644 index d357f6207d7..12c5db42a7c --- a/test/index/testing_index_util.cpp +++ b/test/index/testing_index_util.cpp @@ -140,7 +140,7 @@ void TestingIndexUtil::UniqueKeyDeleteTest(const IndexType index_type) { std::vector location_ptrs; // INDEX - std::unique_ptr index( + std::unique_ptr index( TestingIndexUtil::BuildIndex(index_type, true), DestroyIndex); const catalog::Schema *key_schema = index->GetKeySchema(); @@ -150,12 +150,12 @@ void TestingIndexUtil::UniqueKeyDeleteTest(const IndexType index_type) { LaunchParallelTest(1, TestingIndexUtil::InsertHelper, index.get(), pool, scale_factor); LOG_DEBUG("INDEX VALUE CONTENTS BEFORE DELETE:\n%s", - index::IndexUtil::Debug(index.get()).c_str()); + index::IndexUtil::Debug(index.get()).c_str()); LaunchParallelTest(1, TestingIndexUtil::DeleteHelper, index.get(), pool, scale_factor); LOG_DEBUG("INDEX VALUE CONTENTS AFTER DELETE:\n%s", - index::IndexUtil::Debug(index.get()).c_str()); + index::IndexUtil::Debug(index.get()).c_str()); // Checks std::unique_ptr key0(new storage::Tuple(key_schema, true)); @@ -170,7 +170,7 @@ void TestingIndexUtil::UniqueKeyDeleteTest(const IndexType index_type) { key2->SetValue(1, type::ValueFactory::GetVarcharValue("c"), pool); LOG_DEBUG("INDEX CONTENTS:\n%s", - index::IndexUtil::Debug(index.get()).c_str()); + index::IndexUtil::Debug(index.get()).c_str()); LOG_DEBUG("ScanKey(key0=%s)", key0->GetInfo().c_str()); index->ScanKey(key0.get(), location_ptrs); diff --git a/test/logging/buffer_pool_test.cpp b/test/logging/buffer_pool_test.cpp index 89de8e6cfb8..5e47151b925 100644 --- a/test/logging/buffer_pool_test.cpp +++ b/test/logging/buffer_pool_test.cpp @@ -10,7 +10,6 @@ // // // //===----------------------------------------------------------------------===// - // #include "common/harness.h" // #include "logging/circular_buffer_pool.h" // #include @@ -27,7 +26,8 @@ // class BufferPoolTests : public PelotonTest {}; -// void EnqueueTest(logging::CircularBufferPool *buffer_pool, unsigned int count) { +// void EnqueueTest(logging::CircularBufferPool *buffer_pool, unsigned int +// count) { // for (unsigned int i = 0; i < count; i++) { // std::unique_ptr buf(new logging::LogBuffer(nullptr)); // buf->SetSize(i); @@ -35,7 +35,8 @@ // } // } -// void DequeueTest(logging::CircularBufferPool *buffer_pool, unsigned int count) { +// void DequeueTest(logging::CircularBufferPool *buffer_pool, unsigned int +// count) { // for (unsigned int i = 0; i < count; i++) { // auto buf = std::move(buffer_pool->Get()); // PELOTON_ASSERT(buf); @@ -46,7 +47,8 @@ // void BackendThread(logging::WriteAheadBackendLogger *logger, // unsigned int count) { // for (unsigned int i = 1; i <= count; i++) { -// logging::TransactionRecord begin_record(LOGRECORD_TYPE_TRANSACTION_COMMIT, +// logging::TransactionRecord +// begin_record(LOGRECORD_TYPE_TRANSACTION_COMMIT, // i); // logger->Log(&begin_record); // } @@ -125,9 +127,11 @@ // std::vector columns; -// catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), +// catalog::Column column1(type::TypeId::INTEGER, +// type::Type::GetTypeSize(type::TypeId::INTEGER), // "A", true); -// catalog::Column column2(type::TypeId::VARCHAR, 1024 * 1024 * 20, "B", false); +// catalog::Column column2(type::TypeId::VARCHAR, 1024 * 1024 * 20, "B", +// false); // columns.push_back(column1); // columns.push_back(column2); @@ -140,9 +144,11 @@ // std::string(1024 * 1024 * 20, 'e').c_str()), // testing_pool); -// logging::TupleRecord record(LOGRECORD_TYPE_WAL_TUPLE_INSERT, INITIAL_TXN_ID, +// logging::TupleRecord record(LOGRECORD_TYPE_WAL_TUPLE_INSERT, +// INITIAL_TXN_ID, // INVALID_OID, INVALID_ITEMPOINTER, -// INVALID_ITEMPOINTER, tuple.get(), DEFAULT_DB_ID); +// INVALID_ITEMPOINTER, tuple.get(), +// DEFAULT_DB_ID); // record.SetTuple(tuple.get()); // logging::LogBuffer log_buffer(0); diff --git a/test/logging/checkpoint_test.cpp b/test/logging/checkpoint_test.cpp index 656ec7cfaa5..ea626c0d643 100644 --- a/test/logging/checkpoint_test.cpp +++ b/test/logging/checkpoint_test.cpp @@ -64,7 +64,8 @@ // // TEST_F(CheckpointTests, CheckpointIntegrationTest) { // // logging::LoggingUtil::RemoveDirectory("pl_checkpoint", false); -// // auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); +// // auto &txn_manager = +// concurrency::TransactionManagerFactory::GetInstance(); // // auto txn = txn_manager.BeginTransaction(); // // // Create a table and wrap it in logical tile @@ -74,9 +75,11 @@ // // oid_t default_table_oid = 13; // // // table has 3 tile groups // // storage::DataTable *target_table = -// // TestingExecutorUtil::CreateTable(tile_group_size, true, default_table_oid); +// // TestingExecutorUtil::CreateTable(tile_group_size, true, +// default_table_oid); // // TestingExecutorUtil::PopulateTable(target_table, -// // tile_group_size * table_tile_group_count, +// // tile_group_size * +// table_tile_group_count, // // false, false, false, txn); // // txn_manager.CommitTransaction(txn); @@ -97,7 +100,8 @@ // // checkpointer->DoCheckpoint(); -// // auto most_recent_checkpoint_cid = checkpointer->GetMostRecentCheckpointCid(); +// // auto most_recent_checkpoint_cid = +// checkpointer->GetMostRecentCheckpointCid(); // // EXPECT_TRUE(most_recent_checkpoint_cid != INVALID_CID); // // // destroy and restart @@ -119,7 +123,8 @@ // // TEST_F(CheckpointTests, CheckpointScanTest) { // // logging::LoggingUtil::RemoveDirectory("pl_checkpoint", false); -// // auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); +// // auto &txn_manager = +// concurrency::TransactionManagerFactory::GetInstance(); // // auto txn = txn_manager.BeginTransaction(); // // // Create a table and wrap it in logical tile @@ -130,7 +135,8 @@ // // std::unique_ptr target_table( // // TestingExecutorUtil::CreateTable(tile_group_size)); // // TestingExecutorUtil::PopulateTable(target_table.get(), -// // tile_group_size * table_tile_group_count, +// // tile_group_size * +// table_tile_group_count, // // false, false, false, txn); // // txn_manager.CommitTransaction(txn); @@ -191,7 +197,8 @@ // auto tuple = record.GetTuple(); // auto target_location = record.GetInsertLocation(); // // recovery checkpoint from these records -// simple_checkpoint.RecoverTuple(tuple, recovery_table.get(), target_location, +// simple_checkpoint.RecoverTuple(tuple, recovery_table.get(), +// target_location, // DEFAULT_RECOVERY_CID); // } diff --git a/test/logging/log_buffer_pool_test.cpp b/test/logging/log_buffer_pool_test.cpp index a4c4bb56cc5..5acf5685d1b 100644 --- a/test/logging/log_buffer_pool_test.cpp +++ b/test/logging/log_buffer_pool_test.cpp @@ -20,10 +20,9 @@ namespace test { // Log Buffer Pool Tests //===--------------------------------------------------------------------===// -class LogBufferPoolTests : public PelotonTest {}; +class LogBufferPoolTests : public PelotonTests {}; TEST_F(LogBufferPoolTests, PoolTest) { - logging::LogBufferPool log_buffer_pool(1); size_t thread_id = log_buffer_pool.GetThreadId(); @@ -35,16 +34,14 @@ TEST_F(LogBufferPoolTests, PoolTest) { log_buffer_pool.GetBuffer(1); size_t slot_count = log_buffer_pool.GetEmptySlotCount(); - + EXPECT_EQ(slot_count, log_buffer_pool.GetMaxSlotCount() - 1); log_buffer_pool.PutBuffer(std::move(log_buffer)); slot_count = log_buffer_pool.GetEmptySlotCount(); - - EXPECT_EQ(slot_count, log_buffer_pool.GetMaxSlotCount()); + EXPECT_EQ(slot_count, log_buffer_pool.GetMaxSlotCount()); } - } } diff --git a/test/logging/log_buffer_test.cpp b/test/logging/log_buffer_test.cpp index 29b8c7a5a3d..caf8e6ff6f2 100644 --- a/test/logging/log_buffer_test.cpp +++ b/test/logging/log_buffer_test.cpp @@ -20,10 +20,9 @@ namespace test { // Log Buffer Tests //===--------------------------------------------------------------------===// -class LogBufferTests : public PelotonTest {}; +class LogBufferTests : public PelotonTests {}; TEST_F(LogBufferTests, LogBufferTest) { - logging::LogBuffer log_buffer(1, 1); int eid = log_buffer.GetEpochId(); @@ -48,7 +47,7 @@ TEST_F(LogBufferTests, LogBufferTest) { int num = 99; - rt = log_buffer.WriteData((char*)(&num), sizeof(num)); + rt = log_buffer.WriteData((char *)(&num), sizeof(num)); EXPECT_TRUE(rt); @@ -71,8 +70,6 @@ TEST_F(LogBufferTests, LogBufferTest) { size = log_buffer.GetSize(); EXPECT_EQ(size, 0); - } - } } diff --git a/test/logging/log_record_test.cpp b/test/logging/log_record_test.cpp index 7d674a0e922..324bc358d94 100644 --- a/test/logging/log_record_test.cpp +++ b/test/logging/log_record_test.cpp @@ -20,47 +20,39 @@ namespace test { // Log Buffer Tests //===--------------------------------------------------------------------===// -class LogRecordTests : public PelotonTest {}; +class LogRecordTests : public PelotonTests {}; TEST_F(LogRecordTests, LogRecordTest) { - - std::vector tuple_type_list = { - LogRecordType::TUPLE_INSERT, - LogRecordType::TUPLE_DELETE, - LogRecordType::TUPLE_UPDATE - }; + std::vector tuple_type_list = {LogRecordType::TUPLE_INSERT, + LogRecordType::TUPLE_DELETE, + LogRecordType::TUPLE_UPDATE}; for (auto type : tuple_type_list) { - logging::LogRecord tuple_record = + logging::LogRecord tuple_record = logging::LogRecordFactory::CreateTupleRecord(type, ItemPointer(0, 0)); EXPECT_EQ(tuple_record.GetType(), type); } - + std::vector txn_type_list = { - LogRecordType::TRANSACTION_BEGIN, - LogRecordType::TRANSACTION_COMMIT - }; + LogRecordType::TRANSACTION_BEGIN, LogRecordType::TRANSACTION_COMMIT}; for (auto type : txn_type_list) { - logging::LogRecord txn_record = + logging::LogRecord txn_record = logging::LogRecordFactory::CreateTxnRecord(type, 50); EXPECT_EQ(txn_record.GetType(), type); } - std::vector epoch_type_list = { - LogRecordType::EPOCH_BEGIN, - LogRecordType::EPOCH_END - }; + std::vector epoch_type_list = {LogRecordType::EPOCH_BEGIN, + LogRecordType::EPOCH_END}; for (auto type : epoch_type_list) { - logging::LogRecord epoch_record = + logging::LogRecord epoch_record = logging::LogRecordFactory::CreateEpochRecord(type, 100); EXPECT_EQ(epoch_record.GetType(), type); } } - } } diff --git a/test/logging/logging_util_test.cpp b/test/logging/logging_util_test.cpp index 91f30aa6fff..aee7e4f2006 100644 --- a/test/logging/logging_util_test.cpp +++ b/test/logging/logging_util_test.cpp @@ -10,7 +10,6 @@ // // // //===----------------------------------------------------------------------===// - // #include "common/harness.h" // #include "logging/logging_util.h" diff --git a/test/logging/new_checkpointing_test.cpp b/test/logging/new_checkpointing_test.cpp index b16ea56471c..21a9e096fcf 100644 --- a/test/logging/new_checkpointing_test.cpp +++ b/test/logging/new_checkpointing_test.cpp @@ -20,14 +20,13 @@ namespace test { // Checkpointing Tests //===--------------------------------------------------------------------===// -class NewCheckpointingTests : public PelotonTest {}; +class NewCheckpointingTests : public PelotonTests {}; TEST_F(NewCheckpointingTests, MyTest) { auto &checkpoint_manager = logging::CheckpointManagerFactory::GetInstance(); checkpoint_manager.Reset(); - + EXPECT_TRUE(true); } - } } diff --git a/test/logging/new_logging_test.cpp b/test/logging/new_logging_test.cpp index 5973af7d475..586e7c336fb 100644 --- a/test/logging/new_logging_test.cpp +++ b/test/logging/new_logging_test.cpp @@ -20,15 +20,13 @@ namespace test { // Logging Tests //===--------------------------------------------------------------------===// -class NewLoggingTests : public PelotonTest {}; +class NewLoggingTests : public PelotonTests {}; TEST_F(NewLoggingTests, MyTest) { auto &log_manager = logging::LogManagerFactory::GetInstance(); log_manager.Reset(); - + EXPECT_TRUE(true); - } - } } diff --git a/test/logging/recovery_test.cpp b/test/logging/recovery_test.cpp index 8e1cd5d2a2f..93093473b0d 100644 --- a/test/logging/recovery_test.cpp +++ b/test/logging/recovery_test.cpp @@ -73,7 +73,8 @@ // // First column is unique in this case // tuple->SetValue(0, // type::ValueFactory::GetIntegerValue( -// TestingExecutorUtil::PopulatedValue(populate_value, 0)), +// TestingExecutorUtil::PopulatedValue(populate_value, +// 0)), // testing_pool); // // In case of random, make sure this column has duplicated values @@ -115,7 +116,8 @@ // cid_t default_delimiter = INVALID_CID; // // XXX: for now hardcode for one logger (suffix 0) -// std::string dir_name = logging::WriteAheadFrontendLogger::wal_directory_path; +// std::string dir_name = +// logging::WriteAheadFrontendLogger::wal_directory_path; // storage::Database *db = new storage::Database(DEFAULT_DB_ID); // catalog->AddDatabase(db); @@ -132,7 +134,8 @@ // logging::LoggingUtil::RemoveDirectory(dir_name.c_str(), false); -// auto status = logging::LoggingUtil::CreateDirectory(dir_name.c_str(), 0700); +// auto status = logging::LoggingUtil::CreateDirectory(dir_name.c_str(), +// 0700); // EXPECT_TRUE(status); // logging::LogManager::GetInstance().SetLogDirectoryName("./"); @@ -141,7 +144,8 @@ // std::to_string(i) + std::string(".log"); // FILE *fp = fopen(file_name.c_str(), "wb"); -// // now set the first 8 bytes to 0 - this is for the max_log id in this file +// // now set the first 8 bytes to 0 - this is for the max_log id in this +// file // fwrite((void *)&default_commit_id, sizeof(default_commit_id), 1, fp); // // now set the next 8 bytes to 0 - this is for the max delimiter in this @@ -181,15 +185,18 @@ // // // is present at the end of this list // // if (i == num_files - 1) { // // CopySerializeOutput output_buffer_delete; -// // records[num_files * tile_group_size + 1].Serialize(output_buffer_delete); +// // records[num_files * tile_group_size + +// 1].Serialize(output_buffer_delete); // // fwrite(records[num_files * tile_group_size + 1].GetMessage(), // // sizeof(char), -// // records[num_files * tile_group_size + 1].GetMessageLength(), fp); +// // records[num_files * tile_group_size + 1].GetMessageLength(), +// fp); // // } // // // Now write commit -// // logging::TransactionRecord record_commit(LOGRECORD_TYPE_TRANSACTION_COMMIT, +// // logging::TransactionRecord +// record_commit(LOGRECORD_TYPE_TRANSACTION_COMMIT, // // i + 2); // // CopySerializeOutput output_buffer_commit; @@ -200,7 +207,8 @@ // // // Now write delimiter // // CopySerializeOutput output_buffer_delim; -// // logging::TransactionRecord record_delim(LOGRECORD_TYPE_ITERATION_DELIMITER, +// // logging::TransactionRecord +// record_delim(LOGRECORD_TYPE_ITERATION_DELIMITER, // // i + 2); // // record_delim.Serialize(output_buffer_delim); @@ -309,16 +317,20 @@ // EXPECT_TRUE(tg_header->GetBeginCommitId(5) <= test_commit_id); // EXPECT_EQ(tg_header->GetEndCommitId(5), MAX_CID); -// type::Value rval0 = (recovery_table->GetTileGroupById(100)->GetValue(5, 0)); +// type::Value rval0 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 0)); // CmpBool cmp0 = (val0.CompareEquals(rval0)); // EXPECT_TRUE(cmp0 == CmpBool::CmpTrue); -// type::Value rval1 = (recovery_table->GetTileGroupById(100)->GetValue(5, 1)); +// type::Value rval1 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 1)); // CmpBool cmp1 = (val1.CompareEquals(rval1)); // EXPECT_TRUE(cmp1 == CmpBool::CmpTrue); -// type::Value rval2 = (recovery_table->GetTileGroupById(100)->GetValue(5, 2)); +// type::Value rval2 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 2)); // CmpBool cmp2 = (val2.CompareEquals(rval2)); // EXPECT_TRUE(cmp2 == CmpBool::CmpTrue); -// type::Value rval3 = (recovery_table->GetTileGroupById(100)->GetValue(5, 3)); +// type::Value rval3 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 3)); // CmpBool cmp3 = (val3.CompareEquals(rval3)); // EXPECT_TRUE(cmp3 == CmpBool::CmpTrue); @@ -363,16 +375,20 @@ // EXPECT_EQ(tg_header->GetEndCommitId(5), MAX_CID); // EXPECT_EQ(tg_header->GetEndCommitId(4), test_commit_id); -// type::Value rval0 = (recovery_table->GetTileGroupById(100)->GetValue(5, 0)); +// type::Value rval0 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 0)); // CmpBool cmp0 = (val0.CompareEquals(rval0)); // EXPECT_TRUE(cmp0 == CmpBool::CmpTrue); -// type::Value rval1 = (recovery_table->GetTileGroupById(100)->GetValue(5, 1)); +// type::Value rval1 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 1)); // CmpBool cmp1 = (val1.CompareEquals(rval1)); // EXPECT_TRUE(cmp1 == CmpBool::CmpTrue); -// type::Value rval2 = (recovery_table->GetTileGroupById(100)->GetValue(5, 2)); +// type::Value rval2 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 2)); // CmpBool cmp2 = (val2.CompareEquals(rval2)); // EXPECT_TRUE(cmp2 == CmpBool::CmpTrue); -// type::Value rval3 = (recovery_table->GetTileGroupById(100)->GetValue(5, 3)); +// type::Value rval3 = (recovery_table->GetTileGroupById(100)->GetValue(5, +// 3)); // CmpBool cmp3 = (val3.CompareEquals(rval3)); // EXPECT_TRUE(cmp3 == CmpBool::CmpTrue); @@ -429,7 +445,8 @@ // cid_t test_commit_id = 10; // auto curr_rec = new logging::TupleRecord( -// LOGRECORD_TYPE_TUPLE_UPDATE, test_commit_id + 1, recovery_table->GetOid(), +// LOGRECORD_TYPE_TUPLE_UPDATE, test_commit_id + 1, +// recovery_table->GetOid(), // INVALID_ITEMPOINTER, ItemPointer(100, 5), nullptr, DEFAULT_DB_ID); // fel.DeleteTuple(curr_rec); // delete curr_rec; diff --git a/test/logging/testing_logging_util.cpp b/test/logging/testing_logging_util.cpp index e495e32556b..c65634c5983 100644 --- a/test/logging/testing_logging_util.cpp +++ b/test/logging/testing_logging_util.cpp @@ -37,7 +37,8 @@ // records.push_back(record); // } // } -// LOG_TRACE("Built a vector of %lu tuple WAL insert records", records.size()); +// LOG_TRACE("Built a vector of %lu tuple WAL insert records", +// records.size()); // return records; // } @@ -77,14 +78,16 @@ // auto &tuple = tuples[tile_group_size * table_tile_group_count + // out_of_range_tuples + i]; // PELOTON_ASSERT(tuple->GetSchema()); -// logging::TupleRecord record(LOGRECORD_TYPE_WAL_TUPLE_DELETE, 4, INVALID_OID, +// logging::TupleRecord record(LOGRECORD_TYPE_WAL_TUPLE_DELETE, 4, +// INVALID_OID, // INVALID_ITEMPOINTER, location, nullptr, // DEFAULT_DB_ID); // record.SetTuple(tuple.get()); // records.push_back(record); // } -// LOG_TRACE("Built a vector of %lu tuple WAL insert records", records.size()); +// LOG_TRACE("Built a vector of %lu tuple WAL insert records", +// records.size()); // return records; // } @@ -107,12 +110,14 @@ // int populate_value = rowid; // if (mutate) populate_value *= 3; -// std::shared_ptr tuple(new storage::Tuple(schema, allocate)); +// std::shared_ptr tuple(new storage::Tuple(schema, +// allocate)); // // First column is unique in this case // tuple->SetValue(0, // type::ValueFactory::GetIntegerValue( -// TestingExecutorUtil::PopulatedValue(populate_value, 0)), +// TestingExecutorUtil::PopulatedValue(populate_value, +// 0)), // testing_pool); // // In case of random, make sure this column has duplicated values @@ -226,7 +231,8 @@ // } // case LOGGING_OP_INSERT: { // LOG_TRACE("Execute Insert txn %d", (int)cid); -// auto tuple = TestingLoggingUtil::BuildTuples(table, 1, false, false)[0]; +// auto tuple = TestingLoggingUtil::BuildTuples(table, 1, false, +// false)[0]; // std::unique_ptr tuple_record( // backend_logger->GetTupleRecord(LOGRECORD_TYPE_TUPLE_INSERT, cid, 1, // DEFAULT_DB_ID, INVALID_ITEMPOINTER, @@ -237,7 +243,8 @@ // } // case LOGGING_OP_UPDATE: { // LOG_TRACE("Execute Update txn %d", (int)cid); -// auto tuple = TestingLoggingUtil::BuildTuples(table, 1, false, false)[0]; +// auto tuple = TestingLoggingUtil::BuildTuples(table, 1, false, +// false)[0]; // std::unique_ptr tuple_record( // backend_logger->GetTupleRecord(LOGRECORD_TYPE_TUPLE_UPDATE, cid, 1, // DEFAULT_DB_ID, INVALID_ITEMPOINTER, @@ -248,7 +255,8 @@ // } // case LOGGING_OP_DELETE: { // LOG_TRACE("Execute Delete txn %d", (int)cid); -// auto tuple = TestingLoggingUtil::BuildTuples(table, 1, false, false)[0]; +// auto tuple = TestingLoggingUtil::BuildTuples(table, 1, false, +// false)[0]; // std::unique_ptr tuple_record( // backend_logger->GetTupleRecord(LOGRECORD_TYPE_TUPLE_DELETE, cid, 1, // DEFAULT_DB_ID, INVALID_ITEMPOINTER, @@ -264,7 +272,8 @@ // } // case LOGGING_OP_COMMIT: { // LOG_TRACE("Execute Commit txn %d", (int)cid); -// std::unique_ptr record(new logging::TransactionRecord( +// std::unique_ptr record(new +// logging::TransactionRecord( // LOGRECORD_TYPE_TRANSACTION_COMMIT, cid)); // PELOTON_ASSERT(backend_logger); // backend_logger->Log(record.get()); @@ -272,7 +281,8 @@ // } // case LOGGING_OP_ABORT: { // LOG_TRACE("Execute Abort txn %d", (int)cid); -// std::unique_ptr record(new logging::TransactionRecord( +// std::unique_ptr record(new +// logging::TransactionRecord( // LOGRECORD_TYPE_TRANSACTION_ABORT, cid)); // PELOTON_ASSERT(backend_logger); // backend_logger->Log(record.get()); @@ -334,7 +344,8 @@ // } // for (unsigned int i = 0; // i < num_frontend_logger * num_backend_logger_per_frontend; i++) { -// backend_threads.emplace_back(&backend_schedules[i], log_manager, i, table, +// backend_threads.emplace_back(&backend_schedules[i], log_manager, i, +// table, // i % num_backend_logger_per_frontend); // } diff --git a/test/logging/write_behind_logging_test.cpp b/test/logging/write_behind_logging_test.cpp index 18fdca7d20d..e0d2fa0d39a 100644 --- a/test/logging/write_behind_logging_test.cpp +++ b/test/logging/write_behind_logging_test.cpp @@ -10,7 +10,6 @@ // // // //===----------------------------------------------------------------------===// - // #include "executor/testing_executor_util.h" // #include "logging/testing_logging_util.h" // #include "common/harness.h" @@ -42,8 +41,10 @@ // } // } -// // not sure the best way to test this, so I will spawn a new thread to bump up the grant every 10 ms -// // and ensure enough time has passed by the end of the test (we are not prematurely +// // not sure the best way to test this, so I will spawn a new thread to bump +// up the grant every 10 ms +// // and ensure enough time has passed by the end of the test (we are not +// prematurely // // allowing transactions to continue with unsanctioned cids // TEST_F(WriteBehindLoggingTests, BasicGrantTest) { // auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); @@ -58,7 +59,6 @@ // EXPECT_TRUE(end-begin > min_expected_dur); // granting_thread.join(); - // } // */ @@ -89,12 +89,14 @@ // //check the visibility // // TEST_F(WriteBehindLoggingTests, DirtyRangeVisibilityTest) { -// // auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); +// // auto &txn_manager = +// concurrency::TransactionManagerFactory::GetInstance(); // // auto &catalog_manager = catalog::Manager::GetInstance(); // // ItemPointer *index_entry_ptr = nullptr; -// // std::unique_ptr table(TestingExecutorUtil::CreateTable()); +// // std::unique_ptr +// table(TestingExecutorUtil::CreateTable()); // // auto pool = TestingHarness::GetInstance().GetTestingPool(); // // txn_manager.SetNextCid(1); @@ -112,23 +114,25 @@ // // auto visible2 = table->InsertTuple(tuple.get(), txn, &index_entry_ptr); // // txn_manager.PerformInsert(txn, visible2, index_entry_ptr); // // txn_manager.CommitTransaction(txn); - + // // // got cid 3 // // txn = txn_manager.BeginTransaction(); // // tuple = TestingExecutorUtil::GetTuple(table.get(), 3, pool); // // index_entry_ptr = nullptr; -// // auto invisible1 = table->InsertTuple(tuple.get(), txn, &index_entry_ptr); +// // auto invisible1 = table->InsertTuple(tuple.get(), txn, +// &index_entry_ptr); // // txn_manager.PerformInsert(txn, invisible1, index_entry_ptr); // // txn_manager.CommitTransaction(txn); - + // // // got cid 4 // // txn = txn_manager.BeginTransaction(); // // tuple = TestingExecutorUtil::GetTuple(table.get(), 4, pool); // // index_entry_ptr = nullptr; -// // auto invisible2 = table->InsertTuple(tuple.get(), txn, &index_entry_ptr); +// // auto invisible2 = table->InsertTuple(tuple.get(), txn, +// &index_entry_ptr); // // txn_manager.PerformInsert(txn, invisible2, index_entry_ptr); // // txn_manager.CommitTransaction(txn); - + // // // got cid 5 // // txn = txn_manager.BeginTransaction(); // // tuple = TestingExecutorUtil::GetTuple(table.get(), 5, pool); @@ -136,7 +140,7 @@ // // auto visible3 = table->InsertTuple(tuple.get(), txn, &index_entry_ptr); // // txn_manager.PerformInsert(txn, visible3, index_entry_ptr); // // txn_manager.CommitTransaction(txn); - + // // // got cid 6 // // std::vector column_ids; // // column_ids.push_back(0); @@ -145,24 +149,43 @@ // // column_ids.push_back(3); // // txn = txn_manager.BeginTransaction(); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(visible1.block)->GetHeader(), visible1.offset) == VisibilityType::OK); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(visible2.block)->GetHeader(), visible2.offset) == VisibilityType::OK); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(invisible1.block)->GetHeader(), invisible1.offset) == VisibilityType::OK); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(invisible2.block)->GetHeader(), invisible2.offset) == VisibilityType::OK); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(visible3.block)->GetHeader(), visible3.offset) == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(visible1.block)->GetHeader(), visible1.offset) +// == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(visible2.block)->GetHeader(), visible2.offset) +// == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(invisible1.block)->GetHeader(), +// invisible1.offset) == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(invisible2.block)->GetHeader(), +// invisible2.offset) == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(visible3.block)->GetHeader(), visible3.offset) +// == VisibilityType::OK); // // txn_manager.AbortTransaction(txn); // // txn_manager.SetDirtyRange(std::make_pair(2, 4)); // // txn = txn_manager.BeginTransaction(); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(visible1.block)->GetHeader(), visible1.offset) == VisibilityType::OK); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(visible2.block)->GetHeader(), visible2.offset) == VisibilityType::OK); -// // EXPECT_FALSE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(invisible1.block)->GetHeader(), invisible1.offset) == VisibilityType::OK); -// // EXPECT_FALSE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(invisible2.block)->GetHeader(), invisible2.offset) == VisibilityType::OK); -// // EXPECT_TRUE(txn_manager.IsVisible(txn, catalog_manager.GetTileGroup(visible3.block)->GetHeader(), visible3.offset) == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(visible1.block)->GetHeader(), visible1.offset) +// == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(visible2.block)->GetHeader(), visible2.offset) +// == VisibilityType::OK); +// // EXPECT_FALSE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(invisible1.block)->GetHeader(), +// invisible1.offset) == VisibilityType::OK); +// // EXPECT_FALSE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(invisible2.block)->GetHeader(), +// invisible2.offset) == VisibilityType::OK); +// // EXPECT_TRUE(txn_manager.IsVisible(txn, +// catalog_manager.GetTileGroup(visible3.block)->GetHeader(), visible3.offset) +// == VisibilityType::OK); // // txn_manager.AbortTransaction(txn); // // } // } // namespace test // } // namespace peloton - diff --git a/test/network/exception_test.cpp b/test/network/exception_test.cpp index 73118f0478e..d546d429973 100644 --- a/test/network/exception_test.cpp +++ b/test/network/exception_test.cpp @@ -31,14 +31,14 @@ namespace test { // Exception Test //===--------------------------------------------------------------------===// -class ExceptionTests : public PelotonTest {}; +class ExceptionTests : public PelotonTests {}; void *ExecutorExceptionTest(int port) { try { - pqxx::connection C(StringUtil::Format( - "host=127.0.0.1 port=%d user=default_database " - "sslmode=disable application_name=psql", - port)); + pqxx::connection C( + StringUtil::Format("host=127.0.0.1 port=%d user=default_database " + "sslmode=disable application_name=psql", + port)); int exception_count = 0; pqxx::work txn1(C); try { @@ -69,10 +69,10 @@ void *ExecutorExceptionTest(int port) { void *ParserExceptionTest(int port) { try { // forcing the factory to generate psql protocol handler - pqxx::connection C(StringUtil::Format( - "host=127.0.0.1 port=%d user=default_database " - "sslmode=disable application_name=psql", - port)); + pqxx::connection C( + StringUtil::Format("host=127.0.0.1 port=%d user=default_database " + "sslmode=disable application_name=psql", + port)); peloton::network::ConnectionHandle *conn = peloton::network::ConnectionHandleFactory::GetInstance() diff --git a/test/network/network_address_test.cpp b/test/network/network_address_test.cpp index a78b0e40b29..1f0e280cee6 100644 --- a/test/network/network_address_test.cpp +++ b/test/network/network_address_test.cpp @@ -19,7 +19,7 @@ namespace peloton { namespace test { -class NetworkAddressTests : public PelotonTest {}; +class NetworkAddressTests : public PelotonTests {}; TEST_F(NetworkAddressTests, ParseTest) { // Valid address @@ -33,7 +33,8 @@ TEST_F(NetworkAddressTests, ParseTest) { // Invalid address ip = "The terrier has diarrhea"; address = StringUtil::Format("%s:%d", ip.c_str(), port); - ASSERT_THROW(new network::service::NetworkAddress(address), peloton::Exception); + ASSERT_THROW(new network::service::NetworkAddress(address), + peloton::Exception); } } } diff --git a/test/network/prepare_stmt_test.cpp b/test/network/prepare_stmt_test.cpp index 3e11472dd54..6d96a96af1b 100644 --- a/test/network/prepare_stmt_test.cpp +++ b/test/network/prepare_stmt_test.cpp @@ -26,7 +26,7 @@ namespace test { // Prepare Stmt Tests //===--------------------------------------------------------------------===// -class PrepareStmtTests : public PelotonTest {}; +class PrepareStmtTests : public PelotonTests {}; /** * named prepare statement without parameters @@ -42,12 +42,14 @@ void *PrepareStatementTest(int port) { pqxx::work txn1(C); peloton::network::ConnectionHandle *conn = - peloton::network::ConnectionHandleFactory::GetInstance().ConnectionHandleAt( - peloton::network::PelotonServer::recent_connfd).get(); + peloton::network::ConnectionHandleFactory::GetInstance() + .ConnectionHandleAt(peloton::network::PelotonServer::recent_connfd) + .get(); - //Check type of protocol handler - network::PostgresProtocolHandler* handler = - dynamic_cast(conn->GetProtocolHandler().get()); + // Check type of protocol handler + network::PostgresProtocolHandler *handler = + dynamic_cast( + conn->GetProtocolHandler().get()); EXPECT_NE(handler, nullptr); @@ -80,7 +82,6 @@ void *PrepareStatementTest(int port) { } TEST_F(PrepareStmtTests, PrepareStatementTest) { - peloton::PelotonInit::Initialize(); LOG_INFO("Server initialized"); peloton::network::PelotonServer server; diff --git a/test/network/rpc_client_test.cpp b/test/network/rpc_client_test.cpp index ffd945049a8..ebd7a70164f 100644 --- a/test/network/rpc_client_test.cpp +++ b/test/network/rpc_client_test.cpp @@ -25,7 +25,7 @@ namespace peloton { namespace test { -class RpcClientTests : public PelotonTest {}; +class RpcClientTests : public PelotonTests {}; TEST_F(RpcClientTests, BasicTest) { // FIXME: If we comment out the entire test case, then there'll be some static @@ -73,7 +73,8 @@ TEST_F(RpcClientTests, BasicTest) { // copy the hashcode into the buf, following the header PELOTON_ASSERT(OPCODELEN == sizeof(opcode)); - PELOTON_MEMCPY(buf + sizeof(msg_len) + sizeof(type), &opcode, sizeof(opcode)); + PELOTON_MEMCPY(buf + sizeof(msg_len) + sizeof(type), &opcode, + sizeof(opcode)); // call protobuf to serialize the request message into sending buf request.SerializeToArray( diff --git a/test/network/rpc_queryplan_test.cpp b/test/network/rpc_queryplan_test.cpp index cb11891a1db..bd67dae0603 100644 --- a/test/network/rpc_queryplan_test.cpp +++ b/test/network/rpc_queryplan_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "network/service/rpc_server.h" #include "network/service/peloton_service.h" @@ -19,7 +18,7 @@ namespace peloton { namespace test { -class RpcQueryPlanTests : public PelotonTest {}; +class RpcQueryPlanTests : public PelotonTests {}; TEST_F(RpcQueryPlanTests, BasicTest) { peloton::planner::SeqScanPlan mapped_plan_ptr; diff --git a/test/network/rpc_server_test.cpp b/test/network/rpc_server_test.cpp index adaa3329471..808fcee8089 100644 --- a/test/network/rpc_server_test.cpp +++ b/test/network/rpc_server_test.cpp @@ -17,7 +17,7 @@ namespace peloton { namespace test { -class RpcServerTests : public PelotonTest {}; +class RpcServerTests : public PelotonTests {}; TEST_F(RpcServerTests, BasicTest) { // FIXME: If we comment out the entire test case, then there'll be some static diff --git a/test/network/select_all_test.cpp b/test/network/select_all_test.cpp index 786cb71d2ef..07e5064238d 100644 --- a/test/network/select_all_test.cpp +++ b/test/network/select_all_test.cpp @@ -27,25 +27,30 @@ namespace test { // Select All Tests //===--------------------------------------------------------------------===// -class SelectAllTests : public PelotonTest {}; +class SelectAllTests : public PelotonTests {}; /** * Select All Test - * In this test, peloton will return the result that exceeds the 8192 bytes limits. + * In this test, peloton will return the result that exceeds the 8192 bytes + * limits. * The response will be put into multiple packets and be sent back to clients. */ void *SelectAllTest(int port) { try { // forcing the factory to generate psql protocol handler - pqxx::connection C(StringUtil::Format( - "host=127.0.0.1 port=%d user=default_database sslmode=disable application_name=psql", port)); + pqxx::connection C( + StringUtil::Format("host=127.0.0.1 port=%d user=default_database " + "sslmode=disable application_name=psql", + port)); pqxx::work txn1(C); peloton::network::ConnectionHandle *conn = - peloton::network::ConnectionHandleFactory::GetInstance().ConnectionHandleAt( - peloton::network::PelotonServer::recent_connfd).get(); + peloton::network::ConnectionHandleFactory::GetInstance() + .ConnectionHandleAt(peloton::network::PelotonServer::recent_connfd) + .get(); network::PostgresProtocolHandler *handler = - dynamic_cast(conn->GetProtocolHandler().get()); + dynamic_cast( + conn->GetProtocolHandler().get()); EXPECT_NE(handler, nullptr); // create table and insert some data @@ -96,5 +101,5 @@ TEST_F(SelectAllTests, SelectAllTest) { LOG_INFO("Peloton has shut down"); } -} // namespace test -} // namespace peloton +} // namespace test +} // namespace peloton diff --git a/test/network/simple_query_test.cpp b/test/network/simple_query_test.cpp index eb728e3fd6e..a01c7df2ee4 100644 --- a/test/network/simple_query_test.cpp +++ b/test/network/simple_query_test.cpp @@ -29,7 +29,7 @@ namespace test { // Simple Query Tests //===--------------------------------------------------------------------===// -class SimpleQueryTests : public PelotonTest {}; +class SimpleQueryTests : public PelotonTests {}; /** * Simple select query test @@ -37,16 +37,20 @@ class SimpleQueryTests : public PelotonTest {}; void *SimpleQueryTest(int port) { try { // forcing the factory to generate psql protocol handler - pqxx::connection C(StringUtil::Format( - "host=127.0.0.1 port=%d user=default_database sslmode=disable application_name=psql", port)); + pqxx::connection C( + StringUtil::Format("host=127.0.0.1 port=%d user=default_database " + "sslmode=disable application_name=psql", + port)); pqxx::work txn1(C); peloton::network::ConnectionHandle *conn = - peloton::network::ConnectionHandleFactory::GetInstance().ConnectionHandleAt( - peloton::network::PelotonServer::recent_connfd).get(); + peloton::network::ConnectionHandleFactory::GetInstance() + .ConnectionHandleAt(peloton::network::PelotonServer::recent_connfd) + .get(); network::PostgresProtocolHandler *handler = - dynamic_cast(conn->GetProtocolHandler().get()); + dynamic_cast( + conn->GetProtocolHandler().get()); EXPECT_NE(handler, nullptr); // EXPECT_EQ(conn->state, peloton::network::READ); diff --git a/test/network/ssl/root_test.crt b/test/network/ssl/root_test.crt new file mode 100644 index 00000000000..005cd7e216b --- /dev/null +++ b/test/network/ssl/root_test.crt @@ -0,0 +1,62 @@ +-----BEGIN CERTIFICATE----- +MIIFVDCCAzygAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwLzELMAkGA1UEBhMCVVMx +CzAJBgNVBAgMAlBBMRMwEQYDVQQKDApQaXR0c2J1cmdoMB4XDTE3MTEyNzA0NDkx +NloXDTI3MTEyNTA0NDkxNlowQzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAlBBMRMw +EQYDVQQKDApQaXR0c2J1cmdoMRIwEAYDVQQDDAlsb2NhbGhvc3QwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQDVoaVhpg15X9mMDhPeID3nR1Q7iEoZ4YW/ +V6fUexKb0TsLL60xN4xIQFbmaTqc1tdHXEo84/60YyZdmQNOT3c4rqxEUctl7WUx +fewGdUz26oQvffPj5aNdCNLJH6mjFUVC6AJh/R/gEwohQ5iNZzKDavrwXziBkREm +9+rNm7U/sO9yubaYyRMRfWvhK9yQKyXd2XJAiigwSjAoeecDMfgAeLggBvXhlqQm +SYjn/qvB1O698vJW8ofzuYR2QQudQWCJ8afSGxXa+65+qEgfOW840ngIXZi8wU5W +d+ztkF1xZ0KYIVs0/3pjPjaiK1A5cnigQCksQNzCsp9FsRCo+4aCvjFnsXUKgyp+ +NDBa6SwAwQWi8ILax/hdK+FeEmRg4zT8x+Mc1WRS0H9rgUPyI1RtsL1oxyD+Xfk5 +xJpsOKnIvO6iXxMP0pPHGhZB7/3sBQlPe/OT1mMQbUOLDyyBW3mQtGDyQiVzeNgW +PVvqkNwLQdhlbnJsdS4ZSUc/EyP7nzPb96ggUXp8VXdnkzbG+J8VGIGIt1XLRO8B +5Qtup1X6iNabxwaCZf7V3OHyi5kOdLOuUDftTktkNz4xnR/CBbLve4kmNF7bIRKP +OISIybmhQTfKzbbaEIg1XFnDSNiYbTPJ4RXevamJk4bLRgBAb4LPzxFe5nlKunEG +5gA9nFy9mwIDAQABo2YwZDAdBgNVHQ4EFgQUcaiV27VZxpt1EyoACYkD+5uq16sw +HwYDVR0jBBgwFoAUml+q/zwADx4o3JT6nSDKKJ4WgwIwEgYDVR0TAQH/BAgwBgEB +/wIBADAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAFZHqxup+0g6 +qqibE9zHkFmmeLva9ffRbC8ySbXIh9Hgg2kLoamt33JSwuj/MNVVLA8nZGCJHYkU +8tZEvAPopRMQ7hyQGK6LtVLKtdlCAL0jazKRyGoS+GBCVawcvJHYsNtiU9whbcqj +Or2yLd4kLdNNtSKcx+/gH557ii6x/YNAWfI/11xMv7xKFi4QSL/vMGQbnu94gliU +tDyeprtW1ws86jHiVUqqJY3lsL/haWh+gxPh1FFHp9SkjVsur6omMMzXuPYbw9U0 +NBDzcAOlk6XdnzWcya+sRoaLzhuYB3F5ySVr0+h8Cbz68wcEbdr7Qb1yebxeRhTL +L3+8hG4xkobuJWfO+Eog1eGO7F2Tx1dhJFH3nQMeN60j/r4r7u5htuHG2nR86PKW +uz7lJ7qShgS+YhznkWwaDDYlfbapmboNprcoI76T+akxMnplEVPZH8jRTLGlz1gg +lflUbEYCRbbQFzqIe7B3CEiPIFLbuzZX9w4zby5R8STDWXIP7aFVenZNEAay5fXJ +9F8AVh80x/DlQgW/vVGHcjfO0geUmryDNrTNJZ/bHUOUZRI4SzWMxTot5N/7bqIH +C4R2c8Zr4P40kJDUjA0+EKF4UBQhikqZoWM55Nk3XG6gu+QCl7RPZ7EdgesXzaPD +G2RPoc39jiSfszDWG+9mUNJSEi4FSvAD +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIFRDCCAyygAwIBAgIJANZJppsmJe2MMA0GCSqGSIb3DQEBCwUAMC8xCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJQQTETMBEGA1UECgwKUGl0dHNidXJnaDAeFw0xNzEx +MjcwNDQ3MjZaFw0zNzExMjIwNDQ3MjZaMC8xCzAJBgNVBAYTAlVTMQswCQYDVQQI +DAJQQTETMBEGA1UECgwKUGl0dHNidXJnaDCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAKcAnqx7R43Bv4hLl2SRVwAotJlI9424kCKTmRkutDNO5lHRIK43 +YczGiH3pNw3qWdh8OBQvtiKh7BKRebIXeEK3VUd8Es0Ds2Ih+91uE8UJTxbcUiZb +ElyXmzTAAYorin3QmwDFYYC9TXtZ7nCHgS0thcC5mHK9pOuDM10c7ShWHDnvwOWn +Y591VrPpYg0IN4j1aQVyNsFqf89Z+6obGEZFWiso+FA3IVfD5lBZCRZ6aXVkVAMr +zzG6Z0xVwoI/XPMna5mbZIHmJMTTXJqfAkudoKZGXM0EbwO0xRA92CEp6VmNtBUr +hF93M9r+dFjurxIysI2ZUn6ikGJ3ilxl+PAury5s4cMCIqTkyvxhgytMRUP8YRJe +fZXBEHzXm/IWA8ywm6vuGL7MA0yLusvC18JOytGlBuhrvFuUHanpjU8Qxkb4pAZc +P6xKesvwtpOatZiHbPIflHQ8/28cTnLXjQq9f4wsdMKqqL67Ya8YRbBaNzwuFYj1 +8iuaVAEWFiXgS8AAEL8a+vw+FWhCH/OUXu2en7HSFSG3lBfZG3hnUeOv5KrQdbUF +a6E+VraC4MxnbukeM/eIQJqvdEyovBeV7Tkc0WX8MAVZvcv2KD344NOkk4ycQ1Wm +tzNOU7H1JDpBNeAZETUc86sRFzXUhW8+YE0SgI2ztxTxGHdUlw7mn3P7AgMBAAGj +YzBhMB0GA1UdDgQWBBSaX6r/PAAPHijclPqdIMoonhaDAjAfBgNVHSMEGDAWgBSa +X6r/PAAPHijclPqdIMoonhaDAjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE +AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAS/hLt44dbYBcd0e4TQA3F9pAifMdOpbY +xF/bFla1hd5IVCc3c5EPk3n1HpU+8H0KmzId+Z7u311/AWa31xIsCXV/u2XIBz1j +W1Qf0P78odJq4H2fBeyJ40yNf9Rnkm4qNlj1RDpOpqHH7Ihj32J/pzeIM1/lLQ5j +SqNP+unamjmLz0hzBow0Qjrub9Db9hx2Mwv9YjyTjEZxGu1skP/kvqjhueBjxCk6 +Xr6xGN9TaVXoEp4WMypoJutG+yDc2fzk39a+yPGwA7DG+Dd7zcgIY9/UVuhQ5r6v +B+E5ucfvvkpH7tBBnuJE9zVz2H2jquRIHbL26Xa+7GtdJPwIfqgkFv94BIrAvlQo +ceVZKELSd419jUhVMQp5cKaN3ZkSwGrTthUW3TQvG4lJ68uqtB319y4i/tXQbSRr +6+q6FYVISl2kU1JRPaDKVdNLUewwZSJl5XZ4ndt8QQYoXVpd3J2F+IfjfhD3CQnM +ogGWf60cwgYhBNpxb10pyRIFYVBTJ/+mgFaUMKq5fZkwjiPJmsJ5UYb+iK+pYOt0 +N+r343Ci71uLvwLc+jsIJFNERwSM4FLyGiz+zUMjkKI8KTvkFB69kch31sukmQ+f +UO680R71To2QG5T5h6WOnvnc9QiXZ1SGriFWU97+cTekpRlciGOxge2iH4Vz+UIP +FX0KrqS3mT4= +-----END CERTIFICATE----- diff --git a/test/network/ssl/server_test.crt b/test/network/ssl/server_test.crt new file mode 100644 index 00000000000..88781e36291 --- /dev/null +++ b/test/network/ssl/server_test.crt @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIIE9zCCAt+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwQzELMAkGA1UEBhMCVVMx +CzAJBgNVBAgMAlBBMRMwEQYDVQQKDApQaXR0c2J1cmdoMRIwEAYDVQQDDAlsb2Nh +bGhvc3QwHhcNMTcxMTI3MDQ1MDQ3WhcNMTgxMjA3MDQ1MDQ3WjBDMQswCQYDVQQG +EwJVUzELMAkGA1UECAwCUEExEzARBgNVBAoMClBpdHRzYnVyZ2gxEjAQBgNVBAMM +CWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKzK8A0K +KFUHTavU6teEtZ0vaTlXmH8f1dm96uAN8j3wIxvJFEge8bZx6NtOtB7HTgMN6X00 +UJMgDSLDkh8AOVF0LqqBCzCl3sbUZEbmYDJrvKLUQOVnUWAyZa8ps4CFOc6tcgHY +4rpIr8H9Wu8F6je8Bw92eDp3ExevdCFAswKn3wDk/41Yjt3USGVGK8ljObCM8jB4 +c5MqfhMviLJjDoLjTeItpo5RaMOWUM0YqMmjiVMlLAVXaKLYmkCU0q6a6rFIeWcI +sHQMn6c0t229HKoSqRFHt9VGYMIiB+qkmHqXqsBlNO2oVArNwQIglgR9hf/hndTy +7dorMBOnn/bsf4UCAwEAAaOB9DCB8TAJBgNVHRMEAjAAMBEGCWCGSAGG+EIBAQQE +AwIGQDAzBglghkgBhvhCAQ0EJhYkT3BlblNTTCBHZW5lcmF0ZWQgU2VydmVyIENl +cnRpZmljYXRlMB0GA1UdDgQWBBS0xSsqM1LNhX5I9LHV1zn475S3/DBYBgNVHSME +UTBPgBRxqJXbtVnGm3UTKgAJiQP7m6rXq6EzpDEwLzELMAkGA1UEBhMCVVMxCzAJ +BgNVBAgMAlBBMRMwEQYDVQQKDApQaXR0c2J1cmdoggIQADAOBgNVHQ8BAf8EBAMC +BaAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDQYJKoZIhvcNAQELBQADggIBAFQY1zO+ +tupoF2Ij6tmZB1kLbQy1qFFdoCLZ7wsERmNR5SWAjLiidNYl4r3eLEuYZOSjR8I/ +DnvsQi0IKIiocazt7Li5R0umGtkxKdDNBMm3HDw31CnaOivDZR1L3BqednGB89xn +yY+r1ZQ53o43coSI4tteurHrgnAA8xftQ8f3hvaw2zQkKycL5lfE58gBTyruMCqI +lAWd08o0rAF0Gd+Vbjawp3F8hlrrHRCiMKh1gTUpTlXgZYSsuf6z/E/EjtWYTOTB +bp+OJpOwvqMjmXMx0OCa/rGeItnsYaXWA7W+QWKwhIanXcaYZjy7w5FSHCpVMjN9 +jDHqeb1xP+hRmR9ZZzECY1BdL7wnrUPwpQj4hVgKErJ2LXBxoFm4vUKsS4K/LqtL +SVxq+1nNKGeB8Z6/Np4gmSLZF1ok12sMzdD1hgJiKpRTlr3QD5ymTIRUKL0Bo+yc +1qOSyVtsjjsgiWX8Ue64DuyUb3bQs6gsYuAiSoyyIIi5IEp4P+sgrCTPn2t+OB7t +GmQC94S8nP+aC7a7npQzGHLUL0SramOVvj87UOKYmlP7Cv65oNvcvBgtDtVHpU0D +DoH6lPjT2FX7mq5+YsQRHY054enBhxSmn76WDrUPRNDd4o/PPpgBUz2avT2ZGptK +yPo5qqmfKquela8y2MBaFVicwwymwXpbTX3J +-----END CERTIFICATE----- diff --git a/test/network/ssl/server_test.key b/test/network/ssl/server_test.key new file mode 100644 index 00000000000..d6d548140ea --- /dev/null +++ b/test/network/ssl/server_test.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEArMrwDQooVQdNq9Tq14S1nS9pOVeYfx/V2b3q4A3yPfAjG8kU +SB7xtnHo2060HsdOAw3pfTRQkyANIsOSHwA5UXQuqoELMKXextRkRuZgMmu8otRA +5WdRYDJlrymzgIU5zq1yAdjiukivwf1a7wXqN7wHD3Z4OncTF690IUCzAqffAOT/ +jViO3dRIZUYryWM5sIzyMHhzkyp+Ey+IsmMOguNN4i2mjlFow5ZQzRioyaOJUyUs +BVdootiaQJTSrprqsUh5ZwiwdAyfpzS3bb0cqhKpEUe31UZgwiIH6qSYepeqwGU0 +7ahUCs3BAiCWBH2F/+Gd1PLt2iswE6ef9ux/hQIDAQABAoIBAQCguPcGOf9/75Yo +kZiLNO61MWdfpgG7pUIGEehJ1c8QG7CcZLHPz7CnMlcUvqU9x8bhgmw/QIz9/J8b +Sew9l7i48ieCAxwEeRS5vs8zP5AU9i91CZb/itWfc+EvR8umbMVzX9Oesj1aZsfM +2jtd/xN4GhY7JMf6Ic4JhvKvB346paAtjPZqp72FuEGQtuzrFgOd4DbJOsXEYhoL +BMEy5RwRJmv7Xl8YSYErbyUCkU/oG6jmv/JoNQGBj7++l32YNRwRS0o9/gA0HhSQ +TahcsLSGwTtsEyZf1J1+3WuWrkGgsN9zKIzjfHjyAxe41IVWqJZFEacTXl1kdf5q +7vffdoKVAoGBAOX5Q7s1rM4O6wGupaVScpTKfxJcbSVfXq95D3hQTOr5ONBrjkYp +Vq7wfVg6OeDDfC5wBe235uPhyGxsbexjPLp6sU3M8+Zt4C20cPbsUUQ/mUg6Lq1d +KTi8ozhE+thv0d/58VHmQYQGCm4S+XH6Ml+MV0Afch9RgZdBzXsWQmOnAoGBAMBZ +Cq4K2ilcw60vw9lick99IRnsRNw4y0wPCHL00TdP9CuoOeFIuf8TSUfame6ZarDD +DyVW+qntFxPci7z+P61wEGAUBKUxkPmiSsTKtQ0IxdN3KkyUGHKAp94/nngJc62F +Y58uUTiNNuNcbIvCgcHV/aBJ2aYtTL7cCM5V9djzAoGBAOHO9SB3Paw+naZTNDa2 +U+ehRVBkDI+rqy8k8XmzbzMxbwXG9jYSFRlE7e6ZjYcSq3Z1bHzUHBQZ+E/tz6lS +b6izHDFGUx4pOPvntxvdQpZ+1CVFa9uyI+2f26w+nweyFCOWKcu/CQl3XPpkCyZN +AvUquekud0IlJ9e7NuXrH1j1AoGAIv2Ptc1/llqrtgukYx1HkjI/HUof1Lf4M6Pg +c5kZnihLUM3Pia4DN+W4RPv9WKxL/k/dp3tFKjhZJGHQgdb2moRyVigOGEcGCoN9 +eoMtoGtiIW/iIAAo2luRLhsApvGBO6WyU7jHSbRWsdGUZXBCzpIxC0Gj+FjxRx8b +8v0sNgUCgYEAmeOwwVoPwtTZghdfQ/iYnMSApWxgo/JPT4USVZ52MR/7v7FPV9cc +RSPpGAI+xHpK1on/KgJIE2JPXZ8T6ng5cZelXrk8p7W8KuUcTY5AV0L8KjE/uZ9/ +DD3fZtG1pgOk7vrRQcleBaeWuyCQciqebmHikRRoLdpAPnvb54IYDcQ= +-----END RSA PRIVATE KEY----- diff --git a/test/network/ssl_test.cpp b/test/network/ssl_test.cpp index 555f069afbd..a4af2ebd0dd 100644 --- a/test/network/ssl_test.cpp +++ b/test/network/ssl_test.cpp @@ -30,7 +30,7 @@ namespace test { // SSL TESTS //===--------------------------------------------------------------------===// -class SSLTests : public PelotonTest {}; +class SSLTests : public PelotonTests {}; // The following keys and certificates are generated using // https://www.postgresql.org/docs/9.5/static/libpq-ssl.html diff --git a/test/optimizer/column_stats_collector_test.cpp b/test/optimizer/column_stats_collector_test.cpp index 105310a50bf..321ba949a89 100644 --- a/test/optimizer/column_stats_collector_test.cpp +++ b/test/optimizer/column_stats_collector_test.cpp @@ -27,7 +27,7 @@ namespace test { using namespace optimizer; -class ColumnStatsCollectorTests : public PelotonTest {}; +class ColumnStatsCollectorTests : public PelotonTests {}; // Basic test with tiny dataset. TEST_F(ColumnStatsCollectorTests, BasicTest) { @@ -65,7 +65,8 @@ TEST_F(ColumnStatsCollectorTests, DistinctValueTest) { // Test dataset with extreme distribution. // More specifically distribution with large amount of data at tail // with single continuous value to the left of tail. -// This test is commented out because it's a performance test and takes long time. +// This test is commented out because it's a performance test and takes long +// time. // TEST_F(ColumnStatsCollectorTests, SkewedDistTest) { // ColumnStatsCollector colstats{TEST_OID, TEST_OID, TEST_OID, // type::TypeId::BIGINT, ""}; @@ -96,7 +97,8 @@ TEST_F(ColumnStatsCollectorTests, DistinctValueTest) { // EXPECT_LE(cardinality, (big_int + 10) * (1 + error) + buffer); // EXPECT_GE(colstats.GetHistogramBound().size(), 0); // // test null -// type::Value null = type::ValueFactory::GetNullValueByType(type::TypeId::BIGINT); +// type::Value null = +// type::ValueFactory::GetNullValueByType(type::TypeId::BIGINT); // colstats.AddValue(null); // EXPECT_GE(colstats.GetFracNull(), 0); // } diff --git a/test/optimizer/cost_test.cpp b/test/optimizer/cost_test.cpp index 2c1531ab367..6aaca915b48 100644 --- a/test/optimizer/cost_test.cpp +++ b/test/optimizer/cost_test.cpp @@ -42,23 +42,26 @@ using namespace optimizer; // const int N_ROW = 100; -class CostTests : public PelotonTest {}; +class CostTests : public PelotonTests {}; // tablename: test // database name: DEFAULT_DB_NAME // void CreateAndLoadTable(const std::string& table_name = {"test"}) { // TestingSQLUtil::ExecuteSQLQuery( -// "CREATE TABLE " + table_name + " (id INT PRIMARY KEY, name VARCHAR, salary DECIMAL);"); +// "CREATE TABLE " + table_name + " (id INT PRIMARY KEY, name VARCHAR, +// salary DECIMAL);"); // for (int i = 1; i <= N_ROW; i++) { // std::stringstream ss; -// ss << "INSERT INTO " << table_name << " VALUES (" << i << ", 'name', 1.1);"; +// ss << "INSERT INTO " << table_name << " VALUES (" << i << ", 'name', +// 1.1);"; // TestingSQLUtil::ExecuteSQLQuery(ss.str()); // } // } // // std::shared_ptr GetPropertyColumns() { // std::vector> cols; -// auto star_expr = std::shared_ptr(new expression::StarExpression()); +// auto star_expr = std::shared_ptr(new +// expression::StarExpression()); // cols.push_back(star_expr); // return std::make_shared(cols); // } @@ -109,10 +112,12 @@ class CostTests : public PelotonTest {}; // // // condition1: id < 1000 // type::Value value1 = type::ValueFactory::GetIntegerValue(1000); -// ValueCondition condition1{0, "id", ExpressionType::COMPARE_LESSTHAN, value1}; +// ValueCondition condition1{0, "id", ExpressionType::COMPARE_LESSTHAN, +// value1}; // std::shared_ptr output_stats(new TableStats{}); // double cost1 = -// Cost::SingleConditionSeqScanCost(table_stats, condition1, output_stats); +// Cost::SingleConditionSeqScanCost(table_stats, condition1, +// output_stats); // LOG_INFO("cost for condition 1 is %f", cost1); // EXPECT_GE(cost1, 0); // // EXPECT_EQ(output_stats->num_rows, 1000); @@ -121,7 +126,8 @@ class CostTests : public PelotonTest {}; // ValueCondition condition2{0, "id", ExpressionType::COMPARE_EQUAL, value1}; // output_stats->ClearColumnStats(); // double cost2 = -// Cost::SingleConditionSeqScanCost(table_stats, condition2, output_stats); +// Cost::SingleConditionSeqScanCost(table_stats, condition2, +// output_stats); // LOG_INFO("cost for condition 2 is: %f", cost2); // EXPECT_GE(cost2, 0); // // EXPECT_EQ(output_stats->num_rows, 1); @@ -131,7 +137,8 @@ class CostTests : public PelotonTest {}; // // // Free the database // txn = txn_manager.BeginTransaction(); -// catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); +// catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, +// txn); // txn_manager.CommitTransaction(txn); // } // @@ -172,7 +179,8 @@ class CostTests : public PelotonTest {}; // // auto expr1 = new expression::TupleValueExpression("id", "test1"); // auto expr2 = new expression::TupleValueExpression("id", "test2"); -// auto predicate = std::shared_ptr(expression::ExpressionUtil::ComparisonFactory( +// auto predicate = +// std::shared_ptr(expression::ExpressionUtil::ComparisonFactory( // ExpressionType::COMPARE_EQUAL, expr1, expr2)); // // @@ -183,7 +191,8 @@ class CostTests : public PelotonTest {}; // right_table_stats, // column_prop.get()); // -// double cost = Cost::NLJoinCost(left_table_stats, right_table_stats, output_stats, predicate, JoinType::INNER, true); +// double cost = Cost::NLJoinCost(left_table_stats, right_table_stats, +// output_stats, predicate, JoinType::INNER, true); // LOG_INFO("Estimated output size %lu", output_stats->num_rows); // EXPECT_EQ(cost, 100); // EXPECT_EQ(output_stats->GetSampler()->GetSampledTuples().size(), 100); diff --git a/test/optimizer/count_min_sketch_test.cpp b/test/optimizer/count_min_sketch_test.cpp index 1369a42d687..1ade6c688cb 100644 --- a/test/optimizer/count_min_sketch_test.cpp +++ b/test/optimizer/count_min_sketch_test.cpp @@ -21,7 +21,7 @@ namespace test { using namespace optimizer; -class CountMinSketchTests : public PelotonTest {}; +class CountMinSketchTests : public PelotonTests {}; // Basic CM-Sketch testing with double datatype. TEST_F(CountMinSketchTests, SimpleCountMinSketchIntegerTest) { diff --git a/test/optimizer/histogram_test.cpp b/test/optimizer/histogram_test.cpp index 8bfd622e389..f1a9ac430a0 100644 --- a/test/optimizer/histogram_test.cpp +++ b/test/optimizer/histogram_test.cpp @@ -24,7 +24,7 @@ namespace test { using namespace optimizer; -class HistogramTests : public PelotonTest {}; +class HistogramTests : public PelotonTests {}; // 100k values with uniform distribution from 1 to 100. TEST_F(HistogramTests, UniformDistTest) { diff --git a/test/optimizer/hyperloglog_test.cpp b/test/optimizer/hyperloglog_test.cpp index 5be972ad029..4ab1783a0b6 100644 --- a/test/optimizer/hyperloglog_test.cpp +++ b/test/optimizer/hyperloglog_test.cpp @@ -29,10 +29,10 @@ namespace test { using namespace optimizer; -class HyperLogLogTests : public PelotonTest {}; +class HyperLogLogTests : public PelotonTests {}; // 100k values with 10k distinct. -TEST_F(HyperLogLogTests, SmallDatasetTest1) { +TEST_F(HyperLogLogTests, SmallDataset1Test) { HyperLogLog hll{}; int threshold = 100000; int ratio = 10; @@ -52,7 +52,7 @@ TEST_F(HyperLogLogTests, SmallDatasetTest1) { // 100k values with 1k distinct. // This case HLL does not perform very well. -TEST_F(HyperLogLogTests, SmallDatasetTest2) { +TEST_F(HyperLogLogTests, SmallDataset2Test) { HyperLogLog hll{}; int threshold = 100000; int ratio = 100; @@ -67,7 +67,7 @@ TEST_F(HyperLogLogTests, SmallDatasetTest2) { } // 100k values with 100 distinct. -TEST_F(HyperLogLogTests, SmallDatasetTest3) { +TEST_F(HyperLogLogTests, SmallDataset3Test) { HyperLogLog hll{}; int threshold = 100000; int ratio = 1000; @@ -83,7 +83,7 @@ TEST_F(HyperLogLogTests, SmallDatasetTest3) { } // 100k values with 100k distinct. -TEST_F(HyperLogLogTests, SmallDatasetTest4) { +TEST_F(HyperLogLogTests, SmallDataset4Test) { HyperLogLog hll{}; int threshold = 100000; int ratio = 1; diff --git a/test/optimizer/old_optimizer_test.cpp b/test/optimizer/old_optimizer_test.cpp index 92949cc8521..8f0bff92a74 100644 --- a/test/optimizer/old_optimizer_test.cpp +++ b/test/optimizer/old_optimizer_test.cpp @@ -36,7 +36,7 @@ namespace test { using namespace optimizer; -class OldOptimizerTests : public PelotonTest {}; +class OldOptimizerTests : public PelotonTests {}; // Test whether update stament will use index scan plan // TODO: Split the tests into separate test cases. diff --git a/test/optimizer/operator_test.cpp b/test/optimizer/operator_test.cpp index a6b7677cf6a..02066f579f2 100644 --- a/test/optimizer/operator_test.cpp +++ b/test/optimizer/operator_test.cpp @@ -23,7 +23,7 @@ namespace test { using namespace optimizer; -class OperatorTests : public PelotonTest {}; +class OperatorTests : public PelotonTests {}; // TODO: Test complex expressions TEST_F(OperatorTests, OperatorHashAndEqualTest) { diff --git a/test/optimizer/operator_transformer_test.cpp b/test/optimizer/operator_transformer_test.cpp index f1d5229798c..1398e8f323b 100644 --- a/test/optimizer/operator_transformer_test.cpp +++ b/test/optimizer/operator_transformer_test.cpp @@ -30,11 +30,11 @@ namespace test { using namespace optimizer; -class OperatorTransformerTests : public PelotonTest { +class OperatorTransformerTests : public PelotonTests { protected: virtual void SetUp() override { // Call parent virtual function first - PelotonTest::SetUp(); + PelotonTests::SetUp(); // Create test database auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); @@ -98,7 +98,7 @@ class OperatorTransformerTests : public PelotonTest { txn_manager.CommitTransaction(txn); // Call parent virtual function - PelotonTest::TearDown(); + PelotonTests::TearDown(); } }; // TODO(boweic): Since operator transformer has a huge change during the diff --git a/test/optimizer/optimizer_rule_test.cpp b/test/optimizer/optimizer_rule_test.cpp index 12d047ad51a..25678d67026 100644 --- a/test/optimizer/optimizer_rule_test.cpp +++ b/test/optimizer/optimizer_rule_test.cpp @@ -46,7 +46,7 @@ namespace test { using namespace optimizer; -class OptimizerRuleTests : public PelotonTest {}; +class OptimizerRuleTests : public PelotonTests {}; TEST_F(OptimizerRuleTests, SimpleCommutativeRuleTest) { // Build op plan node to match rule @@ -166,7 +166,7 @@ TEST_F(OptimizerRuleTests, SimpleAssociativeRuleTest) { delete root_context; } -TEST_F(OptimizerRuleTests, SimpleAssociativeRuleTest2) { +TEST_F(OptimizerRuleTests, SimpleAssociativeRule2Test) { // Start Join Structure: (left JOIN middle) JOIN right // End Join Structure: left JOIN (middle JOIN right) // Query: SELECT * from test1, test2, test3 WHERE test1.a = test3.a AND diff --git a/test/optimizer/optimizer_test.cpp b/test/optimizer/optimizer_test.cpp index 8b5ed1e0ec7..5a142f5d947 100644 --- a/test/optimizer/optimizer_test.cpp +++ b/test/optimizer/optimizer_test.cpp @@ -46,7 +46,7 @@ namespace test { using namespace optimizer; -class OptimizerTests : public PelotonTest { +class OptimizerTests : public PelotonTests { protected: GroupExpression *GetSingleGroupExpression(Memo &memo, GroupExpression *expr, int child_group_idx) { @@ -64,7 +64,7 @@ class OptimizerTests : public PelotonTest { txn_manager.CommitTransaction(txn); // Call parent virtual function - PelotonTest::TearDown(); + PelotonTests::TearDown(); } }; diff --git a/test/optimizer/selectivity_test.cpp b/test/optimizer/selectivity_test.cpp index cbb8df08d2c..fa614f332c8 100644 --- a/test/optimizer/selectivity_test.cpp +++ b/test/optimizer/selectivity_test.cpp @@ -33,7 +33,7 @@ namespace test { using namespace optimizer; -class SelectivityTests : public PelotonTest {}; +class SelectivityTests : public PelotonTests {}; const std::string TEST_TABLE_NAME = "test"; diff --git a/test/optimizer/stats_storage_test.cpp b/test/optimizer/stats_storage_test.cpp index edf42131355..83749d1c147 100644 --- a/test/optimizer/stats_storage_test.cpp +++ b/test/optimizer/stats_storage_test.cpp @@ -33,7 +33,7 @@ namespace test { using namespace optimizer; -class StatsStorageTests : public PelotonTest {}; +class StatsStorageTests : public PelotonTests {}; const int tuple_count = 100; const int tuple_per_tilegroup = 100; diff --git a/test/optimizer/table_stats_collector_test.cpp b/test/optimizer/table_stats_collector_test.cpp index e98f1a54bf9..80ce21d0b9e 100644 --- a/test/optimizer/table_stats_collector_test.cpp +++ b/test/optimizer/table_stats_collector_test.cpp @@ -32,9 +32,9 @@ namespace test { using namespace optimizer; -class TableStatsCollectorTests : public PelotonTest {}; +class TableStatsCollectorTests : public PelotonTests {}; -TEST_F(TableStatsCollectorTests, BasicTests) { +TEST_F(TableStatsCollectorTests, BasicTest) { std::unique_ptr data_table( TestingExecutorUtil::CreateTable()); TableStatsCollector table_stats_collector{data_table.get()}; diff --git a/test/optimizer/table_stats_test.cpp b/test/optimizer/table_stats_test.cpp index e994a55c514..93da8a7696e 100644 --- a/test/optimizer/table_stats_test.cpp +++ b/test/optimizer/table_stats_test.cpp @@ -24,7 +24,7 @@ namespace test { using namespace optimizer; -class TableStatsTests : public PelotonTest {}; +class TableStatsTests : public PelotonTests {}; std::shared_ptr CreateTestColumnStats( oid_t database_id, oid_t table_id, oid_t column_id, std::string column_name, @@ -36,7 +36,7 @@ std::shared_ptr CreateTestColumnStats( // Test the constructors of TableStats // Test the Get function of TableStats -TEST_F(TableStatsTests, BaiscTests) { +TEST_F(TableStatsTests, BaiscTest) { TableStats table_stats0; EXPECT_EQ(table_stats0.num_rows, 0); @@ -70,7 +70,7 @@ TEST_F(TableStatsTests, BaiscTests) { // Test all update functions of TableStats, including UpdateNumRows, // AddColumnStats, RemoveColumnStats and ClearColumnStats. -TEST_F(TableStatsTests, UpdateTests) { +TEST_F(TableStatsTests, UpdateTest) { auto col_stats0 = CreateTestColumnStats(0, 0, 0, "col0", true, 10); auto col_stats1 = CreateTestColumnStats(1, 1, 1, "col1", false, 20); auto col_stats2 = CreateTestColumnStats(2, 2, 2, "col2", true, 30); diff --git a/test/optimizer/top_k_elements_test.cpp b/test/optimizer/top_k_elements_test.cpp index a52cac4e3f3..c91ced1b5cc 100644 --- a/test/optimizer/top_k_elements_test.cpp +++ b/test/optimizer/top_k_elements_test.cpp @@ -25,7 +25,7 @@ namespace test { using namespace optimizer; -class TopKElementsTests : public PelotonTest {}; +class TopKElementsTests : public PelotonTests {}; TEST_F(TopKElementsTests, SimpleArrivalOnlyTest) { CountMinSketch sketch(10, 20, 0); diff --git a/test/optimizer/tuple_sampler_test.cpp b/test/optimizer/tuple_sampler_test.cpp index 97348063f4f..6b99543250a 100644 --- a/test/optimizer/tuple_sampler_test.cpp +++ b/test/optimizer/tuple_sampler_test.cpp @@ -30,7 +30,7 @@ namespace test { using namespace optimizer; -class TupleSamplerTests : public PelotonTest {}; +class TupleSamplerTests : public PelotonTests {}; TEST_F(TupleSamplerTests, SampleCountTest) { const int tuple_count = 100; diff --git a/test/optimizer/tuple_samples_storage_test.cpp b/test/optimizer/tuple_samples_storage_test.cpp index 72ed769f270..4994d3480b7 100644 --- a/test/optimizer/tuple_samples_storage_test.cpp +++ b/test/optimizer/tuple_samples_storage_test.cpp @@ -30,7 +30,7 @@ namespace test { using namespace optimizer; -class TupleSamplesStorageTests : public PelotonTest {}; +class TupleSamplesStorageTests : public PelotonTests {}; void PrintColumnSamples(std::vector &column_samples) { for (size_t i = 0; i < column_samples.size(); i++) { diff --git a/test/parser/parser_test.cpp b/test/parser/parser_test.cpp index 93abf1c497c..2688a7bd102 100644 --- a/test/parser/parser_test.cpp +++ b/test/parser/parser_test.cpp @@ -26,7 +26,7 @@ namespace test { // Parser Tests //===--------------------------------------------------------------------===// -class ParserTests : public PelotonTest {}; +class ParserTests : public PelotonTests {}; TEST_F(ParserTests, BasicTest) { std::vector queries; diff --git a/test/parser/parser_utils_test.cpp b/test/parser/parser_utils_test.cpp index 88f4e5d220a..b98e98fdc37 100644 --- a/test/parser/parser_utils_test.cpp +++ b/test/parser/parser_utils_test.cpp @@ -25,7 +25,7 @@ namespace test { // Parser Tests //===--------------------------------------------------------------------===// -class ParserUtilTests : public PelotonTest {}; +class ParserUtilTests : public PelotonTests {}; TEST_F(ParserUtilTests, BasicTest) { std::vector queries; diff --git a/test/parser/postgresparser_test.cpp b/test/parser/postgresparser_test.cpp index 36910bdc9a9..4a5026e31df 100644 --- a/test/parser/postgresparser_test.cpp +++ b/test/parser/postgresparser_test.cpp @@ -30,7 +30,7 @@ namespace test { // PostgresParser Tests //===--------------------------------------------------------------------===// -class PostgresParserTests : public PelotonTest {}; +class PostgresParserTests : public PelotonTests {}; TEST_F(PostgresParserTests, BasicTest) { std::vector queries; @@ -525,7 +525,7 @@ TEST_F(PostgresParserTests, DeleteTest) { } } -TEST_F(PostgresParserTests, DeleteTestWithPredicate) { +TEST_F(PostgresParserTests, DeleteWithPredicateTest) { std::vector queries; // Delete with a predicate diff --git a/test/performance/index_performance_test.cpp b/test/performance/index_performance_test.cpp index aef50336a3b..2f028af6060 100644 --- a/test/performance/index_performance_test.cpp +++ b/test/performance/index_performance_test.cpp @@ -30,7 +30,7 @@ namespace test { // Index Performance Tests //===--------------------------------------------------------------------===// -class IndexPerformanceTests : public PelotonTest {}; +class IndexPerformanceTests : public PelotonTests {}; catalog::Schema *key_schema = nullptr; catalog::Schema *tuple_schema = nullptr; diff --git a/test/performance/insert_performance_test.cpp b/test/performance/insert_performance_test.cpp index a65be8e7ead..22a1f13275e 100644 --- a/test/performance/insert_performance_test.cpp +++ b/test/performance/insert_performance_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -50,7 +49,7 @@ namespace test { // Insert Tests //===--------------------------------------------------------------------===// -class InsertPerformanceTests : public PelotonTest {}; +class InsertPerformanceTests : public PelotonTests {}; std::atomic loader_tuple_id; @@ -118,7 +117,8 @@ TEST_F(InsertPerformanceTests, LoadingTest) { auto expected_tile_group_count = 0; - int total_tuple_count = loader_threads_count * tilegroup_count_per_loader * TEST_TUPLES_PER_TILEGROUP; + int total_tuple_count = loader_threads_count * tilegroup_count_per_loader * + TEST_TUPLES_PER_TILEGROUP; int max_cached_tuple_count = TEST_TUPLES_PER_TILEGROUP * storage::DataTable::GetActiveTileGroupCount(); int max_unfill_cached_tuple_count = @@ -137,7 +137,10 @@ TEST_F(InsertPerformanceTests, LoadingTest) { int filled_tile_group_count = total_tuple_count / max_cached_tuple_count * storage::DataTable::GetActiveTileGroupCount(); - if (total_tuple_count - filled_tile_group_count * TEST_TUPLES_PER_TILEGROUP - max_unfill_cached_tuple_count <= 0) { + if (total_tuple_count - + filled_tile_group_count * TEST_TUPLES_PER_TILEGROUP - + max_unfill_cached_tuple_count <= + 0) { expected_tile_group_count = filled_tile_group_count + storage::DataTable::GetActiveTileGroupCount(); } else { diff --git a/test/planner/plan_util_test.cpp b/test/planner/plan_util_test.cpp index 77df6f54e88..2d03d658a5a 100644 --- a/test/planner/plan_util_test.cpp +++ b/test/planner/plan_util_test.cpp @@ -30,7 +30,7 @@ namespace test { #define TEST_DB_NAME "test_db" #define TEST_DB_COLUMNS "test_db_columns" -class PlanUtilTests : public PelotonTest {}; +class PlanUtilTests : public PelotonTests {}; TEST_F(PlanUtilTests, GetAffectedIndexesTest) { auto catalog = catalog::Catalog::GetInstance(); diff --git a/test/planner/planner_equality_test.cpp b/test/planner/planner_equality_test.cpp index fe109bc9dff..b721f7c2e05 100644 --- a/test/planner/planner_equality_test.cpp +++ b/test/planner/planner_equality_test.cpp @@ -21,11 +21,11 @@ namespace peloton { namespace test { -class PlannerEqualityTest : public PelotonTest { +class PlannerEqualityTests : public PelotonTests { protected: virtual void SetUp() override { // Call parent virtual function first - PelotonTest::SetUp(); + PelotonTests::SetUp(); // Create test database CreateAndLoadTable(); @@ -39,7 +39,7 @@ class PlannerEqualityTest : public PelotonTest { txn_manager.CommitTransaction(txn); // Call parent virtual function - PelotonTest::TearDown(); + PelotonTests::TearDown(); } void CreateAndLoadTable() { @@ -89,7 +89,7 @@ class PlannerEqualityTest : public PelotonTest { int rows_changed; }; -TEST_F(PlannerEqualityTest, Select) { +TEST_F(PlannerEqualityTests, SelectTest) { // set up optimizer for every test optimizer.reset(new optimizer::Optimizer()); @@ -173,7 +173,7 @@ TEST_F(PlannerEqualityTest, Select) { } } -TEST_F(PlannerEqualityTest, Insert) { +TEST_F(PlannerEqualityTests, InsertTest) { // set up optimizer for every test optimizer.reset(new optimizer::Optimizer()); @@ -219,7 +219,7 @@ TEST_F(PlannerEqualityTest, Insert) { } } -TEST_F(PlannerEqualityTest, Delete) { +TEST_F(PlannerEqualityTests, DeleteTest) { optimizer.reset(new optimizer::Optimizer()); std::vector items{ {"DELETE from test where a=1", "DELETE from test where a=1", true, true}, @@ -252,7 +252,7 @@ TEST_F(PlannerEqualityTest, Delete) { } } -TEST_F(PlannerEqualityTest, Update) { +TEST_F(PlannerEqualityTests, UpdateTest) { // set up optimizer for every test optimizer.reset(new optimizer::Optimizer()); diff --git a/test/planner/planner_test.cpp b/test/planner/planner_test.cpp index 5fd1709eaca..a43d95b1e59 100644 --- a/test/planner/planner_test.cpp +++ b/test/planner/planner_test.cpp @@ -38,9 +38,9 @@ namespace test { // Planner Test //===--------------------------------------------------------------------===// -class PlannerTest : public PelotonTest {}; +class PlannerTests : public PelotonTests {}; -TEST_F(PlannerTest, CreateDatabasePlanTest) { +TEST_F(PlannerTests, CreateDatabasePlanTest) { auto &peloton_parser = parser::PostgresParser::GetInstance(); auto parse_tree_list = peloton_parser.BuildParseTree("CREATE DATABASE pelotondb;"); @@ -54,7 +54,7 @@ TEST_F(PlannerTest, CreateDatabasePlanTest) { EXPECT_EQ(CreateType::DB, create_DB_plan->GetCreateType()); } -TEST_F(PlannerTest, DropDatabasePlanTest) { +TEST_F(PlannerTests, DropDatabasePlanTest) { auto &peloton_parser = parser::PostgresParser::GetInstance(); auto parse_tree_list = peloton_parser.BuildParseTree("DROP DATABASE pelotondb;"); @@ -68,7 +68,7 @@ TEST_F(PlannerTest, DropDatabasePlanTest) { EXPECT_EQ(DropType::DB, drop_DB_plan->GetDropType()); } -TEST_F(PlannerTest, DeletePlanTestParameter) { +TEST_F(PlannerTests, DeletePlanParameterTest) { // Bootstrapping peloton auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -132,7 +132,7 @@ TEST_F(PlannerTest, DeletePlanTestParameter) { txn_manager.CommitTransaction(txn); } -TEST_F(PlannerTest, UpdatePlanTestParameter) { +TEST_F(PlannerTests, UpdatePlanParameterTest) { // Bootstrapping peloton auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -229,7 +229,7 @@ TEST_F(PlannerTest, UpdatePlanTestParameter) { txn_manager.CommitTransaction(txn); } -TEST_F(PlannerTest, InsertPlanTestParameter) { +TEST_F(PlannerTests, InsertPlanParameterTest) { // Bootstrapping peloton auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -303,7 +303,7 @@ TEST_F(PlannerTest, InsertPlanTestParameter) { txn_manager.CommitTransaction(txn); } -TEST_F(PlannerTest, InsertPlanTestParameterColumns) { +TEST_F(PlannerTests, InsertPlanParameterColumnsTest) { // Bootstrapping peloton auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); diff --git a/test/settings/settings_manager_test.cpp b/test/settings/settings_manager_test.cpp index e9e00162259..c1f7d93f4ca 100644 --- a/test/settings/settings_manager_test.cpp +++ b/test/settings/settings_manager_test.cpp @@ -19,7 +19,7 @@ namespace peloton { namespace test { -class SettingsManagerTests : public PelotonTest {}; +class SettingsManagerTests : public PelotonTests {}; TEST_F(SettingsManagerTests, InitializationTest) { auto catalog = catalog::Catalog::GetInstance(); diff --git a/test/sql/aggregate_groupby_sql_test.cpp b/test/sql/aggregate_groupby_sql_test.cpp index 527ede393ca..39dece3cec9 100644 --- a/test/sql/aggregate_groupby_sql_test.cpp +++ b/test/sql/aggregate_groupby_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class AggregateGroupBySQLTests : public PelotonTest { +class AggregateGroupBySQLTests : public PelotonTests { protected: void CreateAndLoadTable() { // Create a table first diff --git a/test/sql/aggregate_sql_test.cpp b/test/sql/aggregate_sql_test.cpp index 62fcaddea8a..5a1c5006dd8 100644 --- a/test/sql/aggregate_sql_test.cpp +++ b/test/sql/aggregate_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class AggregateSQLTests : public PelotonTest {}; +class AggregateSQLTests : public PelotonTests {}; TEST_F(AggregateSQLTests, EmptyTableTest) { PELOTON_ASSERT(&TestingSQLUtil::counter_); @@ -40,7 +40,7 @@ TEST_F(AggregateSQLTests, EmptyTableTest) { std::vector tuple_descriptor; std::string error_message; int rows_affected; -// optimizer::Optimizer optimizer; + // optimizer::Optimizer optimizer; // All of these aggregates should return null std::vector nullAggregates = {"MIN", "MAX", "AVG", "SUM"}; @@ -102,7 +102,7 @@ TEST_F(AggregateSQLTests, MinMaxTest) { std::vector tuple_descriptor; std::string error_message; int rows_affected; -// optimizer::Optimizer optimizer; + // optimizer::Optimizer optimizer; // test small int TestingSQLUtil::ExecuteSQLQuery("SELECT min(b) from test", result, diff --git a/test/sql/analyze_sql_test.cpp b/test/sql/analyze_sql_test.cpp index 16191ec000d..3487ce2a88a 100644 --- a/test/sql/analyze_sql_test.cpp +++ b/test/sql/analyze_sql_test.cpp @@ -25,7 +25,7 @@ namespace peloton { namespace test { -class AnalyzeSQLTests : public PelotonTest {}; +class AnalyzeSQLTests : public PelotonTests {}; void CreateAndLoadTable() { // Create a table first diff --git a/test/sql/case_sql_test.cpp b/test/sql/case_sql_test.cpp index 7fe464b2974..9a5a04c4ddc 100644 --- a/test/sql/case_sql_test.cpp +++ b/test/sql/case_sql_test.cpp @@ -24,7 +24,7 @@ namespace peloton { namespace test { -class CaseSQLTests : public PelotonTest {}; +class CaseSQLTests : public PelotonTests {}; void CreateAndLoadTable() { // Create a table first @@ -38,8 +38,7 @@ void CreateAndLoadTable() { TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test VALUES (4, 00, 555);"); } -TEST_F(CaseSQLTests, Simple) { - +TEST_F(CaseSQLTests, SimpleTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -56,8 +55,8 @@ TEST_F(CaseSQLTests, Simple) { LOG_DEBUG("Running SELECT a, case when a=1 then 2 else 0 end from test"); TestingSQLUtil::ExecuteSQLQuery( - "SELECT a, case when a=1 then 2 else 0 end from test", - result, tuple_descriptor, rows_changed, error_message); + "SELECT a, case when a=1 then 2 else 0 end from test", result, + tuple_descriptor, rows_changed, error_message); // Check the return value EXPECT_EQ(0, rows_changed); @@ -74,11 +73,9 @@ TEST_F(CaseSQLTests, Simple) { txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - } -TEST_F(CaseSQLTests, SimpleWithArg) { - +TEST_F(CaseSQLTests, SimpleWithArgTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -90,8 +87,9 @@ TEST_F(CaseSQLTests, SimpleWithArg) { std::string error_message; int rows_changed; - LOG_DEBUG("Running SELECT a, case a when 1 then 2 when 2 then 3 " - "else 100 end from test"); + LOG_DEBUG( + "Running SELECT a, case a when 1 then 2 when 2 then 3 " + "else 100 end from test"); TestingSQLUtil::ExecuteSQLQuery( "SELECT a, case a when 1 then 2 when 2 then 3 else 100 end from test", result, tuple_descriptor, rows_changed, error_message); @@ -111,11 +109,9 @@ TEST_F(CaseSQLTests, SimpleWithArg) { txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - } -TEST_F(CaseSQLTests, SimpleWithArgStringResult) { - +TEST_F(CaseSQLTests, SimpleWithArgStringResultTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -127,11 +123,13 @@ TEST_F(CaseSQLTests, SimpleWithArgStringResult) { std::string error_message; int rows_changed; - LOG_DEBUG("Running SELECT a, case a when 1 then '2' when 2 then '3' " - "else '100' end from test"); + LOG_DEBUG( + "Running SELECT a, case a when 1 then '2' when 2 then '3' " + "else '100' end from test"); TestingSQLUtil::ExecuteSQLQuery( "SELECT a, case a when 1 then '2' when 2 then '3' else '100' end " - "from test", result, tuple_descriptor, rows_changed, error_message); + "from test", + result, tuple_descriptor, rows_changed, error_message); // Check the return value EXPECT_EQ(0, rows_changed); @@ -148,11 +146,9 @@ TEST_F(CaseSQLTests, SimpleWithArgStringResult) { txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - } -TEST_F(CaseSQLTests, SimpleMultipleWhen) { - +TEST_F(CaseSQLTests, SimpleMultipleWhenTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -186,11 +182,9 @@ TEST_F(CaseSQLTests, SimpleMultipleWhen) { txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - } -TEST_F(CaseSQLTests, SimpleMultipleWhenWithoutElse) { - +TEST_F(CaseSQLTests, SimpleMultipleWhenWithoutElseTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -206,8 +200,8 @@ TEST_F(CaseSQLTests, SimpleMultipleWhenWithoutElse) { LOG_DEBUG("Running SELECT a, case when a=1 then 2 end from test"); TestingSQLUtil::ExecuteSQLQuery( - "SELECT a, case when a=1 then 2 when a=2 then 3 end from test", - result, tuple_descriptor, rows_changed, error_message); + "SELECT a, case when a=1 then 2 when a=2 then 3 end from test", result, + tuple_descriptor, rows_changed, error_message); // Check the return value EXPECT_EQ(0, rows_changed); @@ -224,7 +218,6 @@ TEST_F(CaseSQLTests, SimpleMultipleWhenWithoutElse) { txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - } } // namespace test diff --git a/test/sql/decimal_functions_sql_test.cpp b/test/sql/decimal_functions_sql_test.cpp index 850e075a62c..727d86ecbab 100644 --- a/test/sql/decimal_functions_sql_test.cpp +++ b/test/sql/decimal_functions_sql_test.cpp @@ -20,11 +20,11 @@ namespace peloton { namespace test { -class DecimalSQLTestsBase : public PelotonTest { +class DecimalSQLBaseTests : public PelotonTests { protected: virtual void SetUp() override { // Call parent virtual function first - PelotonTest::SetUp(); + PelotonTests::SetUp(); CreateDB(); } /*** Helper functions **/ @@ -54,13 +54,13 @@ class DecimalSQLTestsBase : public PelotonTest { txn_manager.CommitTransaction(txn); // Call parent virtual function - PelotonTest::TearDown(); + PelotonTests::TearDown(); } }; -class DecimalFunctionsSQLTest : public PelotonTest {}; +class DecimalFunctionsSQLTests : public PelotonTests {}; -TEST_F(DecimalFunctionsSQLTest, FloorTest) { +TEST_F(DecimalFunctionsSQLTests, FloorTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -111,7 +111,7 @@ TEST_F(DecimalFunctionsSQLTest, FloorTest) { txn_manager.CommitTransaction(txn); } -TEST_F(DecimalSQLTestsBase, TinyIntAbsTest) { +TEST_F(DecimalSQLBaseTests, TinyIntAbsTest) { CreateTableWithCol("tinyint"); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -148,7 +148,7 @@ TEST_F(DecimalSQLTestsBase, TinyIntAbsTest) { TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result, true); } -TEST_F(DecimalSQLTestsBase, SmallIntAbsTest) { +TEST_F(DecimalSQLBaseTests, SmallIntAbsTest) { CreateTableWithCol("smallint"); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -185,7 +185,7 @@ TEST_F(DecimalSQLTestsBase, SmallIntAbsTest) { TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result, true); } -TEST_F(DecimalSQLTestsBase, IntAbsTest) { +TEST_F(DecimalSQLBaseTests, IntAbsTest) { CreateTableWithCol("int"); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -222,7 +222,7 @@ TEST_F(DecimalSQLTestsBase, IntAbsTest) { TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result, true); } -TEST_F(DecimalSQLTestsBase, BigIntAbsTest) { +TEST_F(DecimalSQLBaseTests, BigIntAbsTest) { CreateTableWithCol("bigint"); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -259,7 +259,7 @@ TEST_F(DecimalSQLTestsBase, BigIntAbsTest) { TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result, true); } -TEST_F(DecimalSQLTestsBase, DecimalAbsTest) { +TEST_F(DecimalSQLBaseTests, DecimalAbsTest) { CreateTableWithCol("decimal"); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -294,7 +294,7 @@ TEST_F(DecimalSQLTestsBase, DecimalAbsTest) { TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result, true); } -TEST_F(DecimalFunctionsSQLTest, CeilTest) { +TEST_F(DecimalFunctionsSQLTests, CeilTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); diff --git a/test/sql/distinct_aggregate_sql_test.cpp b/test/sql/distinct_aggregate_sql_test.cpp index a48412e0b68..171e60626e9 100644 --- a/test/sql/distinct_aggregate_sql_test.cpp +++ b/test/sql/distinct_aggregate_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class DistinctAggregateSQLTests : public PelotonTest { +class DistinctAggregateSQLTests : public PelotonTests { protected: void CreateAndLoadTable() { // Create a table first diff --git a/test/sql/distinct_sql_test.cpp b/test/sql/distinct_sql_test.cpp index d2bfa637ddf..c7ddbb68bd0 100644 --- a/test/sql/distinct_sql_test.cpp +++ b/test/sql/distinct_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class DistinctSQLTests : public PelotonTest { +class DistinctSQLTests : public PelotonTests { protected: void CreateAndLoadTable() { // Create a table first @@ -38,24 +38,26 @@ class DistinctSQLTests : public PelotonTest { "INSERT INTO test VALUES (3, 11, 222, 'abcd');"); } - void ExecuteSQLQueryAndCheckUnorderedResult(std::string query, std::unordered_set ref_result) { + void ExecuteSQLQueryAndCheckUnorderedResult( + std::string query, std::unordered_set ref_result) { std::vector result; std::vector tuple_descriptor; std::string error_message; int rows_changed; // Execute query - TestingSQLUtil::ExecuteSQLQuery(std::move(query), result, tuple_descriptor, rows_changed, error_message); + TestingSQLUtil::ExecuteSQLQuery(std::move(query), result, tuple_descriptor, + rows_changed, error_message); unsigned int rows = result.size() / tuple_descriptor.size(); - // Build actual result as set of rows for comparison std::unordered_set actual_result(rows); for (unsigned int i = 0; i < rows; i++) { std::string row_string; for (unsigned int j = 0; j < tuple_descriptor.size(); j++) { - row_string += TestingSQLUtil::GetResultValueAsString(result, i * tuple_descriptor.size() + j); + row_string += TestingSQLUtil::GetResultValueAsString( + result, i * tuple_descriptor.size() + j); if (j < tuple_descriptor.size() - 1) { row_string += "|"; } @@ -64,13 +66,11 @@ class DistinctSQLTests : public PelotonTest { actual_result.insert(std::move(row_string)); } - // Compare actual result to expected result EXPECT_EQ(ref_result.size(), actual_result.size()); for (auto &result_row : ref_result) { if (actual_result.erase(result_row) == 0) { - EXPECT_EQ(ref_result, actual_result); break; } @@ -121,8 +121,7 @@ TEST_F(DistinctSQLTests, DistinctTupleTest) { CreateAndLoadTable(); ExecuteSQLQueryAndCheckUnorderedResult("SELECT DISTINCT b, c FROM test;", - {"22|333", - "11|222"}); + {"22|333", "11|222"}); // free the database just created txn = txn_manager.BeginTransaction(); @@ -148,8 +147,7 @@ TEST_F(DistinctSQLTests, DistinctStarTest) { "INSERT INTO test VALUES (1, 22, 222, 'abcd');"); ExecuteSQLQueryAndCheckUnorderedResult("SELECT DISTINCT * FROM test;", - {"1|22|333|abcd", - "1|22|222|abcd"}); + {"1|22|333|abcd", "1|22|222|abcd"}); // free the database just created txn = txn_manager.BeginTransaction(); @@ -163,8 +161,7 @@ TEST_F(DistinctSQLTests, DistinctDateTimeTest) { catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - TestingSQLUtil::ExecuteSQLQuery( - "CREATE TABLE test(a INT, b TIMESTAMP);"); + TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE test(a INT, b TIMESTAMP);"); // Insert tuples into table TestingSQLUtil::ExecuteSQLQuery( @@ -174,9 +171,9 @@ TEST_F(DistinctSQLTests, DistinctDateTimeTest) { TestingSQLUtil::ExecuteSQLQuery( "INSERT INTO test VALUES (1, '2016-06-22 19:10:25-07');"); - ExecuteSQLQueryAndCheckUnorderedResult("SELECT DISTINCT b FROM test;", - {"2016-06-22 19:10:25.000000-07", - "2017-06-22 19:10:25.000000-07"}); + ExecuteSQLQueryAndCheckUnorderedResult( + "SELECT DISTINCT b FROM test;", + {"2016-06-22 19:10:25.000000-07", "2017-06-22 19:10:25.000000-07"}); // free the database just created txn = txn_manager.BeginTransaction(); diff --git a/test/sql/drop_sql_test.cpp b/test/sql/drop_sql_test.cpp index 90ebbe69bf0..760770fa654 100644 --- a/test/sql/drop_sql_test.cpp +++ b/test/sql/drop_sql_test.cpp @@ -24,7 +24,7 @@ namespace peloton { namespace test { -class DropSQLTests : public PelotonTest {}; +class DropSQLTests : public PelotonTests {}; TEST_F(DropSQLTests, DropTableTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); diff --git a/test/sql/foreign_key_sql_test.cpp b/test/sql/foreign_key_sql_test.cpp index da29b9883b7..dd7fe318e83 100644 --- a/test/sql/foreign_key_sql_test.cpp +++ b/test/sql/foreign_key_sql_test.cpp @@ -10,37 +10,35 @@ namespace peloton { namespace test { -class ForeignKeySQLTests : public PelotonTest {}; +class ForeignKeySQLTests : public PelotonTests {}; TEST_F(ForeignKeySQLTests, NoActionTest) { - auto catalog = catalog::Catalog::GetInstance(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog->CreateDatabase(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - TestingSQLUtil::ExecuteSQLQuery( - "CREATE TABLE tb1(id INT PRIMARY KEY);"); + TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE tb1(id INT PRIMARY KEY);"); TestingSQLUtil::ExecuteSQLQuery( "CREATE TABLE tb2(num INT REFERENCES tb1(id));"); - EXPECT_NE(TestingSQLUtil::ExecuteSQLQuery( - "INSERT INTO tb2 VALUES (1);"), ResultType::SUCCESS); + EXPECT_NE(TestingSQLUtil::ExecuteSQLQuery("INSERT INTO tb2 VALUES (1);"), + ResultType::SUCCESS); - TestingSQLUtil::ExecuteSQLQuery( - "INSERT INTO tb1 VALUES (1);"); + TestingSQLUtil::ExecuteSQLQuery("INSERT INTO tb1 VALUES (1);"); - EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery( - "INSERT INTO tb2 VALUES (1);"), ResultType::SUCCESS); + EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery("INSERT INTO tb2 VALUES (1);"), + ResultType::SUCCESS); // Update/delete any referenced row should fail - EXPECT_NE(TestingSQLUtil::ExecuteSQLQuery( - "UPDATE tb1 SET id = 10 where id = 1;"), ResultType::SUCCESS); + EXPECT_NE( + TestingSQLUtil::ExecuteSQLQuery("UPDATE tb1 SET id = 10 where id = 1;"), + ResultType::SUCCESS); - EXPECT_NE(TestingSQLUtil::ExecuteSQLQuery( - "DELETE FROM tb1 WHERE id = 1;"), ResultType::SUCCESS); + EXPECT_NE(TestingSQLUtil::ExecuteSQLQuery("DELETE FROM tb1 WHERE id = 1;"), + ResultType::SUCCESS); txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); @@ -54,33 +52,31 @@ TEST_F(ForeignKeySQLTests, CascadeTest) { catalog->CreateDatabase(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - TestingSQLUtil::ExecuteSQLQuery( - "CREATE TABLE tb1(id INT PRIMARY KEY);"); + TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE tb1(id INT PRIMARY KEY);"); TestingSQLUtil::ExecuteSQLQuery( - "CREATE TABLE tb2(num INT REFERENCES tb1(id) on update cascade on delete cascade);"); + "CREATE TABLE tb2(num INT REFERENCES tb1(id) on update cascade on delete " + "cascade);"); - EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery( - "INSERT INTO tb1 VALUES (1);"), ResultType::SUCCESS); + EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery("INSERT INTO tb1 VALUES (1);"), + ResultType::SUCCESS); - EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery( - "INSERT INTO tb2 VALUES (1);"), ResultType::SUCCESS); + EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery("INSERT INTO tb2 VALUES (1);"), + ResultType::SUCCESS); - EXPECT_EQ(TestingSQLUtil::ExecuteSQLQuery( - "UPDATE tb1 SET id = 10 where id = 1;"), ResultType::SUCCESS); + EXPECT_EQ( + TestingSQLUtil::ExecuteSQLQuery("UPDATE tb1 SET id = 10 where id = 1;"), + ResultType::SUCCESS); - TestingSQLUtil::ExecuteSQLQueryAndCheckResult("SELECT id from tb1;", - {"10"}, + TestingSQLUtil::ExecuteSQLQueryAndCheckResult("SELECT id from tb1;", {"10"}, true); - TestingSQLUtil::ExecuteSQLQueryAndCheckResult("SELECT num from tb2;", - {"10"}, + TestingSQLUtil::ExecuteSQLQueryAndCheckResult("SELECT num from tb2;", {"10"}, true); txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); } - } } \ No newline at end of file diff --git a/test/sql/index_scan_sql_test.cpp b/test/sql/index_scan_sql_test.cpp index a0d6df7e3ba..8eb91ea9878 100644 --- a/test/sql/index_scan_sql_test.cpp +++ b/test/sql/index_scan_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class IndexScanSQLTests : public PelotonTest {}; +class IndexScanSQLTests : public PelotonTests {}; void CreateAndLoadTable() { // Create a table first diff --git a/test/sql/insert_sql_test.cpp b/test/sql/insert_sql_test.cpp index 74b767bfa5c..5f8ff857d3b 100644 --- a/test/sql/insert_sql_test.cpp +++ b/test/sql/insert_sql_test.cpp @@ -24,7 +24,7 @@ namespace peloton { namespace test { -class InsertSQLTests : public PelotonTest {}; +class InsertSQLTests : public PelotonTests {}; void CreateAndLoadTable() { // Create a table first @@ -110,7 +110,7 @@ void CreateAndLoadTable8() { "CREATE TABLE test8(num1 int, num2 int, num3 int not null);"); } -TEST_F(InsertSQLTests, InsertOneValue) { +TEST_F(InsertSQLTests, InsertOneValueTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -153,7 +153,7 @@ TEST_F(InsertSQLTests, InsertOneValue) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, InsertMultipleValues) { +TEST_F(InsertSQLTests, InsertMultipleValuesTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -205,7 +205,7 @@ TEST_F(InsertSQLTests, InsertMultipleValues) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, InsertSpecifyColumns) { +TEST_F(InsertSQLTests, InsertSpecifyColumnsTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -249,7 +249,7 @@ TEST_F(InsertSQLTests, InsertSpecifyColumns) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, InsertTooLargeVarchar) { +TEST_F(InsertSQLTests, InsertTooLargeVarcharTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -292,7 +292,7 @@ TEST_F(InsertSQLTests, InsertTooLargeVarchar) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, InsertIntoSelectSimple) { +TEST_F(InsertSQLTests, InsertIntoSelectSimpleTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -367,7 +367,7 @@ TEST_F(InsertSQLTests, InsertIntoSelectSimple) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, InsertIntoSelectSimpleAllType) { +TEST_F(InsertSQLTests, InsertIntoSelectSimpleAllTypeTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -455,7 +455,7 @@ TEST_F(InsertSQLTests, InsertIntoSelectSimpleAllType) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, InsertIntoSelectColumn) { +TEST_F(InsertSQLTests, InsertIntoSelectColumnTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -530,7 +530,7 @@ TEST_F(InsertSQLTests, InsertIntoSelectColumn) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, UniqueColumn) { +TEST_F(InsertSQLTests, UniqueColumnTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -575,7 +575,7 @@ TEST_F(InsertSQLTests, UniqueColumn) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, BadTypes) { +TEST_F(InsertSQLTests, BadTypesTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -614,7 +614,7 @@ TEST_F(InsertSQLTests, BadTypes) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, NonExistentTable) { +TEST_F(InsertSQLTests, NonExistentTableTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -635,7 +635,7 @@ TEST_F(InsertSQLTests, NonExistentTable) { txn_manager.CommitTransaction(txn); } -TEST_F(InsertSQLTests, BadInserts) { +TEST_F(InsertSQLTests, BadInsertsTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); diff --git a/test/sql/is_null_sql_test.cpp b/test/sql/is_null_sql_test.cpp index 6e7d1eaab20..5cb8dfc119f 100644 --- a/test/sql/is_null_sql_test.cpp +++ b/test/sql/is_null_sql_test.cpp @@ -23,7 +23,7 @@ namespace peloton { namespace test { -class IsNullSqlTests : public PelotonTest {}; +class IsNullSqlTests : public PelotonTests {}; void CreateAndLoadTable() { // Create a table first diff --git a/test/sql/optimizer_sql_test.cpp b/test/sql/optimizer_sql_test.cpp index 3855c015e20..c4c3d524677 100644 --- a/test/sql/optimizer_sql_test.cpp +++ b/test/sql/optimizer_sql_test.cpp @@ -30,11 +30,11 @@ using std::vector; namespace peloton { namespace test { -class OptimizerSQLTests : public PelotonTest { +class OptimizerSQLTests : public PelotonTests { protected: virtual void SetUp() override { // Call parent virtual function first - PelotonTest::SetUp(); + PelotonTests::SetUp(); // Create test database CreateAndLoadTable(); @@ -49,7 +49,7 @@ class OptimizerSQLTests : public PelotonTest { txn_manager.CommitTransaction(txn); // Call parent virtual function - PelotonTest::TearDown(); + PelotonTests::TearDown(); } /*** Helper functions **/ @@ -132,10 +132,9 @@ class OptimizerSQLTests : public PelotonTest { TEST_F(OptimizerSQLTests, SimpleSelectTest) { // Testing select star expression - TestUtil( - "SELECT * from test", - {"333", "22", "1", "2", "11", "0", "3", "33", "444", "4", "0", "555"}, - false); + TestUtil("SELECT * from test", {"333", "22", "1", "2", "11", "0", "3", "33", + "444", "4", "0", "555"}, + false); // Something wrong with column property. string query = "SELECT b from test order by c"; @@ -230,10 +229,9 @@ TEST_F(OptimizerSQLTests, SelectOrderByTest) { true); // Testing order by * expression - TestUtil( - "SELECT * from test order by a", - {"1", "22", "333", "2", "11", "0", "3", "33", "444", "4", "0", "555"}, - true); + TestUtil("SELECT * from test order by a", {"1", "22", "333", "2", "11", "0", + "3", "33", "444", "4", "0", "555"}, + true); } TEST_F(OptimizerSQLTests, SelectLimitTest) { @@ -613,14 +611,7 @@ TEST_F(OptimizerSQLTests, JoinTest) { "SELECT A.b, B.b FROM test1 as A, test1 as B " "WHERE A.a = B.a", { - "22", - "22", - "22", - "22", - "11", - "11", - "0", - "0", + "22", "22", "22", "22", "11", "11", "0", "0", }, false); diff --git a/test/sql/order_by_sql_test.cpp b/test/sql/order_by_sql_test.cpp index f3643389bfd..5d8a04dcfa1 100644 --- a/test/sql/order_by_sql_test.cpp +++ b/test/sql/order_by_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class OrderBySQLTests : public PelotonTest {}; +class OrderBySQLTests : public PelotonTests {}; void CreateAndLoadTable() { // Create a table first @@ -85,11 +85,12 @@ TEST_F(OrderBySQLTests, PerformanceTest) { std::chrono::system_clock::now(); auto latency = std::chrono::duration_cast( - end_time - start_time).count(); + end_time - start_time) + .count(); LOG_INFO( "OrderBy Query (table size:%d) with Limit 10 Execution Time is: %lu ms", - table_size, (unsigned long) latency); + table_size, (unsigned long)latency); // test OrderBy without Limit start_time = std::chrono::system_clock::now(); @@ -100,11 +101,12 @@ TEST_F(OrderBySQLTests, PerformanceTest) { end_time = std::chrono::system_clock::now(); - latency = std::chrono::duration_cast( - end_time - start_time).count(); + latency = std::chrono::duration_cast(end_time - + start_time) + .count(); LOG_INFO("OrderBy Query (table size:%d) Execution Time is: %lu ms", - table_size, (unsigned long) latency); + table_size, (unsigned long)latency); // free the database just created txn = txn_manager.BeginTransaction(); @@ -356,7 +358,7 @@ TEST_F(OrderBySQLTests, OrderByWithoutColumnsAndLimitDescTest) { txn_manager.CommitTransaction(txn); } -TEST_F(OrderBySQLTests, OrderByStar) { +TEST_F(OrderBySQLTests, OrderByStarTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -389,7 +391,7 @@ TEST_F(OrderBySQLTests, OrderByStar) { txn_manager.CommitTransaction(txn); } -TEST_F(OrderBySQLTests, OrderByStarDesc) { +TEST_F(OrderBySQLTests, OrderByStarDescTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -422,7 +424,7 @@ TEST_F(OrderBySQLTests, OrderByStarDesc) { txn_manager.CommitTransaction(txn); } -TEST_F(OrderBySQLTests, OrderByStarWithLimit) { +TEST_F(OrderBySQLTests, OrderByStarWithLimitTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -454,7 +456,7 @@ TEST_F(OrderBySQLTests, OrderByStarWithLimit) { txn_manager.CommitTransaction(txn); } -TEST_F(OrderBySQLTests, OrderByStarWithLimitDesc) { +TEST_F(OrderBySQLTests, OrderByStarWithLimitDescTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -626,7 +628,7 @@ TEST_F(OrderBySQLTests, OrderByWithProjectionLimitDescTest) { txn_manager.CommitTransaction(txn); } -TEST_F(OrderBySQLTests, OrderByWithNullCheck) { +TEST_F(OrderBySQLTests, OrderByWithNullCheckTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); diff --git a/test/sql/projection_sql_test.cpp b/test/sql/projection_sql_test.cpp index 98ed0e4d45c..dca06f01374 100644 --- a/test/sql/projection_sql_test.cpp +++ b/test/sql/projection_sql_test.cpp @@ -21,7 +21,7 @@ namespace peloton { namespace test { -class ProjectionSQLTests : public PelotonTest { +class ProjectionSQLTests : public PelotonTests { public: ProjectionSQLTests() { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); diff --git a/test/sql/string_functions_sql_test.cpp b/test/sql/string_functions_sql_test.cpp index 4a57c8a3b45..97c8141261c 100644 --- a/test/sql/string_functions_sql_test.cpp +++ b/test/sql/string_functions_sql_test.cpp @@ -22,14 +22,14 @@ namespace peloton { namespace test { -class StringFunctionTest : public PelotonTest {}; +class StringFunctionTests : public PelotonTests {}; /* The following test inserts 32 tuples in the datatable. Each tuple inserted is of the form (i, i * 'a' ), where i belongs to [0,32) We then perform a sequential scan on the table and retrieve the id and length of the second column. */ -TEST_F(StringFunctionTest, LengthTest) { +TEST_F(StringFunctionTests, LengthTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); diff --git a/test/sql/timestamp_functions_sql_test.cpp b/test/sql/timestamp_functions_sql_test.cpp index c368f84ad1c..f6bdbb62fcc 100644 --- a/test/sql/timestamp_functions_sql_test.cpp +++ b/test/sql/timestamp_functions_sql_test.cpp @@ -20,9 +20,9 @@ namespace peloton { namespace test { -class TimestampFunctionsSQLTest : public PelotonTest {}; +class TimestampFunctionsSQLTests : public PelotonTests {}; -TEST_F(TimestampFunctionsSQLTest, DateTruncTest) { +TEST_F(TimestampFunctionsSQLTests, DateTruncTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -76,7 +76,7 @@ TEST_F(TimestampFunctionsSQLTest, DateTruncTest) { txn_manager.CommitTransaction(txn); } -TEST_F(TimestampFunctionsSQLTest, DatePartTest) { +TEST_F(TimestampFunctionsSQLTests, DatePartTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); diff --git a/test/sql/type_sql_test.cpp b/test/sql/type_sql_test.cpp index 1da4f602646..7e1f156e465 100644 --- a/test/sql/type_sql_test.cpp +++ b/test/sql/type_sql_test.cpp @@ -20,10 +20,10 @@ namespace peloton { namespace test { -class TypeSQLTests : public PelotonTest { +class TypeSQLTests : public PelotonTests { protected: virtual void SetUp() override { - PelotonTest::SetUp(); + PelotonTests::SetUp(); auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); @@ -37,7 +37,7 @@ class TypeSQLTests : public PelotonTest { catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); txn_manager.CommitTransaction(txn); - PelotonTest::TearDown(); + PelotonTests::TearDown(); } }; diff --git a/test/sql/update_primary_index_sql_test.cpp b/test/sql/update_primary_index_sql_test.cpp index 0b6f91b39f1..8d5f6111b26 100644 --- a/test/sql/update_primary_index_sql_test.cpp +++ b/test/sql/update_primary_index_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class UpdatePrimaryIndexSQLTests : public PelotonTest {}; +class UpdatePrimaryIndexSQLTests : public PelotonTests {}; TEST_F(UpdatePrimaryIndexSQLTests, UpdatePrimaryIndexTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); diff --git a/test/sql/update_secondary_index_sql_test.cpp b/test/sql/update_secondary_index_sql_test.cpp index 842bc1ca9ee..f667edf8084 100644 --- a/test/sql/update_secondary_index_sql_test.cpp +++ b/test/sql/update_secondary_index_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class UpdateSecondaryIndexSQLTests : public PelotonTest {}; +class UpdateSecondaryIndexSQLTests : public PelotonTests {}; TEST_F(UpdateSecondaryIndexSQLTests, UpdateSecondaryIndexTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); diff --git a/test/sql/update_sql_test.cpp b/test/sql/update_sql_test.cpp index f3584843918..b3ff27b6b69 100644 --- a/test/sql/update_sql_test.cpp +++ b/test/sql/update_sql_test.cpp @@ -22,7 +22,7 @@ namespace peloton { namespace test { -class UpdateSQLTests : public PelotonTest {}; +class UpdateSQLTests : public PelotonTests {}; TEST_F(UpdateSQLTests, SimpleUpdateSQLTest) { LOG_DEBUG("Bootstrapping..."); @@ -222,8 +222,7 @@ TEST_F(UpdateSQLTests, UpdateSQLCastTest) { LOG_DEBUG("Inserting a tuple..."); LOG_DEBUG("Query: INSERT INTO employees VALUES (0, 1, 0.5)"); - TestingSQLUtil::ExecuteSQLQuery( - "INSERT INTO employees VALUES (0, 1, 0.5);"); + TestingSQLUtil::ExecuteSQLQuery("INSERT INTO employees VALUES (0, 1, 0.5);"); LOG_DEBUG("Tuple inserted!"); @@ -237,8 +236,8 @@ TEST_F(UpdateSQLTests, UpdateSQLCastTest) { int rows_affected; TestingSQLUtil::ExecuteSQLQuery( - "UPDATE employees SET salary = 2.0 WHERE e_id = 0", - result, tuple_descriptor, rows_affected, error_message); + "UPDATE employees SET salary = 2.0 WHERE e_id = 0", result, + tuple_descriptor, rows_affected, error_message); LOG_DEBUG("Tuple Updated!"); @@ -257,8 +256,8 @@ TEST_F(UpdateSQLTests, UpdateSQLCastTest) { LOG_DEBUG("Query: UPDATE employees SET salary = 3 WHERE e_id = 0"); TestingSQLUtil::ExecuteSQLQuery( - "UPDATE employees SET salary = 3 WHERE e_id = 0", - result, tuple_descriptor, rows_affected, error_message); + "UPDATE employees SET salary = 3 WHERE e_id = 0", result, + tuple_descriptor, rows_affected, error_message); LOG_DEBUG("Tuple Updated Again!"); @@ -355,7 +354,7 @@ TEST_F(UpdateSQLTests, HalloweenProblemTest) { txn_manager.CommitTransaction(txn); } -TEST_F(UpdateSQLTests, HalloweenProblemTestWithPK) { +TEST_F(UpdateSQLTests, HalloweenProblemWithPKTest) { // This SQL Test verifies that executor does not cause the Halloween Problem // This test checks for tables with Primary Keys // It checks for updates on both Non-Primary Key column & Primary Key column @@ -380,7 +379,8 @@ TEST_F(UpdateSQLTests, HalloweenProblemTestWithPK) { LOG_DEBUG("Creating a table..."); LOG_DEBUG("Query: CREATE TABLE test(a INT PRIMARY KEY, b INT)"); - TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE test(a INT PRIMARY KEY, b INT);"); + TestingSQLUtil::ExecuteSQLQuery( + "CREATE TABLE test(a INT PRIMARY KEY, b INT);"); LOG_DEBUG("Table created!"); @@ -447,9 +447,6 @@ TEST_F(UpdateSQLTests, HalloweenProblemTestWithPK) { EXPECT_EQ(TestingSQLUtil::GetResultValueAsString(result, 0), "500"); LOG_DEBUG("Successfully updated tuple."); - - - // free the database just created txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); @@ -520,7 +517,6 @@ TEST_F(UpdateSQLTests, MultiTileGroupUpdateSQLTest) { EXPECT_EQ(1, rows_affected); LOG_DEBUG("Tuple Update successful, again!"); - // free the database just created txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn); diff --git a/test/statistics/stats_test.cpp b/test/statistics/stats_test.cpp index ef3c7da6cba..765dca3a7be 100644 --- a/test/statistics/stats_test.cpp +++ b/test/statistics/stats_test.cpp @@ -40,7 +40,7 @@ namespace peloton { namespace test { -class StatsTests : public PelotonTest {}; +class StatsTests : public PelotonTests {}; // Launch the aggregator thread manually void LaunchAggregator(int64_t stat_interval) { @@ -142,8 +142,7 @@ TEST_F(StatsTests, MultiThreadStatsTest) { // Create multiple stat worker threads int num_threads = 8; - storage::Database *database = - catalog->GetDatabaseWithName("emp_db", txn); + storage::Database *database = catalog->GetDatabaseWithName("emp_db", txn); storage::DataTable *table = catalog->GetTableWithName( "emp_db", DEFAULT_SCHEMA_NAME, "department_table", txn); txn_manager.CommitTransaction(txn); diff --git a/test/storage/backend_manager_test.cpp b/test/storage/backend_manager_test.cpp index ec2c6fece01..0d4e5a98c7e 100644 --- a/test/storage/backend_manager_test.cpp +++ b/test/storage/backend_manager_test.cpp @@ -21,7 +21,7 @@ namespace test { // Storage Manager Test //===--------------------------------------------------------------------===// -class StorageManagerTests : public PelotonTest {}; +class StorageManagerTests : public PelotonTests {}; /** * Test basic functionality diff --git a/test/storage/data_table_test.cpp b/test/storage/data_table_test.cpp index d64ec8bcb90..309f49ca664 100644 --- a/test/storage/data_table_test.cpp +++ b/test/storage/data_table_test.cpp @@ -27,7 +27,7 @@ namespace test { // Data Table Tests //===--------------------------------------------------------------------===// -class DataTableTests : public PelotonTest {}; +class DataTableTests : public PelotonTests {}; TEST_F(DataTableTests, TransformTileGroupTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; @@ -37,8 +37,8 @@ TEST_F(DataTableTests, TransformTileGroupTest) { auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); - TestingExecutorUtil::PopulateTable(data_table.get(), tuple_count, false, false, - true, txn); + TestingExecutorUtil::PopulateTable(data_table.get(), tuple_count, false, + false, true, txn); txn_manager.CommitTransaction(txn); // Create the new column map @@ -72,17 +72,16 @@ TEST_F(DataTableTests, TransformTileGroupTest) { data_table->TransformTileGroup(0, theta); } - TEST_F(DataTableTests, GlobalTableTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); - std::unique_ptr data_table_test_table ( + std::unique_ptr data_table_test_table( TestingExecutorUtil::CreateTable(tuple_count, false)); TestingExecutorUtil::PopulateTable(data_table_test_table.get(), tuple_count, - false, false, true, txn); + false, false, true, txn); txn_manager.CommitTransaction(txn); } diff --git a/test/storage/database_test.cpp b/test/storage/database_test.cpp index 427d4c220e3..0a76d68ec91 100644 --- a/test/storage/database_test.cpp +++ b/test/storage/database_test.cpp @@ -28,7 +28,7 @@ namespace test { // Database Tests //===--------------------------------------------------------------------===// -class DatabaseTests : public PelotonTest {}; +class DatabaseTests : public PelotonTests {}; TEST_F(DatabaseTests, AddDropTest) { // ADD! diff --git a/test/storage/masked_tuple_test.cpp b/test/storage/masked_tuple_test.cpp index 44e549b09e8..a7d33ef6e56 100644 --- a/test/storage/masked_tuple_test.cpp +++ b/test/storage/masked_tuple_test.cpp @@ -30,7 +30,7 @@ const int NUM_COLUMNS = 5; // MaskedTuple Tests //===--------------------------------------------------------------------===// -class MaskedTupleTests : public PelotonTest {}; +class MaskedTupleTests : public PelotonTests {}; void MaskedTupleTestHelper(storage::MaskedTuple *masked_tuple, std::vector values, std::vector mask) { @@ -67,8 +67,8 @@ TEST_F(MaskedTupleTests, BasicTest) { tuple_schema.reset(new catalog::Schema(column_list)); // CREATE REAL TUPLE - std::unique_ptr tuple(new storage::Tuple(tuple_schema.get(), - true)); + std::unique_ptr tuple( + new storage::Tuple(tuple_schema.get(), true)); std::vector values; for (int i = 0; i < NUM_COLUMNS; i++) { int val = (10 * i) + i; diff --git a/test/storage/temp_table_test.cpp b/test/storage/temp_table_test.cpp index 8c1f6b0caaa..74bc856c924 100644 --- a/test/storage/temp_table_test.cpp +++ b/test/storage/temp_table_test.cpp @@ -29,16 +29,17 @@ namespace test { // TempTable Tests //===--------------------------------------------------------------------===// -class TempTableTests : public PelotonTest {}; +class TempTableTests : public PelotonTests {}; TEST_F(TempTableTests, InsertTest) { const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; auto pool = TestingHarness::GetInstance().GetTestingPool(); - catalog::Schema *schema = new catalog::Schema( - {TestingExecutorUtil::GetColumnInfo(0), TestingExecutorUtil::GetColumnInfo(1), - TestingExecutorUtil::GetColumnInfo(2), - TestingExecutorUtil::GetColumnInfo(3)}); + catalog::Schema *schema = + new catalog::Schema({TestingExecutorUtil::GetColumnInfo(0), + TestingExecutorUtil::GetColumnInfo(1), + TestingExecutorUtil::GetColumnInfo(2), + TestingExecutorUtil::GetColumnInfo(3)}); // Create our TempTable storage::TempTable table(INVALID_OID, schema, true); diff --git a/test/storage/tile_group_iterator_test.cpp b/test/storage/tile_group_iterator_test.cpp index e133618ff46..57144160d24 100644 --- a/test/storage/tile_group_iterator_test.cpp +++ b/test/storage/tile_group_iterator_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include "common/harness.h" @@ -29,7 +28,7 @@ namespace test { // TileGroupIterator Tests //===--------------------------------------------------------------------===// -class TileGroupIteratorTests : public PelotonTest {}; +class TileGroupIteratorTests : public PelotonTests {}; TEST_F(TileGroupIteratorTests, BasicTest) { const int tuples_per_tilegroup = TESTS_TUPLES_PER_TILEGROUP; @@ -42,8 +41,8 @@ TEST_F(TileGroupIteratorTests, BasicTest) { auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuples_per_tilegroup, false)); - TestingExecutorUtil::PopulateTable(data_table.get(), tuple_count, false, false, - true, txn); + TestingExecutorUtil::PopulateTable(data_table.get(), tuple_count, false, + false, true, txn); txn_manager.CommitTransaction(txn); storage::TileGroupIterator tile_group_itr(data_table.get()); diff --git a/test/storage/tile_group_test.cpp b/test/storage/tile_group_test.cpp index 4aca1ecb536..9ba5e789cc8 100644 --- a/test/storage/tile_group_test.cpp +++ b/test/storage/tile_group_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include "common/harness.h" #include "type/value_factory.h" @@ -30,7 +29,7 @@ namespace test { // Tile Group Tests //===--------------------------------------------------------------------===// -class TileGroupTests : public PelotonTest {}; +class TileGroupTests : public PelotonTests {}; TEST_F(TileGroupTests, BasicTest) { std::vector columns; @@ -40,12 +39,15 @@ TEST_F(TileGroupTests, BasicTest) { // SCHEMA - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); catalog::Column column4(type::TypeId::VARCHAR, 25, "D", false); columns.push_back(column1); @@ -122,16 +124,16 @@ TEST_F(TileGroupTests, BasicTest) { auto txn = txn_manager.BeginTransaction(); auto tuple_slot = tile_group->InsertTuple(tuple1.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot)); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot)); tuple_slot = tile_group->InsertTuple(tuple2.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot)); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot)); tuple_slot = tile_group->InsertTuple(tuple1.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot)); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot)); txn_manager.CommitTransaction(txn); @@ -152,15 +154,16 @@ void TileGroupInsert(std::shared_ptr tile_group, tuple->SetValue(0, type::ValueFactory::GetIntegerValue(1), pool); tuple->SetValue(1, type::ValueFactory::GetIntegerValue(1), pool); tuple->SetValue(2, type::ValueFactory::GetTinyIntValue(1), pool); - tuple->SetValue( - 3, type::ValueFactory::GetVarcharValue("thread " + std::to_string(thread_id)), - pool); + tuple->SetValue(3, type::ValueFactory::GetVarcharValue( + "thread " + std::to_string(thread_id)), + pool); for (int insert_itr = 0; insert_itr < 1000; insert_itr++) { ItemPointer *index_entry_ptr = nullptr; auto tuple_slot = tile_group->InsertTuple(tuple.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot), index_entry_ptr); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot), + index_entry_ptr); } txn_manager.CommitTransaction(txn); @@ -173,12 +176,15 @@ TEST_F(TileGroupTests, StressTest) { std::vector schemas; // SCHEMA - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); catalog::Column column4(type::TypeId::VARCHAR, 50, "D", false); columns.push_back(column1); @@ -356,12 +362,15 @@ TEST_F(TileGroupTests, TileCopyTest) { std::vector> column_names; std::vector schemas; - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); catalog::Column column4(type::TypeId::VARCHAR, 25, "D", false); catalog::Column column5(type::TypeId::VARCHAR, 25, "E", false); @@ -417,37 +426,41 @@ TEST_F(TileGroupTests, TileCopyTest) { tuple1->SetValue(0, type::ValueFactory::GetIntegerValue(1), pool); tuple1->SetValue(1, type::ValueFactory::GetIntegerValue(1), pool); tuple1->SetValue(2, type::ValueFactory::GetTinyIntValue(1), pool); - tuple1->SetValue(3, type::ValueFactory::GetVarcharValue("vivek sengupta"), pool); - tuple1->SetValue(4, type::ValueFactory::GetVarcharValue("vivek sengupta again"), + tuple1->SetValue(3, type::ValueFactory::GetVarcharValue("vivek sengupta"), pool); + tuple1->SetValue( + 4, type::ValueFactory::GetVarcharValue("vivek sengupta again"), pool); tuple2->SetValue(0, type::ValueFactory::GetIntegerValue(2), pool); tuple2->SetValue(1, type::ValueFactory::GetIntegerValue(2), pool); tuple2->SetValue(2, type::ValueFactory::GetTinyIntValue(2), pool); tuple2->SetValue(3, type::ValueFactory::GetVarcharValue("ming fang"), pool); - tuple2->SetValue(4, type::ValueFactory::GetVarcharValue("ming fang again"), pool); + tuple2->SetValue(4, type::ValueFactory::GetVarcharValue("ming fang again"), + pool); tuple3->SetValue(0, type::ValueFactory::GetIntegerValue(3), pool); tuple3->SetValue(1, type::ValueFactory::GetIntegerValue(3), pool); tuple3->SetValue(2, type::ValueFactory::GetTinyIntValue(3), pool); - tuple3->SetValue(3, type::ValueFactory::GetVarcharValue("jinwoong kim"), pool); - tuple3->SetValue(4, type::ValueFactory::GetVarcharValue("jinwoong kim again"), pool); + tuple3->SetValue(3, type::ValueFactory::GetVarcharValue("jinwoong kim"), + pool); + tuple3->SetValue(4, type::ValueFactory::GetVarcharValue("jinwoong kim again"), + pool); tile->InsertTuple(0, tuple1.get()); tile->InsertTuple(1, tuple2.get()); tile->InsertTuple(2, tuple3.get()); tuple_slot_id = tile_group->InsertTuple(tuple1.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot_id)); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot_id)); EXPECT_EQ(0, tuple_slot_id); tuple_slot_id = tile_group->InsertTuple(tuple2.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot_id)); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot_id)); EXPECT_EQ(1, tuple_slot_id); tuple_slot_id = tile_group->InsertTuple(tuple3.get()); - txn_manager.PerformInsert(txn, - ItemPointer(tile_group->GetTileGroupId(), tuple_slot_id)); + txn_manager.PerformInsert( + txn, ItemPointer(tile_group->GetTileGroupId(), tuple_slot_id)); EXPECT_EQ(2, tuple_slot_id); txn_manager.CommitTransaction(txn); @@ -495,18 +508,18 @@ TEST_F(TileGroupTests, TileCopyTest) { // Iterate over all the tuples for the current uninlined column in the tile for (int tup_itr = 0; tup_itr < new_tile_active_tuple_count; tup_itr++) { - //Value uninlined_col_value, new_uninlined_col_value; + // Value uninlined_col_value, new_uninlined_col_value; - type::Value uninlined_col_value = ( - tile->GetValue(tup_itr, uninlined_col_index)); + type::Value uninlined_col_value = + (tile->GetValue(tup_itr, uninlined_col_index)); uninlined_col_object_len = uninlined_col_value.GetLength(); uninlined_col_object_ptr = (char *)uninlined_col_value.GetData(); std::string uninlined_varchar_str( reinterpret_cast(uninlined_col_object_ptr), uninlined_col_object_len); - type::Value new_uninlined_col_value = ( - new_tile->GetValue(tup_itr, uninlined_col_index)); + type::Value new_uninlined_col_value = + (new_tile->GetValue(tup_itr, uninlined_col_index)); new_uninlined_col_object_len = new_uninlined_col_value.GetLength(); new_uninlined_col_object_ptr = (char *)new_uninlined_col_value.GetData(); std::string new_uninlined_varchar_str( @@ -514,10 +527,11 @@ TEST_F(TileGroupTests, TileCopyTest) { new_uninlined_col_object_len); // Compare original and copied tile details for current tuple - type::Value cmp = type::ValueFactory::GetBooleanValue((uninlined_col_value.CompareNotEquals( - new_uninlined_col_value))); + type::Value cmp = type::ValueFactory::GetBooleanValue( + (uninlined_col_value.CompareNotEquals(new_uninlined_col_value))); int is_value_not_same = cmp.IsTrue(); -// int is_length_same = uninlined_col_object_len == uninlined_col_object_len; + // int is_length_same = uninlined_col_object_len == + // uninlined_col_object_len; int is_length_same = true; int is_pointer_same = uninlined_col_object_ptr == new_uninlined_col_object_ptr; @@ -525,7 +539,8 @@ TEST_F(TileGroupTests, TileCopyTest) { new_uninlined_varchar_str.c_str()); // Break if there is any mismatch - if (is_value_not_same || !is_length_same || is_pointer_same || is_data_same) { + if (is_value_not_same || !is_length_same || is_pointer_same || + is_data_same) { intended_behavior = false; break; } diff --git a/test/storage/tile_test.cpp b/test/storage/tile_test.cpp index 9cfb9b48948..8b13759a2f9 100644 --- a/test/storage/tile_test.cpp +++ b/test/storage/tile_test.cpp @@ -24,18 +24,21 @@ namespace test { // Tile Tests //===--------------------------------------------------------------------===// -class TileTests : public PelotonTest {}; +class TileTests : public PelotonTests {}; TEST_F(TileTests, BasicTest) { // Columns std::vector columns; - catalog::Column column1(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "A", true); - catalog::Column column2(type::TypeId::INTEGER, type::Type::GetTypeSize(type::TypeId::INTEGER), - "B", true); - catalog::Column column3(type::TypeId::TINYINT, type::Type::GetTypeSize(type::TypeId::TINYINT), - "C", true); + catalog::Column column1(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "A", + true); + catalog::Column column2(type::TypeId::INTEGER, + type::Type::GetTypeSize(type::TypeId::INTEGER), "B", + true); + catalog::Column column3(type::TypeId::TINYINT, + type::Type::GetTypeSize(type::TypeId::TINYINT), "C", + true); catalog::Column column4(type::TypeId::VARCHAR, 25, "D", false); catalog::Column column5(type::TypeId::VARCHAR, 25, "E", false); @@ -67,32 +70,36 @@ TEST_F(TileTests, BasicTest) { BackendType::MM, INVALID_OID, INVALID_OID, INVALID_OID, INVALID_OID, header.get(), *schema, nullptr, tuple_count)); - std::unique_ptr tuple1(new storage::Tuple(schema.get(), - true)); - std::unique_ptr tuple2(new storage::Tuple(schema.get(), - true)); - std::unique_ptr tuple3(new storage::Tuple(schema.get(), - true)); + std::unique_ptr tuple1( + new storage::Tuple(schema.get(), true)); + std::unique_ptr tuple2( + new storage::Tuple(schema.get(), true)); + std::unique_ptr tuple3( + new storage::Tuple(schema.get(), true)); auto pool = tile->GetPool(); tuple1->SetValue(0, type::ValueFactory::GetIntegerValue(1), pool); tuple1->SetValue(1, type::ValueFactory::GetIntegerValue(1), pool); tuple1->SetValue(2, type::ValueFactory::GetTinyIntValue(1), pool); - tuple1->SetValue(3, type::ValueFactory::GetVarcharValue("vivek sengupta"), pool); - tuple1->SetValue(4, type::ValueFactory::GetVarcharValue("vivek sengupta again"), + tuple1->SetValue(3, type::ValueFactory::GetVarcharValue("vivek sengupta"), pool); + tuple1->SetValue( + 4, type::ValueFactory::GetVarcharValue("vivek sengupta again"), pool); tuple2->SetValue(0, type::ValueFactory::GetIntegerValue(2), pool); tuple2->SetValue(1, type::ValueFactory::GetIntegerValue(2), pool); tuple2->SetValue(2, type::ValueFactory::GetTinyIntValue(2), pool); tuple2->SetValue(3, type::ValueFactory::GetVarcharValue("ming fang"), pool); - tuple2->SetValue(4, type::ValueFactory::GetVarcharValue("ming fang again"), pool); + tuple2->SetValue(4, type::ValueFactory::GetVarcharValue("ming fang again"), + pool); tuple3->SetValue(0, type::ValueFactory::GetIntegerValue(3), pool); tuple3->SetValue(1, type::ValueFactory::GetIntegerValue(3), pool); tuple3->SetValue(2, type::ValueFactory::GetTinyIntValue(3), pool); - tuple3->SetValue(3, type::ValueFactory::GetVarcharValue("jinwoong kim"), pool); - tuple3->SetValue(4, type::ValueFactory::GetVarcharValue("jinwoong kim again"), pool); + tuple3->SetValue(3, type::ValueFactory::GetVarcharValue("jinwoong kim"), + pool); + tuple3->SetValue(4, type::ValueFactory::GetVarcharValue("jinwoong kim again"), + pool); tile->InsertTuple(0, tuple1.get()); tile->InsertTuple(1, tuple2.get()); diff --git a/test/storage/tuple_test.cpp b/test/storage/tuple_test.cpp index 23526711575..2757b4e7aa6 100644 --- a/test/storage/tuple_test.cpp +++ b/test/storage/tuple_test.cpp @@ -25,7 +25,7 @@ namespace test { // Tuple Tests //===--------------------------------------------------------------------===// -class TupleTests : public PelotonTest {}; +class TupleTests : public PelotonTests {}; TEST_F(TupleTests, BasicTest) { std::vector columns; @@ -131,11 +131,12 @@ TEST_F(TupleTests, VarcharTest) { LOG_TRACE("%s", tuple->GetInfo().c_str()); // test if VARCHAR length is enforced - auto val3 = type::ValueFactory::GetVarcharValue((std::string) "this is a very long string", pool); + auto val3 = type::ValueFactory::GetVarcharValue( + (std::string) "this is a very long string", pool); try { tuple->SetValue(3, val3, pool); + } catch (peloton::ValueOutOfRangeException e) { } - catch (peloton::ValueOutOfRangeException e) {} value3 = (tuple->GetValue(3)); cmp = type::ValueFactory::GetBooleanValue((value3.CompareNotEquals(val3))); EXPECT_TRUE(cmp.IsTrue()); diff --git a/test/storage/zone_map_test.cpp b/test/storage/zone_map_test.cpp index f075eda2f5a..c71dc2ada9d 100644 --- a/test/storage/zone_map_test.cpp +++ b/test/storage/zone_map_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include "common/harness.h" @@ -34,7 +33,7 @@ namespace peloton { namespace test { -class ZoneMapTests : public PelotonTest {}; +class ZoneMapTests : public PelotonTests {}; namespace { /* @@ -223,8 +222,8 @@ TEST_F(ZoneMapTests, ZoneMapIntegerEqualityPredicateTest) { oid_t num_tile_groups = (data_table.get())->GetTileGroupCount(); auto temp = (std::vector *)parsed_predicates; for (oid_t i = 0; i < num_tile_groups - 1; i++) { - bool result = zone_map_manager->ShouldScanTileGroup( - temp->data(), 1, data_table.get(), i); + bool result = zone_map_manager->ShouldScanTileGroup(temp->data(), 1, + data_table.get(), i); if (i == 0) { EXPECT_EQ(result, true); } else { @@ -251,8 +250,8 @@ TEST_F(ZoneMapTests, ZoneMapIntegerLessThanPredicateTest) { oid_t num_tile_groups = (data_table.get())->GetTileGroupCount(); auto temp = (std::vector *)parsed_predicates; for (oid_t i = 0; i < num_tile_groups - 1; i++) { - bool result = zone_map_manager->ShouldScanTileGroup( - temp->data(), 1, data_table.get(), i); + bool result = zone_map_manager->ShouldScanTileGroup(temp->data(), 1, + data_table.get(), i); if (i <= 1) { EXPECT_EQ(result, true); } else { @@ -279,8 +278,8 @@ TEST_F(ZoneMapTests, ZoneMapIntegerGreaterThanPredicateTest) { oid_t num_tile_groups = (data_table.get())->GetTileGroupCount(); auto temp = (std::vector *)parsed_predicates; for (oid_t i = 0; i < num_tile_groups - 1; i++) { - bool result = zone_map_manager->ShouldScanTileGroup( - temp->data(), 1, data_table.get(), i); + bool result = zone_map_manager->ShouldScanTileGroup(temp->data(), 1, + data_table.get(), i); if (i <= 2) { EXPECT_EQ(result, false); } else { @@ -315,8 +314,8 @@ TEST_F(ZoneMapTests, ZoneMapIntegerConjunctionPredicateTest) { oid_t num_tile_groups = (data_table.get())->GetTileGroupCount(); auto temp = (std::vector *)parsed_predicates; for (oid_t i = 0; i < num_tile_groups - 1; i++) { - bool result = zone_map_manager->ShouldScanTileGroup( - temp->data(), 2, data_table.get(), i); + bool result = zone_map_manager->ShouldScanTileGroup(temp->data(), 2, + data_table.get(), i); if (i == 0 || i == 3) { EXPECT_EQ(result, false); } else { @@ -353,8 +352,8 @@ TEST_F(ZoneMapTests, ZoneMapDecimalConjunctionPredicateTest) { oid_t num_tile_groups = (data_table.get())->GetTileGroupCount(); auto temp = (std::vector *)parsed_predicates; for (oid_t i = 0; i < num_tile_groups - 1; i++) { - bool result = zone_map_manager->ShouldScanTileGroup( - temp->data(), 2, data_table.get(), i); + bool result = zone_map_manager->ShouldScanTileGroup(temp->data(), 2, + data_table.get(), i); if (i < 3) { EXPECT_EQ(result, false); } else { @@ -401,8 +400,8 @@ TEST_F(ZoneMapTests, ZoneMapMultiColumnConjunctionPredicateTest) { oid_t num_tile_groups = (data_table.get())->GetTileGroupCount(); auto temp = (std::vector *)parsed_predicates; for (oid_t i = 0; i < num_tile_groups - 1; i++) { - bool result = zone_map_manager->ShouldScanTileGroup( - temp->data(), 4, data_table.get(), i); + bool result = zone_map_manager->ShouldScanTileGroup(temp->data(), 4, + data_table.get(), i); if (i == 2) { EXPECT_EQ(result, true); } else { diff --git a/test/trigger/trigger_test.cpp b/test/trigger/trigger_test.cpp index c9c5b238ca3..6ddd7841446 100644 --- a/test/trigger/trigger_test.cpp +++ b/test/trigger/trigger_test.cpp @@ -24,7 +24,7 @@ namespace peloton { namespace test { -class TriggerTests : public PelotonTest { +class TriggerTests : public PelotonTests { protected: std::string table_name = "accounts"; std::string col_1 = "dept_id"; @@ -222,7 +222,7 @@ TEST_F(TriggerTests, BasicTest) { } // Test trigger type: before & after, each row, insert -TEST_F(TriggerTests, BeforeAndAfterRowInsertTriggers) { +TEST_F(TriggerTests, BeforeAndAfterRowInsertTriggersTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto parser = parser::PostgresParser::GetInstance(); @@ -307,7 +307,7 @@ TEST_F(TriggerTests, BeforeAndAfterRowInsertTriggers) { } // Test trigger type: after, statement, insert -TEST_F(TriggerTests, AfterStatmentInsertTriggers) { +TEST_F(TriggerTests, AfterStatmentInsertTriggersTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto parser = parser::PostgresParser::GetInstance(); @@ -388,7 +388,7 @@ TEST_F(TriggerTests, AfterStatmentInsertTriggers) { // Test other types of trigger in a relatively simple way. Because the workflow // is similar, and it is costly to manage redundant test cases. -TEST_F(TriggerTests, OtherTypesTriggers) { +TEST_F(TriggerTests, OtherTypesTriggersTest) { // Bootstrap auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto parser = parser::PostgresParser::GetInstance(); diff --git a/test/tuning/brain_util_test.cpp b/test/tuning/brain_util_test.cpp index dad2e4cbe94..b15f06c0193 100644 --- a/test/tuning/brain_util_test.cpp +++ b/test/tuning/brain_util_test.cpp @@ -34,7 +34,7 @@ namespace test { // BrainUtil Tests //===--------------------------------------------------------------------===// -class BrainUtilTests : public PelotonTest { +class BrainUtilTests : public PelotonTests { public: void TearDown() override { for (auto path : tempFiles) { @@ -42,7 +42,7 @@ class BrainUtilTests : public PelotonTest { std::remove(path.c_str()); } } // FOR - PelotonTest::TearDown(); + PelotonTests::TearDown(); } std::vector tempFiles; }; diff --git a/test/tuning/clusterer_test.cpp b/test/tuning/clusterer_test.cpp index 8153e680f8a..26ee2a73e77 100644 --- a/test/tuning/clusterer_test.cpp +++ b/test/tuning/clusterer_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -29,7 +28,7 @@ namespace test { // Clusterer Tests //===--------------------------------------------------------------------===// -class ClustererTests : public PelotonTest {}; +class ClustererTests : public PelotonTests {}; TEST_F(ClustererTests, BasicTest) { oid_t column_count = 7; @@ -73,19 +72,25 @@ TEST_F(ClustererTests, BasicTest) { std::ostringstream os; os << "COLUMN\tTILE\n"; for (UNUSED_ATTRIBUTE auto entry : partitioning1) { - os << entry.first << "\t" << entry.second.first << " : " << entry.second.second << "\n"; + os << entry.first << "\t" << entry.second.first << " : " + << entry.second.second << "\n"; } - LOG_INFO("\n%s", peloton::StringUtil::Prefix(peloton::StringTableUtil::Table(os.str(), true), - GETINFO_SPACER).c_str()); + LOG_INFO("\n%s", + peloton::StringUtil::Prefix( + peloton::StringTableUtil::Table(os.str(), true), GETINFO_SPACER) + .c_str()); os.str(""); auto partitioning2 = clusterer.GetPartitioning(4); os << "COLUMN\tTILE\n"; for (UNUSED_ATTRIBUTE auto entry : partitioning2) { - os << entry.first << "\t" << entry.second.first << " : " << entry.second.second << "\n"; + os << entry.first << "\t" << entry.second.first << " : " + << entry.second.second << "\n"; } - LOG_INFO("\n%s", peloton::StringUtil::Prefix(peloton::StringTableUtil::Table(os.str(), true), - GETINFO_SPACER).c_str()); + LOG_INFO("\n%s", + peloton::StringUtil::Prefix( + peloton::StringTableUtil::Table(os.str(), true), GETINFO_SPACER) + .c_str()); } } // namespace test diff --git a/test/tuning/index_tuner_test.cpp b/test/tuning/index_tuner_test.cpp index d03ff44c675..95083939122 100644 --- a/test/tuning/index_tuner_test.cpp +++ b/test/tuning/index_tuner_test.cpp @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// - #include #include #include @@ -34,10 +33,9 @@ namespace test { // Index Tuner Tests //===--------------------------------------------------------------------===// -class IndexTunerTests : public PelotonTest {}; +class IndexTunerTests : public PelotonTests {}; TEST_F(IndexTunerTests, BasicTest) { - const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; // Create a table and populate it @@ -45,8 +43,8 @@ TEST_F(IndexTunerTests, BasicTest) { auto txn = txn_manager.BeginTransaction(); std::unique_ptr data_table( TestingExecutorUtil::CreateTable(tuple_count, false)); - TestingExecutorUtil::PopulateTable(data_table.get(), tuple_count, false, false, - true, txn); + TestingExecutorUtil::PopulateTable(data_table.get(), tuple_count, false, + false, true, txn); txn_manager.CommitTransaction(txn); // Check column count @@ -87,9 +85,8 @@ TEST_F(IndexTunerTests, BasicTest) { // Create a table access sample // Indicates the columns present in predicate, query weight, and selectivity - tuning::Sample sample(columns_accessed, - sample_weight, - tuning::SampleType::ACCESS); + tuning::Sample sample(columns_accessed, sample_weight, + tuning::SampleType::ACCESS); // Collect index sample in table data_table->RecordIndexSample(sample); @@ -97,7 +94,7 @@ TEST_F(IndexTunerTests, BasicTest) { // Periodically sleep a bit // Index tuner thread will process the index samples periodically, // and materialize the appropriate ad-hoc indexes - if(sample_itr % 100 == 0 ){ + if (sample_itr % 100 == 0) { std::this_thread::sleep_for(std::chrono::microseconds(10000)); } } @@ -141,7 +138,6 @@ TEST_F(IndexTunerTests, BasicTest) { EXPECT_TRUE(candidate_index_found); } - } } // namespace test diff --git a/test/tuning/layout_tuner_test.cpp b/test/tuning/layout_tuner_test.cpp index 521ff92cc78..3b7228aa783 100644 --- a/test/tuning/layout_tuner_test.cpp +++ b/test/tuning/layout_tuner_test.cpp @@ -32,10 +32,9 @@ namespace test { // Layout Tuner Tests //===--------------------------------------------------------------------===// -class LayoutTunerTests : public PelotonTest {}; +class LayoutTunerTests : public PelotonTests {}; TEST_F(LayoutTunerTests, BasicTest) { - const int tuple_count = TESTS_TUPLES_PER_TILEGROUP; std::string db_name = "test_db"; @@ -79,8 +78,7 @@ TEST_F(LayoutTunerTests, BasicTest) { if (rng_val < 0.9) { columns_accessed = {0, 1, 2}; sample_weight = 100; - } - else { + } else { columns_accessed = {3}; sample_weight = 10; } @@ -96,7 +94,7 @@ TEST_F(LayoutTunerTests, BasicTest) { // Layout tuner thread will process the layout samples periodically, // derive the new table layout, and // transform the layout of existing tile groups in the table - if(sample_itr % 100 == 0 ){ + if (sample_itr % 100 == 0) { std::this_thread::sleep_for(std::chrono::microseconds(1000)); } } diff --git a/test/type/array_value_test.cpp b/test/type/array_value_test.cpp index 91e73647c98..bc05cacb8b2 100644 --- a/test/type/array_value_test.cpp +++ b/test/type/array_value_test.cpp @@ -28,7 +28,7 @@ namespace peloton { namespace test { -class ArrayValueTests : public PelotonTest {}; +class ArrayValueTests : public PelotonTests {}; #define RANDOM(a) (rand() % a) // Generate a random number in [0, a) #define RANDOM_DECIMAL() ((double)rand() / (double)rand()) @@ -67,7 +67,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_bool.push_back(RANDOM(2)); } - type::Value array_bool = type::Value(type::TypeId::ARRAY, vec_bool, type::TypeId::BOOLEAN); + type::Value array_bool = + type::Value(type::TypeId::ARRAY, vec_bool, type::TypeId::BOOLEAN); for (size_t i = 0; i < n; i++) { type::Value ele = array_bool.GetElementAt(i); EXPECT_EQ(bool(ele.GetAs()), vec_bool[i]); @@ -77,7 +78,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_tinyint.push_back(RANDOM8()); } - type::Value array_tinyint = type::Value(type::TypeId::ARRAY, vec_tinyint, type::TypeId::TINYINT); + type::Value array_tinyint = + type::Value(type::TypeId::ARRAY, vec_tinyint, type::TypeId::TINYINT); for (size_t i = 0; i < n; i++) { type::Value ele = array_tinyint.GetElementAt(i); EXPECT_EQ(ele.GetAs(), vec_tinyint[i]); @@ -87,7 +89,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_smallint.push_back(RANDOM16()); } - type::Value array_smallint = type::Value(type::TypeId::ARRAY, vec_smallint, type::TypeId::SMALLINT); + type::Value array_smallint = + type::Value(type::TypeId::ARRAY, vec_smallint, type::TypeId::SMALLINT); for (size_t i = 0; i < n; i++) { type::Value ele = array_smallint.GetElementAt(i); EXPECT_EQ(ele.GetAs(), vec_smallint[i]); @@ -97,7 +100,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_integer.push_back(RANDOM32()); } - type::Value array_integer = type::Value(type::TypeId::ARRAY, vec_integer, type::TypeId::INTEGER); + type::Value array_integer = + type::Value(type::TypeId::ARRAY, vec_integer, type::TypeId::INTEGER); for (size_t i = 0; i < n; i++) { type::Value ele = array_integer.GetElementAt(i); EXPECT_EQ(ele.GetAs(), vec_integer[i]); @@ -107,7 +111,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_bigint.push_back(RANDOM64()); } - type::Value array_bigint = type::Value(type::TypeId::ARRAY, vec_bigint, type::TypeId::BIGINT); + type::Value array_bigint = + type::Value(type::TypeId::ARRAY, vec_bigint, type::TypeId::BIGINT); for (size_t i = 0; i < n; i++) { type::Value ele = array_bigint.GetElementAt(i); EXPECT_EQ(ele.GetAs(), vec_bigint[i]); @@ -117,7 +122,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_decimal.push_back(RANDOM_DECIMAL()); } - type::Value array_decimal = type::Value(type::TypeId::ARRAY, vec_decimal, type::TypeId::DECIMAL); + type::Value array_decimal = + type::Value(type::TypeId::ARRAY, vec_decimal, type::TypeId::DECIMAL); for (size_t i = 0; i < n; i++) { type::Value ele = array_decimal.GetElementAt(i); EXPECT_EQ(ele.GetAs(), vec_decimal[i]); @@ -127,7 +133,8 @@ TEST_F(ArrayValueTests, GetElementTest) { for (size_t i = 0; i < n; i++) { vec_varchar.push_back(RANDOM_STRING(RANDOM(100) + 1)); } - type::Value array_varchar = type::Value(type::TypeId::ARRAY, vec_varchar, type::TypeId::VARCHAR); + type::Value array_varchar = + type::Value(type::TypeId::ARRAY, vec_varchar, type::TypeId::VARCHAR); for (size_t i = 0; i < n; i++) { type::Value ele = array_varchar.GetElementAt(i); EXPECT_EQ((ele).GetData(), vec_varchar[i]); @@ -142,7 +149,8 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_bool.push_back(RANDOM(2)); } - type::Value array_bool = type::Value(type::TypeId::ARRAY, vec_bool, type::TypeId::BOOLEAN); + type::Value array_bool = + type::Value(type::TypeId::ARRAY, vec_bool, type::TypeId::BOOLEAN); for (size_t i = 0; i < n; i++) { type::Value in_list = array_bool.InList(type::ValueFactory::GetBooleanValue(vec_bool[i])); @@ -153,10 +161,11 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_tinyint.push_back(RANDOM8()); } - type::Value array_tinyint = type::Value(type::TypeId::ARRAY, vec_tinyint, type::TypeId::TINYINT); + type::Value array_tinyint = + type::Value(type::TypeId::ARRAY, vec_tinyint, type::TypeId::TINYINT); for (size_t i = 0; i < n; i++) { - type::Value in_list = - array_tinyint.InList(type::ValueFactory::GetTinyIntValue(vec_tinyint[i])); + type::Value in_list = array_tinyint.InList( + type::ValueFactory::GetTinyIntValue(vec_tinyint[i])); EXPECT_TRUE((in_list).IsTrue()); } for (size_t i = 0; i < n; i++) { @@ -164,7 +173,8 @@ TEST_F(ArrayValueTests, InListTest) { std::vector::iterator it = find(vec_tinyint.begin(), vec_tinyint.end(), val); if (it == vec_tinyint.end()) { - type::Value in_list = array_tinyint.InList(type::ValueFactory::GetTinyIntValue(val)); + type::Value in_list = + array_tinyint.InList(type::ValueFactory::GetTinyIntValue(val)); EXPECT_TRUE((in_list).IsFalse()); } } @@ -173,10 +183,11 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_smallint.push_back(RANDOM16()); } - type::Value array_smallint = type::Value(type::TypeId::ARRAY, vec_smallint, type::TypeId::SMALLINT); + type::Value array_smallint = + type::Value(type::TypeId::ARRAY, vec_smallint, type::TypeId::SMALLINT); for (size_t i = 0; i < n; i++) { - type::Value in_list = - array_smallint.InList(type::ValueFactory::GetSmallIntValue(vec_smallint[i])); + type::Value in_list = array_smallint.InList( + type::ValueFactory::GetSmallIntValue(vec_smallint[i])); EXPECT_TRUE((in_list).IsTrue()); } for (size_t i = 0; i < n; i++) { @@ -194,10 +205,11 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_integer.push_back(RANDOM32()); } - type::Value array_integer = type::Value(type::TypeId::ARRAY, vec_integer, type::TypeId::INTEGER); + type::Value array_integer = + type::Value(type::TypeId::ARRAY, vec_integer, type::TypeId::INTEGER); for (size_t i = 0; i < n; i++) { - type::Value in_list = - array_integer.InList(type::ValueFactory::GetIntegerValue(vec_integer[i])); + type::Value in_list = array_integer.InList( + type::ValueFactory::GetIntegerValue(vec_integer[i])); EXPECT_TRUE((in_list).IsTrue()); } for (size_t i = 0; i < n; i++) { @@ -205,7 +217,8 @@ TEST_F(ArrayValueTests, InListTest) { std::vector::iterator it = find(vec_integer.begin(), vec_integer.end(), val); if (it == vec_integer.end()) { - type::Value in_list = array_integer.InList(type::ValueFactory::GetIntegerValue(val)); + type::Value in_list = + array_integer.InList(type::ValueFactory::GetIntegerValue(val)); EXPECT_TRUE((in_list).IsFalse()); } } @@ -214,7 +227,8 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_bigint.push_back(RANDOM64()); } - type::Value array_bigint = type::Value(type::TypeId::ARRAY, vec_bigint, type::TypeId::BIGINT); + type::Value array_bigint = + type::Value(type::TypeId::ARRAY, vec_bigint, type::TypeId::BIGINT); for (size_t i = 0; i < n; i++) { type::Value in_list = array_bigint.InList(type::ValueFactory::GetBigIntValue(vec_bigint[i])); @@ -225,7 +239,8 @@ TEST_F(ArrayValueTests, InListTest) { std::vector::iterator it = find(vec_bigint.begin(), vec_bigint.end(), val); if (it == vec_bigint.end()) { - type::Value in_list = array_bigint.InList(type::ValueFactory::GetBigIntValue(val)); + type::Value in_list = + array_bigint.InList(type::ValueFactory::GetBigIntValue(val)); EXPECT_TRUE((in_list).IsFalse()); } } @@ -234,10 +249,11 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_decimal.push_back(RANDOM64()); } - type::Value array_decimal = type::Value(type::TypeId::ARRAY, vec_decimal, type::TypeId::DECIMAL); + type::Value array_decimal = + type::Value(type::TypeId::ARRAY, vec_decimal, type::TypeId::DECIMAL); for (size_t i = 0; i < n; i++) { - type::Value in_list = - array_decimal.InList(type::ValueFactory::GetDecimalValue(vec_decimal[i])); + type::Value in_list = array_decimal.InList( + type::ValueFactory::GetDecimalValue(vec_decimal[i])); EXPECT_TRUE((in_list).IsTrue()); } for (size_t i = 0; i < n; i++) { @@ -245,7 +261,8 @@ TEST_F(ArrayValueTests, InListTest) { std::vector::iterator it = find(vec_decimal.begin(), vec_decimal.end(), val); if (it == vec_decimal.end()) { - type::Value in_list = array_decimal.InList(type::ValueFactory::GetDecimalValue(val)); + type::Value in_list = + array_decimal.InList(type::ValueFactory::GetDecimalValue(val)); EXPECT_TRUE((in_list).IsFalse()); } } @@ -254,10 +271,11 @@ TEST_F(ArrayValueTests, InListTest) { for (size_t i = 0; i < n; i++) { vec_varchar.push_back(RANDOM_STRING(RANDOM(100) + 1)); } - type::Value array_varchar = type::Value(type::TypeId::ARRAY, vec_varchar, type::TypeId::VARCHAR); + type::Value array_varchar = + type::Value(type::TypeId::ARRAY, vec_varchar, type::TypeId::VARCHAR); for (size_t i = 0; i < n; i++) { - type::Value in_list = - array_varchar.InList(type::ValueFactory::GetVarcharValue(vec_varchar[i])); + type::Value in_list = array_varchar.InList( + type::ValueFactory::GetVarcharValue(vec_varchar[i])); EXPECT_TRUE((in_list).IsTrue()); } for (size_t i = 0; i < n; i++) { @@ -265,7 +283,8 @@ TEST_F(ArrayValueTests, InListTest) { std::vector::iterator it = find(vec_varchar.begin(), vec_varchar.end(), val); if (it == vec_varchar.end()) { - type::Value in_list = array_varchar.InList(type::ValueFactory::GetVarcharValue(val)); + type::Value in_list = + array_varchar.InList(type::ValueFactory::GetVarcharValue(val)); EXPECT_TRUE((in_list).IsFalse()); } } @@ -340,7 +359,8 @@ TEST_F(ArrayValueTests, CompareTest) { type::Value v = type::ValueFactory::GetVarcharValue(""); // Test null varchar - EXPECT_TRUE(v.CompareEquals(type::ValueFactory::GetVarcharValue(nullptr, 0)) == CmpBool::NULL_); + EXPECT_TRUE(v.CompareEquals(type::ValueFactory::GetVarcharValue( + nullptr, 0)) == CmpBool::NULL_); } } } diff --git a/test/type/boolean_value_test.cpp b/test/type/boolean_value_test.cpp index 0e8544d3df2..58aca4f5f8b 100644 --- a/test/type/boolean_value_test.cpp +++ b/test/type/boolean_value_test.cpp @@ -21,7 +21,7 @@ namespace test { // Boolean Value Test //===--------------------------------------------------------------------===// -class BooleanValueTests : public PelotonTest {}; +class BooleanValueTests : public PelotonTests {}; TEST_F(BooleanValueTests, BasicTest) { auto valTrue = type::ValueFactory::GetBooleanValue(true); @@ -111,8 +111,7 @@ TEST_F(BooleanValueTests, ComparisonTest) { } // SWITCH LOG_TRACE("%s %s %s => %d | %d\n", val0.ToString().c_str(), ExpressionTypeToString(etype).c_str(), - val1.ToString().c_str(), - static_cast(expected), + val1.ToString().c_str(), static_cast(expected), static_cast(result)); if (expected_null) expected = false; diff --git a/test/type/date_value_test.cpp b/test/type/date_value_test.cpp index 0547dedaf5d..32b201ff586 100644 --- a/test/type/date_value_test.cpp +++ b/test/type/date_value_test.cpp @@ -21,7 +21,7 @@ namespace test { // Date Value Test //===--------------------------------------------------------------------===// -class DateValueTests : public PelotonTest {}; +class DateValueTests : public PelotonTests {}; TEST_F(DateValueTests, ComparisonTest) { std::vector compares = { @@ -47,8 +47,8 @@ TEST_F(DateValueTests, ComparisonTest) { val0 = type::ValueFactory::GetNullValueByType(type::TypeId::DATE); expected_null = true; } else { - val0 = type::ValueFactory::GetDateValue( - static_cast(values[i])); + val0 = + type::ValueFactory::GetDateValue(static_cast(values[i])); } // VALUE #1 @@ -56,8 +56,8 @@ TEST_F(DateValueTests, ComparisonTest) { val1 = type::ValueFactory::GetNullValueByType(type::TypeId::DATE); expected_null = true; } else { - val1 = type::ValueFactory::GetDateValue( - static_cast(values[j])); + val1 = + type::ValueFactory::GetDateValue(static_cast(values[j])); } bool temp = expected_null; @@ -97,8 +97,7 @@ TEST_F(DateValueTests, ComparisonTest) { } // SWITCH LOG_TRACE("%s %s %s => %d | %d\n", val0.ToString().c_str(), ExpressionTypeToString(etype).c_str(), - val1.ToString().c_str(), - static_cast(expected), + val1.ToString().c_str(), static_cast(expected), static_cast(result)); if (expected_null) { @@ -129,15 +128,14 @@ TEST_F(DateValueTests, HashTest) { if (values[i] == type::PELOTON_DATE_NULL) { val0 = type::ValueFactory::GetNullValueByType(type::TypeId::DATE); } else { - val0 = type::ValueFactory::GetDateValue( - static_cast(values[i])); + val0 = type::ValueFactory::GetDateValue(static_cast(values[i])); } for (int j = 0; j < 2; j++) { if (values[j] == type::PELOTON_DATE_NULL) { val1 = type::ValueFactory::GetNullValueByType(type::TypeId::DATE); } else { - val1 = type::ValueFactory::GetDateValue( - static_cast(values[j])); + val1 = + type::ValueFactory::GetDateValue(static_cast(values[j])); } result = type::ValueFactory::GetBooleanValue(val0.CompareEquals(val1)); diff --git a/test/type/numeric_value_test.cpp b/test/type/numeric_value_test.cpp index 3aa5c1bc066..c6e5d31722d 100644 --- a/test/type/numeric_value_test.cpp +++ b/test/type/numeric_value_test.cpp @@ -24,32 +24,26 @@ namespace peloton { namespace test { -class NumericValueTests : public PelotonTest {}; +class NumericValueTests : public PelotonTests {}; #define RANDOM_DECIMAL() ((double)rand() / (double)rand()) #define SEED 233 #define TEST_NUM 100 -int8_t RANDOM8() { - return ((rand() % (SCHAR_MAX * 2 - 1)) - (SCHAR_MAX - 1)); -} +int8_t RANDOM8() { return ((rand() % (SCHAR_MAX * 2 - 1)) - (SCHAR_MAX - 1)); } -int16_t RANDOM16() { - return ((rand() % (SHRT_MAX * 2 - 1)) - (SHRT_MAX - 1)); -} +int16_t RANDOM16() { return ((rand() % (SHRT_MAX * 2 - 1)) - (SHRT_MAX - 1)); } int32_t RANDOM32() { int32_t ret = (((size_t)(rand()) << 1) | ((size_t)(rand()) & 0x1)); - if (ret != type::PELOTON_INT32_NULL) - return ret; + if (ret != type::PELOTON_INT32_NULL) return ret; return 1; } int64_t RANDOM64() { int64_t ret = (((size_t)(rand()) << 33) | ((size_t)(rand()) << 2) | ((size_t)(rand()) & 0x3)); - if (ret != type::PELOTON_INT64_NULL) - return ret; + if (ret != type::PELOTON_INT64_NULL) return ret; return 1; } @@ -102,7 +96,7 @@ void CheckGreaterThan(type::Value &v1, type::Value &v2) { } // Compare two integers -template +template void CheckCompare1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { type::Value v1 = type::Value(xtype, x); type::Value v2 = type::Value(ytype, y); @@ -115,7 +109,7 @@ void CheckCompare1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { } // Compare integer and decimal -template +template void CheckCompare2(T x, double y, type::TypeId xtype) { type::Value v1 = type::Value(xtype, x); type::Value v2 = type::ValueFactory::GetDecimalValue(y); @@ -128,7 +122,7 @@ void CheckCompare2(T x, double y, type::TypeId xtype) { } // Compare decimal and integer -template +template void CheckCompare3(double x, T y, type::TypeId ytype) { type::Value v1 = type::ValueFactory::GetDecimalValue(x); type::Value v2 = type::Value(ytype, y); @@ -153,10 +147,11 @@ void CheckCompare4(double x, double y) { } // Compare number with varchar -template +template void CheckCompare5(T x, T y, type::TypeId xtype) { type::Value v1 = type::Value(xtype, x); - type::Value v2 = type::ValueFactory::GetVarcharValue(type::Value(xtype, y).ToString()); + type::Value v2 = + type::ValueFactory::GetVarcharValue(type::Value(xtype, y).ToString()); if (x == y) CheckEqual(v1, v2); else if (x < y) @@ -171,9 +166,9 @@ inline double ValMod(double x, double y) { } // Check the operations of two integers -template +template void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { - type::TypeId maxtype = xtype > ytype? xtype : ytype; + type::TypeId maxtype = xtype > ytype ? xtype : ytype; type::Value v1; type::Value v2; // Test x + y @@ -184,18 +179,15 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { if ((x + y) != sum1 && (x + y) != sum2) { EXPECT_THROW(type::Value(xtype, x).Add(type::Value(ytype, y)), peloton::Exception); - } - else if (sizeof(x) >= sizeof(y)) { + } else if (sizeof(x) >= sizeof(y)) { if ((x > 0 && y > 0 && sum1 < 0) || (x < 0 && y < 0 && sum1 > 0)) { EXPECT_THROW(type::Value(xtype, x).Add(type::Value(ytype, y)), peloton::Exception); } - } - else if ((x > 0 && y > 0 && sum2 < 0) || (x < 0 && y < 0 && sum2 > 0)) { + } else if ((x > 0 && y > 0 && sum2 < 0) || (x < 0 && y < 0 && sum2 > 0)) { EXPECT_THROW(type::Value(xtype, x).Add(type::Value(ytype, y)), peloton::Exception); - } - else { + } else { v1 = type::Value(xtype, x).Add(type::Value(ytype, y)); CheckEqual(v1, v2); } @@ -207,18 +199,15 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { if ((x - y) != diff1 && (x - y) != diff2) { EXPECT_THROW(type::Value(xtype, x).Subtract(type::Value(ytype, y)), peloton::Exception); - } - else if (sizeof(x) >= sizeof(y)) { + } else if (sizeof(x) >= sizeof(y)) { if ((x > 0 && y < 0 && diff1 < 0) || (x < 0 && y > 0 && diff1 > 0)) { EXPECT_THROW(type::Value(xtype, x).Subtract(type::Value(ytype, y)), peloton::Exception); } - } - else if ((x > 0 && y < 0 && diff2 < 0) || (x < 0 && y > 0 && diff2 > 0)) { + } else if ((x > 0 && y < 0 && diff2 < 0) || (x < 0 && y > 0 && diff2 > 0)) { EXPECT_THROW(type::Value(xtype, x).Subtract(type::Value(ytype, y)), peloton::Exception); - } - else { + } else { v1 = type::Value(xtype, x).Subtract(type::Value(ytype, y)); CheckEqual(v1, v2); } @@ -231,18 +220,15 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { if ((x * y) != prod1 && (x * y) != prod2) { EXPECT_THROW(type::Value(xtype, x).Multiply(type::Value(ytype, y)), peloton::Exception); - } - else if (sizeof(x) >= sizeof(y)) { + } else if (sizeof(x) >= sizeof(y)) { if (y != 0 && prod1 / y != x) { EXPECT_THROW(type::Value(xtype, x).Multiply(type::Value(ytype, y)), peloton::Exception); } - } - else if (y != 0 && prod2 / y != x) { + } else if (y != 0 && prod2 / y != x) { EXPECT_THROW(type::Value(xtype, x).Multiply(type::Value(ytype, y)), peloton::Exception); - } - else { + } else { v1 = type::Value(xtype, x).Multiply(type::Value(ytype, y)); CheckEqual(v1, v2); } @@ -252,8 +238,7 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { if (y == 0) { EXPECT_THROW(type::Value(xtype, x).Divide(type::Value(ytype, y)), peloton::Exception); - } - else { + } else { v1 = type::Value(xtype, x).Divide(type::Value(ytype, y)); v2 = type::Value(maxtype, x / y); CheckEqual(v1, v2); @@ -264,8 +249,7 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { if (y == 0) { EXPECT_THROW(type::Value(xtype, x).Modulo(type::Value(ytype, y)), peloton::Exception); - } - else { + } else { v1 = type::Value(xtype, x).Modulo(type::Value(ytype, y)); v2 = type::Value(maxtype, x % y); CheckEqual(v1, v2); @@ -273,10 +257,8 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { // Test sqrt(x) if (x < 0) { - EXPECT_THROW(type::Value(xtype, x).Sqrt(), - peloton::Exception); - } - else { + EXPECT_THROW(type::Value(xtype, x).Sqrt(), peloton::Exception); + } else { v1 = type::Value(xtype, x).Sqrt(); v2 = type::ValueFactory::GetDecimalValue(sqrt(x)); CheckEqual(v1, v2); @@ -284,7 +266,7 @@ void CheckMath1(T1 x, T2 y, type::TypeId xtype, type::TypeId ytype) { } // Check the operations of an integer and a decimal -template +template void CheckMath2(T x, double y, type::TypeId xtype) { type::Value v1, v2; v1 = type::Value(xtype, x).Add(type::ValueFactory::GetDecimalValue(y)); @@ -301,8 +283,9 @@ void CheckMath2(T x, double y, type::TypeId xtype) { // Divide by zero detection if (y == 0) - EXPECT_THROW(type::Value(xtype, x).Divide(type::ValueFactory::GetDecimalValue(y)), - peloton::Exception); + EXPECT_THROW( + type::Value(xtype, x).Divide(type::ValueFactory::GetDecimalValue(y)), + peloton::Exception); else { v1 = type::Value(xtype, x).Divide(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(x / y); @@ -311,8 +294,9 @@ void CheckMath2(T x, double y, type::TypeId xtype) { // Divide by zero detection if (y == 0) - EXPECT_THROW(type::Value(xtype, x).Modulo(type::ValueFactory::GetDecimalValue(y)), - peloton::Exception); + EXPECT_THROW( + type::Value(xtype, x).Modulo(type::ValueFactory::GetDecimalValue(y)), + peloton::Exception); else { v1 = type::Value(xtype, x).Modulo(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(ValMod(x, y)); @@ -321,7 +305,7 @@ void CheckMath2(T x, double y, type::TypeId xtype) { } // Check the operations of a decimal and an integer -template +template void CheckMath3(double x, T y, type::TypeId ytype) { type::Value v1, v2; @@ -339,8 +323,9 @@ void CheckMath3(double x, T y, type::TypeId ytype) { // Divide by zero detection if (y == 0) - EXPECT_THROW(type::ValueFactory::GetDecimalValue(x).Divide(type::Value(ytype, y)), - peloton::Exception); + EXPECT_THROW( + type::ValueFactory::GetDecimalValue(x).Divide(type::Value(ytype, y)), + peloton::Exception); else { v1 = type::ValueFactory::GetDecimalValue(x).Divide(type::Value(ytype, y)); v2 = type::ValueFactory::GetDecimalValue(x / y); @@ -349,8 +334,9 @@ void CheckMath3(double x, T y, type::TypeId ytype) { // Divide by zero detection if (y == 0) - EXPECT_THROW(type::ValueFactory::GetDecimalValue(x).Modulo(type::Value(ytype, y)), - peloton::Exception); + EXPECT_THROW( + type::ValueFactory::GetDecimalValue(x).Modulo(type::Value(ytype, y)), + peloton::Exception); else { v1 = type::ValueFactory::GetDecimalValue(x).Modulo(type::Value(ytype, y)); v2 = type::ValueFactory::GetDecimalValue(ValMod(x, y)); @@ -362,41 +348,48 @@ void CheckMath3(double x, T y, type::TypeId ytype) { void CheckMath4(double x, double y) { type::Value v1, v2; - v1 = type::ValueFactory::GetDecimalValue(x).Add(type::ValueFactory::GetDecimalValue(y)); + v1 = type::ValueFactory::GetDecimalValue(x) + .Add(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(x + y); CheckEqual(v1, v2); - v1 = type::ValueFactory::GetDecimalValue(x).Subtract(type::ValueFactory::GetDecimalValue(y)); + v1 = type::ValueFactory::GetDecimalValue(x) + .Subtract(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(x - y); CheckEqual(v1, v2); - v1 = type::ValueFactory::GetDecimalValue(x).Multiply(type::ValueFactory::GetDecimalValue(y)); + v1 = type::ValueFactory::GetDecimalValue(x) + .Multiply(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(x * y); CheckEqual(v1, v2); // Divide by zero detection if (y == 0) - EXPECT_THROW(type::ValueFactory::GetDecimalValue(x).Divide(type::ValueFactory::GetDecimalValue(y)), - peloton::Exception); + EXPECT_THROW(type::ValueFactory::GetDecimalValue(x) + .Divide(type::ValueFactory::GetDecimalValue(y)), + peloton::Exception); else { - v1 = type::ValueFactory::GetDecimalValue(x).Divide(type::ValueFactory::GetDecimalValue(y)); + v1 = type::ValueFactory::GetDecimalValue(x) + .Divide(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(x / y); CheckEqual(v1, v2); } // Divide by zero detection if (y == 0) - EXPECT_THROW(type::ValueFactory::GetDecimalValue(x).Modulo(type::ValueFactory::GetDecimalValue(y)), - peloton::Exception); + EXPECT_THROW(type::ValueFactory::GetDecimalValue(x) + .Modulo(type::ValueFactory::GetDecimalValue(y)), + peloton::Exception); else { - v1 = type::ValueFactory::GetDecimalValue(x).Modulo(type::ValueFactory::GetDecimalValue(y)); + v1 = type::ValueFactory::GetDecimalValue(x) + .Modulo(type::ValueFactory::GetDecimalValue(y)); v2 = type::ValueFactory::GetDecimalValue(ValMod(x, y)); CheckEqual(v1, v2); } - + if (x < 0) - EXPECT_THROW(type::ValueFactory::GetDecimalValue(x).Sqrt(), - peloton::Exception); + EXPECT_THROW(type::ValueFactory::GetDecimalValue(x).Sqrt(), + peloton::Exception); else { v1 = type::ValueFactory::GetDecimalValue(x).Sqrt(); v2 = type::ValueFactory::GetDecimalValue(sqrt(x)); @@ -407,10 +400,14 @@ void CheckMath4(double x, double y) { TEST_F(NumericValueTests, TinyIntComparisonTest) { std::srand(SEED); for (int i = 0; i < TEST_NUM; i++) { - CheckCompare1(RANDOM8(), RANDOM8(), type::TypeId::TINYINT, type::TypeId::TINYINT); - CheckCompare1(RANDOM8(), RANDOM16(), type::TypeId::TINYINT, type::TypeId::SMALLINT); - CheckCompare1(RANDOM8(), RANDOM32(), type::TypeId::TINYINT, type::TypeId::INTEGER); - CheckCompare1(RANDOM8(), RANDOM64(), type::TypeId::TINYINT, type::TypeId::BIGINT); + CheckCompare1(RANDOM8(), RANDOM8(), type::TypeId::TINYINT, + type::TypeId::TINYINT); + CheckCompare1(RANDOM8(), RANDOM16(), type::TypeId::TINYINT, + type::TypeId::SMALLINT); + CheckCompare1(RANDOM8(), RANDOM32(), type::TypeId::TINYINT, + type::TypeId::INTEGER); + CheckCompare1(RANDOM8(), RANDOM64(), type::TypeId::TINYINT, + type::TypeId::BIGINT); CheckCompare2(RANDOM8(), RANDOM_DECIMAL(), type::TypeId::TINYINT); CheckCompare3(RANDOM_DECIMAL(), RANDOM8(), type::TypeId::TINYINT); @@ -426,12 +423,18 @@ TEST_F(NumericValueTests, TinyIntComparisonTest) { TEST_F(NumericValueTests, SmallIntComparisonTest) { std::srand(SEED); for (int i = 0; i < TEST_NUM; i++) { - CheckCompare1(RANDOM16(), RANDOM8(), type::TypeId::SMALLINT, type::TypeId::TINYINT); - CheckCompare1(RANDOM16(), RANDOM16(), type::TypeId::SMALLINT, type::TypeId::SMALLINT); - CheckCompare1(RANDOM16(), RANDOM32(), type::TypeId::SMALLINT, type::TypeId::INTEGER); - CheckCompare1(RANDOM16(), RANDOM64(), type::TypeId::SMALLINT, type::TypeId::BIGINT); - CheckCompare2(RANDOM16(), RANDOM_DECIMAL(), type::TypeId::SMALLINT); - CheckCompare3(RANDOM_DECIMAL(), RANDOM16(), type::TypeId::SMALLINT); + CheckCompare1( + RANDOM16(), RANDOM8(), type::TypeId::SMALLINT, type::TypeId::TINYINT); + CheckCompare1( + RANDOM16(), RANDOM16(), type::TypeId::SMALLINT, type::TypeId::SMALLINT); + CheckCompare1( + RANDOM16(), RANDOM32(), type::TypeId::SMALLINT, type::TypeId::INTEGER); + CheckCompare1( + RANDOM16(), RANDOM64(), type::TypeId::SMALLINT, type::TypeId::BIGINT); + CheckCompare2(RANDOM16(), RANDOM_DECIMAL(), + type::TypeId::SMALLINT); + CheckCompare3(RANDOM_DECIMAL(), RANDOM16(), + type::TypeId::SMALLINT); int16_t v0 = RANDOM16(); int16_t v1 = v0 + 1; @@ -445,10 +448,14 @@ TEST_F(NumericValueTests, SmallIntComparisonTest) { TEST_F(NumericValueTests, IntComparisonTest) { std::srand(SEED); for (int i = 0; i < TEST_NUM; i++) { - CheckCompare1(RANDOM32(), RANDOM8(), type::TypeId::INTEGER, type::TypeId::TINYINT); - CheckCompare1(RANDOM32(), RANDOM16(), type::TypeId::INTEGER, type::TypeId::SMALLINT); - CheckCompare1(RANDOM32(), RANDOM32(), type::TypeId::INTEGER, type::TypeId::INTEGER); - CheckCompare1(RANDOM32(), RANDOM64(), type::TypeId::INTEGER, type::TypeId::BIGINT); + CheckCompare1(RANDOM32(), RANDOM8(), type::TypeId::INTEGER, + type::TypeId::TINYINT); + CheckCompare1( + RANDOM32(), RANDOM16(), type::TypeId::INTEGER, type::TypeId::SMALLINT); + CheckCompare1( + RANDOM32(), RANDOM32(), type::TypeId::INTEGER, type::TypeId::INTEGER); + CheckCompare1( + RANDOM32(), RANDOM64(), type::TypeId::INTEGER, type::TypeId::BIGINT); CheckCompare2(RANDOM32(), RANDOM_DECIMAL(), type::TypeId::INTEGER); CheckCompare3(RANDOM_DECIMAL(), RANDOM32(), type::TypeId::INTEGER); @@ -464,10 +471,14 @@ TEST_F(NumericValueTests, IntComparisonTest) { TEST_F(NumericValueTests, BigIntComparisonTest) { std::srand(SEED); for (int i = 0; i < TEST_NUM; i++) { - CheckCompare1(RANDOM64(), RANDOM8(), type::TypeId::BIGINT, type::TypeId::TINYINT); - CheckCompare1(RANDOM64(), RANDOM16(), type::TypeId::BIGINT, type::TypeId::SMALLINT); - CheckCompare1(RANDOM64(), RANDOM32(), type::TypeId::BIGINT, type::TypeId::INTEGER); - CheckCompare1(RANDOM64(), RANDOM64(), type::TypeId::BIGINT, type::TypeId::BIGINT); + CheckCompare1(RANDOM64(), RANDOM8(), type::TypeId::BIGINT, + type::TypeId::TINYINT); + CheckCompare1( + RANDOM64(), RANDOM16(), type::TypeId::BIGINT, type::TypeId::SMALLINT); + CheckCompare1( + RANDOM64(), RANDOM32(), type::TypeId::BIGINT, type::TypeId::INTEGER); + CheckCompare1(RANDOM64(), RANDOM64(), + type::TypeId::BIGINT, type::TypeId::BIGINT); CheckCompare2(RANDOM64(), RANDOM_DECIMAL(), type::TypeId::BIGINT); CheckCompare3(RANDOM_DECIMAL(), RANDOM64(), type::TypeId::BIGINT); CheckCompare4(RANDOM_DECIMAL(), RANDOM_DECIMAL()); @@ -487,28 +498,44 @@ TEST_F(NumericValueTests, MathTest) { // Generate two values v1 and v2 // Check type::Value(v1) op type::Value(v2) == type::Value(v1 op v2); for (int i = 0; i < TEST_NUM; i++) { - CheckMath1(RANDOM8(), RANDOM8(), type::TypeId::TINYINT, type::TypeId::TINYINT); - CheckMath1(RANDOM8(), RANDOM16(), type::TypeId::TINYINT, type::TypeId::SMALLINT); - CheckMath1(RANDOM8(), RANDOM32(), type::TypeId::TINYINT, type::TypeId::INTEGER); - CheckMath1(RANDOM8(), RANDOM64(), type::TypeId::TINYINT, type::TypeId::BIGINT); + CheckMath1(RANDOM8(), RANDOM8(), type::TypeId::TINYINT, + type::TypeId::TINYINT); + CheckMath1(RANDOM8(), RANDOM16(), type::TypeId::TINYINT, + type::TypeId::SMALLINT); + CheckMath1(RANDOM8(), RANDOM32(), type::TypeId::TINYINT, + type::TypeId::INTEGER); + CheckMath1(RANDOM8(), RANDOM64(), type::TypeId::TINYINT, + type::TypeId::BIGINT); CheckMath2(RANDOM8(), RANDOM_DECIMAL(), type::TypeId::TINYINT); - CheckMath1(RANDOM16(), RANDOM8(), type::TypeId::SMALLINT, type::TypeId::TINYINT); - CheckMath1(RANDOM16(), RANDOM16(), type::TypeId::SMALLINT, type::TypeId::SMALLINT); - CheckMath1(RANDOM16(), RANDOM32(), type::TypeId::SMALLINT, type::TypeId::INTEGER); - CheckMath1(RANDOM16(), RANDOM64(), type::TypeId::SMALLINT, type::TypeId::BIGINT); + CheckMath1(RANDOM16(), RANDOM8(), type::TypeId::SMALLINT, + type::TypeId::TINYINT); + CheckMath1(RANDOM16(), RANDOM16(), type::TypeId::SMALLINT, + type::TypeId::SMALLINT); + CheckMath1(RANDOM16(), RANDOM32(), type::TypeId::SMALLINT, + type::TypeId::INTEGER); + CheckMath1(RANDOM16(), RANDOM64(), type::TypeId::SMALLINT, + type::TypeId::BIGINT); CheckMath2(RANDOM16(), RANDOM_DECIMAL(), type::TypeId::SMALLINT); - CheckMath1(RANDOM32(), RANDOM8(), type::TypeId::INTEGER, type::TypeId::TINYINT); - CheckMath1(RANDOM32(), RANDOM16(), type::TypeId::INTEGER, type::TypeId::SMALLINT); - CheckMath1(RANDOM32(), RANDOM32(), type::TypeId::INTEGER, type::TypeId::INTEGER); - CheckMath1(RANDOM32(), RANDOM64(), type::TypeId::BIGINT, type::TypeId::BIGINT); + CheckMath1(RANDOM32(), RANDOM8(), type::TypeId::INTEGER, + type::TypeId::TINYINT); + CheckMath1(RANDOM32(), RANDOM16(), type::TypeId::INTEGER, + type::TypeId::SMALLINT); + CheckMath1(RANDOM32(), RANDOM32(), type::TypeId::INTEGER, + type::TypeId::INTEGER); + CheckMath1(RANDOM32(), RANDOM64(), type::TypeId::BIGINT, + type::TypeId::BIGINT); CheckMath2(RANDOM32(), RANDOM_DECIMAL(), type::TypeId::INTEGER); - CheckMath1(RANDOM64(), RANDOM8(), type::TypeId::BIGINT, type::TypeId::TINYINT); - CheckMath1(RANDOM64(), RANDOM16(), type::TypeId::BIGINT, type::TypeId::SMALLINT); - CheckMath1(RANDOM64(), RANDOM32(), type::TypeId::BIGINT, type::TypeId::INTEGER); - CheckMath1(RANDOM64(), RANDOM64(), type::TypeId::BIGINT, type::TypeId::BIGINT); + CheckMath1(RANDOM64(), RANDOM8(), type::TypeId::BIGINT, + type::TypeId::TINYINT); + CheckMath1(RANDOM64(), RANDOM16(), type::TypeId::BIGINT, + type::TypeId::SMALLINT); + CheckMath1(RANDOM64(), RANDOM32(), type::TypeId::BIGINT, + type::TypeId::INTEGER); + CheckMath1(RANDOM64(), RANDOM64(), type::TypeId::BIGINT, + type::TypeId::BIGINT); CheckMath2(RANDOM64(), RANDOM_DECIMAL(), type::TypeId::BIGINT); CheckMath3(RANDOM_DECIMAL(), RANDOM8(), type::TypeId::TINYINT); @@ -552,7 +579,6 @@ TEST_F(NumericValueTests, IsZeroTest) { } TEST_F(NumericValueTests, SqrtTest) { - for (int i = 1; i <= 10; i++) { type::Value v1, v2; @@ -571,18 +597,13 @@ TEST_F(NumericValueTests, SqrtTest) { v1 = type::ValueFactory::GetBigIntValue(i * i).Sqrt(); v2 = type::ValueFactory::GetBigIntValue(i); CheckEqual(v1, v2); - } // FOR + } // FOR } TEST_F(NumericValueTests, CastAsTest) { - std::vector types = { - type::TypeId::TINYINT, - type::TypeId::SMALLINT, - type::TypeId::INTEGER, - type::TypeId::BIGINT, - type::TypeId::DECIMAL, - type::TypeId::VARCHAR, + type::TypeId::TINYINT, type::TypeId::SMALLINT, type::TypeId::INTEGER, + type::TypeId::BIGINT, type::TypeId::DECIMAL, type::TypeId::VARCHAR, }; for (int i = type::PELOTON_INT8_MIN; i <= type::PELOTON_INT8_MAX; i++) { @@ -607,7 +628,7 @@ TEST_F(NumericValueTests, CastAsTest) { break; case type::TypeId::VARCHAR: v1 = type::ValueFactory::GetVarcharValue( - type::ValueFactory::GetSmallIntValue(i).ToString()); + type::ValueFactory::GetSmallIntValue(i).ToString()); break; default: LOG_ERROR("Unexpected type!"); @@ -616,41 +637,55 @@ TEST_F(NumericValueTests, CastAsTest) { EXPECT_FALSE(v1.IsNull()); for (auto t2 : types) { type::Value v2 = v1.CastAs(t2); - LOG_TRACE("[%02d] %s -> %s", - i, TypeIdToString(t1).c_str(), + LOG_TRACE("[%02d] %s -> %s", i, TypeIdToString(t1).c_str(), TypeIdToString(t2).c_str()); CheckEqual(v1, v2); - } // FOR - } // FOR - } // FOR - + } // FOR + } // FOR + } // FOR } TEST_F(NumericValueTests, DivideByZeroTest) { std::srand(SEED); - CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, type::TypeId::TINYINT); - CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, type::TypeId::SMALLINT); - CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, type::TypeId::INTEGER); - CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, type::TypeId::BIGINT); + CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, + type::TypeId::TINYINT); + CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, + type::TypeId::SMALLINT); + CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, + type::TypeId::INTEGER); + CheckMath1(RANDOM8(), 0, type::TypeId::TINYINT, + type::TypeId::BIGINT); CheckMath2(RANDOM8(), 0, type::TypeId::TINYINT); - CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, type::TypeId::TINYINT); - CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, type::TypeId::SMALLINT); - CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, type::TypeId::INTEGER); - CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, type::TypeId::BIGINT); + CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, + type::TypeId::TINYINT); + CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, + type::TypeId::SMALLINT); + CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, + type::TypeId::INTEGER); + CheckMath1(RANDOM16(), 0, type::TypeId::SMALLINT, + type::TypeId::BIGINT); CheckMath2(RANDOM16(), 0, type::TypeId::SMALLINT); - CheckMath1(RANDOM32(), 0, type::TypeId::INTEGER, type::TypeId::TINYINT); - CheckMath1(RANDOM32(), 0, type::TypeId::INTEGER, type::TypeId::SMALLINT); - CheckMath1(RANDOM32(), 0, type::TypeId::INTEGER, type::TypeId::INTEGER); - CheckMath1(RANDOM32(), 0, type::TypeId::BIGINT, type::TypeId::BIGINT); + CheckMath1(RANDOM32(), 0, type::TypeId::INTEGER, + type::TypeId::TINYINT); + CheckMath1(RANDOM32(), 0, type::TypeId::INTEGER, + type::TypeId::SMALLINT); + CheckMath1(RANDOM32(), 0, type::TypeId::INTEGER, + type::TypeId::INTEGER); + CheckMath1(RANDOM32(), 0, type::TypeId::BIGINT, + type::TypeId::BIGINT); CheckMath2(RANDOM32(), 0, type::TypeId::INTEGER); - CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, type::TypeId::TINYINT); - CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, type::TypeId::SMALLINT); - CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, type::TypeId::INTEGER); - CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, type::TypeId::BIGINT); + CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, + type::TypeId::TINYINT); + CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, + type::TypeId::SMALLINT); + CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, + type::TypeId::INTEGER); + CheckMath1(RANDOM64(), 0, type::TypeId::BIGINT, + type::TypeId::BIGINT); CheckMath2(RANDOM64(), 0, type::TypeId::BIGINT); CheckMath3(RANDOM_DECIMAL(), 0, type::TypeId::TINYINT); @@ -666,189 +701,224 @@ TEST_F(NumericValueTests, NullValueTest) { // Compare null bool_result[0] = type::ValueFactory::GetIntegerValue(rand()).CompareEquals( - type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); bool_result[1] = type::ValueFactory::GetIntegerValue(rand()).CompareEquals( - type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); bool_result[2] = type::ValueFactory::GetIntegerValue(rand()).CompareEquals( - type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); bool_result[3] = type::ValueFactory::GetIntegerValue(rand()).CompareEquals( - type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); bool_result[4] = type::ValueFactory::GetIntegerValue(rand()).CompareEquals( - type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); for (int i = 0; i < 5; i++) { EXPECT_TRUE(bool_result[i] == CmpBool::NULL_); } - bool_result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).CompareEquals( - type::ValueFactory::GetIntegerValue(rand())); - bool_result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).CompareEquals( - type::ValueFactory::GetIntegerValue(rand())); - bool_result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).CompareEquals( - type::ValueFactory::GetIntegerValue(rand())); - bool_result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).CompareEquals( - type::ValueFactory::GetIntegerValue(rand())); - bool_result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).CompareEquals( - type::ValueFactory::GetIntegerValue(rand())); + bool_result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .CompareEquals(type::ValueFactory::GetIntegerValue(rand())); + bool_result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .CompareEquals(type::ValueFactory::GetIntegerValue(rand())); + bool_result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .CompareEquals(type::ValueFactory::GetIntegerValue(rand())); + bool_result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .CompareEquals(type::ValueFactory::GetIntegerValue(rand())); + bool_result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .CompareEquals(type::ValueFactory::GetIntegerValue(rand())); for (int i = 0; i < 5; i++) { EXPECT_TRUE(bool_result[i] == CmpBool::NULL_); } type::Value result[5]; - // Operate null result[0] = type::ValueFactory::GetIntegerValue(rand()).Add( - type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); result[1] = type::ValueFactory::GetIntegerValue(rand()).Add( - type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); result[2] = type::ValueFactory::GetIntegerValue(rand()).Add( - type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); result[3] = type::ValueFactory::GetIntegerValue(rand()).Add( - type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); result[4] = type::ValueFactory::GetIntegerValue(rand()).Add( - type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } result[0] = type::ValueFactory::GetIntegerValue(rand()).Subtract( - type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); result[1] = type::ValueFactory::GetIntegerValue(rand()).Subtract( - type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); result[2] = type::ValueFactory::GetIntegerValue(rand()).Subtract( - type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); result[3] = type::ValueFactory::GetIntegerValue(rand()).Subtract( - type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); result[4] = type::ValueFactory::GetIntegerValue(rand()).Subtract( - type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - - result[0] = type::ValueFactory::GetIntegerValue(rand()).Multiply( - type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); result[1] = type::ValueFactory::GetIntegerValue(rand()).Multiply( - type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); result[2] = type::ValueFactory::GetIntegerValue(rand()).Multiply( - type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); result[3] = type::ValueFactory::GetIntegerValue(rand()).Multiply( - type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); result[4] = type::ValueFactory::GetIntegerValue(rand()).Multiply( - type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } result[0] = type::ValueFactory::GetIntegerValue(rand()).Divide( - type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); result[1] = type::ValueFactory::GetIntegerValue(rand()).Divide( - type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); result[2] = type::ValueFactory::GetIntegerValue(rand()).Divide( - type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); result[3] = type::ValueFactory::GetIntegerValue(rand()).Divide( - type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); result[4] = type::ValueFactory::GetIntegerValue(rand()).Divide( - type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } result[0] = type::ValueFactory::GetIntegerValue(rand()).Modulo( - type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL)); result[1] = type::ValueFactory::GetIntegerValue(rand()).Modulo( - type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL)); result[2] = type::ValueFactory::GetIntegerValue(rand()).Modulo( - type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL)); result[3] = type::ValueFactory::GetIntegerValue(rand()).Modulo( - type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL)); result[4] = type::ValueFactory::GetIntegerValue(rand()).Modulo( - type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL)); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).Add( - type::ValueFactory::GetIntegerValue(rand())); - result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).Add( - type::ValueFactory::GetIntegerValue(rand())); - result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).Add( - type::ValueFactory::GetIntegerValue(rand())); - result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).Add( - type::ValueFactory::GetIntegerValue(rand())); - result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).Add( - type::ValueFactory::GetIntegerValue(rand())); + result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .Add(type::ValueFactory::GetIntegerValue(rand())); + result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .Add(type::ValueFactory::GetIntegerValue(rand())); + result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .Add(type::ValueFactory::GetIntegerValue(rand())); + result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .Add(type::ValueFactory::GetIntegerValue(rand())); + result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .Add(type::ValueFactory::GetIntegerValue(rand())); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).Subtract( - type::ValueFactory::GetIntegerValue(rand())); - result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).Subtract( - type::ValueFactory::GetIntegerValue(rand())); - result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).Subtract( - type::ValueFactory::GetIntegerValue(rand())); - result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).Subtract( - type::ValueFactory::GetIntegerValue(rand())); - result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).Subtract( - type::ValueFactory::GetIntegerValue(rand())); + result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .Subtract(type::ValueFactory::GetIntegerValue(rand())); + result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .Subtract(type::ValueFactory::GetIntegerValue(rand())); + result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .Subtract(type::ValueFactory::GetIntegerValue(rand())); + result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .Subtract(type::ValueFactory::GetIntegerValue(rand())); + result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .Subtract(type::ValueFactory::GetIntegerValue(rand())); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).Multiply( - type::ValueFactory::GetIntegerValue(rand())); - result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).Multiply( - type::ValueFactory::GetIntegerValue(rand())); - result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).Multiply( - type::ValueFactory::GetIntegerValue(rand())); - result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).Multiply( - type::ValueFactory::GetIntegerValue(rand())); - result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).Multiply( - type::ValueFactory::GetIntegerValue(rand())); + result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .Multiply(type::ValueFactory::GetIntegerValue(rand())); + result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .Multiply(type::ValueFactory::GetIntegerValue(rand())); + result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .Multiply(type::ValueFactory::GetIntegerValue(rand())); + result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .Multiply(type::ValueFactory::GetIntegerValue(rand())); + result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .Multiply(type::ValueFactory::GetIntegerValue(rand())); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).Divide( - type::ValueFactory::GetIntegerValue(rand())); - result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).Divide( - type::ValueFactory::GetIntegerValue(rand())); - result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).Divide( - type::ValueFactory::GetIntegerValue(rand())); - result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).Divide( - type::ValueFactory::GetIntegerValue(rand())); - result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).Divide( - type::ValueFactory::GetIntegerValue(rand())); + result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .Divide(type::ValueFactory::GetIntegerValue(rand())); + result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .Divide(type::ValueFactory::GetIntegerValue(rand())); + result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .Divide(type::ValueFactory::GetIntegerValue(rand())); + result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .Divide(type::ValueFactory::GetIntegerValue(rand())); + result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .Divide(type::ValueFactory::GetIntegerValue(rand())); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).Modulo( - type::ValueFactory::GetIntegerValue(rand())); - result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).Modulo( - type::ValueFactory::GetIntegerValue(rand())); - result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).Modulo( - type::ValueFactory::GetIntegerValue(rand())); - result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).Modulo( - type::ValueFactory::GetIntegerValue(rand())); - result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).Modulo( - type::ValueFactory::GetIntegerValue(rand())); + result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .Modulo(type::ValueFactory::GetIntegerValue(rand())); + result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .Modulo(type::ValueFactory::GetIntegerValue(rand())); + result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .Modulo(type::ValueFactory::GetIntegerValue(rand())); + result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .Modulo(type::ValueFactory::GetIntegerValue(rand())); + result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .Modulo(type::ValueFactory::GetIntegerValue(rand())); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } - - result[0] = type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL).Sqrt(); - result[1] = type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL).Sqrt(); - result[2] = type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL).Sqrt(); - result[3] = type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL).Sqrt(); - result[4] = type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL).Sqrt(); + result[0] = + type::ValueFactory::GetTinyIntValue((int8_t)type::PELOTON_INT8_NULL) + .Sqrt(); + result[1] = + type::ValueFactory::GetSmallIntValue((int16_t)type::PELOTON_INT16_NULL) + .Sqrt(); + result[2] = + type::ValueFactory::GetIntegerValue((int32_t)type::PELOTON_INT32_NULL) + .Sqrt(); + result[3] = + type::ValueFactory::GetBigIntValue((int64_t)type::PELOTON_INT64_NULL) + .Sqrt(); + result[4] = + type::ValueFactory::GetDecimalValue((double)type::PELOTON_DECIMAL_NULL) + .Sqrt(); for (int i = 0; i < 5; i++) { EXPECT_TRUE(result[i].IsNull()); } } - } } diff --git a/test/type/pool_test.cpp b/test/type/pool_test.cpp index a1c1521c46f..57a1567f1b5 100644 --- a/test/type/pool_test.cpp +++ b/test/type/pool_test.cpp @@ -20,27 +20,26 @@ namespace peloton { namespace test { -class PoolTests : public PelotonTest {}; +class PoolTests : public PelotonTests {}; #define N 10 #define M 1000 #define R 1 -#define RANDOM(a) (rand() % a) // Generate a random number in [0, a) +#define RANDOM(a) (rand() % a) // Generate a random number in [0, a) // disable unused const variable warning for clang #ifdef __APPLE__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-const-variable" #endif -const size_t str_len = 1000; // test string length +const size_t str_len = 1000; // test string length #ifdef __APPLE__ #pragma clang diagnostic pop #endif // Round up to block size size_t get_align(size_t size) { - if (size <= 16) - return 16; + if (size <= 16) return 16; size_t n = size - 1; size_t bits = 0; while (n > 0) { diff --git a/test/type/timestamp_value_test.cpp b/test/type/timestamp_value_test.cpp index 8c8c816bae6..226d993d79b 100644 --- a/test/type/timestamp_value_test.cpp +++ b/test/type/timestamp_value_test.cpp @@ -21,7 +21,7 @@ namespace test { // Timestamp Value Test //===--------------------------------------------------------------------===// -class TimestampValueTests : public PelotonTest {}; +class TimestampValueTests : public PelotonTests {}; TEST_F(TimestampValueTests, ComparisonTest) { std::vector compares = { @@ -111,7 +111,8 @@ TEST_F(TimestampValueTests, ComparisonTest) { } TEST_F(TimestampValueTests, NullToStringTest) { - auto valNull = type::ValueFactory::GetNullValueByType(type::TypeId::TIMESTAMP); + auto valNull = + type::ValueFactory::GetNullValueByType(type::TypeId::TIMESTAMP); EXPECT_EQ(valNull.ToString(), "timestamp_null"); } @@ -162,7 +163,8 @@ TEST_F(TimestampValueTests, CastTest) { type::Value result; auto strNull = type::ValueFactory::GetNullValueByType(type::TypeId::VARCHAR); - auto valNull = type::ValueFactory::GetNullValueByType(type::TypeId::TIMESTAMP); + auto valNull = + type::ValueFactory::GetNullValueByType(type::TypeId::TIMESTAMP); result = valNull.CastAs(type::TypeId::TIMESTAMP); EXPECT_TRUE(result.IsNull()); diff --git a/test/type/type_test.cpp b/test/type/type_test.cpp index cb237e5d1c7..a9d40c37eac 100644 --- a/test/type/type_test.cpp +++ b/test/type/type_test.cpp @@ -26,7 +26,7 @@ namespace test { // Type Tests //===--------------------------------------------------------------------===// -class TypeTests : public PelotonTest {}; +class TypeTests : public PelotonTests {}; const std::vector typeTestTypes = { type::TypeId::BOOLEAN, type::TypeId::TINYINT, type::TypeId::SMALLINT, diff --git a/test/type/type_util_test.cpp b/test/type/type_util_test.cpp index eff7cac5411..11f74526c6d 100644 --- a/test/type/type_util_test.cpp +++ b/test/type/type_util_test.cpp @@ -24,9 +24,9 @@ namespace test { // TypeUtil Tests //===--------------------------------------------------------------------===// -class TypeUtilTests : public PelotonTest {}; +class TypeUtilTests : public PelotonTests {}; -catalog::Schema* TypeUtilTestsGenerateSchema() { +catalog::Schema *TypeUtilTestsGenerateSchema() { // Construct Tuple Schema std::vector col_types = { type::TypeId::BOOLEAN, type::TypeId::TINYINT, type::TypeId::SMALLINT, @@ -49,11 +49,11 @@ catalog::Schema* TypeUtilTestsGenerateSchema() { catalog::Column column(col_types[i], length, os.str(), inlined); column_list.push_back(column); } - catalog::Schema* schema = new catalog::Schema(column_list); + catalog::Schema *schema = new catalog::Schema(column_list); return (schema); } -std::shared_ptr TypeUtilTestsHelper(catalog::Schema* schema, +std::shared_ptr TypeUtilTestsHelper(catalog::Schema *schema, int tuple_id) { // Populate tuple auto pool = TestingHarness::GetInstance().GetTestingPool(); @@ -128,16 +128,15 @@ TEST_F(TypeUtilTests, CompareEqualsRawTest) { const int num_cols = (int)schema->GetColumnCount(); for (int tuple_idx = 1; tuple_idx < 3; tuple_idx++) { - CmpBool expected = (tuple_idx == 2 ? - CmpBool::CmpTrue : - CmpBool::CmpFalse); + CmpBool expected = (tuple_idx == 2 ? CmpBool::CmpTrue : CmpBool::CmpFalse); for (int i = 0; i < num_cols; i++) { - const char* val0 = tuples[0]->GetDataPtr(i); - const char* val1 = tuples[tuple_idx]->GetDataPtr(i); + const char *val0 = tuples[0]->GetDataPtr(i); + const char *val1 = tuples[tuple_idx]->GetDataPtr(i); auto type = schema->GetColumn(i).GetType(); bool inlined = schema->IsInlined(i); - CmpBool result = type::TypeUtil::CompareEqualsRaw(type, val0, val1, inlined); + CmpBool result = + type::TypeUtil::CompareEqualsRaw(type, val0, val1, inlined); LOG_TRACE( "'%s'=='%s' => Expected:%s / Result:%s", @@ -162,8 +161,8 @@ TEST_F(TypeUtilTests, CompareLessThanRawTest) { const int num_cols = (int)schema->GetColumnCount(); for (int tuple_idx = 1; tuple_idx < 3; tuple_idx++) { for (int i = 0; i < num_cols; i++) { - const char* val0 = tuples[0]->GetDataPtr(i); - const char* val1 = tuples[tuple_idx]->GetDataPtr(i); + const char *val0 = tuples[0]->GetDataPtr(i); + const char *val1 = tuples[tuple_idx]->GetDataPtr(i); auto type = schema->GetColumn(i).GetType(); bool inlined = schema->IsInlined(i); CmpBool result = @@ -189,8 +188,8 @@ TEST_F(TypeUtilTests, CompareGreaterThanRawTest) { const int num_cols = (int)schema->GetColumnCount(); for (int tuple_idx = 1; tuple_idx < 3; tuple_idx++) { for (int i = 0; i < num_cols; i++) { - const char* val0 = tuples[0]->GetDataPtr(i); - const char* val1 = tuples[tuple_idx]->GetDataPtr(i); + const char *val0 = tuples[0]->GetDataPtr(i); + const char *val1 = tuples[tuple_idx]->GetDataPtr(i); auto type = schema->GetColumn(i).GetType(); bool inlined = schema->IsInlined(i); CmpBool result = @@ -226,17 +225,17 @@ TEST_F(TypeUtilTests, CompareStringsTest) { // str2 = StringUtil::Upper(str2); } - CmpBool result = type::GetCmpBool( - type::TypeUtil::CompareStrings(str1.c_str(), i, - str2.c_str(), j) < 0); + CmpBool result = + type::GetCmpBool(type::TypeUtil::CompareStrings( + str1.c_str(), i, str2.c_str(), j) < 0); if (result != CmpBool::CmpTrue) { LOG_ERROR("INVALID '%s' < '%s'", str1.c_str(), str2.c_str()); } EXPECT_EQ(CmpBool::CmpTrue, result); - } // FOR (upper2) - } // FOR (str2) - } // FOR (upper1) - } // FOR (str1) + } // FOR (upper2) + } // FOR (str2) + } // FOR (upper1) + } // FOR (str1) } } // namespace test diff --git a/test/type/value_factory_test.cpp b/test/type/value_factory_test.cpp index a130bca58d3..ba4f2f06647 100644 --- a/test/type/value_factory_test.cpp +++ b/test/type/value_factory_test.cpp @@ -24,41 +24,32 @@ #include "type/value_peeker.h" #include "common/harness.h" - namespace peloton { namespace test { -class ValueFactoryTests : public PelotonTest {}; +class ValueFactoryTests : public PelotonTests {}; const std::vector valuefactory_test_types = { - type::TypeId::BOOLEAN, type::TypeId::TINYINT, - type::TypeId::SMALLINT, type::TypeId::INTEGER, - type::TypeId::BIGINT, type::TypeId::DECIMAL, - type::TypeId::TIMESTAMP, type::TypeId::DATE -}; + type::TypeId::BOOLEAN, type::TypeId::TINYINT, type::TypeId::SMALLINT, + type::TypeId::INTEGER, type::TypeId::BIGINT, type::TypeId::DECIMAL, + type::TypeId::TIMESTAMP, type::TypeId::DATE}; #define RANDOM_DECIMAL() ((double)rand() / (double)rand()) -int8_t RANDOM8() { - return ((rand() % (SCHAR_MAX * 2 - 1)) - (SCHAR_MAX - 1)); -} +int8_t RANDOM8() { return ((rand() % (SCHAR_MAX * 2 - 1)) - (SCHAR_MAX - 1)); } -int16_t RANDOM16() { - return ((rand() % (SHRT_MAX * 2 - 1)) - (SHRT_MAX - 1)); -} +int16_t RANDOM16() { return ((rand() % (SHRT_MAX * 2 - 1)) - (SHRT_MAX - 1)); } int32_t RANDOM32() { int32_t ret = (((size_t)(rand()) << 1) | ((size_t)(rand()) & 0x1)); - if (ret != type::PELOTON_INT32_NULL) - return ret; + if (ret != type::PELOTON_INT32_NULL) return ret; return 1; } int64_t RANDOM64() { int64_t ret = (((size_t)(rand()) << 33) | ((size_t)(rand()) << 2) | ((size_t)(rand()) & 0x3)); - if (ret != type::PELOTON_INT64_NULL) - return ret; + if (ret != type::PELOTON_INT64_NULL) return ret; return 1; } @@ -91,59 +82,89 @@ TEST_F(ValueFactoryTests, PeekValueTest) { TEST_F(ValueFactoryTests, CastTest) { type::Value v1(type::ValueFactory::CastAsBigInt( - type::Value(type::TypeId::INTEGER, (int32_t)type::PELOTON_INT32_MAX))); + type::Value(type::TypeId::INTEGER, (int32_t)type::PELOTON_INT32_MAX))); EXPECT_EQ(v1.GetTypeId(), type::TypeId::BIGINT); EXPECT_EQ(v1.GetAs(), type::PELOTON_INT32_MAX); type::Value v2(type::ValueFactory::CastAsBigInt( - type::Value(type::TypeId::SMALLINT, (int16_t)type::PELOTON_INT16_MAX))); + type::Value(type::TypeId::SMALLINT, (int16_t)type::PELOTON_INT16_MAX))); EXPECT_EQ(v2.GetTypeId(), type::TypeId::BIGINT); - EXPECT_THROW(type::ValueFactory::CastAsBigInt(type::Value(type::TypeId::BOOLEAN, 0)), peloton::Exception); - EXPECT_THROW(type::ValueFactory::CastAsSmallInt(type::Value(type::TypeId::INTEGER, type::PELOTON_INT32_MAX)), - peloton::Exception); - EXPECT_THROW(type::ValueFactory::CastAsTinyInt(type::Value(type::TypeId::INTEGER,type::PELOTON_INT32_MAX)), - peloton::Exception); - - type::Value v3(type::ValueFactory::CastAsVarchar(type::ValueFactory::GetVarcharValue("hello"))); + EXPECT_THROW( + type::ValueFactory::CastAsBigInt(type::Value(type::TypeId::BOOLEAN, 0)), + peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsSmallInt( + type::Value(type::TypeId::INTEGER, type::PELOTON_INT32_MAX)), + peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsTinyInt( + type::Value(type::TypeId::INTEGER, type::PELOTON_INT32_MAX)), + peloton::Exception); + + type::Value v3(type::ValueFactory::CastAsVarchar( + type::ValueFactory::GetVarcharValue("hello"))); EXPECT_EQ(v3.GetTypeId(), type::TypeId::VARCHAR); type::Value v4(type::ValueFactory::Clone(v3)); EXPECT_TRUE(v3.CompareEquals(v4) == CmpBool::CmpTrue); - type::Value v5(type::ValueFactory::CastAsVarchar(type::Value(type::TypeId::TINYINT, (int8_t)type::PELOTON_INT8_MAX))); + type::Value v5(type::ValueFactory::CastAsVarchar( + type::Value(type::TypeId::TINYINT, (int8_t)type::PELOTON_INT8_MAX))); EXPECT_EQ(v5.ToString(), "127"); - type::Value v6(type::ValueFactory::CastAsVarchar(type::Value(type::TypeId::BIGINT, (int64_t)type::PELOTON_INT64_MAX))); + type::Value v6(type::ValueFactory::CastAsVarchar( + type::Value(type::TypeId::BIGINT, (int64_t)type::PELOTON_INT64_MAX))); EXPECT_EQ(v6.ToString(), "9223372036854775807"); std::string str1("9999-12-31 23:59:59.999999+14"); - type::Value v7(type::ValueFactory::CastAsTimestamp(type::Value(type::TypeId::VARCHAR, str1))); + type::Value v7(type::ValueFactory::CastAsTimestamp( + type::Value(type::TypeId::VARCHAR, str1))); EXPECT_EQ(v7.ToString(), str1); std::string str2("9999-12-31 23:59:59-01"); - type::Value v77(type::ValueFactory::CastAsTimestamp(type::Value(type::TypeId::VARCHAR, str2))); + type::Value v77(type::ValueFactory::CastAsTimestamp( + type::Value(type::TypeId::VARCHAR, str2))); EXPECT_EQ(v77.ToString(), "9999-12-31 23:59:59.000000-01"); - EXPECT_THROW(type::ValueFactory::CastAsTimestamp(type::Value(type::TypeId::VARCHAR, "1900-02-29 23:59:59.999999+12")), - peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsTimestamp(type::Value( + type::TypeId::VARCHAR, "1900-02-29 23:59:59.999999+12")), + peloton::Exception); - type::Value v8(type::ValueFactory::CastAsBigInt(type::Value(type::TypeId::VARCHAR, "9223372036854775807"))); + type::Value v8(type::ValueFactory::CastAsBigInt( + type::Value(type::TypeId::VARCHAR, "9223372036854775807"))); EXPECT_EQ(v8.GetAs(), 9223372036854775807); - EXPECT_THROW(type::ValueFactory::CastAsBigInt(type::Value(type::TypeId::VARCHAR, "9223372036854775808")), peloton::Exception); - EXPECT_THROW(type::ValueFactory::CastAsBigInt(type::Value(type::TypeId::VARCHAR, "-9223372036854775808")), peloton::Exception); - - type::Value v9(type::ValueFactory::CastAsInteger(type::Value(type::TypeId::VARCHAR, "2147483647"))); + EXPECT_THROW(type::ValueFactory::CastAsBigInt( + type::Value(type::TypeId::VARCHAR, "9223372036854775808")), + peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsBigInt( + type::Value(type::TypeId::VARCHAR, "-9223372036854775808")), + peloton::Exception); + + type::Value v9(type::ValueFactory::CastAsInteger( + type::Value(type::TypeId::VARCHAR, "2147483647"))); EXPECT_EQ(v9.GetAs(), 2147483647); - EXPECT_THROW(type::ValueFactory::CastAsInteger(type::Value(type::TypeId::VARCHAR, "-2147483648")), peloton::Exception); - EXPECT_THROW(type::ValueFactory::CastAsInteger(type::Value(type::TypeId::VARCHAR, "2147483648")), peloton::Exception); - - type::Value v10(type::ValueFactory::CastAsSmallInt(type::Value(type::TypeId::VARCHAR, "32767"))); + EXPECT_THROW(type::ValueFactory::CastAsInteger( + type::Value(type::TypeId::VARCHAR, "-2147483648")), + peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsInteger( + type::Value(type::TypeId::VARCHAR, "2147483648")), + peloton::Exception); + + type::Value v10(type::ValueFactory::CastAsSmallInt( + type::Value(type::TypeId::VARCHAR, "32767"))); EXPECT_EQ(v10.GetAs(), 32767); - EXPECT_THROW(type::ValueFactory::CastAsSmallInt(type::Value(type::TypeId::VARCHAR, "-32768")), peloton::Exception); - EXPECT_THROW(type::ValueFactory::CastAsSmallInt(type::Value(type::TypeId::VARCHAR, "32768")), peloton::Exception); - - type::Value v11(type::ValueFactory::CastAsTinyInt(type::Value(type::TypeId::VARCHAR, "127"))); + EXPECT_THROW(type::ValueFactory::CastAsSmallInt( + type::Value(type::TypeId::VARCHAR, "-32768")), + peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsSmallInt( + type::Value(type::TypeId::VARCHAR, "32768")), + peloton::Exception); + + type::Value v11(type::ValueFactory::CastAsTinyInt( + type::Value(type::TypeId::VARCHAR, "127"))); EXPECT_EQ(v11.GetAs(), 127); - EXPECT_THROW(type::ValueFactory::CastAsTinyInt(type::Value(type::TypeId::VARCHAR, "-128")), peloton::Exception); - EXPECT_THROW(type::ValueFactory::CastAsTinyInt(type::Value(type::TypeId::VARCHAR, "128")), peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsTinyInt( + type::Value(type::TypeId::VARCHAR, "-128")), + peloton::Exception); + EXPECT_THROW(type::ValueFactory::CastAsTinyInt( + type::Value(type::TypeId::VARCHAR, "128")), + peloton::Exception); } TEST_F(ValueFactoryTests, SerializationTest) { @@ -156,15 +177,14 @@ TEST_F(ValueFactoryTests, SerializationTest) { peloton::CopySerializeInput in(out.Data(), out.Size()); for (auto col_type : valuefactory_test_types) { for (auto expect_min : {true, false}) { - type::Value v = (type::Value::DeserializeFrom(in, type::Type::GetInstance(col_type)->GetTypeId(), nullptr)); + type::Value v = (type::Value::DeserializeFrom( + in, type::Type::GetInstance(col_type)->GetTypeId(), nullptr)); EXPECT_EQ(v.GetTypeId(), col_type); - type::Value expected = (expect_min ? - type::Type::GetMinValue(col_type) : - type::Type::GetMaxValue(col_type)); + type::Value expected = (expect_min ? type::Type::GetMinValue(col_type) + : type::Type::GetMaxValue(col_type)); EXPECT_EQ(CmpBool::CmpTrue, v.CompareEquals(expected)); } } } - } } diff --git a/test/type/value_test.cpp b/test/type/value_test.cpp index ff1994def1a..065a87f83df 100644 --- a/test/type/value_test.cpp +++ b/test/type/value_test.cpp @@ -24,7 +24,7 @@ namespace test { // Value Tests //===--------------------------------------------------------------------===// -class ValueTests : public PelotonTest {}; +class ValueTests : public PelotonTests {}; const std::vector valueTestTypes = { type::TypeId::BOOLEAN, type::TypeId::TINYINT, type::TypeId::SMALLINT, @@ -38,8 +38,10 @@ TEST_F(ValueTests, HashTest) { // Special case for VARCHAR if (col_type == type::TypeId::VARCHAR) { - max_val = type::ValueFactory::GetVarcharValue(std::string("XXX"), nullptr); - min_val = type::ValueFactory::GetVarcharValue(std::string("YYY"), nullptr); + max_val = + type::ValueFactory::GetVarcharValue(std::string("XXX"), nullptr); + min_val = + type::ValueFactory::GetVarcharValue(std::string("YYY"), nullptr); } LOG_TRACE("%s => MAX:%s <-> MIN:%s", TypeIdToString(col_type).c_str(), max_val.ToString().c_str(), min_val.ToString().c_str()); @@ -67,8 +69,10 @@ TEST_F(ValueTests, MinMaxTest) { // Special case for VARCHAR if (col_type == type::TypeId::VARCHAR) { - max_val = type::ValueFactory::GetVarcharValue(std::string("AAA"), nullptr); - min_val = type::ValueFactory::GetVarcharValue(std::string("ZZZ"), nullptr); + max_val = + type::ValueFactory::GetVarcharValue(std::string("AAA"), nullptr); + min_val = + type::ValueFactory::GetVarcharValue(std::string("ZZZ"), nullptr); EXPECT_EQ(CmpBool::CmpFalse, min_val.CompareLessThan(max_val)); EXPECT_EQ(CmpBool::CmpFalse, max_val.CompareGreaterThan(min_val)); } @@ -86,7 +90,7 @@ TEST_F(ValueTests, MinMaxTest) { EXPECT_EQ(CmpBool::CmpTrue, max_val.Max(min_val).CompareEquals(max_val)); EXPECT_EQ(CmpBool::CmpTrue, min_val.Max(max_val).CompareEquals(max_val)); EXPECT_EQ(CmpBool::CmpTrue, max_val.Max(min_val).CompareEquals(max_val)); - } // FOR + } // FOR } TEST_F(ValueTests, VarcharCopyTest) { diff --git a/test/udf/udf_test.cpp b/test/udf/udf_test.cpp index b45b29510b3..c3b2d8b66b8 100644 --- a/test/udf/udf_test.cpp +++ b/test/udf/udf_test.cpp @@ -20,9 +20,9 @@ namespace peloton { namespace test { -class UDFTest : public PelotonTest {}; +class UDFTests : public PelotonTests {}; -TEST_F(UDFTest, SimpleExpressionTest) { +TEST_F(UDFTests, SimpleExpressionTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -76,7 +76,7 @@ TEST_F(UDFTest, SimpleExpressionTest) { txn_manager.CommitTransaction(txn); } -TEST_F(UDFTest, ComplexExpressionTest) { +TEST_F(UDFTests, ComplexExpressionTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -132,7 +132,7 @@ TEST_F(UDFTest, ComplexExpressionTest) { txn_manager.CommitTransaction(txn); } -TEST_F(UDFTest, IfElseExpressionTest) { +TEST_F(UDFTests, IfElseExpressionTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); @@ -190,7 +190,7 @@ TEST_F(UDFTest, IfElseExpressionTest) { txn_manager.CommitTransaction(txn); } -TEST_F(UDFTest, RecursiveFunctionTest) { +TEST_F(UDFTests, RecursiveFunctionTest) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); auto txn = txn_manager.BeginTransaction(); catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); diff --git a/test/util/file_util_test.cpp b/test/util/file_util_test.cpp index d11f96c3ade..4e29ea4e896 100644 --- a/test/util/file_util_test.cpp +++ b/test/util/file_util_test.cpp @@ -28,7 +28,7 @@ namespace test { // FileUtil Test //===--------------------------------------------------------------------===// -class FileUtilTests : public PelotonTest { +class FileUtilTests : public PelotonTests { public: void TearDown() override { for (auto path : tempFiles) { @@ -37,7 +37,7 @@ class FileUtilTests : public PelotonTest { std::remove(path.c_str()); } } // FOR - PelotonTest::TearDown(); + PelotonTests::TearDown(); } std::vector tempFiles; diff --git a/test/util/set_util_test.cpp b/test/util/set_util_test.cpp index 4a4c1f9cdae..ffaef495ed5 100644 --- a/test/util/set_util_test.cpp +++ b/test/util/set_util_test.cpp @@ -24,7 +24,7 @@ namespace test { // SetUtil Test //===--------------------------------------------------------------------===// -class SetUtilTests : public PelotonTest {}; +class SetUtilTests : public PelotonTests {}; TEST_F(SetUtilTests, DisjointTest) { // Check sorted sets diff --git a/test/util/string_util_test.cpp b/test/util/string_util_test.cpp index c39da696007..12b9650418f 100644 --- a/test/util/string_util_test.cpp +++ b/test/util/string_util_test.cpp @@ -25,7 +25,7 @@ namespace test { // StringUtil Test //===--------------------------------------------------------------------===// -class StringUtilTests : public PelotonTest {}; +class StringUtilTests : public PelotonTests {}; TEST_F(StringUtilTests, ContainsTest) { std::string str = "Word up, two for fives over here baby"; diff --git a/test/util/stringbox_util_test.cpp b/test/util/stringbox_util_test.cpp index 15aac227c15..ec92276b478 100644 --- a/test/util/stringbox_util_test.cpp +++ b/test/util/stringbox_util_test.cpp @@ -22,7 +22,7 @@ namespace test { // StringBoxUtil Test //===--------------------------------------------------------------------===// -class StringBoxUtilTests : public PelotonTest {}; +class StringBoxUtilTests : public PelotonTests {}; void CheckBox(std::string &box, std::string key, int num_lines) { // Make sure that our search key is in the box diff --git a/test/util/stringtable_util_test.cpp b/test/util/stringtable_util_test.cpp index 0cdaf2a3c08..735df612da4 100644 --- a/test/util/stringtable_util_test.cpp +++ b/test/util/stringtable_util_test.cpp @@ -22,7 +22,7 @@ namespace test { // StringTableUtil Test //===--------------------------------------------------------------------===// -class StringTableUtilTests : public PelotonTest {}; +class StringTableUtilTests : public PelotonTests {}; void CheckTable(std::string &table, bool header, int num_lines) { // Make sure that it has the same number of lines as the input @@ -38,9 +38,9 @@ void CheckTable(std::string &table, bool header, int num_lines) { TEST_F(StringTableUtilTests, BoxTest) { std::string message = "Meeting\tRoom\tPeople\n" - "Peloton\t9001\tA\n" - "Bike\t8001\tB, C, D\n" - "Transformer\t7001\tE, F, G\n"; + "Peloton\t9001\tA\n" + "Bike\t8001\tB, C, D\n" + "Transformer\t7001\tE, F, G\n"; std::string result = StringTableUtil::Table(message, true); EXPECT_TRUE(result.size() > 0); LOG_INFO("\n%s", result.c_str()); @@ -48,8 +48,8 @@ TEST_F(StringTableUtilTests, BoxTest) { message = "Halloween\tOctorber\n" - "Thanksgiving\tNovember\n" - "Christmas\tDecember\n"; + "Thanksgiving\tNovember\n" + "Christmas\tDecember\n"; result = StringTableUtil::Table(message, false); LOG_INFO("\n%s", result.c_str()); CheckTable(result, false, 3);