Exemplo n.º 1
0
    def test_check_netperf_within_vn(self, no_of_vn=1, encap='MPLSoUDP', test_name='TCP_STREAM', duration=10):
        ''' Validate Network performance between two VMs within a VN.
        '''
        if getattr(self, 'res', None):
            self.vn1_fixture = self.res.get_vn1_fixture()
            self.vn2_fixture = self.res.get_vn2_fixture()
            if no_of_vn == 2:
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn2_vm3_fixture()
            else:
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn1_vm6_fixture()
        else:
            self.vn1_fq_name = "default-domain:admin:vn1"
            self.vn1_name = "vn1"
            self.vn1_subnets = ['31.1.1.0/24']
            self.vm1_name = 'vm1'
            self.vm2_name = 'vm2'
            if no_of_vn == 2:
                self.vn2_fq_name = "default-domain:admin:vn2"
                self.vn2_name = "vn2"
                self.vn2_subnets = ['32.1.1.0/24']

        if getattr(self, 'res', None):
            self.vn1_fixture = self.res.get_vn1_fixture()
            assert self.vn1_fixture.verify_on_setup()
        else:
            self.vn1_fixture = self.config_vn(self.vn1_name, self.vn1_subnets)

        if no_of_vn == 2:
            if getattr(self, 'res', None):
                self.vn2_fixture = self.res.get_vn2_fixture()
                assert self.vn2_fixture.verify_on_setup()
            else:
                self.vn2_fixture = self.config_vn(self.vn2_name, self.vn2_subnets)

            self.policy_name = 'netperf_policy'
            self.rules = [{'direction': '<>',
                           'protocol': 'tcp',
                           'source_network': self.vn1_name,
                           'src_ports': [0, -1],
                           'dest_network': self.vn2_name,
                           'dst_ports': [0, -1],
                           'simple_action': 'pass',
                           }
                          ]
            self.policy_fix = self.config_policy(self.policy_name, self.rules)
            self.policy_attach_fix = self.attach_policy_to_vn(self.policy_fix, self.vn1_fixture)
            self.policy_attach_fix = self.attach_policy_to_vn(self.policy_fix, self.vn2_fixture)

            if getattr(self, 'res', None):
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn2_vm3_fixture()
            else:
                # Making sure VM falls on diffrent compute host
                host_list = self.connections.nova_h.get_hosts()
                compute_1 = host_list[0]
                compute_2 = host_list[0]
                if len(host_list) > 1:
                    compute_1 = host_list[0]
                    compute_2 = host_list[1]
                self.vm1_fixture = self.config_vm(self.vn1_fixture, self.vm1_name, node_name=compute_1)
                self.vm2_fixture = self.config_vm(self.vn2_fixture, self.vm2_name, node_name=compute_2)

            assert self.vm1_fixture.verify_on_setup()
            assert self.vm2_fixture.verify_on_setup()
            self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj)
            self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj)
        else:
            if getattr(self, 'res', None):
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn1_vm6_fixture()
            else:
                # Making sure VM falls on diffrent compute host
                host_list = self.connections.nova_h.get_hosts()
                compute_1 = host_list[0]
                compute_2 = host_list[0]
                if len(host_list) > 1:
                    compute_1 = host_list[0]
                    compute_2 = host_list[1]
                self.vm1_fixture = self.config_vm(self.vn1_fixture, self.vm1_name, node_name=compute_1)
                self.vm2_fixture = self.config_vm(self.vn1_fixture, self.vm2_name, node_name=compute_2)

            assert self.vm1_fixture.verify_on_setup()
            assert self.vm2_fixture.verify_on_setup()
            self.nova_h.wait_till_vm_is_up(self.vm1_fixture.vm_obj)
            self.nova_h.wait_till_vm_is_up(self.vm2_fixture.vm_obj)
        results = []
        # set the cpu to highest performance in compute nodes before running
        # the test
        hosts = []
        hosts.append(self.inputs.host_data[self.vm1_fixture.vm_node_ip])
        hosts.append(self.inputs.host_data[self.vm2_fixture.vm_node_ip])
        self.set_cpu_performance(hosts)

        #Change the encap type if user has passed different value other than default:MPLSoUDP
        if encap == 'MPLSoGRE':
            self.changeEncap_setting(encap1='MPLSoGRE', encap2='MPLSoUDP', encap3='VXLAN')

        self.logger.info("Running netperf for %s sec to check throughput",duration)
        cmd = 'sudo netperf -H %s -t %s -l %s' % (self.vm2_fixture.vm_ip, test_name, duration)
        self.vm1_fixture.run_cmd_on_vm(cmds=[cmd])
        netperf = NetPerfParser(self.vm1_fixture.return_output_values_list[0])
        if test_name == 'TCP_RR' or test_name == 'UDP_RR':
            trans_rate = netperf.get_trans_rate()
            self.logger.info("%s transaction rate: %s" % (test_name,trans_rate))
        if test_name == 'TCP_STREAM' or test_name == 'UDP_STREAM':
            throughout = netperf.get_throughput()
            self.logger.info("%s throughput: %s" % (test_name,throughout))
            results.append((netperf.get_throughput() > 900,
                       "Throughput is(%s) less than 900" % throughout))

        errmsg = ''
        for (rc, msg) in results:
            if not rc:
                self.logger.error(msg)
                errmsg += msg + '\n'
        if errmsg:
            #assert False, errmsg
            self.logger.info("This test wont fail; until we identify a number for throughput.")
            self.logger.error(errmsg)

        return True
