14
14
#include < memory>
15
15
#include < thread>
16
16
17
- #include < boost/asio.hpp>
18
- #include < boost/process.hpp>
19
17
#include < boost/test/unit_test.hpp>
20
18
19
+ #include " Process.hpp"
21
20
#include " ecflow/attribute/NodeAttr.hpp"
22
21
#include " ecflow/client/ClientInvoker.hpp"
23
22
#include " ecflow/core/EcfPortLock.hpp"
24
23
#include " ecflow/core/File.hpp"
24
+ #include " ecflow/core/Filesystem.hpp"
25
25
#include " ecflow/core/Host.hpp"
26
26
#include " ecflow/core/Str.hpp"
27
27
#include " ecflow/node/Defs.hpp"
28
28
#include " ecflow/node/Node.hpp"
29
29
#include " ecflow/test/scaffold/Naming.hpp"
30
30
#include " ecflow/udp/UDPClient.hpp"
31
31
32
- namespace bp = boost::process;
33
-
34
32
namespace ecf ::test {
35
33
36
34
template <typename SERVER>
@@ -46,7 +44,7 @@ class BaseMockServer {
46
44
BOOST_REQUIRE_MESSAGE (!host_.empty (), " determiner host name" );
47
45
BOOST_REQUIRE_MESSAGE (port_ > 0 , " port is be larger than 0" );
48
46
49
- server_ = SERVER::launch (host_, port_, std::forward<Args>(args)...);
47
+ server_ = std::move ( SERVER::launch (host_, port_, std::forward<Args>(args)...) );
50
48
ECF_TEST_DBG (<< " MOCK: " << SERVER::designation << " has been started!" );
51
49
}
52
50
BaseMockServer (const BaseMockServer&) = delete ;
@@ -65,7 +63,7 @@ class BaseMockServer {
65
63
hostname_t host_;
66
64
uint16_t port_;
67
65
68
- bp::child server_;
66
+ Process server_;
69
67
};
70
68
71
69
/* *
@@ -78,7 +76,7 @@ class MockServer : public BaseMockServer<MockServer> {
78
76
void load_definition (const std::string& defs) const {
79
77
ClientInvoker client (ecf::Str::LOCALHOST (), port ());
80
78
try {
81
- BOOST_REQUIRE_MESSAGE (fs::exists (defs), " definitions file exists at: " + defs);
79
+ BOOST_REQUIRE_MESSAGE (fs::exists (defs), " definitions file doesn't exist at: " + defs);
82
80
auto error = client.loadDefs (defs);
83
81
BOOST_REQUIRE_MESSAGE (!error, " load definitions, without error " );
84
82
}
@@ -132,7 +130,7 @@ class MockServer : public BaseMockServer<MockServer> {
132
130
public:
133
131
static constexpr const char * designation = " ecFlow server" ;
134
132
135
- static bp::child launch (const hostname_t & host, port_t port) {
133
+ static Process launch (const hostname_t & host, port_t port) {
136
134
// Just for precaution, in case a previous run didn't clean up...
137
135
cleanup (host, port);
138
136
@@ -141,20 +139,16 @@ class MockServer : public BaseMockServer<MockServer> {
141
139
BOOST_REQUIRE_MESSAGE (!invoke_command.empty (), " The server program could not be found" );
142
140
BOOST_REQUIRE_MESSAGE (fs::exists (invoke_command), " Server exe does not exist at:" << invoke_command);
143
141
144
- invoke_command += " --port " ;
145
- invoke_command += std::to_string (port);
146
- invoke_command += " -d &" ;
147
-
148
142
ECF_TEST_DBG (<< " Launching ecflow_server @" << host << " :" << port << " , with: " << invoke_command);
149
143
150
- bp::child child (invoke_command);
144
+ auto server = Process (invoke_command, { " --port " , std::to_string (port), " -d " } );
151
145
152
146
ClientInvoker client (ecf::Str::LOCALHOST (), port);
153
147
if (!client.wait_for_server_reply (5 )) {
154
148
BOOST_REQUIRE_MESSAGE (false , " could not launch ecflow server" );
155
149
}
156
150
157
- return child ;
151
+ return server ;
158
152
}
159
153
160
154
static void cleanup (const hostname_t & host, port_t port) {
@@ -233,21 +227,18 @@ class MockUDPServer : public BaseMockServer<MockUDPServer> {
233
227
public:
234
228
static constexpr const char * designation = " ecFlow UDP" ;
235
229
236
- static bp::child launch (const hostname_t & host, port_t port, port_t ecflow_port) {
230
+ static Process launch (const hostname_t & host, port_t port, port_t ecflow_port) {
237
231
238
232
std::string invoke_command = ecf::File::root_build_dir () + " /bin/ecflow_udp" ;
239
- invoke_command += " --port " ;
240
- invoke_command += std::to_string (port);
241
- invoke_command += " --ecflow_port " ;
242
- invoke_command += std::to_string (ecflow_port);
243
- invoke_command += " --verbose" ;
244
233
245
234
ECF_TEST_DBG (<< " Launching ecflow_udp @" << host << " :" << port << " , with: " << invoke_command);
246
235
247
- bp::child server (invoke_command);
236
+ auto server =
237
+ Process (invoke_command,
238
+ {" --port" , std::to_string (port), " --ecflow_port" , std::to_string (ecflow_port), " --verbose" });
248
239
249
240
// Wait for server to start...
250
- std::this_thread::sleep_for (std::chrono::milliseconds (2000 ));
241
+ std::this_thread::sleep_for (std::chrono::milliseconds (2500 ));
251
242
252
243
return server;
253
244
}
@@ -286,7 +277,7 @@ struct EnableServersFixture
286
277
: ecflow_server(ecflow_server_port),
287
278
ecflow_udp (ecflow_udp_port, ecflow_server_port) {
288
279
// Load 'reference' suite for tests...
289
- ecflow_server.load_definition (" data/reference.def" );
280
+ ecflow_server.load_definition (fs::absolute ( " data/reference.def" ). string () );
290
281
}
291
282
};
292
283
0 commit comments