From 1bbb2f896e5b7bf1dada6ac3534598e170ac23cc Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Tue, 5 Feb 2019 23:26:29 +0100 Subject: [PATCH] [426-cassandra-unit-tests-ends-with-success-even-though-they-fail] Made DB script failure to throw --- src/lib/cql/testutils/cql_schema.cc | 4 +++- src/lib/cql/testutils/cql_schema.h | 5 +++-- src/lib/mysql/testutils/mysql_schema.cc | 4 +++- src/lib/mysql/testutils/mysql_schema.h | 5 +++-- src/lib/pgsql/testutils/pgsql_schema.cc | 4 +++- src/lib/pgsql/testutils/pgsql_schema.h | 5 +++-- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/lib/cql/testutils/cql_schema.cc b/src/lib/cql/testutils/cql_schema.cc index 26586b0b15..93a6c8b7d8 100644 --- a/src/lib/cql/testutils/cql_schema.cc +++ b/src/lib/cql/testutils/cql_schema.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,6 +10,7 @@ #include #include +#include #include @@ -79,6 +80,7 @@ runCqlScript(const std::string& path, int32_t retval = ::system(cmd.str().c_str()); if (retval) { std::cerr << "runCqlSchema failed:" << cmd.str() << std::endl; + isc_throw(Unexpected, "runCqlSchema failed:" << cmd.str()); } } diff --git a/src/lib/cql/testutils/cql_schema.h b/src/lib/cql/testutils/cql_schema.h index 55f93e0ada..6127afd4bd 100644 --- a/src/lib/cql/testutils/cql_schema.h +++ b/src/lib/cql/testutils/cql_schema.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -57,11 +57,12 @@ void createCqlSchema(bool force_wipe, bool show_err = false); /// Submits the given CQL script to CQL via cqlsh CLI. The output of /// stderr is suppressed unless the parameter, show_err is true. The is done /// to suppress warnings that might otherwise make test output needlessly -/// noisy. A gtest assertion occurs if the script fails to execute. +/// noisy. An exception is thrown if the script fails to execute. /// /// @param path - path (if not blank) of the script to execute /// @param script_name - file name of the path to execute /// @param show_err flag which governs whether or not stderr is suppressed. +/// @throw Unexpected when the script returns an error. void runCqlScript(const std::string& path, const std::string& script_name, bool show_err); diff --git a/src/lib/mysql/testutils/mysql_schema.cc b/src/lib/mysql/testutils/mysql_schema.cc index 42bcf0406c..93ed9418c2 100644 --- a/src/lib/mysql/testutils/mysql_schema.cc +++ b/src/lib/mysql/testutils/mysql_schema.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,7 @@ void runMySQLScript(const std::string& path, const std::string& script_name, int retval = ::system(cmd.str().c_str()); if (retval) { std::cerr << "runMySQLSchema failed:" << cmd.str() << std::endl; + isc_throw(Unexpected, "runMySQLSchema failed:" << cmd.str()); } } diff --git a/src/lib/mysql/testutils/mysql_schema.h b/src/lib/mysql/testutils/mysql_schema.h index ad2202d5a2..9457a3341c 100644 --- a/src/lib/mysql/testutils/mysql_schema.h +++ b/src/lib/mysql/testutils/mysql_schema.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -53,11 +53,12 @@ void createMySQLSchema(bool show_err = false); /// Submits the given SQL script to MySQL via mysql CLI. The output of /// stderr is suppressed unless the parameter, show_err is true. The is done /// to suppress warnings that might otherwise make test output needlessly -/// noisy. A gtest assertion occurs if the script fails to execute. +/// noisy. An exception is thrown if the script fails to execute. /// /// @param path - path (if not blank) of the script to execute /// @param script_name - file name of the path to execute /// @param show_err flag which governs whether or not stderr is suppressed. +/// @throw Unexpected when the script returns an error. void runMySQLScript(const std::string& path, const std::string& script_name, bool show_err); diff --git a/src/lib/pgsql/testutils/pgsql_schema.cc b/src/lib/pgsql/testutils/pgsql_schema.cc index 1d4ab1b8ac..1ee6baf1ca 100644 --- a/src/lib/pgsql/testutils/pgsql_schema.cc +++ b/src/lib/pgsql/testutils/pgsql_schema.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -56,6 +57,7 @@ void runPgSQLScript(const std::string& path, const std::string& script_name, int retval = ::system(cmd.str().c_str()); if (retval) { std::cerr << "runPgSQLSchema failed:" << cmd.str() << std::endl; + isc_throw(Unexpected, "runPgSQLSchema failed:" << cmd.str()); } } diff --git a/src/lib/pgsql/testutils/pgsql_schema.h b/src/lib/pgsql/testutils/pgsql_schema.h index 8f07ceb6cb..e17572a464 100644 --- a/src/lib/pgsql/testutils/pgsql_schema.h +++ b/src/lib/pgsql/testutils/pgsql_schema.h @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -53,11 +53,12 @@ void createPgSQLSchema(bool show_err = false); /// Submits the given SQL script to Postgresql via psql CLI. The output of /// stderr is suppressed unless the parameter, show_err is true. The is done /// to suppress warnings that might otherwise make test output needlessly -/// noisy. A gtest assertion occurs if the script fails to execute. +/// noisy. An exception is thrown if the script fails to execute. /// /// @param path - path (if not blank) of the script to execute /// @param script_name - file name of the path to execute /// @param show_err flag which governs whether or not stderr is suppressed. +/// @throw Unexpected when the script returns an error. void runPgSQLScript(const std::string& path, const std::string& script_name, bool show_err); -- 2.47.2