Minor fixes to tests.
authorDavin McCall <davmac@davmac.org>
Tue, 16 Jan 2018 21:01:03 +0000 (21:01 +0000)
committerDavin McCall <davmac@davmac.org>
Tue, 16 Jan 2018 21:01:03 +0000 (21:01 +0000)
Make sure to initialise all service properties in tests.

src/includes/proc-service.h
src/tests/proctests.cc

index 0952fffb659eb1aa6755cbe0421d8036086e604e..6a5831c20c979a2bdc3d801d61bc98b3bf6e3ddb 100644 (file)
@@ -110,6 +110,8 @@ class base_process_service : public service_record
     void kill_pg(int signo) noexcept;
 
     public:
+    // Constructor for a base_process_service. Note that the various parameters not specified here must in
+    // general be set separately (using the appropriate set_xxx function for each).
     base_process_service(service_set *sset, string name, service_type_t record_type_p, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
             const std::list<prelim_dep> &deplist_p);
index 25d473692dc3c6148c052555c874f7eb19d8003f..d1eae39eb43f8c4151bc5dc91ad53d1814c14073 100644 (file)
@@ -35,6 +35,15 @@ namespace bp_sys {
     extern pid_t last_forked_pid;
 }
 
+static void init_service_defaults(process_service &ps)
+{
+    ps.set_restart_interval(time_val(10,0), 3);
+    ps.set_restart_delay(time_val(0, 200000000)); // 200 milliseconds
+    ps.set_stop_timeout(time_val(10,0));
+    ps.set_start_timeout(time_val(10,0));
+    ps.set_start_interruptible(false);
+}
+
 // Regular service start
 void test_proc_service_start()
 {
@@ -48,6 +57,8 @@ void test_proc_service_start()
     std::list<prelim_dep> depends;
 
     process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+    init_service_defaults(p);
+
     p.start(true);
     sset.process_queues();
 
@@ -99,6 +110,8 @@ void test_term_via_stop()
     std::list<prelim_dep> depends;
 
     process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+    init_service_defaults(p);
+
     p.start(true);
     sset.process_queues();
 
@@ -131,6 +144,8 @@ void test_proc_start_timeout()
     std::list<prelim_dep> depends;
 
     process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+    init_service_defaults(p);
+
     p.start(true);
     sset.process_queues();
 
@@ -160,6 +175,8 @@ void test_proc_stop_timeout()
     std::list<prelim_dep> depends;
 
     process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+    init_service_defaults(p);
+
     p.start(true);
     sset.process_queues();
 
@@ -202,6 +219,7 @@ void test_proc_smooth_recovery1()
     std::list<prelim_dep> depends;
 
     process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+    init_service_defaults(p);
     p.set_smooth_recovery(true);
 
     p.start(true);
@@ -229,6 +247,7 @@ void test_proc_smooth_recovery1()
     assert(p.get_state() == service_state_t::STARTED);
 }
 
+// Smooth recovery without restart delay
 void test_proc_smooth_recovery2()
 {
     using namespace std;
@@ -241,6 +260,7 @@ void test_proc_smooth_recovery2()
     std::list<prelim_dep> depends;
 
     process_service p = process_service(&sset, "testproc", std::move(command), command_offsets, depends);
+    init_service_defaults(p);
     p.set_smooth_recovery(true);
     p.set_restart_delay(time_val(0, 0));