def test_core_map(self): print '*' * 80 print "start to test interface fail" mgr = ManagerProcess(simulator=False) mgr.is_ip_in_core_map('eth0', '1.1.1.1') mgr.remove_ip_in_core_map('eth0', '1.1.1.1') mgr.add_ip_to_core_map('eth0', ('1.1.1.1', '', 4)) mgr.get_core_map('eth0', '1.1.1.1') mgr.get_core_map('eth0', '1.1.1.1') mgr.is_valid_ip('1.1')
def test_start_process(self): """Start provision process with real agent.""" print '*' * 80 print "start to test provision manager with real agent" mgr = ManagerProcess(simulator=False) mgr.dhcp_parameter['eth0'] = { 'TimeServers': [ '1.1.1.1', ], 'TimeOffset': 100, 'CCAPCores': [ '1.1.1.1', ], 'LogServers': [ '1.1.1.1', ] } # no core mgr.core_orchestrator.orchestrator_cb(None) # startup mgr.fsm.INTERFACE_SCAN(interface='eth0') mgr.add_ip_to_core_map('eth0', ('1.1.1.1', '', mgr.HA_CORE_TRIGGER)) mgr.core_orchestrator.orchestrator_cb(None) mgr.remove_ip_in_core_map('eth0', ('1.1.1.1', '', mgr.HA_CORE_TRIGGER)) # cb w/o candidate list mgr.core_orchestrator.orchestrator_cb(None) mgr.add_ip_to_core_map('eth0', ('1.1.1.1', '', mgr.HA_CORE_TRIGGER)) mgr.interface_list.append({ "interface": 'eth0', "status": mgr.INTERFACE_UP, }) mgr.core_orchestrator.orchestrator_cb(None) # is system time confirmed. mgr.set_time(time.time()) mgr.is_system_time_confirmed() # mgr state transmit mgr.fsm.STARTUP_DHCP_OK() mgr.core_orchestrator.orchestrator_cb(None) # operational mgr.fsm.OPERATIONAL_OK() print mgr.fsm.current, mgr.core_orchestrator.active_list mgr.core_orchestrator.orchestrator_cb(None) # check ka mgr.check_ka_status(None) mgr.check_ka_status(None) mgr.check_ka_status(None) keys = CCAPCore.ccap_core_db.keys() for key in keys: CCAPCore.ccap_core_db.pop(key) mgr.process_agent_db[ProcessAgent.AGENTTYPE_INTERFACE_STATUS][ "status"] = mgr.MGR_UNREGISTERED mgr.check_ka_status(None) # fail mgr.core_orchestrator.orchestrator_cb(None) mgr.fsm.Error(msg='test fsm error')