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 106 107 108 109 110 111 112 113 114 115 116 117
|
/*
* 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 <boost/test/unit_test.hpp>
#include "scaffold/Naming.hpp"
#include "scaffold/Provisioning.hpp"
BOOST_AUTO_TEST_SUITE(S_Foolproof)
BOOST_AUTO_TEST_SUITE(T_Basic)
BOOST_AUTO_TEST_CASE(test_e2e_ping) {
ECF_NAME_THIS_TEST();
using namespace foolproof::scaffold;
auto cwd = MakeDirectory{}.create();
auto host = MakeHost{}.create();
auto port = MakePort{}.with(AutomaticPortValue{}).create();
const auto server = MakeServer{}.with(host).with(port).with(cwd).launch();
{
BOOST_REQUIRE(server.ok());
auto& s = server.value();
BOOST_CHECK(s.pid() > 0);
BOOST_CHECK(s.port().value() == port.value());
BOOST_CHECK(s.host().is_valid());
}
{
auto client = RunClient{}.with(host).with(port).with(cwd).execute(RunClient::CommandPing{});
BOOST_CHECK(client.ok());
auto& c = client.value();
ECF_TEST_DBG("Output of --ping:\n" << c.stdout_buffer);
}
// Notice the automatic cleaned up when exiting scope!
// . shutdown server
// . remove port lock file
// . remove working directory
}
BOOST_AUTO_TEST_CASE(test_e2e_load) {
ECF_NAME_THIS_TEST();
using namespace foolproof::scaffold;
auto cwd = MakeDirectory{}.create();
auto host = MakeHost{}.create();
auto port = MakePort{}.with(AutomaticPortValue{}).create();
const auto server = MakeServer{}.with(host).with(port).with(cwd).launch();
{
BOOST_REQUIRE(server.ok());
auto& s = server.value();
BOOST_CHECK(s.pid() > 0);
BOOST_CHECK(s.port().value() == port.value());
BOOST_CHECK(s.host().is_valid());
}
auto defs = MakeTestFile{}
.with(SpecificFileLocation{"suite.def", cwd})
.with(
R"--(
suite s
family f
task task
endfamily
endsuite;
)--")
.create();
{
auto client = RunClient{}.with(host).with(port).with(cwd).execute(RunClient::CommandLoad{defs.path()});
BOOST_REQUIRE(client.ok());
auto& c = client.value();
ECF_TEST_DBG("Output of --load:\n" << c.stdout_buffer);
}
{
auto client = RunClient{}.with(host).with(port).with(cwd).execute(RunClient::CommandGet{});
BOOST_REQUIRE(client.ok());
auto& c = client.value();
BOOST_CHECK(c.stdout_contains("suite s"));
BOOST_CHECK(c.stdout_contains("family f"));
BOOST_CHECK(c.stdout_contains("task task"));
ECF_TEST_DBG("Output of --get:\n" << c.stdout_buffer);
}
{
auto client = RunClient{}.with(host).with(port).with(cwd).execute(RunClient::CommandGetState{});
BOOST_REQUIRE(client.ok());
auto& c = client.value();
BOOST_CHECK(c.stdout_contains("suite s"));
BOOST_CHECK(c.stdout_contains("family f"));
BOOST_CHECK(c.stdout_contains("task task"));
ECF_TEST_DBG("Output of --get_state:\n" << c.stdout_buffer);
}
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
|