From 943c82b33be16859575b6fe79295991e1e77f7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Feb 2018 12:55:30 +0200 Subject: [PATCH] Extend cdc_datatypes test The test now also creates TIME type values and checks that they are converted correctly. Also added NULL value tests for all values and made required adjustments to the code. --- .../cdc_datatypes/cdc_datatypes.cpp | 32 ++++++++++++++++--- .../cdc_datatypes/cdc_result.h | 6 ++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp b/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp index 5695d6d7a..c749fa88d 100644 --- a/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp +++ b/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp @@ -28,6 +28,7 @@ static const char* integer_values[] = "-1", "20", "-20", + "NULL", NULL }; @@ -47,6 +48,7 @@ static const char* decimal_values[] = "-1.5", "20.5", "-20.5", + "NULL", NULL }; @@ -65,7 +67,7 @@ static const char* string_values[] = { "\"Hello world!\"", "\"The quick brown fox jumps over the lazy dog\"", -// "\"The Unicode should work: äöåǢ\"", + "NULL", NULL }; @@ -85,26 +87,27 @@ static const char* binary_values[] = "\"Hello world!\"", "\"The quick brown fox jumps over the lazy dog\"", "NULL", -// "\"The Unicode should work: äöåǢ\"", -// "\"These should work for binary types: ⦿☏☃☢😤😂\"", NULL }; static const char* datetime_types[] = { + "DATETIME", "DATETIME(1)", "DATETIME(2)", "DATETIME(3)", "DATETIME(4)", "DATETIME(5)", "DATETIME(6)", - "TIMESTAMP", + // TODO: Fix test setup to use same timezone + // "TIMESTAMP", NULL }; static const char* datetime_values[] = { "'2018-01-01 11:11:11'", + "NULL", NULL }; @@ -117,6 +120,26 @@ static const char* date_types[] = static const char* date_values[] = { "'2018-01-01'", + "NULL", + NULL +}; + +static const char* time_types[] = +{ + "TIME", + "TIME(1)", + "TIME(2)", + "TIME(3)", + "TIME(4)", + "TIME(5)", + "TIME(6)", + NULL +}; + +static const char* time_values[] = +{ + "'12:00:00'", + "NULL", NULL }; @@ -132,6 +155,7 @@ struct { binary_types, binary_values }, { datetime_types, datetime_values }, { date_types, date_values }, + { time_types, time_values }, { 0 } }; diff --git a/maxscale-system-test/cdc_datatypes/cdc_result.h b/maxscale-system-test/cdc_datatypes/cdc_result.h index 2475230d6..03c209855 100644 --- a/maxscale-system-test/cdc_datatypes/cdc_result.h +++ b/maxscale-system-test/cdc_datatypes/cdc_result.h @@ -39,8 +39,10 @@ public: bool operator ==(const TestOutput& output) const { return m_value == output.getValue() || - (m_type.find("BLOB") != std::string::npos && - output.getValue().length() == 0); + (m_type.find("BLOB") != std::string::npos && output.getValue().length() == 0) || + // A NULL timestamp appears to be inserted as NOW() by default in 10.2, a NULL INT is + // inserted as 0 and a NULL string gets converted into an empty string by the CDC system + (m_value == "NULL" && (output.getValue().empty() || m_type == "TIMESTAMP" || output.getValue() == "0")); } bool operator !=(const TestOutput& output) const