Exemplo n.º 2
0
    def test_check_netperf_within_vn(self, no_of_vn=1):
        ''' Validate Network performance between two VMs within a VN.
        '''
        if getattr(self, 'res', None):
            self.vn1_fixture = self.res.get_vn1_fixture()
            self.vn2_fixture = self.res.get_vn2_fixture()
            if no_of_vn == 2:
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn2_vm3_fixture()
            else:
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn1_vm6_fixture()
        else:
            self.vn1_fq_name = "default-domain:admin:vn1"
            self.vn1_name = "vn1"
            self.vn1_subnets = ['31.1.1.0/24']
            self.vm1_name = 'vm1'
            self.vm2_name = 'vm2'
            if no_of_vn == 2:
                self.vn2_fq_name = "default-domain:admin:vn2"
                self.vn2_name = "vn2"
                self.vn2_subnets = ['32.1.1.0/24']

        if getattr(self, 'res', None):
            self.vn1_fixture = self.res.get_vn1_fixture()
            assert self.vn1_fixture.verify_on_setup()
        else:
            self.vn1_fixture = self.config_vn(self.vn1_name, self.vn1_subnets)

        if no_of_vn == 2:
            if getattr(self, 'res', None):
                self.vn2_fixture = self.res.get_vn2_fixture()
                assert self.vn2_fixture.verify_on_setup()
            else:
                self.vn2_fixture = self.config_vn(
                    self.vn2_name, self.vn2_subnets)

            self.policy_name = 'netperf_policy'
            self.rules = [{'direction': '<>',
                           'protocol': 'tcp',
                           'source_network': self.vn1_name,
                           'src_ports': [0, -1],
                           'dest_network': self.vn2_name,
                           'dst_ports': [0, -1],
                           'simple_action': 'pass',
                           }
                          ]
            self.policy_fix = self.config_policy(self.policy_name, self.rules)
            self.policy_attach_fix = self.attach_policy_to_vn(
                self.policy_fix, self.vn1_fixture)
            self.policy_attach_fix = self.attach_policy_to_vn(
                self.policy_fix, self.vn2_fixture)

            if getattr(self, 'res', None):
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn2_vm3_fixture()
            else:
                # Making sure VM falls on diffrent compute host
                host_list = []
                for host in self.inputs.compute_ips:
                    host_list.append(self.inputs.host_data[host]['name'])
                compute_1 = host_list[0]
                compute_2 = host_list[0]
                if len(host_list) > 1:
                    compute_1 = host_list[0]
                    compute_2 = host_list[1]
                self.vm1_fixture = self.config_vm(
                    self.vn1_fixture, self.vm1_name, node_name=compute_1)
                self.vm2_fixture = self.config_vm(
                    self.vn2_fixture, self.vm2_name, node_name=compute_2)

            assert self.vm1_fixture.verify_on_setup()
            assert self.vm2_fixture.verify_on_setup()
            self.vm1_fixture.wait_till_vm_is_up()
            self.vm2_fixture.wait_till_vm_is_up()
        else:
            if getattr(self, 'res', None):
                self.vm1_fixture = self.res.get_vn1_vm5_fixture()
                self.vm2_fixture = self.res.get_vn1_vm6_fixture()
            else:
                # Making sure VM falls on diffrent compute host
                host_list = []
                for host in self.inputs.compute_ips:
                    host_list.append(self.inputs.host_data[host]['name'])
                compute_1 = host_list[0]
                compute_2 = host_list[0]
                if len(host_list) > 1:
                    compute_1 = host_list[0]
                    compute_2 = host_list[1]
                self.vm1_fixture = self.config_vm(
                    self.vn1_fixture, self.vm1_name, node_name=compute_1)
                self.vm2_fixture = self.config_vm(
                    self.vn1_fixture, self.vm2_name, node_name=compute_2)

            assert self.vm1_fixture.verify_on_setup()
            assert self.vm2_fixture.verify_on_setup()
            self.vm1_fixture.wait_till_vm_is_up()
            self.vm2_fixture.wait_till_vm_is_up()
        results = []
        # set the cpu to highest performance in compute nodes before running
        # the test
        hosts = []
        hosts.append(self.inputs.host_data[self.vm1_fixture.vm_node_ip])
        hosts.append(self.inputs.host_data[self.vm2_fixture.vm_node_ip])
        self.set_cpu_performance(hosts)

        self.logger.info(
            "Running netperf for 60 sec to check outbound throughput")
        cmd = 'sudo netperf -H %s -t TCP_STREAM -B outbound -l 60' % self.vm2_fixture.vm_ip
        self.vm1_fixture.run_cmd_on_vm(cmds=[cmd])
        outbound_netperf = NetPerfParser(
            self.vm1_fixture.return_output_values_list[0])
        outbound_throughout = outbound_netperf.get_throughput()
        self.logger.info("Outbound throughput: %s", outbound_throughout)
        results.append((outbound_netperf.get_throughput() > 900,
                       "Outbound throughput is(%s) less than 900" % outbound_throughout))
        self.logger.info(
            "Running netperf for 60 sec to check inbound throughput")
        cmd = 'sudo netperf -H %s -t TCP_STREAM -B inbound -l 60' % self.vm2_fixture.vm_ip
        self.vm1_fixture.run_cmd_on_vm(cmds=[cmd])
        inbound_netperf = NetPerfParser(
            self.vm1_fixture.return_output_values_list[0])
        inbound_throughout = inbound_netperf.get_throughput()
        self.logger.info("Inbound throughput: %s", outbound_throughout)
        results.append((inbound_netperf.get_throughput() > 900,
                       "Outbound throughput is(%s) less than 900" % inbound_throughout))

        errmsg = ''
        for (rc, msg) in results:
            if not rc:
                self.logger.error(msg)
                errmsg += msg + '\n'
        if errmsg:
            #assert False, errmsg
            self.logger.info(
                "This test wont fail; until we identify a number for throughput.")
            self.logger.error(errmsg)

        return True