Skip to content

Commit

Permalink
Improve tests related to ecflow/test
Browse files Browse the repository at this point in the history
Re ECFLOW-1934
  • Loading branch information
marcosbento committed Dec 21, 2023
1 parent 8c18ec8 commit baeff88
Show file tree
Hide file tree
Showing 33 changed files with 326 additions and 220 deletions.
13 changes: 8 additions & 5 deletions Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# nor does it submit to any jurisdiction.
#

file( GLOB srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp" "src/*.hpp" )

set(srcs
# Headers
src/ServerTestHarness.hpp
Expand Down Expand Up @@ -46,13 +44,16 @@ target_clangformat(libharness)
if (ENABLE_ALL_TESTS)

set(test_srcs
Test_main.cpp # test entry point
TestAbortCmd.cpp
TestAlias.cpp
TestClkSync.cpp
TestComplete.cpp
TestCron.cpp
TestCtsWaitCmd.cpp
TestDayDate.cpp
TestEcfNoScriptCmd.cpp
TestEcfScriptCmd.cpp
TestEvents.cpp
TestFileCmd.cpp
TestHandle.cpp
Expand All @@ -64,13 +65,13 @@ if (ENABLE_ALL_TESTS)
TestQueueCmd.cpp
TestRepeat.cpp
TestRequeueNode.cpp
TestRunner.cpp
TestServer.cpp
TestSpecificIssues.cpp
TestSuspend.cpp
TestTime.cpp
TestToday.cpp
TestTrigger.cpp
TestWhyCmd.cpp
Test_Time.cpp
)

ecbuild_add_test(
Expand All @@ -88,7 +89,7 @@ if (ENABLE_ALL_TESTS)
s_client
)
target_clangformat(s_test CONDITION ENABLE_TESTS)

ecbuild_add_test(
TARGET
s_test_zombies
Expand All @@ -97,6 +98,7 @@ if (ENABLE_ALL_TESTS)
nightly
SOURCES
TestZombies.cpp
TestZombies_main.cpp # test entry point
LIBS
libharness
$<$<BOOL:${OPENSSL_FOUND}>:OpenSSL::SSL>
Expand All @@ -114,6 +116,7 @@ if (ENABLE_ALL_TESTS)
manual
SOURCES
TestSingle.cpp
TestSingle_main.cpp # test entry point
LIBS
libharness
$<$<BOOL:${OPENSSL_FOUND}>:OpenSSL::SSL>
Expand Down
20 changes: 12 additions & 8 deletions Test/TestAbortCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_AbortCmd)

// Test the abort command. This will test the abort command and the
// retry behaviour. i.e if a task is aborted, and the variable ECF_TRIES
// is defined. Then providing its value is less the the task's try number
// we should do an immediate job submission.
BOOST_AUTO_TEST_CASE(test_) {
BOOST_AUTO_TEST_CASE(test_abort_cmd) {
DurationTimer timer;
cout << "Test:: ...test_abort_cmd " << flush;
TestClean clean_at_start_and_end;
Expand All @@ -46,12 +48,12 @@ BOOST_AUTO_TEST_CASE(test_) {
// Allows test to run without requiring installation

// # Note: we have to use relative paths, since these tests are relocatable
// suite test_task_abort_cmd
// edit ECF_TRIES '4'
// family family0
// task abort
// endfamily
// endsuite
// suite test_task_abort_cmd
// edit ECF_TRIES '4'
// family family0
// task abort
// endfamily
// endsuite
Defs theDefs;
{
suite_ptr suite = theDefs.add_suite("test_abort_cmd");
Expand Down Expand Up @@ -88,3 +90,5 @@ BOOST_AUTO_TEST_CASE(test_) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/TestAlias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ using namespace boost::posix_time;
/// Will indirectly test the Alias memento's
///

BOOST_AUTO_TEST_SUITE(TestSingleSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_Alias)

void wait_for_alias_to_complete(const std::string& alias_path) {
AssertTimer assertTimer(10, false); // Bomb out after 10 seconds, fall back if test fail
Expand Down Expand Up @@ -237,3 +239,5 @@ BOOST_AUTO_TEST_CASE(test_alias) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
8 changes: 5 additions & 3 deletions Test/TestClkSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ using namespace ecf;
using namespace boost::gregorian;
using namespace boost::posix_time;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_ClkSync)

BOOST_AUTO_TEST_CASE(test_clk_sync) {
// This test is used to test sync'ing of the suite calendars
Expand Down Expand Up @@ -119,8 +121,6 @@ BOOST_AUTO_TEST_CASE(test_suite_calendar_sync) {
<< " cal_count(" << TestFixture::client().defs()->updateCalendarCount() << ")\n";

for (size_t i = 0; i < 3; i++) {
// cout << "\n loop:" << i << " sleeping for " << TestFixture::job_submission_interval() << "s\n";

// Occasionally we get a random failure.
// It is suspected that BETWEEN the two calls below, one off
// Suite::updateCalendar() or Suite::resolveDependencies() is called in the server:
Expand Down Expand Up @@ -164,3 +164,5 @@ BOOST_AUTO_TEST_CASE(test_suite_calendar_sync) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
28 changes: 16 additions & 12 deletions Test/TestComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_Complete)

// In the test case we will dynamically create all the test data.
// The data is created dynamically so that we can stress test the server
Expand Down Expand Up @@ -56,18 +58,18 @@ BOOST_AUTO_TEST_CASE(test_complete) {
// Allows test to run without requiring installation

// # Note: we have to use relative paths, since these tests are relocatable
// suite test_complete
// family family
// repeat integer YMD 0 1
// complete ./family/check:nofiles # repeat family with waiting for children to complete
// task check
// event 1 nofiles
// task t1
// trigger check==complete
// suite test_complete
// family family
// repeat integer YMD 0 1
// complete ./family/check:nofiles # repeat family with waiting for children to complete
// task check
// event 1 nofiles
// task t1
// trigger check==complete
// task t2
// trigger t2 == complete # never runs
// endfamily
// endsuite
// trigger t2 == complete # never runs
// endfamily
// endsuite
std::string eventName = "nofiles";
Defs theDefs;
{
Expand Down Expand Up @@ -166,3 +168,5 @@ BOOST_AUTO_TEST_CASE(test_complete_with_empty_family) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
18 changes: 11 additions & 7 deletions Test/TestCron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ using namespace ecf;
using namespace boost::gregorian;
using namespace boost::posix_time;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_Cron)

static void wait_for_cron(int max_time_to_wait, const std::string& path) {
AssertTimer assertTimer(max_time_to_wait, false); // Bomb out after n seconds, fall back if test fail
Expand Down Expand Up @@ -79,13 +81,13 @@ BOOST_AUTO_TEST_CASE(test_cron_time_series) {

// # Note: we have to use relative paths, since these tests are relocatable
// suite test_cron_time_series
// edit SLEEPTIME 1
// edit ECF_INCLUDE $ECF_HOME/includes
// edit SLEEPTIME 1
// edit ECF_INCLUDE $ECF_HOME/includes
// clock real <todays date>
// family family
// task t1
// cron <start> <finish> <incr>
// endfamily
// family family
// task t1
// cron <start> <finish> <incr>
// endfamily
// endsuite
Defs theDefs;
std::string path;
Expand Down Expand Up @@ -138,3 +140,5 @@ BOOST_AUTO_TEST_CASE(test_cron_time_series) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/TestCtsWaitCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_CtsWaitCmd)

static void create_defs(Defs& theDefs, const std::string& suite_name) {
// suite test_wait_cmd
Expand Down Expand Up @@ -220,3 +222,5 @@ BOOST_AUTO_TEST_CASE(test_wait_cmd_non_existant_paths) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/TestDayDate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ using namespace ecf;
using namespace boost::gregorian;
using namespace boost::posix_time;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_DayDate)

BOOST_AUTO_TEST_CASE(test_day_at_midnight) {
// See ECFLOW-337 versus ECFLOW-1550
Expand Down Expand Up @@ -135,3 +137,5 @@ BOOST_AUTO_TEST_CASE(test_date_at_midnight) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/TestEcfNoScriptCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_EcfNoScriptCmd)

BOOST_AUTO_TEST_CASE(test_ecf_no_script) {
// This test is used to case where we ONLY want to execute ECF_JOB_CMD WITHOUT processing .ecf script.
Expand Down Expand Up @@ -75,3 +77,5 @@ BOOST_AUTO_TEST_CASE(test_ecf_no_script) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/Test_ECF_SCRIPT_CMD.cpp → Test/TestEcfScriptCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_EcfScriptCmd)

BOOST_AUTO_TEST_CASE(test_ECF_SCRIPT_CMD) {
DurationTimer timer;
Expand Down Expand Up @@ -78,3 +80,5 @@ BOOST_AUTO_TEST_CASE(test_ECF_SCRIPT_CMD) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/TestEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_Events)

// In the test case we will dynamically create all the test data.
// The data is created dynamically so that we can stress test the server
Expand Down Expand Up @@ -164,3 +166,5 @@ BOOST_AUTO_TEST_CASE(test_event_and_query) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
6 changes: 5 additions & 1 deletion Test/TestFileCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ using namespace boost::posix_time;
/// \note This is used to INVOKE a SINGLE test. Easier for debugging
///

BOOST_AUTO_TEST_SUITE(TestSuite)
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_FileCmd)

BOOST_AUTO_TEST_CASE(test_file_cmd) {
DurationTimer timer;
Expand Down Expand Up @@ -133,3 +135,5 @@ BOOST_AUTO_TEST_CASE(test_file_cmd) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
28 changes: 5 additions & 23 deletions Test/TestHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,9 @@ using namespace boost::posix_time;
/// Making it easier for Easier for debugging and development
///

BOOST_AUTO_TEST_SUITE(TestSuite)

// static void dump_suites_and_handles(ClientInvoker& theClient, const std::string& title)
//{
// std::cout << title;
// TestFixture::client().suites();
// {
// const std::vector<std::string>& suites = TestFixture::client().server_reply().get_string_vec();
// for(const std::string& suite: suites) { std::cout << "\n---> " << suite; }
// std::cout << "\n";
//
// const std::vector<std::pair<unsigned int, std::vector<std::string> > >& handles =
// TestFixture::client().server_reply().get_client_handle_suites(); std::pair<unsigned int,
// std::vector<std::string> > int_str_pair; for(size_t i =0; i < handles.size(); i++) {
// std::cout << "handle: " << handles[i].first << " : ";
// for(const std::string& suite: handles[i].second) {
// std::cout << suite << " ";
// }
// std::cout << "\n";
// }
// }
// std::cout << "\n";
// }
BOOST_AUTO_TEST_SUITE(S_Test)

BOOST_AUTO_TEST_SUITE(T_Handle)

BOOST_AUTO_TEST_CASE(test_handle) {
DurationTimer timer;
Expand Down Expand Up @@ -434,3 +414,5 @@ BOOST_AUTO_TEST_CASE(test_handle_add_remove_add) {
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
Loading

0 comments on commit baeff88

Please sign in to comment.