1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*
* Copyright 2009- ECMWF.
*
* This software is licensed under the terms of the Apache Licence version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/
#include <iostream>
#include <boost/test/unit_test.hpp>
#include "ecflow/core/Converter.hpp"
#include "ecflow/node/Defs.hpp"
#include "ecflow/node/Family.hpp"
#include "ecflow/node/Suite.hpp"
#include "ecflow/test/scaffold/Naming.hpp"
using namespace std;
using namespace ecf;
BOOST_AUTO_TEST_SUITE(U_Node)
BOOST_AUTO_TEST_SUITE(T_Defs)
BOOST_AUTO_TEST_CASE(test_defs_absorb) {
ECF_NAME_THIS_TEST();
// Create a defs file corresponding to:
// suite suite1
// family family
// task t1
// endfamily
// endsuite
Defs theDefs;
{
suite_ptr suite = theDefs.add_suite("suite1");
family_ptr fam = suite->add_family("family");
fam->add_task("t1");
}
// Then ABSORB a new def
// suite suite1-n
// family family
// task suite1_task1
// endfamily
// endsuite
Defs otherDefs;
{
for (int i = 0; i < 14; ++i) {
suite_ptr suite1 = otherDefs.add_suite("suite" + ecf::convert_to<std::string>(i));
family_ptr fam = suite1->add_family("family");
fam->add_task("suite1_task1");
}
}
theDefs.absorb(&otherDefs, true);
BOOST_CHECK_MESSAGE(otherDefs.suiteVec().empty(), "absorb failed");
}
BOOST_AUTO_TEST_CASE(test_defs_absorb_server_user_variables) {
ECF_NAME_THIS_TEST();
Defs theDefs;
Defs otherDefs;
{
otherDefs.server_state().add_or_update_user_variables("VAR1", "VAL");
otherDefs.server_state().add_or_update_user_variables("VAR2", "VAL");
otherDefs.server_state().add_or_update_user_variables("VAR3", "VAL");
otherDefs.add_suite("suite");
}
BOOST_CHECK_MESSAGE(theDefs.server_state().user_variables().empty(), "Expected no server user variables");
theDefs.absorb(&otherDefs, true);
BOOST_CHECK_MESSAGE(otherDefs.suiteVec().empty(), "absorb failed");
BOOST_CHECK_MESSAGE(theDefs.suiteVec().size() == 1, "absorb failed");
BOOST_CHECK_MESSAGE(theDefs.server_state().user_variables().size() == 3, "Expected 3 server user variables");
}
BOOST_AUTO_TEST_CASE(test_ECFLOW_1684) {
ECF_NAME_THIS_TEST();
Defs defs;
defs.add_edit_history("/", "request");
defs.add_edit_history("/a/made/up/path1", "request");
defs.add_edit_history("/a/made/up/path1", "request2");
defs.add_edit_history("/a/made/up/path2", "request2");
defs.add_edit_history("/a/made/up/path3", "request2");
BOOST_CHECK_MESSAGE(defs.get_edit_history().size() == 4,
"Expected edit history of size 4 but found " << defs.get_edit_history().size());
// This should remove all edit history, where the history paths do not exist as nodes in a defs, BUT need to leave
// ROOT as is though.
defs.handle_migration();
BOOST_CHECK_MESSAGE(defs.get_edit_history().size() == 1,
"Expected edit history of size 1 but found " << defs.get_edit_history().size());
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
|