def test_service_manager_start_stop(self): """ This test exercises the ServiceManager functions, but doesn't really verify functionality beyond the tests above """ # Skip for integration tests, otherwise will fail on systems without # runit if self.is_integration_test: return mgr = ServiceManager(['dummy1', 'dummy2'], init_system='runit', service_poller=MagicMock()) mgr.start_services() self.subprocess_mock.return_value = ( 'run: e2e_controller: 268195s; run: log: (pid 2275) 268195s\n' ) self.assertEqual(mgr._service_control['dummy1'].status(), ServiceState.Active) self.assertEqual(mgr._service_control['dummy2'].status(), ServiceState.Active) mgr.stop_services() self.subprocess_mock.return_value = ( 'down: e2e_controller: 268195s; run: log: (pid 2275) 268195s\n' ) self.assertEqual(mgr._service_control['dummy1'].status(), ServiceState.Inactive) self.assertEqual(mgr._service_control['dummy2'].status(), ServiceState.Inactive)
def test_service_manager_start_stop(self): """ This test exercises the ServiceManager functions, but doesn't really verify functionality beyond the tests above """ mgr = ServiceManager(['dummy1', 'dummy2'], init_system='docker', service_poller=MagicMock()) try: self._loop.run_until_complete(mgr.start_services()) except FileNotFoundError: pass self.subprocess_mock.return_value = b'[{"State": {"Status": "running"}}]' self.assertEqual(mgr._service_control['dummy1'].status(), ServiceState.Active) self.assertEqual(mgr._service_control['dummy2'].status(), ServiceState.Active) try: self._loop.run_until_complete(mgr.stop_services()) except FileNotFoundError: pass self.subprocess_mock.return_value = b'[{"State": {"Status": "exited"}}]' self.assertEqual(mgr._service_control['dummy1'].status(), ServiceState.Inactive) self.assertEqual(mgr._service_control['dummy2'].status(), ServiceState.Inactive)
def test_service_manager_start_stop(self): """ This test exercises the ServiceManager functions, but doesn't really verify functionality beyond the tests above """ mgr = ServiceManager( ['dummy1', 'dummy2'], init_system='systemd', service_poller=MagicMock(), ) self._loop.run_until_complete(mgr.start_services()) self.subprocess_mock.return_value = b'active\n' self.assertEqual( mgr._service_control['dummy1'].status(), ServiceState.Active, ) self.assertEqual( mgr._service_control['dummy2'].status(), ServiceState.Active, ) self._loop.run_until_complete(mgr.stop_services()) self.subprocess_mock.return_value = b'inactive\n' self.assertEqual( mgr._service_control['dummy1'].status(), ServiceState.Inactive, ) self.assertEqual( mgr._service_control['dummy2'].status(), ServiceState.Inactive, )