def test_050_network_sfm_secondary(self): logging.config.fileConfig("tests/data/test_runner_conf_complete.conf") with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_runner_conf_complete.conf']): options = vars(jnt_parse_args()) stopevent = threading.Event() net_state = JNTNetwork(stopevent, JNTOptions(options), is_primary=False, is_secondary=True, do_heartbeat_dispatch=False, test=True) net_state.start() while net_state.state != 'STARTED': net_state.fsm_network_next() net_state.stop()
def test_100_network_state_primary(self): logging.config.fileConfig("tests/data/test_runner_conf_complete.conf") with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_runner_conf_complete.conf']): options = vars(jnt_parse_args()) stopevent = threading.Event() net_state = JNTNetwork(stopevent, JNTOptions(options), is_primary=True, is_secondary=False, do_heartbeat_dispatch=True) print net_state.state hadds = { 0 : HADD%(self.add_ctrl,0), } net_state.boot(hadds) i = 0 while net_state.state != 'STARTED' and i<150: i += 1 print net_state.state time.sleep(1) self.assertEqual(net_state.state, 'STARTED') net_state.stop() i = 0 while net_state.state != 'STOPPED' and i<150: i += 1 print net_state.state time.sleep(1) self.assertEqual(net_state.state, 'STOPPED')
def test_141_network_state_primary_random_more(self): #~ self.skipTest("Pass but freeze on Docker/CI. Surely a non stopped thread in the state machine") self.onlyCITest() logging.config.fileConfig("tests/data/test_runner_conf_complete.conf") with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_runner_conf_complete.conf']): options = vars(jnt_parse_args()) stopevent = threading.Event() net_state = JNTNetwork(stopevent, JNTOptions(options), is_primary=True, is_secondary=False, do_heartbeat_dispatch=True, resolv_timeout=5) print net_state.state hadds = { 0 : HADD%(self.add_ctrl,0), } net_state.boot(hadds) time.sleep(5) net_state.stop() i = 0 while net_state.state != 'STOPPED' and i<150: i += 1 print net_state.state time.sleep(1) self.assertEqual(net_state.state, 'STOPPED') net_state.boot(hadds) time.sleep(25) net_state.stop() i = 0 while net_state.state != 'STOPPED' and i<150: i += 1 print net_state.state time.sleep(1) self.assertEqual(net_state.state, 'STOPPED') net_state.boot(hadds) time.sleep(31) net_state.stop() i = 0 while net_state.state != 'STOPPED' and i<150: i += 1 print net_state.state time.sleep(1) self.assertEqual(net_state.state, 'STOPPED') net_state.boot(hadds) time.sleep(52) net_state.stop() i = 0 while net_state.state != 'STOPPED' and i<150: i += 1 print net_state.state time.sleep(1) self.assertEqual(net_state.state, 'STOPPED')