def test_100_node_state(self): with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_nodeman.conf']): options = vars(jnt_parse_args()) options = JNTOptions(options) section = 'fake' thread_uuid = options.get_option(section, 'uuid') if thread_uuid == None: thread_uuid = muuid.uuid1() options.set_option(section, 'uuid', "%s"%thread_uuid) node_state = JNTNodeMan(options, section, thread_uuid) print node_state.state hadds = { 0 : HADD%(self.add_ctrl,0), } node_state.start() i = 0 while node_state.state != 'ONLINE' and i<120: i += 1 print node_state.state time.sleep(1) self.assertEqual(node_state.state, 'ONLINE') node_state.stop() i = 0 while node_state.state != 'OFFLINE' and i<120: i += 1 print node_state.state time.sleep(1) self.assertEqual(node_state.state, 'OFFLINE') node_state = None
def test_100_node_state(self): with mock.patch("sys.argv", [self.prog, "start", "--conf_file=tests/data/test_nodeman.conf"]): options = vars(jnt_parse_args()) options = JNTOptions(options) section = "fake" thread_uuid = options.get_option(section, "uuid") if thread_uuid == None: thread_uuid = muuid.uuid1() options.set_option(section, "uuid", "%s" % thread_uuid) node_state = JNTNodeMan(options, section, thread_uuid) print node_state.state hadds = {0: HADD % (self.add_ctrl, 0)} node_state.start() i = 0 while node_state.state != "ONLINE" and i < 120: i += 1 print node_state.state time.sleep(1) self.assertEqual(node_state.state, "ONLINE") node_state.stop() i = 0 while node_state.state != "OFFLINE" and i < 120: i += 1 print node_state.state time.sleep(1) self.assertEqual(node_state.state, "OFFLINE") node_state = None
def test_010_nodeman_sfm_states(self): with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_nodeman.conf']): options = vars(jnt_parse_args()) options = JNTOptions(options) section = 'fake' thread_uuid = options.get_option(section, 'uuid') if thread_uuid == None: thread_uuid = muuid.uuid1() options.set_option(section, 'uuid', "%s"%thread_uuid) node_state = JNTNodeMan(options, section, thread_uuid, test=True) node_state.start() #~ net_state.fsm_network_start() while node_state.state != 'ONLINE': node_state.fsm_state_next() node_state.stop()
def test_010_nodeman_sfm_states(self): with mock.patch("sys.argv", [self.prog, "start", "--conf_file=tests/data/test_nodeman.conf"]): options = vars(jnt_parse_args()) options = JNTOptions(options) section = "fake" thread_uuid = options.get_option(section, "uuid") if thread_uuid == None: thread_uuid = muuid.uuid1() options.set_option(section, "uuid", "%s" % thread_uuid) node_state = JNTNodeMan(options, section, thread_uuid, test=True) node_state.start() # ~ net_state.fsm_network_start() while node_state.state != "ONLINE": node_state.fsm_state_next() node_state.stop()
def test_112_node_start_wait_random_stop_more(self): #~ self.skipTest("Pass but freeze on Docker/CI. Surely a non stopped thread in the state machine") self.onlyCITest() with mock.patch('sys.argv', [self.prog, 'start', '--conf_file=tests/data/test_nodeman.conf']): options = vars(jnt_parse_args()) options = JNTOptions(options) section = 'fake' thread_uuid = options.get_option(section, 'uuid') if thread_uuid == None: thread_uuid = muuid.uuid1() options.set_option(section, 'uuid', "%s"%thread_uuid) node_state = JNTNodeMan(options, section, thread_uuid) print node_state.state hadds = { 0 : HADD%(self.add_ctrl,0), } node_state.start() time.sleep(6) node_state.stop() i = 0 while node_state.state != 'OFFLINE' and i<120: i += 1 print node_state.state time.sleep(1) node_state.start() time.sleep(15) node_state.stop() i = 0 while node_state.state != 'OFFLINE' and i<120: i += 1 print node_state.state time.sleep(1) node_state.start() time.sleep(32) node_state.stop() i = 0 while node_state.state != 'OFFLINE' and i<120: i += 1 print node_state.state time.sleep(1)
def test_111_node_start_wait_random_stop(self): # ~ self.skipTest("Pass but freeze on Docker/CI. Surely a non stopped thread in the state machine") self.onlyCITest() with mock.patch("sys.argv", [self.prog, "start", "--conf_file=tests/data/test_nodeman.conf"]): options = vars(jnt_parse_args()) options = JNTOptions(options) section = "fake" thread_uuid = options.get_option(section, "uuid") if thread_uuid == None: thread_uuid = muuid.uuid1() options.set_option(section, "uuid", "%s" % thread_uuid) node_state = JNTNodeMan(options, section, thread_uuid) print node_state.state hadds = {0: HADD % (self.add_ctrl, 0)} node_state.start() time.sleep(4) node_state.stop() i = 0 while node_state.state != "OFFLINE" and i < 120: i += 1 print node_state.state time.sleep(1) node_state.start() time.sleep(8) node_state.stop() i = 0 while node_state.state != "OFFLINE" and i < 120: i += 1 print node_state.state time.sleep(1) node_state.start() time.sleep(22) node_state.stop() i = 0 while node_state.state != "OFFLINE" and i < 120: i += 1 print node_state.state time.sleep(1)