Example #1
0
    def test_ping_within_vn_two_vms_two_different_subnets(self):
        '''
        Description:  Validate Ping between 2 VMs in the same VN, 2 VMs in different VN
        subnets.
        Test steps:
                1. Create 1 IPAM's.
                2. Create 1 VN with 2 subnets and launch 2 VMs in them.
                3. Ping between the VMs in the same VN should go thru fine.
                4. Ping to the subnet broadcast and all-broadcast address.
        Pass criteria: VM in the same subnet will respond to both the pings, while the VM in a different VN should respond only to the
                        all-broadcast address.
        Maintainer : [email protected]
        '''
        subnet1 = '31.1.1.0/29'
        subnet2 = '31.1.2.0/29'
        fixed_ip1 = '31.1.1.4'
        fixed_ip2 = '31.1.2.4'
        vn1_subnets = [subnet1, subnet2]

        ipam_obj = self.create_ipam()
        vn1_fixture = self.create_vn(vn_subnets=vn1_subnets,
                                     ipam_fq_name=ipam_obj.fq_name)

        subnet_objects = vn1_fixture.get_subnets()
        ports = {}

        for subnet in subnet_objects:
            if subnet['cidr'] == subnet1:
                ports['subnet1'] = vn1_fixture.create_port(
                    vn1_fixture.vn_id,
                    subnet_id=subnet['id'],
                    ip_address=fixed_ip1)
            elif subnet['cidr'] == subnet2:
                ports['subnet2'] = vn1_fixture.create_port(
                    vn1_fixture.vn_id,
                    subnet_id=subnet['id'],
                    ip_address=fixed_ip2)

        vm1 = self.create_vm(image_name='cirros',
                             vn_fixture=vn1_fixture,
                             port_ids=[ports['subnet1']['id']])
        vm2 = self.create_vm(image_name='cirros',
                             vn_fixture=vn1_fixture,
                             port_ids=[ports['subnet2']['id']])
        vm3 = self.create_vm(image_name='cirros', vn_fixture=vn1_fixture)
        assert ipam_obj.verify_on_setup()
        assert vn1_fixture.verify_on_setup()
        assert vm1.wait_till_vm_is_up()
        assert vm2.wait_till_vm_is_up()
        assert vm3.wait_till_vm_is_up()
        assert vm1.ping_to_ip(vm2.vm_ip)
        assert vm2.ping_to_ip(vm1.vm_ip)
        # Geting the VM ips
        vm1_ip = vm1.vm_ip
        vm2_ip = vm2.vm_ip
        vm3_ip = vm3.vm_ip
        ip_list = [vm1_ip, vm2_ip, vm3_ip]

        ip_broadcast = get_subnet_broadcast('%s/%s' % (vm1_ip, '29'))
        list_of_ip_to_ping = [ip_broadcast, '224.0.0.1', '255.255.255.255']
        cmd_list_to_pass_vm = [
            'echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts'
        ]

        vm1.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)
        vm2.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)
        vm3.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)

        for dst_ip in list_of_ip_to_ping:
            ping_output = vm1.ping_to_ip(dst_ip, return_output=True)
            expected_result = ' 0% packet loss'
            assert (expected_result in ping_output)
            string_count_dict = get_string_match_count(ip_list, ping_output)
            if (dst_ip == ip_broadcast):
                assert (string_count_dict[vm2_ip] == 0)
                assert (string_count_dict[vm3_ip] > 0)
            if (dst_ip == '224.0.0.1' or dst_ip == '255.255.255.255'):
                assert (string_count_dict[vm2_ip] > 0)
                assert (string_count_dict[vm3_ip] > 0)
    def test_ping_within_vn_two_vms_two_different_subnets(self):
        '''
        Description:  Validate Ping between 2 VMs in the same VN, 2 VMs in different VNs.
        Test steps:
                1. Create 2 VNs and launch 2 VMs in them.
                2. Ping between the VMs in the same VN should go thru fine.
                3. Ping to the subnet broadcast and all-broadcast address.
        Pass criteria: VM in the same subnet will respond to both the pings, while the VM in a different VN should respond only to the
                        all-broadcast address.
        Maintainer : [email protected]
        '''
        vn1_name = get_random_name('vn030')
        vn1_subnets = ['31.1.1.0/29', '31.1.2.0/29']
        subnet1 = '31.1.1.0/29'
        subnet2 = '31.1.2.0/29'
        fixed_ip1 = '31.1.1.4'
        fixed_ip2 = '31.1.2.4'
        subnet_objects = []
        # vn1_subnets=['30.1.1.0/24']
        vn1_vm1_name = get_random_name('vm1')
        vn1_vm2_name = get_random_name('vm2')
        vn1_fixture = self.useFixture(
            VNFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_name=vn1_name,
                      inputs=self.inputs,
                      subnets=vn1_subnets))
        assert vn1_fixture.verify_on_setup()

        subnet_objects = vn1_fixture.get_subnets()
        ports = {}

        for subnet in subnet_objects:
            if subnet['cidr'] == subnet1:
                ports['subnet1'] = vn1_fixture.create_port(
                    vn1_fixture.vn_id,
                    subnet_id=subnet['id'],
                    ip_address=fixed_ip1)
            elif subnet['cidr'] == subnet2:
                ports['subnet2'] = vn1_fixture.create_port(
                    vn1_fixture.vn_id,
                    subnet_id=subnet['id'],
                    ip_address=fixed_ip2)

        vm1_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=vn1_fixture.obj,
                      vm_name=vn1_vm1_name,
                      port_ids=[ports['subnet1']['id']]))
        vm2_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=vn1_fixture.obj,
                      vm_name=vn1_vm2_name,
                      port_ids=[ports['subnet2']['id']]))
        assert vm1_fixture.verify_on_setup()
        assert vm2_fixture.verify_on_setup()
        vm1_fixture.wait_till_vm_is_up()
        vm2_fixture.wait_till_vm_is_up()
        assert vm1_fixture.ping_to_ip(vm2_fixture.vm_ip)
        assert vm2_fixture.ping_to_ip(vm1_fixture.vm_ip)
        # Geting the VM ips
        vm1_ip = vm1_fixture.vm_ip
        vm2_ip = vm2_fixture.vm_ip
        ip_list = [vm1_ip, vm2_ip]
        #       gettig broadcast ip for vm1_ip
        ip_broadcast = get_subnet_broadcast('%s/%s' % (vm1_ip, '29'))
        list_of_ip_to_ping = [ip_broadcast, '224.0.0.1', '255.255.255.255']
        # passing command to vms so that they respond to subnet broadcast
        cmd_list_to_pass_vm = [
            'echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts'
        ]

        vm1_fixture.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)
        vm2_fixture.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)

        for dst_ip in list_of_ip_to_ping:
            print 'pinging from %s to %s' % (vm1_ip, dst_ip)
            # pinging from Vm1 to subnet broadcast
            if os.environ.has_key('ci_image'):
                ping_output = vm1_fixture.ping_to_ip(dst_ip,
                                                     return_output=True)
            else:
                ping_output = vm1_fixture.ping_to_ip(dst_ip,
                                                     return_output=True,
                                                     other_opt='-b')
            expected_result = ' 0% packet loss'
            assert (expected_result in ping_output)
            # getting count of ping response from each vm
            string_count_dict = {}
            string_count_dict = get_string_match_count(ip_list, ping_output)
            print string_count_dict
            if (dst_ip == ip_broadcast):
                assert (string_count_dict[vm2_ip] == 0)
            if (dst_ip == '224.0.0.1' or dst_ip == '255.255.255.255'):
                assert (string_count_dict[vm2_ip] > 0) or ('DUP!'
                                                           in ping_output)
        return True
