File: TestClientHandleCmd.cpp

package info (click to toggle)
ecflow 5.15.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,868 kB
  • sloc: cpp: 269,341; python: 22,756; sh: 3,609; perl: 770; xml: 333; f90: 204; ansic: 141; makefile: 70
file content (78 lines) | stat: -rw-r--r-- 3,766 bytes parent folder | download
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
/*
 * 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 "InvokeServer.hpp"
#include "SCPort.hpp"
#include "ecflow/node/Defs.hpp"
#include "ecflow/node/System.hpp"
#include "ecflow/test/scaffold/Naming.hpp"

using namespace std;
using namespace ecf;

BOOST_AUTO_TEST_SUITE(S_Client)

BOOST_AUTO_TEST_SUITE(T_ClientHandleCmd)

BOOST_AUTO_TEST_CASE(test_client_handle_cmd) {
    ECF_NAME_THIS_TEST();

    /// This will remove checkpt and backup , to avoid server from loading it. (i.e from previous test)
    InvokeServer invokeServer("Client:: ...test_client_handle_cmd ", SCPort::next());
    BOOST_REQUIRE_MESSAGE(invokeServer.server_started(),
                          "Server failed to start on " << invokeServer.host() << ":" << invokeServer.port());
    ClientInvoker theClient(invokeServer.host(), invokeServer.port());
    theClient.set_auto_sync(true);

    std::vector<std::string> suites = {"s1", "s2"};
    defs_ptr defs                   = Defs::create();
    for (auto s : suites) {
        defs->add_suite(s);
    }

    BOOST_REQUIRE_MESSAGE(theClient.load(defs) == 0, "load defs failed \n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.defs()->suiteVec().size() == suites.size(), "load failed");

    BOOST_REQUIRE_MESSAGE(theClient.ch1_register(true, suites) == 0, "ch1_register failed\n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.defs()->suiteVec().size() == suites.size(), "register group sync failed");
    BOOST_REQUIRE_MESSAGE(theClient.server_reply().client_handle() == 1, " ch1_register failed expected handle 1");

    BOOST_REQUIRE_MESSAGE(theClient.delete_all() == 0, "delete_all failed\n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.defs()->suiteVec().size() == 0, "delete all failed");
    BOOST_REQUIRE_MESSAGE(theClient.server_reply().client_handle() == 0,
                          "delete all failed expected handle 0 but found " << theClient.server_reply().client_handle());

    // repeat test without auto_sync
    theClient.set_auto_sync(false);
    BOOST_REQUIRE_MESSAGE(theClient.load(defs) == 0, "load defs failed \n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.sync_local() == 0, "sync_local failed \n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.defs()->suiteVec().size() == suites.size(), "load failed");

    BOOST_REQUIRE_MESSAGE(theClient.ch1_register(true, suites) == 0, "ch1_register failed\n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.sync_local() == 0, "sync_local failed \n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.defs()->suiteVec().size() == suites.size(), "register group sync failed");
    BOOST_REQUIRE_MESSAGE(theClient.server_reply().client_handle() == 1, " ch1_register failed expected handle 1");

    BOOST_REQUIRE_MESSAGE(theClient.delete_all() == 0, "delete_all failed\n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.sync_local() == 0, "sync_local failed \n" << theClient.errorMsg());
    BOOST_REQUIRE_MESSAGE(theClient.defs()->suiteVec().size() == 0, "delete all failed");
    BOOST_REQUIRE_MESSAGE(theClient.server_reply().client_handle() == 0,
                          "delete all failed expected handle 0 but found " << theClient.server_reply().client_handle());

    System::destroy();
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()