def __init__(self,params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpapic1' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.debug = params['pausetodebug']
def __init__(self, params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpleaf1' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.leaf_port_comp_node1 = params[ 'leaf1_port1'] #This connects Leaf to Comp-node1 self.node_id = params['leaf1_node_id']
def __init__(self, params): self.gbpcfg = gbpCfgCli() self.gbpverify = Gbp_Verify() self.gbpdeftraff = Gbp_def_traff() self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpapic3' self.cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(self.cntlr_ip) self.gbpnova = gbpNova(self.cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.debug = param['pausetodebug'] self.test_name = 'DISCONN_APIC_UPDATECFG_RECONN_APIC' self._log.info( "\nSteps of the TESTCASE_GBP_INTG_APIC_2_DISCONN_APIC_UPDATECFG_RECONN_APIC to be executed\n" ) if self.test_step_SetUpConfig() != 1: self._log.info("Test Failed at Step_1 == SetUpConfig") self.test_CleanUp() if self.test_step_VerifyTraffic() != 1: self._log.info("Test Failed at Step_2 == TestVerifyTraffic") self.test_CleanUp() objs_uuid = self.gbpverify.get_uuid_from_stack(self.heat_temp_test, self.heat_stack_name) self.ptg_1 = objs_uuid['server_ptg_id'] self.ptg_2 = objs_uuid['client_ptg_id'] self.test_1_prs = objs_uuid['demo_ruleset_icmp_id'] self.test_2_prs = objs_uuid['demo_ruleset_tcp_id'] self.test_3_prs = objs_uuid['demo_ruleset_udp_id'] self.test_4_prs = objs_uuid['demo_ruleset_icmp_tcp_id'] self.test_5_prs = objs_uuid['demo_ruleset_icmp_udp_id'] self.test_6_prs = objs_uuid['demo_ruleset_tcp_udp_id'] self.prs_proto = {self.test_1_prs:['icmp'],self.test_2_prs:['tcp'],self.test_3_prs:['udp'],\ self.test_4_prs:['icmp','tcp'],self.test_5_prs:['icmp','udp'],self.test_6_prs:['tcp','udp']}
def __init__(self,params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpvpc5' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.apic_ip = params['apic_ip'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.network_node = params['network_node'] self.leaf1_port_comp_node1 = params['leaf1_port1'] #This connects Leaf1 to Comp-node1 self.leaf1_port_comp_node2 = params['leaf1_port2'] #This connects Leaf1 to Comp-node2 self.node_id = params['leaf1_node_id']
def __init__(self,params): self.gbpcfg = gbpCfgCli() self.gbpverify = Gbp_Verify() self.gbpdeftraff = Gbp_def_traff() self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpapic3' self.cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(self.cntlr_ip) self.gbpnova = gbpNova(self.cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.debug = param['pausetodebug'] self.test_name = 'DISCONN_APIC_UPDATECFG_RECONN_APIC' self._log.info("\nSteps of the TESTCASE_GBP_INTG_APIC_2_DISCONN_APIC_UPDATECFG_RECONN_APIC to be executed\n") if self.test_step_SetUpConfig()!=1: self._log.info("Test Failed at Step_1 == SetUpConfig") self.test_CleanUp() if self.test_step_VerifyTraffic() != 1: self._log.info("Test Failed at Step_2 == TestVerifyTraffic") self.test_CleanUp() objs_uuid = self.gbpverify.get_uuid_from_stack(self.heat_temp_test,self.heat_stack_name) self.ptg_1 = objs_uuid['server_ptg_id'] self.ptg_2 = objs_uuid['client_ptg_id'] self.test_1_prs = objs_uuid['demo_ruleset_icmp_id'] self.test_2_prs = objs_uuid['demo_ruleset_tcp_id'] self.test_3_prs = objs_uuid['demo_ruleset_udp_id'] self.test_4_prs = objs_uuid['demo_ruleset_icmp_tcp_id'] self.test_5_prs = objs_uuid['demo_ruleset_icmp_udp_id'] self.test_6_prs = objs_uuid['demo_ruleset_tcp_udp_id'] self.prs_proto = {self.test_1_prs:['icmp'],self.test_2_prs:['tcp'],self.test_3_prs:['udp'],\ self.test_4_prs:['icmp','tcp'],self.test_5_prs:['icmp','udp'],self.test_6_prs:['tcp','udp']}
class testcase_gbp_aci_intg_apic_2(object): """ This is a GBP_ACI Integration TestCase """ # Initialize logging logging.basicConfig(format='%(asctime)s [%(levelname)s] %(name)s - %(message)s', level=logging.WARNING) _log = logging.getLogger( __name__ ) hdlr = logging.FileHandler('/tmp/testcase_gbp_aci_intg_apic_2.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) _log.addHandler(hdlr) _log.setLevel(logging.INFO) _log.setLevel(logging.DEBUG) def __init__(self,params): self.gbpcfg = gbpCfgCli() self.gbpverify = Gbp_Verify() self.gbpdeftraff = Gbp_def_traff() self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpapic3' self.cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(self.cntlr_ip) self.gbpnova = gbpNova(self.cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.debug = param['pausetodebug'] self.test_name = 'DISCONN_APIC_UPDATECFG_RECONN_APIC' self._log.info("\nSteps of the TESTCASE_GBP_INTG_APIC_2_DISCONN_APIC_UPDATECFG_RECONN_APIC to be executed\n") if self.test_step_SetUpConfig()!=1: self._log.info("Test Failed at Step_1 == SetUpConfig") self.test_CleanUp() if self.test_step_VerifyTraffic() != 1: self._log.info("Test Failed at Step_2 == TestVerifyTraffic") self.test_CleanUp() objs_uuid = self.gbpverify.get_uuid_from_stack(self.heat_temp_test,self.heat_stack_name) self.ptg_1 = objs_uuid['server_ptg_id'] self.ptg_2 = objs_uuid['client_ptg_id'] self.test_1_prs = objs_uuid['demo_ruleset_icmp_id'] self.test_2_prs = objs_uuid['demo_ruleset_tcp_id'] self.test_3_prs = objs_uuid['demo_ruleset_udp_id'] self.test_4_prs = objs_uuid['demo_ruleset_icmp_tcp_id'] self.test_5_prs = objs_uuid['demo_ruleset_icmp_udp_id'] self.test_6_prs = objs_uuid['demo_ruleset_tcp_udp_id'] self.prs_proto = {self.test_1_prs:['icmp'],self.test_2_prs:['tcp'],self.test_3_prs:['udp'],\ self.test_4_prs:['icmp','tcp'],self.test_5_prs:['icmp','udp'],self.test_6_prs:['tcp','udp']} def test_runner(self): """ Method to run the Testcase in Ordered Steps """ testcase_steps = [self.test_step_DisconnectApic, self.test_step_UpdatePtg, self.test_step_ReconnectApic, self.test_step_RestartNeutron, self.test_step_VerifyTraffic] status = '' for prs,proto in self.prs_proto.iteritems(): for step in testcase_steps: if step == 'self.test_step_VerifyTraffic': if step(proto) != 1: self._log.info("Test Failed at Step == VerifyTraffic for Protocol = %s" %(proto)) self._log.info("%s_%s == FAILED" %(self.__class__.__name__.upper(),self.test_name)) status = 'failed' break elif step()!=1: self._log.info("Test Failed at Step == %s" %(step.__name__.lstrip('self'))) self._log.info("%s_%s == FAILED" %(self.__class__.__name__.upper(),self.test_name)) status = 'failed' break if status == 'failed': if self.debug == True: PauseToDebug() break if status != 'failed': self._log.info("%s_%s == PASSED" %(self.__class__.__name__.upper(),self.test_name)) self.test_CleanUp() def test_step_SetUpConfig(self): """ Test Step using Heat, setup the Test Config """ self.agg_id = self.gbpnova.avail_zone('api','create',self.nova_agg,avail_zone_name=self.nova_az) if self.agg_id == 0: self._log.info("\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed") sys.exit(1) self._log.info(" Agg %s" %(self.agg_id)) if self.gbpnova.avail_zone('api','addhost',self.agg_id,hostname=self.az_comp_node) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, availability zone creation Failed") self.gbpnova.avail_zone('api','delete',self.nova_agg,avail_zone_name=self.nova_az) # Cleaning up sys.exit(1) sleep(3) if self.gbpheat.cfg_all_cli(1,self.heat_stack_name,heat_temp=self.heat_temp_test) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" %(self.heat_stack_name)) self.test_CleanUp() sys.exit(1) print 'Enable SSH .. sleeping for 20 secs' create_add_filter(self.apic_ip,'demo_bd') # 'demo_bd' is the name of L2Policy in the Heat Temp sleep(20) return 1 def test_step_UpdatePtg(self,prs): """ Update the PTG with new PRS & Restart the Neutron-Server """ if self.gbpcfg.gbp_policy_cfg_all(2,'group',self.ptg_1,provided_policy_rule_sets="%s=scope" %(prs))\ and self.gbpcfg.gbp_policy_cfg_all(2,'group',self.ptg_2,consumed_policy_rule_sets="%s=scope" %(prs))==0: self._log.info("Updating PTG = Failed") return 0 def test_step_RestartNeutron(self): getoutput('systemctl restart neutron-server.service') sleep(5) return 1 def test_step_DisconnectApic(self): """ Test Step to Disconnect APIC from Ostack Controller """ if self.gbpaci.dev_conn_disconn(self.cntlr_ip,self.apic_ip,'disconnect') == 0: return 0 return 1 def test_step_VerifyObjsApic(self): """ Test Step to verify that all configured objs are available in APIC """ if self.gbpaci.apic_verify_mos(self.apic_ip) == 0: return 0 return 1 def test_step_ReconnectApic(self): """ Test Step to Reconnect APIC to Ostack Controller """ if self.gbpaci.dev_conn_disconn(self.cntlr_ip,self.apic_ip,'reconnect') == 0: return 0 return 1 def test_step_VerifyTraffic(self,proto='all'): """ Send and Verify traffic """ return verify_traff(self.network_node) def test_CleanUp(self): """ Cleanup the Testcase setup """ self.gbpaci.dev_conn_disconn(self.cntlr_ip,self.apic_ip,'reconnect') self.gbpnova.avail_zone('api','removehost',self.agg_id,hostname=self.az_comp_node) self.gbpnova.avail_zone('api','delete',self.agg_id) self.gbpheat.cfg_all_cli(0,self.heat_stack_name)
class testcase_gbp_aci_intg_leaf_vpc_flap_5(object): """ This is a GBP_ACI Integration TestCase """ # Initialize logging #logging.basicConfig(level=logging.INFO) _log = logging.getLogger(__name__) _log.setLevel(logging.INFO) # create a logfile handler hdlr = logging.FileHandler( '/tmp/testcase_gbp_aci_intg_leaf_vpc_flap_5.log') formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') hdlr.setFormatter(formatter) # Add the handler to the logger _log.addHandler(hdlr) def __init__(self, params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpvpc7' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.apic_ip = params['apic_ip'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.network_node = params['network_node'] self.leaf1_port_comp_node1 = params[ 'leaf1_port1'] #This connects Leaf1 to Comp-node1 self.leaf2_port_comp_node2 = params[ 'leaf2_port2'] #This connects Leaf2 to Comp-node2 self.leaf1_node_id = params['leaf1_node_id'] self.leaf2_node_id = params['leaf2_node_id'] self.debug = params['pausetodebug'] def test_runner(self): """ Method to run the Testcase in Ordered Steps """ test_name = 'VPC_DISCON_LEAF1_NODE1_LEAF2_NODE2' self._log.info( "\nSteps of the TESTCASE_GBP_INTG_LEAF_VPC_5_VPC_DISCON_LEAF1_NODE1_LEAF2_NODE2 to be executed\n" ) testcase_steps = [ self.test_step_SetUpConfig, self.test_step_DisconnectLeafsFromHosts, self.test_step_VerifyTraffic ] status = '' for step in testcase_steps: if step() != 1: self._log.info("Test Failed at Step == %s" % (step.__name__.lstrip('self'))) if self.debug == True: PauseToDebug() self._log.info("%s_%s == FAILED" % (self.__class__.__name__.upper(), test_name)) status = 'failed' break if status != 'failed': self._log.info("%s_%s == PASSED" % (self.__class__.__name__.upper(), test_name)) self.test_CleanUp() def test_step_SetUpConfig(self): """ Test Step using Heat, setup the Test Config """ self._log.info( "\nSetupCfg: Create Aggregate & Availability Zone to be executed\n" ) self.agg_id = self.gbpnova.avail_zone('api', 'create', self.nova_agg, avail_zone_name=self.nova_az) if self.agg_id == 0: self._log.info( "\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed" ) sys.exit(1) self._log.info(" Agg %s" % (self.agg_id)) if self.gbpnova.avail_zone('api', 'addhost', self.agg_id, hostname=self.az_comp_node) == 0: self._log.info( "\n ABORTING THE TESTSUITE RUN, availability zone creation Failed" ) self.gbpnova.avail_zone( 'api', 'delete', self.nova_agg, avail_zone_name=self.nova_az) # Cleaning up sys.exit(1) sleep(3) if self.gbpheat.cfg_all_cli(1, self.heat_stack_name, heat_temp=self.heat_temp_test) == 0: self._log.info( "\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" % (self.heat_stack_name)) self.test_CleanUp() sys.exit(1) print 'Enable SSH .. sleeping for 20 secs' create_add_filter( self.apic_ip, 'demo_bd') # 'demo_bd' is the name of L2Policy in the Heat Temp sleep(20) return 1 def test_step_DisconnectLeafsFromHosts(self): """ Test Step to Disconnect Links b/w Leaf1-CompNode1,Leaf2-CompNode2 """ self._log.info( "\nStep to Disconnect Links b/w Leaf1-CompNode1,Leaf2-CompNode2\n") if self.gbpaci.enable_disable_switch_port( self.apic_ip, self.leaf1_node_id, 'disable', self.leaf1_port_comp_node1) == 0: return 0 if self.gbpaci.enable_disable_switch_port( self.apic_ip, self.leaf2_node_id, 'disable', self.leaf2_port_comp_node2) == 0: return 0 return 1 def test_step_VerifyTraffic(self): """ Send and Verify traffic """ self._log.info("\nSend and Verify Traffic\n") return verify_traff(self.network_node) def test_CleanUp(self): """ Cleanup the Testcase setup """ self._log.info("\nCleanUp to be executed\n") self.gbpaci.enable_disable_switch_port(self.apic_ip, self.leaf1_node_id, 'enable', self.leaf1_port_comp_node1) self.gbpaci.enable_disable_switch_port(self.apic_ip, self.leaf2_node_id, 'enable', self.leaf2_port_comp_node2) self.gbpnova.avail_zone('api', 'removehost', self.agg_id, hostname=self.az_comp_node) self.gbpnova.avail_zone('api', 'delete', self.agg_id) self.gbpheat.cfg_all_cli(0, self.heat_stack_name)
class testcase_gbp_aci_intg_leaf_vpc_flap_3(object): """ This is a GBP_ACI Integration TestCase """ # Initialize logging #logging.basicConfig(level=logging.INFO) _log = logging.getLogger(__name__) _log.setLevel(logging.INFO) # create a logfile handler hdlr = logging.FileHandler('/tmp/testcase_gbp_aci_intg_leaf_vpc_flap_3.log') formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') hdlr.setFormatter(formatter) # Add the handler to the logger _log.addHandler(hdlr) def __init__(self,params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpvpc5' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.apic_ip = params['apic_ip'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.network_node = params['network_node'] self.leaf1_port_comp_node1 = params['leaf1_port1'] #This connects Leaf1 to Comp-node1 self.leaf1_port_comp_node2 = params['leaf1_port2'] #This connects Leaf1 to Comp-node2 self.node_id = params['leaf1_node_id'] def test_runner(self): """ Method to run the Testcase in Ordered Steps """ test_name = 'VPC_DISCON_LEAF1_NODE1_NODE2' self._log.info("\nSteps of the TESTCASE_GBP_INTG_LEAF_VPC_3_VPC_DISCON_LEAF1_NODE1_NODE2 to be executed\n") testcase_steps = [self.test_step_SetUpConfig, self.test_step_DisconnectLeafOneHost, self.test_step_VerifyTraffic ] status = '' for step in testcase_steps: if step()!=1: self._log.info("Test Failed at Step == %s" %(step.__name__.lstrip('self'))) self._log.info("%s_%s == FAILED" %(self.__class__.__name__.upper(),test_name)) status = 'failed' break if status != 'failed': self._log.info("%s_%s == PASSED" %(self.__class__.__name__.upper(),test_name)) self.test_CleanUp() def test_step_SetUpConfig(self): """ Test Step using Heat, setup the Test Config """ self._log.info("\nSetupCfg: Create Aggregate & Availability Zone to be executed\n") self.agg_id = self.gbpnova.avail_zone('api','create',self.nova_agg,avail_zone_name=self.nova_az) if self.agg_id == 0: self._log.info("\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed") sys.exit(1) self._log.info(" Agg %s" %(self.agg_id)) if self.gbpnova.avail_zone('api','addhost',self.agg_id,hostname=self.az_comp_node) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, availability zone creation Failed") self.gbpnova.avail_zone('api','delete',self.nova_agg,avail_zone_name=self.nova_az) # Cleaning up sys.exit(1) sleep(3) if self.gbpheat.cfg_all_cli(1,self.heat_stack_name,heat_temp=self.heat_temp_test) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" %(self.heat_stack_name)) self.test_CleanUp() sys.exit(1) print 'Enable SSH .. sleeping for 20 secs' create_add_filter(self.apic_ip,'demo_bd') # 'demo_bd' is the name of L2Policy in the Heat Temp sleep(20) return 1 def test_step_DisconnectLeafOneHost(self): """ Test Step to Disconnect Leaf1 Ports from both Comp-Nodes """ self._log.info("\nStep to Disconnect Links between Leaf1 and Both Comp-nodes\n") if self.gbpaci.enable_disable_switch_port(self.apic_ip,self.node_id,'disable',self.leaf1_port_comp_node1) == 0: return 0 if self.gbpaci.enable_disable_switch_port(self.apic_ip,self.node_id,'disable',self.leaf1_port_comp_node2) == 0: return 0 return 1 def test_step_VerifyTraffic(self): """ Send and Verify traffic """ self._log.info("\nSend and Verify Traffic\n") return verify_traff(self.network_node) def test_CleanUp(self): """ Cleanup the Testcase setup """ self._log.info("\nCleanUp to be executed\n") for port in [self.leaf1_port_comp_node1,self.leaf1_port_comp_node2]: self.gbpaci.enable_disable_switch_port(self.apic_ip,self.node_id,'enable',port) self.gbpnova.avail_zone('api','removehost',self.agg_id,hostname=self.az_comp_node) self.gbpnova.avail_zone('api','delete',self.agg_id) self.gbpheat.cfg_all_cli(0,self.heat_stack_name)
class testcase_gbp_aci_intg_apic_1(object): """ This is a GBP_ACI Integration TestCase """ # Initialize logging logging.basicConfig(format='%(asctime)s [%(levelname)s] %(name)s - %(message)s', level=logging.WARNING) _log = logging.getLogger( __name__ ) hdlr = logging.FileHandler('/tmp/testcase_gbp_aci_intg_apic_1.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) _log.addHandler(hdlr) _log.setLevel(logging.INFO) _log.setLevel(logging.DEBUG) def __init__(self,params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpapic1' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.debug = params['pausetodebug'] def test_runner(self): """ Method to run the Testcase in Ordered Steps """ test_name = 'REBOOT_APIC' self._log.info("\nSteps of the TESTCASE_GBP_INTG_APIC_1_SETUPCFG_REBOOT_APIC to be executed\n") testcase_steps = [self.test_step_SetUpConfig, self.test_step_RebootApic, self.test_step_VerifyTraffic ] status = '' for step in testcase_steps: if step()!=1: self._log.info("Test Failed at Step == %s" %(step.__name__.lstrip('self'))) if self.debug == True: PauseToDebug() self._log.info("%s_%s == FAILED" %(self.__class__.__name__.upper(),test_name)) status = 'failed' break if status != 'failed': self._log.info("%s_%s == PASSED" %(self.__class__.__name__.upper(),test_name)) self.test_CleanUp() def test_step_SetUpConfig(self): """ Test Step using Heat, setup the Test Config """ self.agg_id = self.gbpnova.avail_zone('api','create',self.nova_agg,avail_zone_name=self.nova_az) if self.agg_id == 0: self._log.info("\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed") sys.exit(1) self._log.info(" Agg %s" %(self.agg_id)) if self.gbpnova.avail_zone('api','addhost',self.agg_id,hostname=self.az_comp_node) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, availability zone creation Failed") self.gbpnova.avail_zone('api','delete',self.nova_agg,avail_zone_name=self.nova_az) # Cleaning up sys.exit(1) sleep(3) if self.gbpheat.cfg_all_cli(1,self.heat_stack_name,heat_temp=self.heat_temp_test) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" %(self.heat_stack_name)) self.test_CleanUp() sys.exit(1) print 'Enable SSH .. sleeping for 20 secs' create_add_filter(self.apic_ip,'demo_bd') # 'demo_bd' is the name of L2Policy in the Heat Temp sleep(20) return 1 def test_step_RebootApic(self): """ Test Step to Reboot APIC from Ostack Controller """ if self.gbpaci.reboot_aci(self.apic_ip,node='apic') == 0: return 0 self._log.info("Rebooted the APIC, hence sleeping for 200 secs before exiting the method") sleep(200) return 1 def test_step_VerifyTraffic(self): """ Send and Verify traffic """ return verify_traff(self.network_node) def test_CleanUp(self): """ Cleanup the Testcase setup """ self.gbpnova.avail_zone('api','removehost',self.agg_id,hostname=self.az_comp_node) self.gbpnova.avail_zone('api','delete',self.agg_id) self.gbpheat.cfg_all_cli(0,self.heat_stack_name)
class testcase_gbp_aci_intg_leaf_2(object): """ This is a GBP_ACI Integration TestCase """ # Initialize logging logging.basicConfig(format='%(asctime)s [%(levelname)s] %(name)s - %(message)s', level=logging.WARNING) _log = logging.getLogger( __name__ ) hdlr = logging.FileHandler('/tmp/testcase_gbp_aci_intg_leaf_2.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) _log.addHandler(hdlr) _log.setLevel(logging.INFO) _log.setLevel(logging.DEBUG) def __init__(self,params): self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpleaf3' cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(cntlr_ip) self.gbpnova = gbpNova(cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.leaf_port_comp_node1 = params['leaf1_port1'] #This connects Leaf1 to Comp-node1 self.leaf_port_comp_node2 = params['leaf1_port2'] #This connects Leaf1 to Comp-node2 self.node_id = params['leaf1_node_id'] def test_runner(self): """ Method to run the Testcase in Ordered Steps """ test_name = 'SETUPCFG_WITH_OFFLINE_BOTH_COMP_NODES' self._log.info("\nSteps of the TESTCASE_GBP_INTG_LEAF_3_SETUPCFG_WITH_OFFLINE_BOTH_COMP_NODES to be executed\n") testcase_steps = [self.test_step_DisconnectLeaf, self.test_step_SetUpConfig, self.test_step_ReconnectLeaf, self.test_step_VerifyTraffic ] status = '' for step in testcase_steps: if step()!=1: self._log.info("Test Failed at Step == %s" %(step.__name__.lstrip('self'))) self._log.info("%s_%s == FAILED" %(self.__class__.__name__.upper(),test_name)) status = 'failed' break if status != 'failed': self._log.info("%s_%s == PASSED" %(self.__class__.__name__.upper(),test_name)) self.test_CleanUp() def test_step_SetUpConfig(self): """ Test Step using Heat, setup the Test Config """ self._log.info("\nSetupCfg: Create Aggregate & Availability Zone to be executed\n") self.agg_id = self.gbpnova.avail_zone('api','create',self.nova_agg,avail_zone_name=self.nova_az) if self.agg_id == 0: self._log.info("\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed") sys.exit(1) self._log.info(" Agg %s" %(self.agg_id)) if self.gbpnova.avail_zone('api','addhost',self.agg_id,hostname=self.az_comp_node) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, availability zone creation Failed") self.gbpnova.avail_zone('api','delete',self.nova_agg,avail_zone_name=self.nova_az) # Cleaning up sys.exit(1) sleep(3) if self.gbpheat.cfg_all_cli(1,self.heat_stack_name,heat_temp=self.heat_temp_test) == 0: self._log.info("\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" %(self.heat_stack_name)) self.test_CleanUp() sys.exit(1) print 'Enable SSH .. sleeping for 20 secs' create_add_filter(self.apic_ip,'demo_bd') # 'demo_bd' is the name of L2Policy in the Heat Temp sleep(20) return 1 def test_step_DisconnectLeaf(self): """ Test Step to Disconnect Leaf Port from two Comp-nodes """ self._log.info("\nStep to Disconnect Leaf Port from Two Comp-nodes= CompNode1 & CompNode2\n") for port in [self.leaf_port_comp_node1,self.leaf_port_comp_node2]: if self.gbpaci.enable_disable_switch_port(self.apic_ip,self.node_id,'disable',port) == 0: return 0 return 1 def test_step_ReconnectLeaf(self): """ Test Step to Reconnect Leaf Port to two Comp-nodes """ self._log.info("\nStep to RE-connect Leaf Ports to both Comp-nodes= CompNode1 & CompNode2\n") for port in [self.leaf_port_comp_node1,self.leaf_port_comp_node2]: if self.gbpaci.enable_disable_switch_port(self.apic_ip,self.node_id,'enable',port) == 0: return 0 sleep(20) ##For Opflex to re-converge return 1 def test_step_VerifyTraffic(self): """ Send and Verify traffic """ self._log.info("\nSend and Verify Traffic\n") return verify_traff(self.network_node) def test_CleanUp(self): """ Cleanup the Testcase setup """ self._log.info("\nCleanUp to be executed\n") self.gbpnova.avail_zone('api','removehost',self.agg_id,hostname=self.az_comp_node) self.gbpnova.avail_zone('api','delete',self.agg_id) self.gbpheat.cfg_all_cli(0,self.heat_stack_name)
class testcase_gbp_aci_intg_apic_2(object): """ This is a GBP_ACI Integration TestCase """ # Initialize logging logging.basicConfig( format='%(asctime)s [%(levelname)s] %(name)s - %(message)s', level=logging.WARNING) _log = logging.getLogger(__name__) hdlr = logging.FileHandler('/tmp/testcase_gbp_aci_intg_apic_2.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) _log.addHandler(hdlr) _log.setLevel(logging.INFO) _log.setLevel(logging.DEBUG) def __init__(self, params): self.gbpcfg = gbpCfgCli() self.gbpverify = Gbp_Verify() self.gbpdeftraff = Gbp_def_traff() self.gbpaci = Gbp_Aci() self.heat_stack_name = 'gbpapic3' self.cntlr_ip = params['cntlr_ip'] self.heat_temp_test = params['heat_temp_file'] self.gbpheat = gbpHeat(self.cntlr_ip) self.gbpnova = gbpNova(self.cntlr_ip) self.leaf_ip = params['leaf1_ip'] self.apic_ip = params['apic_ip'] self.network_node = params['network_node'] self.az_comp_node = params['az_comp_node'] self.nova_agg = params['nova_agg'] self.nova_az = params['nova_az'] self.debug = param['pausetodebug'] self.test_name = 'DISCONN_APIC_UPDATECFG_RECONN_APIC' self._log.info( "\nSteps of the TESTCASE_GBP_INTG_APIC_2_DISCONN_APIC_UPDATECFG_RECONN_APIC to be executed\n" ) if self.test_step_SetUpConfig() != 1: self._log.info("Test Failed at Step_1 == SetUpConfig") self.test_CleanUp() if self.test_step_VerifyTraffic() != 1: self._log.info("Test Failed at Step_2 == TestVerifyTraffic") self.test_CleanUp() objs_uuid = self.gbpverify.get_uuid_from_stack(self.heat_temp_test, self.heat_stack_name) self.ptg_1 = objs_uuid['server_ptg_id'] self.ptg_2 = objs_uuid['client_ptg_id'] self.test_1_prs = objs_uuid['demo_ruleset_icmp_id'] self.test_2_prs = objs_uuid['demo_ruleset_tcp_id'] self.test_3_prs = objs_uuid['demo_ruleset_udp_id'] self.test_4_prs = objs_uuid['demo_ruleset_icmp_tcp_id'] self.test_5_prs = objs_uuid['demo_ruleset_icmp_udp_id'] self.test_6_prs = objs_uuid['demo_ruleset_tcp_udp_id'] self.prs_proto = {self.test_1_prs:['icmp'],self.test_2_prs:['tcp'],self.test_3_prs:['udp'],\ self.test_4_prs:['icmp','tcp'],self.test_5_prs:['icmp','udp'],self.test_6_prs:['tcp','udp']} def test_runner(self): """ Method to run the Testcase in Ordered Steps """ testcase_steps = [ self.test_step_DisconnectApic, self.test_step_UpdatePtg, self.test_step_ReconnectApic, self.test_step_RestartNeutron, self.test_step_VerifyTraffic ] status = '' for prs, proto in self.prs_proto.iteritems(): for step in testcase_steps: if step == 'self.test_step_VerifyTraffic': if step(proto) != 1: self._log.info( "Test Failed at Step == VerifyTraffic for Protocol = %s" % (proto)) self._log.info( "%s_%s == FAILED" % (self.__class__.__name__.upper(), self.test_name)) status = 'failed' break elif step() != 1: self._log.info("Test Failed at Step == %s" % (step.__name__.lstrip('self'))) self._log.info( "%s_%s == FAILED" % (self.__class__.__name__.upper(), self.test_name)) status = 'failed' break if status == 'failed': if self.debug == True: PauseToDebug() break if status != 'failed': self._log.info("%s_%s == PASSED" % (self.__class__.__name__.upper(), self.test_name)) self.test_CleanUp() def test_step_SetUpConfig(self): """ Test Step using Heat, setup the Test Config """ self.agg_id = self.gbpnova.avail_zone('api', 'create', self.nova_agg, avail_zone_name=self.nova_az) if self.agg_id == 0: self._log.info( "\n ABORTING THE TESTSUITE RUN,nova host aggregate creation Failed" ) sys.exit(1) self._log.info(" Agg %s" % (self.agg_id)) if self.gbpnova.avail_zone('api', 'addhost', self.agg_id, hostname=self.az_comp_node) == 0: self._log.info( "\n ABORTING THE TESTSUITE RUN, availability zone creation Failed" ) self.gbpnova.avail_zone( 'api', 'delete', self.nova_agg, avail_zone_name=self.nova_az) # Cleaning up sys.exit(1) sleep(3) if self.gbpheat.cfg_all_cli(1, self.heat_stack_name, heat_temp=self.heat_temp_test) == 0: self._log.info( "\n ABORTING THE TESTSUITE RUN, HEAT STACK CREATE of %s Failed" % (self.heat_stack_name)) self.test_CleanUp() sys.exit(1) print 'Enable SSH .. sleeping for 20 secs' create_add_filter( self.apic_ip, 'demo_bd') # 'demo_bd' is the name of L2Policy in the Heat Temp sleep(20) return 1 def test_step_UpdatePtg(self, prs): """ Update the PTG with new PRS & Restart the Neutron-Server """ if self.gbpcfg.gbp_policy_cfg_all(2,'group',self.ptg_1,provided_policy_rule_sets="%s=scope" %(prs))\ and self.gbpcfg.gbp_policy_cfg_all(2,'group',self.ptg_2,consumed_policy_rule_sets="%s=scope" %(prs))==0: self._log.info("Updating PTG = Failed") return 0 def test_step_RestartNeutron(self): getoutput('systemctl restart neutron-server.service') sleep(5) return 1 def test_step_DisconnectApic(self): """ Test Step to Disconnect APIC from Ostack Controller """ if self.gbpaci.dev_conn_disconn(self.cntlr_ip, self.apic_ip, 'disconnect') == 0: return 0 return 1 def test_step_VerifyObjsApic(self): """ Test Step to verify that all configured objs are available in APIC """ if self.gbpaci.apic_verify_mos(self.apic_ip) == 0: return 0 return 1 def test_step_ReconnectApic(self): """ Test Step to Reconnect APIC to Ostack Controller """ if self.gbpaci.dev_conn_disconn(self.cntlr_ip, self.apic_ip, 'reconnect') == 0: return 0 return 1 def test_step_VerifyTraffic(self, proto='all'): """ Send and Verify traffic """ return verify_traff(self.network_node) def test_CleanUp(self): """ Cleanup the Testcase setup """ self.gbpaci.dev_conn_disconn(self.cntlr_ip, self.apic_ip, 'reconnect') self.gbpnova.avail_zone('api', 'removehost', self.agg_id, hostname=self.az_comp_node) self.gbpnova.avail_zone('api', 'delete', self.agg_id) self.gbpheat.cfg_all_cli(0, self.heat_stack_name)