Example #3
0
    def test_ping_within_vn_two_vms_two_different_subnets(self):
        '''
        Description:  Validate Ping between 2 VMs in the same VN, 2 VMs in different VN
        subnets.
        Test steps:
                1. Create 1 IPAM's.
                2. Create 1 VN with 2 subnets and launch 2 VMs in them.
                3. Ping between the VMs in the same VN should go thru fine.
                4. Ping to the subnet broadcast and all-broadcast address.
        Pass criteria: VM in the same subnet will respond to both the pings, while the VM in a different VN should respond only to the
                        all-broadcast address.
        Maintainer : [email protected]
        '''
        ipam_obj = self.useFixture(
            IPAMFixture(connections=self.connections, name=get_random_name('ipam1')))
        assert ipam_obj.verify_on_setup()

        vn1_name = get_random_name('vn030')
        vn1_subnets = ['31.1.1.0/29', '31.1.2.0/29']
        subnet1 = '31.1.1.0/29'
        subnet2 = '31.1.2.0/29'
        fixed_ip1 = '31.1.1.4'
        fixed_ip2 = '31.1.2.4'
        subnet_objects = []
        # vn1_subnets=['30.1.1.0/24']
        vn1_vm1_name = get_random_name('vm1')
        vn1_vm2_name = get_random_name('vm2')
        vn1_fixture = self.useFixture(
            VNFixture(
                project_name=self.inputs.project_name, connections=self.connections,
                vn_name=vn1_name, inputs=self.inputs, subnets=vn1_subnets,
                ipam_fq_name=ipam_obj.fq_name))
        assert vn1_fixture.verify_on_setup()

        subnet_objects = vn1_fixture.get_subnets()
        ports = {}

        for subnet in subnet_objects:
            if subnet['cidr'] == subnet1:
                ports['subnet1'] = vn1_fixture.create_port(vn1_fixture.vn_id,
                    subnet_id=subnet['id'], ip_address=fixed_ip1)
            elif subnet['cidr'] == subnet2:
                ports['subnet2'] = vn1_fixture.create_port(vn1_fixture.vn_id,
                    subnet_id=subnet['id'],ip_address=fixed_ip2)

        vm1_fixture = self.useFixture(
            VMFixture(
                project_name=self.inputs.project_name, connections=self.connections,
                vn_obj=vn1_fixture.obj, vm_name=vn1_vm1_name, port_ids = [ports['subnet1']['id']]))
        vm2_fixture = self.useFixture(
            VMFixture(
                project_name=self.inputs.project_name, connections=self.connections,
                vn_obj=vn1_fixture.obj, vm_name=vn1_vm2_name,port_ids = [ports['subnet2']['id']]))
        assert vm1_fixture.wait_till_vm_is_up()
        assert vm2_fixture.wait_till_vm_is_up()
        assert vm1_fixture.ping_to_ip(vm2_fixture.vm_ip)
        assert vm2_fixture.ping_to_ip(vm1_fixture.vm_ip)
        # Geting the VM ips
        vm1_ip = vm1_fixture.vm_ip
        vm2_ip = vm2_fixture.vm_ip
        ip_list = [vm1_ip, vm2_ip]
#       gettig broadcast ip for vm1_ip
        ip_broadcast = get_subnet_broadcast('%s/%s'%(vm1_ip, '29'))
        list_of_ip_to_ping = [ip_broadcast, '224.0.0.1', '255.255.255.255']
        # passing command to vms so that they respond to subnet broadcast
        cmd_list_to_pass_vm = [
            'echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts']

        vm1_fixture.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)
        vm2_fixture.run_cmd_on_vm(cmds=cmd_list_to_pass_vm, as_sudo=True)

        for dst_ip in list_of_ip_to_ping:
            print 'pinging from %s to %s' % (vm1_ip, dst_ip)
# pinging from Vm1 to subnet broadcast
            if self.inputs.is_ci_setup():
                ping_output = vm1_fixture.ping_to_ip(
                    dst_ip, return_output=True)
            else:
                ping_output = vm1_fixture.ping_to_ip(
                    dst_ip, return_output=True, other_opt='-b')
            expected_result = ' 0% packet loss'
            assert (expected_result in ping_output)
# getting count of ping response from each vm
            string_count_dict = {}
            string_count_dict = get_string_match_count(ip_list, ping_output)
            print string_count_dict
            if (dst_ip == ip_broadcast):
                assert (string_count_dict[vm2_ip] == 0)
            if (dst_ip == '224.0.0.1' or dst_ip == '255.255.255.255'):
                assert (string_count_dict[vm2_ip] > 0) or ('DUP!' in ping_output)
        return True