Пример #1
0
    def verify_traffic(self,
                       sender_vm,
                       receiver_vm,
                       proto,
                       sport,
                       dport,
                       count=None,
                       fip=None):
        # Create stream and profile
        if fip:
            stream = Stream(sport=sport,
                            dport=dport,
                            proto=proto,
                            src=sender_vm.vm_ip,
                            dst=fip)
        else:
            stream = Stream(sport=sport,
                            dport=dport,
                            proto=proto,
                            src=sender_vm.vm_ip,
                            dst=receiver_vm.vm_ip)
        profile_kwargs = {'stream': stream}
        if fip:
            profile_kwargs.update({'listener': receiver_vm.vm_ip})
        if count:
            profile_kwargs.update({'count': count})
            profile = StandardProfile(**profile_kwargs)
        else:
            profile = ContinuousProfile(**profile_kwargs)

        # Set VM credentials
        send_node = Host(
            sender_vm.vm_node_ip,
            self.inputs.host_data[sender_vm.vm_node_ip]['username'],
            self.inputs.host_data[sender_vm.vm_node_ip]['password'])
        recv_node = Host(
            receiver_vm.vm_node_ip,
            self.inputs.host_data[receiver_vm.vm_node_ip]['username'],
            self.inputs.host_data[receiver_vm.vm_node_ip]['password'])
        send_host = Host(sender_vm.local_ip, sender_vm.vm_username,
                         sender_vm.vm_password)
        recv_host = Host(receiver_vm.local_ip, receiver_vm.vm_username,
                         receiver_vm.vm_password)

        # Create send, receive helpers
        sender = Sender("send%s" % proto, profile, send_node, send_host,
                        self.inputs.logger)
        receiver = Receiver("recv%s" % proto, profile, recv_node, recv_host,
                            self.inputs.logger)

        # start traffic
        receiver.start()
        sender.start()
        sleep(5)

        # stop traffic
        sender.stop()
        receiver.stop()
        self.logger.debug("Sent: %s; Received: %s", sender.sent, receiver.recv)
        return (sender.sent, receiver.recv)
Пример #2
0
    def setup_and_create_streams(self, src_vn_fix, dst_vn_fix, src_vm_fix, dst_vm_fix, sport=8000, dport=9000, count=100):
        
        src_vm_node_ip = src_vm_fix.vm_node_ip
        dst_vm_node_ip = dst_vm_fix.vm_node_ip
        src_local_host = Host(
            src_vm_node_ip, self.inputs.host_data[
                src_vm_node_ip]['username'], self.inputs.host_data[
                dst_vm_node_ip]['password'])
        dst_local_host = Host(
            dst_vm_node_ip, self.inputs.host_data[
                dst_vm_node_ip]['username'], self.inputs.host_data[
                dst_vm_node_ip]['password'])
        send_host = Host(src_vm_fix.local_ip,
                              src_vm_fix.vm_username,
                              src_vm_fix.vm_password)
        recv_host = Host(dst_vm_fix.local_ip,
                              dst_vm_fix.vm_username,
                              dst_vm_fix.vm_password)
        send_file_name = 'sendudp'
        recv_file_name = 'recvudp'
        # Create traffic stream
        for i in range(3):
            sport = sport 
            dport = dport + i
            print('count=%s' % (count))
            print('dport=%s' % (dport))

            self.logger.info("Creating streams...")
            stream = Stream(
                protocol="ip",
                proto='udp',
                src=src_vm_fix.vm_ip,
                dst=dst_vm_fix.vm_ip,
                dport=dport,
                sport=sport)

            profile = StandardProfile(
                stream=stream,
                size=100,
                count=count,
                listener=dst_vm_fix.vm_ip)
            sender = Sender(
                send_file_name,
                profile,
                src_local_host,
                send_host,
                self.inputs.logger)
            receiver = Receiver(
                recv_file_name,
                profile,
                dst_local_host,
                recv_host,
                self.inputs.logger)
            receiver.start()
            sender.start()
            sender.stop()
            receiver.stop()
            print(sender.sent, receiver.recv)
            time.sleep(1)
Пример #3
0
    def setup_and_create_streams(self, src_vn_fix, dst_vn_fix, src_vm_fix, dst_vm_fix, sport=8000, dport=9000, count=100):
        
        src_vm_node_ip = src_vm_fix.vm_node_ip
        dst_vm_node_ip = dst_vm_fix.vm_node_ip
        src_local_host = Host(
            src_vm_node_ip, self.inputs.host_data[
                src_vm_node_ip]['username'], self.inputs.host_data[
                dst_vm_node_ip]['password'])
        dst_local_host = Host(
            dst_vm_node_ip, self.inputs.host_data[
                dst_vm_node_ip]['username'], self.inputs.host_data[
                dst_vm_node_ip]['password'])
        send_host = Host(src_vm_fix.local_ip,
                              src_vm_fix.vm_username,
                              src_vm_fix.vm_password)
        recv_host = Host(dst_vm_fix.local_ip,
                              dst_vm_fix.vm_username,
                              dst_vm_fix.vm_password)
        send_file_name = 'sendudp'
        recv_file_name = 'recvudp'
        # Create traffic stream
        for i in range(3):
            sport = sport 
            dport = dport + i
            print 'count=%s' % (count)
            print 'dport=%s' % (dport)

            self.logger.info("Creating streams...")
            stream = Stream(
                protocol="ip",
                proto='udp',
                src=src_vm_fix.vm_ip,
                dst=dst_vm_fix.vm_ip,
                dport=dport,
                sport=sport)

            profile = StandardProfile(
                stream=stream,
                size=100,
                count=count,
                listener=dst_vm_fix.vm_ip)
            sender = Sender(
                send_file_name,
                profile,
                src_local_host,
                send_host,
                self.inputs.logger)
            receiver = Receiver(
                recv_file_name,
                profile,
                dst_local_host,
                recv_host,
                self.inputs.logger)
            receiver.start()
            sender.start()
            sender.stop()
            receiver.stop()
            print sender.sent, receiver.recv
            time.sleep(1)
Пример #4
0
    def verify_traffic(self, sender_vm, receiver_vm, proto, sport, dport, count=None, fip=None):
        # Create stream and profile
        if fip:
            stream = Stream(
                protocol="ip", sport=sport, dport=dport, proto=proto, src=sender_vm.vm_ip,
                dst=fip)
        else:
            stream = Stream(
                protocol="ip", sport=sport, dport=dport, proto=proto, src=sender_vm.vm_ip,
                dst=receiver_vm.vm_ip)
        profile_kwargs = {'stream': stream}
        if fip:
            profile_kwargs.update({'listener': receiver_vm.vm_ip})
        if count:
            profile_kwargs.update({'count': count})
            profile = StandardProfile(**profile_kwargs)
        else:
            profile = ContinuousProfile(**profile_kwargs)

        # Set VM credentials
        send_node = Host(sender_vm.vm_node_ip,
                      self.inputs.host_data[sender_vm.vm_node_ip]['username'],
                      self.inputs.host_data[sender_vm.vm_node_ip]['password'])
        recv_node = Host(receiver_vm.vm_node_ip,
                   self.inputs.host_data[receiver_vm.vm_node_ip]['username'],
                   self.inputs.host_data[receiver_vm.vm_node_ip]['password'])
        send_host = Host(sender_vm.local_ip,
                         sender_vm.vm_username, sender_vm.vm_password)
        recv_host = Host(receiver_vm.local_ip,
                         receiver_vm.vm_username, receiver_vm.vm_password)

        # Create send, receive helpers
        sender = Sender("send%s" %
                        proto, profile, send_node, send_host, self.inputs.logger)
        receiver = Receiver("recv%s" %
                            proto, profile, recv_node, recv_host, self.inputs.logger)

        # start traffic
        receiver.start()
        sender.start()
        sleep(5)

        # stop traffic
        sender.stop()
        receiver.stop()
        self.logger.info("Sent: %s; Received: %s", sender.sent, receiver.recv)
        return (sender.sent, receiver.recv)
Пример #5
0
class BaseResource(BaseSanityResource):

    __metaclass__ = Singleton

    def setUp(self,inputs,connections):
        super(BaseResource , self).setUp(inputs, connections)
        self.setup_common_objects(self.inputs , self.connections)

    def cleanUp(self):
        super(BaseResource, self).cleanUp()

    def setup_common_objects(self, inputs , connections):
        (self.vn2_name, self.fip_vn_name) = (get_random_name("vn2"), get_random_name("fip_vn"))
        self.vn2_vm2_name = get_random_name('vn2_vm2')
        self.fvn_vm1_name = get_random_name('fvn_vm1')

        self.vn2_fixture = self.useFixture(VNFixture(
            project_name=self.inputs.project_name,
            connections=self.connections,
            inputs=self.inputs,
            vn_name=self.vn2_name))

        self.fvn_fixture = self.useFixture(VNFixture(
            project_name=self.inputs.project_name,
            connections=self.connections,
            inputs=self.inputs,
            vn_name=self.fip_vn_name))

        # Making sure VM falls on diffrent compute host
        self.orch = self.connections.orch 
        host_list = self.orch.get_hosts()
        compute_2 = host_list[0]
        if len(host_list) > 1:
            compute_2 = host_list[1]

        self.vn2_vm2_fixture=self.useFixture(VMFixture(project_name= self.inputs.project_name,
                            connections= self.connections, vn_obj= self.vn2_fixture.obj,
                            vm_name= self.vn2_vm2_name, image_name='ubuntu-traffic',
                            node_name=compute_2))
        self.fvn_vm1_fixture=self.useFixture(VMFixture(project_name= self.inputs.project_name,
                                connections= self.connections, vn_obj= self.fvn_fixture.obj,
                                vm_name= self.fvn_vm1_name))
        self.multi_intf_vm_fixture = self.useFixture(VMFixture(connections=self.connections,
                                     vn_objs=[self.vn1_fixture.obj , self.vn2_fixture.obj],
                                     vm_name='mltf_vm',
                                     project_name=self.inputs.project_name))

        self.verify_common_objects()
    #end setup_common_objects

    def verify_common_objects(self):
        super(BaseResource , self).verify_sanity_common_objects()
        assert self.vn2_fixture.verify_on_setup()
        assert self.fvn_fixture.verify_on_setup()
        assert self.fvn_vm1_fixture.wait_till_vm_is_up()
        assert self.vn2_vm2_fixture.wait_till_vm_is_up()
        assert self.multi_intf_vm_fixture.wait_till_vm_is_up()
    #end verify_common_objects

    def start_traffic(self):
        # installing traffic package in vm
        self.vn1_vm1_fixture.install_pkg("Traffic")
        self.vn2_vm2_fixture.install_pkg("Traffic")
        self.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
                            self.tx_vm_node_ip, self.inputs.host_data[
                            self.tx_vm_node_ip]['username'], self.inputs.host_data[
                            self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
                            self.rx_vm_node_ip, self.inputs.host_data[
                            self.rx_vm_node_ip]['username'], self.inputs.host_data[
                            self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.vn1_vm1_fixture.local_ip,
                            self.vn1_vm1_fixture.vm_username,
                            self.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.vn2_vm2_fixture.local_ip,
                            self.vn2_vm2_fixture.vm_username,
                            self.vn2_vm2_fixture.vm_password)
        # Create traffic stream
        self.logger.info("Creating streams...")
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.vn1_vm1_fixture.vm_ip,
            dst=self.vn2_vm2_fixture.vm_ip,
            dport=9000)

        profile = StandardProfile(
            stream=stream,
            size=100,
            count=10,
            listener=self.vn2_vm2_fixture.vm_ip)
        self.sender = Sender(
            "sendudp",
            profile,
            self.tx_local_host,
            self.send_host,
            self.inputs.logger)
        self.receiver = Receiver(
            "recvudp",
            profile,
            self.rx_local_host,
            self.recv_host,
            self.inputs.logger)
        self.receiver.start()
        self.sender.start()
        time.sleep(10)

    def stop_traffic(self):
        self.sender.stop()
        self.receiver.stop()
        self.logger.info("Sent traffic: %s"%(self.sender.sent))
        self.logger.info("Received traffic: %s"%(self.receiver.recv))
    def test_verify_flow_series_table(self):
        ''' Test to validate flow series table

        '''
        vn1_name = self.res.vn1_name
        vn1_subnets = self.res.vn1_fixture.get_cidrs(af='v4')
        vn2_name = self.res.vn2_name
        vn2_subnets = self.res.vn2_fixture.get_cidrs(af='v4')
        policy1_name = 'policy1'
        policy2_name = 'policy2'
        rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn1_name,
                'dest_network': vn2_name,
            },
        ]
        rev_rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn2_name,
                'dest_network': vn1_name,
            },
        ]
        policy1_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy1_name,
                rules_list=rules,
                inputs=self.inputs,
                connections=self.connections))
        policy2_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy2_name,
                rules_list=rev_rules,
                inputs=self.inputs,
                connections=self.connections))
        vn1_fixture = self.res.vn1_fixture
        vn1_fixture.bind_policies(
            [policy1_fixture.policy_fq_name], vn1_fixture.vn_id)
        self.addCleanup(
            vn1_fixture.unbind_policies, vn1_fixture.vn_id, [
                policy1_fixture.policy_fq_name])

        assert vn1_fixture.verify_on_setup()
        vn2_fixture = self.res.vn2_fixture
        vn2_fixture.bind_policies(
            [policy2_fixture.policy_fq_name], vn2_fixture.vn_id)
        assert vn2_fixture.verify_on_setup()
        self.addCleanup(
            vn2_fixture.unbind_policies, vn2_fixture.vn_id, [
                policy2_fixture.policy_fq_name])
#        self.res.verify_common_objects()
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn2_vm2_fixture.install_pkg("Traffic")
#        self.res.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip, self.inputs.host_data[
                self.tx_vm_node_ip]['username'], self.inputs.host_data[
                self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip, self.inputs.host_data[
                self.rx_vm_node_ip]['username'], self.inputs.host_data[
                self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.res.vn1_vm1_fixture.local_ip,
                              self.res.vn1_vm1_fixture.vm_username,
                              self.res.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.res.vn2_vm2_fixture.local_ip,
                              self.res.vn2_vm2_fixture.vm_username,
                              self.res.vn2_vm2_fixture.vm_password)
        # Create traffic stream
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        for i in range(10):
            count = 100
            dport = 9000
            count = count * (i + 1)
            dport = dport + i
            print 'count=%s' % (count)
            print 'dport=%s' % (dport)

            self.logger.info("Creating streams...")
            stream = Stream(
                protocol="ip",
                proto="udp",
                src=self.res.vn1_vm1_fixture.vm_ip,
                dst=self.res.vn2_vm2_fixture.vm_ip,
                dport=dport)

            profile = StandardProfile(
                stream=stream,
                size=100,
                count=count,
                listener=self.res.vn2_vm2_fixture.vm_ip)
            sender = Sender(
                "sendudp",
                profile,
                self.tx_local_host,
                self.send_host,
                self.inputs.logger)
            receiver = Receiver(
                "recvudp",
                profile,
                self.rx_local_host,
                self.recv_host,
                self.inputs.logger)
            receiver.start()
            sender.start()
            sender.stop()
            receiver.stop()
            print sender.sent, receiver.recv
            time.sleep(1)
        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res.vn1_vm1_fixture. nova_h.get_nova_host_of_vm(
                self.res.vn1_vm1_fixture.vm_obj)]['host_ip']
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name']
        time.sleep(300)
        # Verifying flow series table
        src_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        dst_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn2_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = '(' + 'sourcevn=' + src_vn + ') AND (destvn=' + dst_vn + ')'
        for ip in self.inputs.collector_ips:
            self.logger.info('setup_time= %s' % (start_time))
            # Quering flow sreies table
            self.logger.info(
                "Verifying flowSeriesTable through opserver %s" %
                (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowSeriesTable',
                start_time=start_time,
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'sum(packets)',
                    'sport',
                    'dport',
                    'T=1'],
                where_clause=query,
                sort=2,
                limit=5,
                sort_fields=['sum(packets)'])
            assert self.res1
    def test_verify_flow_series_table(self):
        """ Test to validate flow series table

        """
        vn1_name = self.res.vn1_name
        vn1_subnets = self.res.vn1_fixture.get_cidrs(af="v4")
        vn2_name = self.res.vn2_name
        vn2_subnets = self.res.vn2_fixture.get_cidrs(af="v4")
        policy1_name = "policy1"
        policy2_name = "policy2"
        rules = [
            {
                "direction": "<>",
                "simple_action": "pass",
                "protocol": "udp",
                "source_network": vn1_name,
                "dest_network": vn2_name,
            }
        ]
        rev_rules = [
            {
                "direction": "<>",
                "simple_action": "pass",
                "protocol": "udp",
                "source_network": vn2_name,
                "dest_network": vn1_name,
            }
        ]
        policy1_fixture = self.useFixture(
            PolicyFixture(policy_name=policy1_name, rules_list=rules, inputs=self.inputs, connections=self.connections)
        )
        policy2_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy2_name, rules_list=rev_rules, inputs=self.inputs, connections=self.connections
            )
        )
        vn1_fixture = self.res.vn1_fixture
        vn1_fixture.bind_policies([policy1_fixture.policy_fq_name], vn1_fixture.vn_id)
        self.addCleanup(vn1_fixture.unbind_policies, vn1_fixture.vn_id, [policy1_fixture.policy_fq_name])

        assert vn1_fixture.verify_on_setup()
        vn2_fixture = self.res.vn2_fixture
        vn2_fixture.bind_policies([policy2_fixture.policy_fq_name], vn2_fixture.vn_id)
        assert vn2_fixture.verify_on_setup()
        self.addCleanup(vn2_fixture.unbind_policies, vn2_fixture.vn_id, [policy2_fixture.policy_fq_name])
        #        self.res.verify_common_objects()
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn2_vm2_fixture.install_pkg("Traffic")
        #        self.res.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip,
            self.inputs.host_data[self.tx_vm_node_ip]["username"],
            self.inputs.host_data[self.tx_vm_node_ip]["password"],
        )
        self.rx_local_host = Host(
            self.rx_vm_node_ip,
            self.inputs.host_data[self.rx_vm_node_ip]["username"],
            self.inputs.host_data[self.rx_vm_node_ip]["password"],
        )
        self.send_host = Host(
            self.res.vn1_vm1_fixture.local_ip,
            self.res.vn1_vm1_fixture.vm_username,
            self.res.vn1_vm1_fixture.vm_password,
        )
        self.recv_host = Host(
            self.res.vn2_vm2_fixture.local_ip,
            self.res.vn2_vm2_fixture.vm_username,
            self.res.vn2_vm2_fixture.vm_password,
        )
        # Create traffic stream
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        for i in range(10):
            count = 100
            dport = 9000
            count = count * (i + 1)
            dport = dport + i
            print "count=%s" % (count)
            print "dport=%s" % (dport)

            self.logger.info("Creating streams...")
            stream = Stream(
                protocol="ip",
                proto="udp",
                src=self.res.vn1_vm1_fixture.vm_ip,
                dst=self.res.vn2_vm2_fixture.vm_ip,
                dport=dport,
            )

            profile = StandardProfile(stream=stream, size=100, count=count, listener=self.res.vn2_vm2_fixture.vm_ip)
            sender = Sender("sendudp", profile, self.tx_local_host, self.send_host, self.inputs.logger)
            receiver = Receiver("recvudp", profile, self.rx_local_host, self.recv_host, self.inputs.logger)
            receiver.start()
            sender.start()
            sender.stop()
            receiver.stop()
            print sender.sent, receiver.recv
            time.sleep(1)
        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res.vn1_vm1_fixture.orch.get_host_of_vm(self.res.vn1_vm1_fixture.vm_obj)
        ]["host_ip"]
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]["name"]
        time.sleep(300)
        # Verifying flow series table
        src_vn = "default-domain" + ":" + self.inputs.project_name + ":" + self.res.vn1_name
        dst_vn = "default-domain" + ":" + self.inputs.project_name + ":" + self.res.vn2_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = "(" + "sourcevn=" + src_vn + ") AND (destvn=" + dst_vn + ")"
        for ip in self.inputs.collector_ips:
            self.logger.info("setup_time= %s" % (start_time))
            # Quering flow sreies table
            self.logger.info("Verifying flowSeriesTable through opserver %s" % (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                "FlowSeriesTable",
                start_time=start_time,
                end_time="now",
                select_fields=["sourcevn", "sourceip", "destvn", "destip", "sum(packets)", "sport", "dport", "T=1"],
                where_clause=query,
                sort=2,
                limit=5,
                sort_fields=["sum(packets)"],
            )
            assert self.res1
    def test_verify_flow_tables(self):
        '''
          Description:  Test to validate flow tables

            1.Creat 2 vn and 1 vm in each vn
            2.Create policy between vns
            3.send 100 udp packets from vn1 to vn2
            4.Verify in vrouter uve that active flow matches with the agent introspect - fails otherwise
            5.Query flowrecord table for the flow and verify packet count mtches 100 - fails otherwise
            6.Query flow series table or the flow and verify packet count mtches 100 - fails otherwise

         Maintainer: [email protected]
        '''
        vn1_name = self.res.vn1_name
        vn1_fq_name = '%s:%s:%s' % (
            self.inputs.project_fq_name[0], self.inputs.project_fq_name[1], self.res.vn1_name)
        vn1_subnets = self.res.vn1_fixture.get_cidrs(af='v4')
        vn2_name = self.res.vn2_name
        vn2_fq_name = '%s:%s:%s' % (
            self.inputs.project_fq_name[0], self.inputs.project_fq_name[1], self.res.vn2_name)
        vn2_subnets = self.res.vn2_fixture.get_cidrs(af='v4')
        policy1_name = 'policy1'
        policy2_name = 'policy2'
        result = True
        rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn1_name,
                'dest_network': vn2_name,
            },
        ]
        rev_rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn2_name,
                'dest_network': vn1_name,
            },
        ]
        policy1_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy1_name,
                rules_list=rules,
                inputs=self.inputs,
                connections=self.connections))
        policy2_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy2_name,
                rules_list=rev_rules,
                inputs=self.inputs,
                connections=self.connections))
        vn1_fixture = self.res.vn1_fixture
        vn1_fixture.bind_policies(
            [policy1_fixture.policy_fq_name], vn1_fixture.vn_id)
        self.addCleanup(
            vn1_fixture.unbind_policies, vn1_fixture.vn_id, [
                policy1_fixture.policy_fq_name])

        assert vn1_fixture.verify_on_setup()
        vn2_fixture = self.res.vn2_fixture
        vn2_fixture.bind_policies(
            [policy2_fixture.policy_fq_name], vn2_fixture.vn_id)
        assert vn2_fixture.verify_on_setup()
        self.addCleanup(
            vn2_fixture.unbind_policies, vn2_fixture.vn_id, [
                policy2_fixture.policy_fq_name])
#        self.res.verify_common_objects()
        # start_time=self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.verify_on_setup()
        self.res.vn2_vm2_fixture.verify_on_setup()
        self.res.fvn_vm1_fixture.verify_on_setup()
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn2_vm2_fixture.install_pkg("Traffic")
        self.res.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip, self.inputs.host_data[
                self.tx_vm_node_ip]['username'], self.inputs.host_data[
                self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip, self.inputs.host_data[
                self.rx_vm_node_ip]['username'], self.inputs.host_data[
                self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.res.vn1_vm1_fixture.local_ip,
                              self.res.vn1_vm1_fixture.vm_username,
                              self.res.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.res.vn2_vm2_fixture.local_ip,
                              self.res.vn2_vm2_fixture.vm_username,
                              self.res.vn2_vm2_fixture.vm_password)
        pkts_before_traffic = self.analytics_obj.get_inter_vn_stats(
            self.inputs.collector_ips[0],
            src_vn=vn1_fq_name,
            other_vn=vn2_fq_name,
            direction='in')
        if not pkts_before_traffic:
            pkts_before_traffic = 0
        # Create traffic stream
        self.logger.info("Creating streams...")
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.res.vn1_vm1_fixture.vm_ip,
            dst=self.res.vn2_vm2_fixture.vm_ip,
            dport=9000)

        profile = StandardProfile(
            stream=stream,
            size=100,
            count=10,
            listener=self.res.vn2_vm2_fixture.vm_ip)
        sender = Sender(
            "sendudp",
            profile,
            self.tx_local_host,
            self.send_host,
            self.inputs.logger)
        receiver = Receiver(
            "recvudp",
            profile,
            self.rx_local_host,
            self.recv_host,
            self.inputs.logger)
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        receiver.start()
        sender.start()
        time.sleep(10)
        # Poll to make usre traffic flows, optional
        # sender.poll()
        # receiver.poll()
        sender.stop()
        receiver.stop()
        print sender.sent, receiver.recv
        for vn in [self.res.vn1_fixture.vn_fq_name,\
                    self.res.vn2_fixture.vn_fq_name]:
                 
            #ACL count        
            if not (int(self.analytics_obj.get_acl\
                    (self.inputs.collector_ips[0],vn)) > 0):
                    self.logger.error("Acl counts not received from Agent uve \
                                in %s vn uve"%(vn))
                    result = result and False

            if not (int(self.analytics_obj.get_acl\
                    (self.inputs.collector_ips[0], vn, tier = 'Config')) > 0):
                    self.logger.error("Acl counts not received from Config uve \
                                in %s vn uve"%(vn))
                    result = result and False

            #Bandwidth usage        
            if not (int(self.analytics_obj.get_bandwidth_usage\
                    (self.inputs.collector_ips[0], vn, direction = 'out')) > 0):
                    self.logger.error("Bandwidth not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

            if not (int(self.analytics_obj.get_bandwidth_usage\
                    (self.inputs.collector_ips[0], vn, direction = 'in')) > 0):
                    self.logger.error("Bandwidth not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

            #Flow count
            if not (int(self.analytics_obj.get_flow\
                    (self.inputs.collector_ips[0], vn, direction = 'egress')) > 0):
                    self.logger.error("egress flow  not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

            if not (int(self.analytics_obj.get_flow\
                    (self.inputs.collector_ips[0], vn, direction = 'ingress')) > 0):
                    self.logger.error("ingress flow  not shown  \
                                in %s vn uve"%(vn))
                    result = result and False
                   
            #VN stats
            vns = [self.res.vn1_fixture.vn_fq_name,\
                    self.res.vn2_fixture.vn_fq_name]
            vns.remove(vn)
            other_vn = vns[0]        
            if not (self.analytics_obj.get_vn_stats\
                    (self.inputs.collector_ips[0], vn, other_vn)):
                    self.logger.error("vn_stats   not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

        assert "sender.sent == receiver.recv", "UDP traffic to ip:%s failed" % self.res.vn2_vm2_fixture.vm_ip
        # Verifying the vrouter uve for the active flow
        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res.vn1_vm1_fixture.orch.get_host_of_vm(
                self.res.vn1_vm1_fixture.vm_obj)]['host_ip']
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name']
        self.logger.info(
            "Waiting for the %s vrouter uve to be updated with active flows" %
            (vm_host))
        time.sleep(60)
        self.flow_record = self.analytics_obj.get_flows_vrouter_uve(
            vrouter=vm_host)
        self.logger.info(
            "Active flow in vrouter uve = %s" %
            (self.flow_record))
        if (self.flow_record > 0):
            self.logger.info("Flow records  updated")
            result = result and True
        else:
            self.logger.warn("Flow records NOT updated")
            result = result and False

#        assert ( self.flow_record > 0)
#        self.logger.info("Waiting for inter-vn stats to be updated...")
#        time.sleep(60)
        pkts_after_traffic = self.analytics_obj.get_inter_vn_stats(
            self.inputs.collector_ips[0],
            src_vn=vn1_fq_name,
            other_vn=vn2_fq_name,
            direction='in')
        if not pkts_after_traffic:
            pkts_after_traffic = 0
        self.logger.info("Verifying that the inter-vn stats updated")
        self.logger.info(
            "Inter vn stats before traffic %s" %
            (pkts_before_traffic))
        self.logger.info(
            "Inter vn stats after traffic %s" %
            (pkts_after_traffic))
        if ((pkts_after_traffic - pkts_before_traffic) >= 10):
            self.logger.info("Inter vn stats updated")
            result = result and True
        else:
            self.logger.warn("Inter vn stats NOT updated")
            result = result and False

        self.logger.info("Waiting for flow records to be expired...")
        time.sleep(224)
        self.flow_record = self.analytics_obj.get_flows_vrouter_uve(
            vrouter=vm_host)
#        if ( self.flow_record > 0):
#            self.logger.info("Flow records  updated")
#            result = result and True
#        else:
#            self.logger.warn("Flow records NOT updated")
#            result = result and False
        self.logger.debug(
            "Active flow in vrouter uve = %s" %
            (self.flow_record))
#        assert ( self.flow_record == 0)
        # Verifying flow series table
        src_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        dst_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn2_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = '(' + 'sourcevn=' + src_vn + ') AND (destvn=' + dst_vn + ')'
        for ip in self.inputs.collector_ips:
            self.logger.info(
                "Verifying flowRecordTable through opserver %s.." %
                (ip))
            self.res2 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowRecordTable',
                start_time=start_time,
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'setup_time',
                    'teardown_time',
                    'agg-packets'],
                where_clause=query)

            self.logger.info("Query output: %s" % (self.res2))
            assert self.res2
            if self.res2:
                r = self.res2[0]
                s_time = r['setup_time']
                e_time = r['teardown_time']
                agg_pkts = r['agg-packets']
                assert (agg_pkts == sender.sent)
            self.logger.info(
                'setup_time= %s,teardown_time= %s' %
                (s_time, e_time))
            self.logger.info("Records=\n%s" % (self.res2))
            # Quering flow sreies table
            self.logger.info(
                "Verifying flowSeriesTable through opserver %s" %
                (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowSeriesTable',
                start_time=str(s_time),
                end_time=str(e_time),
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'sum(packets)'],
                where_clause=query)
            self.logger.info("Query output: %s" % (self.res1))
            assert self.res1
            if self.res1:
                r1 = self.res1[0]
                sum_pkts = r1['sum(packets)']
                assert (sum_pkts == sender.sent)
            self.logger.info("Flow series Records=\n%s" % (self.res1))
            assert (sum_pkts == agg_pkts)

        assert result
        return True
Пример #9
0
    def test_config_add_change_while_control_nodes_go_down(self):
        """Tests related to configuration add, change, and delete while switching from normal mode
           to headless and back i.e. control nodes go down and come online."""

        if len(self.inputs.compute_ips) < 2:
            raise unittest.SkipTest("This test needs atleast 2 compute nodes.")
        else:
            self.logger.info(
                "Required resources are in place to run the test.")

        result = True
        topology_class_name = None

        self.compute_fixture_dict = {}
        for each_compute in self.inputs.compute_ips:
            self.compute_fixture_dict[each_compute] = self.useFixture(
                ComputeNodeFixture(connections=self.connections,
                                   node_ip=each_compute,
                                   username=self.inputs.username,
                                   password=self.inputs.password))
            mode = self.compute_fixture_dict[
                each_compute].get_agent_headless_mode()
            if mode is False:
                self.compute_fixture_dict[
                    each_compute].set_agent_headless_mode()
        #
        # Get config for test from topology
        result = True
        msg = []
        if not topology_class_name:
            topology_class_name = test_headless_vrouter_topo.sdn_headless_vrouter_topo

        self.logger.info("Scenario for the test used is: %s" %
                         (topology_class_name))
        #
        # Create a list of compute node IP's and pass it to topo if you want to pin
        # a vm to a particular node
        topo_obj = topology_class_name(
            compute_node_list=self.inputs.compute_ips)
        #
        # Test setup: Configure policy, VN, & VM
        # return {'result':result, 'msg': err_msg, 'data': [self.topo, config_topo]}
        # Returned topo is of following format:
        # config_topo= {'policy': policy_fixt, 'vn': vn_fixture, 'vm': vm_fixture}
        topo = {}
        topo_objs = {}
        config_topo = {}
        setup_obj = self.useFixture(
            sdnTopoSetupFixture(self.connections, topo_obj))
        out = setup_obj.sdn_topo_setup()
        self.assertEqual(out['result'], True, out['msg'])
        if out['result']:
            topo_objs, config_topo, vm_fip_info = out['data']

        # Start Test
        proj = config_topo.keys()
        vms = config_topo[proj[0]]['vm'].keys()
        src_vm = config_topo[proj[0]]['vm'][vms[0]]
        dest_vm = config_topo[proj[0]]['vm'][vms[1]]
        flow_cache_timeout = 180

        # Setup Traffic.
        stream = Stream(protocol="ip",
                        proto="icmp",
                        src=src_vm.vm_ip,
                        dst=dest_vm.vm_ip)
        profile = ContinuousProfile(stream=stream, count=0, capfilter="icmp")

        tx_vm_node_ip = src_vm.vm_node_ip
        rx_vm_node_ip = dest_vm.vm_node_ip

        tx_local_host = Host(tx_vm_node_ip, self.inputs.username,
                             self.inputs.password)
        rx_local_host = Host(rx_vm_node_ip, self.inputs.username,
                             self.inputs.password)

        send_host = Host(src_vm.local_ip, src_vm.vm_username,
                         src_vm.vm_password)
        recv_host = Host(dest_vm.local_ip, dest_vm.vm_username,
                         dest_vm.vm_password)

        sender = Sender("icmp", profile, tx_local_host, send_host,
                        self.inputs.logger)
        receiver = Receiver("icmp", profile, rx_local_host, recv_host,
                            self.inputs.logger)

        receiver.start()
        sender.start()
        self.logger.info("Waiting for 5 sec for traffic to be setup ...")
        time.sleep(5)

        #self.start_ping(src_vm, dest_vm)

        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)

        headless_vr_utils.stop_all_control_services(self)
        self.addCleanup(self.inputs.start_service,
                        'contrail-control',
                        self.inputs.bgp_ips,
                        container='control')
        time.sleep(10)
        headless_vr_utils.check_through_tcpdump(self, dest_vm, src_vm)

        flow_index_list2 = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)

        if set(flow_index_list) == set(flow_index_list2):
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        receiver.stop()
        sender.stop()
        project1_instance = config_topo['project1']['project']['project1']
        project1_instance.get_project_connections()
        vnet2_instance = config_topo['project1']['vn']['vnet2']
        # add VM to existing VN
        VM22_fixture = self.useFixture(
            VMFixture(
                connections=project1_instance.project_connections['juniper'],
                vn_obj=vnet2_instance.obj,
                vm_name='VM22',
                project_name=project1_instance.project_name))

        # create new IPAM
        ipam3_obj = self.useFixture(
            IPAMFixture(project_obj=project1_instance, name='ipam3'))
        ipam4_obj = self.useFixture(
            IPAMFixture(project_obj=project1_instance, name='ipam4'))

        # create new VN
        VN3_fixture = self.useFixture(
            VNFixture(
                project_name=project1_instance.project_name,
                connections=project1_instance.project_connections['juniper'],
                vn_name='VN3',
                inputs=project1_instance.inputs,
                subnets=['10.3.1.0/24'],
                ipam_fq_name=ipam3_obj.fq_name))

        VN4_fixture = self.useFixture(
            VNFixture(
                project_name=project1_instance.project_name,
                connections=project1_instance.project_connections['juniper'],
                vn_name='VN4',
                inputs=project1_instance.inputs,
                subnets=['10.4.1.0/24'],
                ipam_fq_name=ipam4_obj.fq_name))

        # create policy
        policy_name = 'policy34'
        rules = []
        rules = [{
            'direction': '<>',
            'protocol': 'icmp',
            'dest_network': VN4_fixture.vn_fq_name,
            'source_network': VN3_fixture.vn_fq_name,
            'dst_ports': 'any',
            'simple_action': 'pass',
            'src_ports': 'any'
        }, {
            'direction': '<>',
            'protocol': 'icmp',
            'dest_network': VN3_fixture.vn_fq_name,
            'source_network': VN4_fixture.vn_fq_name,
            'dst_ports': 'any',
            'simple_action': 'pass',
            'src_ports': 'any'
        }]

        policy34_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy_name,
                rules_list=rules,
                inputs=project1_instance.inputs,
                connections=project1_instance.project_connections['juniper'],
                project_fixture=project1_instance))

        # create VN to policy mapping in a dict of policy list.
        vn_policys = {
            VN3_fixture.vn_name: [policy_name],
            VN4_fixture.vn_name: [policy_name]
        }

        # create a policy object list of policies to be attached to a vm
        policy_obj_dict = {}
        policy_obj_dict[VN3_fixture.vn_name] = [policy34_fixture.policy_obj]
        policy_obj_dict[VN4_fixture.vn_name] = [policy34_fixture.policy_obj]

        # vn fixture dictionary.
        vn_obj_dict = {}
        vn_obj_dict[VN3_fixture.vn_name] = VN3_fixture
        vn_obj_dict[VN4_fixture.vn_name] = VN4_fixture

        # attach policy to VN
        VN3_policy_fixture = self.useFixture(
            VN_Policy_Fixture(
                connections=project1_instance.project_connections['juniper'],
                vn_name=VN3_fixture.vn_name,
                policy_obj=policy_obj_dict,
                vn_obj=vn_obj_dict,
                vn_policys=vn_policys[VN3_fixture.vn_name],
                project_name=project1_instance.project_name))

        VN4_policy_fixture = self.useFixture(
            VN_Policy_Fixture(
                connections=project1_instance.project_connections['juniper'],
                vn_name=VN4_fixture.vn_name,
                policy_obj=policy_obj_dict,
                vn_obj=vn_obj_dict,
                vn_policys=vn_policys[VN4_fixture.vn_name],
                project_name=project1_instance.project_name))

        # add VM to new VN
        VM31_fixture = self.useFixture(
            VMFixture(
                connections=project1_instance.project_connections['juniper'],
                vn_obj=VN3_fixture.obj,
                vm_name='VM31',
                project_name=project1_instance.project_name))

        VM41_fixture = self.useFixture(
            VMFixture(
                connections=project1_instance.project_connections['juniper'],
                vn_obj=VN4_fixture.obj,
                vm_name='VM41',
                project_name=project1_instance.project_name))

        # verification routines.
        test_flag = 0
        if ((VN3_fixture.verify_vn_in_api_server())
                and (VN3_fixture.verify_vn_not_in_agent())
                and (VN3_fixture.verify_vn_policy_in_api_server()['result'])):
            self.logger.info(
                "Verification of VN3 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VN3 FAILED while control nodes down.")
            test_flag = 1

        if ((VN4_fixture.verify_vn_in_api_server())
                and (VN4_fixture.verify_vn_not_in_agent())
                and (VN4_fixture.verify_vn_policy_in_api_server()['result'])):
            self.logger.info(
                "Verification of VN4 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VN4 FAILED while control nodes down.")
            test_flag = 1

        if ((VM22_fixture.verify_vm_launched())
                and (VM22_fixture.verify_vm_in_api_server())):
            self.logger.info(
                "Verification of VM22 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VM22 FAILED while control nodes down.")
            test_flag = 1

        if ((VM31_fixture.verify_vm_launched())
                and (VM31_fixture.verify_vm_in_api_server())):
            self.logger.info(
                "Verification of VM31 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VM31 FAILED while control nodes down.")
            test_flag = 1

        if ((VM41_fixture.verify_vm_launched())
                and (VM41_fixture.verify_vm_in_api_server())):
            self.logger.info(
                "Verification of VM41 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VM41 FAILED while control nodes down.")
            test_flag = 1

        # start all control services.
        headless_vr_utils.start_all_control_services(self)

        # if something went wrong in the controller down state bail out here.
        if test_flag == 1:
            self.logger.error(
                "Verifications and Test failed while the controllers were down in \
                               headless state of agent. Check earlier error logs"
            )
            return False

        # wait for 3 to 5 sec for configuration sync from control nodes to the
        # agents.
        time.sleep(5)

        # wait till VM's are up.
        VM22_fixture.wait_till_vm_is_up()
        VM31_fixture.wait_till_vm_is_up()
        VM41_fixture.wait_till_vm_is_up()

        # verify vm config gets downloaded to the agents.
        if ((VM22_fixture.verify_vm_in_agent())
                and (VM31_fixture.verify_vm_in_agent())
                and (VM41_fixture.verify_vm_in_agent())):
            self.logger.info("VM verification on the agent PASSED")
        else:
            self.logger.error("VM verification on the agent FAILED")
            return False

        # check ping success between the two VM's
        assert config_topo['project1']['vm']['VM11'].ping_with_certainty(
            VM22_fixture.vm_ip, expectation=True)
        assert VM31_fixture.ping_with_certainty(VM41_fixture.vm_ip,
                                                expectation=True)
        assert VM41_fixture.ping_with_certainty(VM31_fixture.vm_ip,
                                                expectation=True)

        # verification routines.
        if ((VN3_fixture.verify_on_setup()) and (VN4_fixture.verify_on_setup())
                and (VM22_fixture.verify_on_setup())
                and (VM31_fixture.verify_on_setup())
                and (VM41_fixture.verify_on_setup())):
            self.logger.info(
                "All verifications passed after controllers came up in headless agent mode"
            )
        else:
            self.logger.error(
                "Verifications FAILED after controllers came up in headless agent mode"
            )
            return False

        return True
    def test_traffic_connections_while_control_nodes_go_down(self):
        """Tests related to connections and traffic while switching from normal mode to headless and back
           i.e. control nodes go down and come online."""

        if len(self.inputs.compute_ips) < 2:
            raise unittest.SkipTest("This test needs atleast 2 compute nodes.")
        else:
            self.logger.info("Required resources are in place to run the test.")

        result = True
        topology_class_name = None

        self.compute_fixture_dict = {}
        for each_compute in self.inputs.compute_ips:
            self.compute_fixture_dict[each_compute] = self.useFixture(
                ComputeNodeFixture(
                    connections=self.connections,
                    node_ip=each_compute,
                    username=self.inputs.username,
                    password=self.inputs.password))
            mode = self.compute_fixture_dict[
                each_compute].get_agent_headless_mode()
            if mode is False:
                self.compute_fixture_dict[
                    each_compute].set_agent_headless_mode()
        #
        # Get config for test from topology
        result = True
        msg = []
        if not topology_class_name:
            topology_class_name = test_headless_vrouter_topo.sdn_headless_vrouter_topo

        self.logger.info("Scenario for the test used is: %s" %
                         (topology_class_name))
        #
        # Create a list of compute node IP's and pass it to topo if you want to pin
        # a vm to a particular node
        topo_obj = topology_class_name(
            compute_node_list=self.inputs.compute_ips)
        #
        # Test setup: Configure policy, VN, & VM
        # return {'result':result, 'msg': err_msg, 'data': [self.topo, config_topo]}
        # Returned topo is of following format:
        # config_topo= {'policy': policy_fixt, 'vn': vn_fixture, 'vm': vm_fixture}
        topo = {}
        topo_objs = {}
        config_topo = {}
        setup_obj = self.useFixture(
            sdnTopoSetupFixture(self.connections, topo_obj))
        out = setup_obj.sdn_topo_setup()
        self.assertEqual(out['result'], True, out['msg'])
        if out['result']:
            topo_objs, config_topo, vm_fip_info = out['data']

        # Start Test
        proj = config_topo.keys()
        vms = config_topo[proj[0]]['vm'].keys()
        src_vm = config_topo[proj[0]]['vm'][vms[0]]
        dest_vm = config_topo[proj[0]]['vm'][vms[1]]
        flow_cache_timeout = 180

        # Setup Traffic.
        stream = Stream(protocol="ip", proto="icmp",
                        src=src_vm.vm_ip, dst=dest_vm.vm_ip)
        profile = ContinuousProfile(stream=stream, count=0, capfilter="icmp")

        tx_vm_node_ip = src_vm.vm_node_ip
        rx_vm_node_ip = dest_vm.vm_node_ip

        tx_local_host = Host(
            tx_vm_node_ip,
            self.inputs.username,
            self.inputs.password)
        rx_local_host = Host(
            rx_vm_node_ip,
            self.inputs.username,
            self.inputs.password)

        send_host = Host(
            src_vm.local_ip,
            src_vm.vm_username,
            src_vm.vm_password)
        recv_host = Host(
            dest_vm.local_ip,
            dest_vm.vm_username,
            dest_vm.vm_password)

        sender = Sender("icmp", profile, tx_local_host,
                        send_host, self.inputs.logger)
        receiver = Receiver("icmp", profile, rx_local_host,
                            recv_host, self.inputs.logger)

        receiver.start()
        sender.start()

        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)

        headless_vr_utils.stop_all_control_services(self)
        self.addCleanup(self.inputs.start_service, 'supervisor-control', self.inputs.bgp_ips)

        headless_vr_utils.check_through_tcpdump(self, dest_vm, src_vm)

        flow_index_list2 = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)

        if set(flow_index_list) == set(flow_index_list2):
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout)

        # verify_flow_is_not_recreated
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)

        if set(flow_index_list) == set(flow_index_list2):
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        receiver.stop()
        sender.stop()

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout + 5)

        # verify_flow_is_cleared
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)
        if not flow_index_list[0]:
            self.logger.info("No flows are present")
        else:
            self.logger.error("Flows are still present.")
            return False

        # start_ping
        receiver.start()
        sender.start()

        # verify_flow_is_recreated
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)
        if (flow_index_list[0] and flow_index_list[1]):
            self.logger.info("Flows are recreated.")
        else:
            self.logger.error("Flows are still absent.")
            return False

        headless_vr_utils.start_all_control_services(self)

        headless_vr_utils.check_through_tcpdump(self, dest_vm, src_vm)

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout + 5)

        flow_index_list2 = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)

        if set(flow_index_list) == set(flow_index_list2):
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        receiver.stop()
        sender.stop()

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout + 5)

        # verify_flow_is_cleared
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)
        if not flow_index_list[0]:
            self.logger.info("No flows are present")
        else:
            self.logger.error("Flows are still present.")
            return False

        # start_ping
        receiver.start()
        sender.start()

        # verify_flow_is_recreated
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)
        if (flow_index_list[0] and flow_index_list[1]):
            self.logger.info("Flows are recreated.")
        else:
            self.logger.error("Flows are still absent.")
            return False

        receiver.stop()
        sender.stop()

        return True
Пример #11
0
    def test_verify_flow_series_table(self):
        ''' Test to validate flow series table

        '''
        vn1_name = self.res.vn1_name
        vn1_subnets = self.res.vn1_fixture.get_cidrs(af='v4')
        vn2_name = self.res.vn2_name
        vn2_subnets = self.res.vn2_fixture.get_cidrs(af='v4')
        policy1_name = 'policy1'
        policy2_name = 'policy2'
        rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn1_name,
                'dest_network': vn2_name,
            },
        ]
        rev_rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn2_name,
                'dest_network': vn1_name,
            },
        ]
        policy1_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy1_name,
                rules_list=rules,
                inputs=self.inputs,
                connections=self.connections))
        policy2_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy2_name,
                rules_list=rev_rules,
                inputs=self.inputs,
                connections=self.connections))
        vn1_fixture = self.res.vn1_fixture
        vn1_fixture.bind_policies(
            [policy1_fixture.policy_fq_name], vn1_fixture.vn_id)
        self.addCleanup(
            vn1_fixture.unbind_policies, vn1_fixture.vn_id, [
                policy1_fixture.policy_fq_name])

        assert vn1_fixture.verify_on_setup()
        vn2_fixture = self.res.vn2_fixture
        vn2_fixture.bind_policies(
            [policy2_fixture.policy_fq_name], vn2_fixture.vn_id)
        assert vn2_fixture.verify_on_setup()
        self.addCleanup(
            vn2_fixture.unbind_policies, vn2_fixture.vn_id, [
                policy2_fixture.policy_fq_name])
#        self.res.verify_common_objects()
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn2_vm2_fixture.install_pkg("Traffic")
#        self.res.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip, self.inputs.host_data[
                self.tx_vm_node_ip]['username'], self.inputs.host_data[
                self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip, self.inputs.host_data[
                self.rx_vm_node_ip]['username'], self.inputs.host_data[
                self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.res.vn1_vm1_fixture.local_ip,
                              self.res.vn1_vm1_fixture.vm_username,
                              self.res.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.res.vn2_vm2_fixture.local_ip,
                              self.res.vn2_vm2_fixture.vm_username,
                              self.res.vn2_vm2_fixture.vm_password)
        # Create traffic stream
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        for i in range(10):
            count = 100
            dport = 9000
            count = count * (i + 1)
            dport = dport + i
            print 'count=%s' % (count)
            print 'dport=%s' % (dport)

            self.logger.info("Creating streams...")
            stream = Stream(
                protocol="ip",
                proto="udp",
                src=self.res.vn1_vm1_fixture.vm_ip,
                dst=self.res.vn2_vm2_fixture.vm_ip,
                dport=dport)

            profile = StandardProfile(
                stream=stream,
                size=100,
                count=count,
                listener=self.res.vn2_vm2_fixture.vm_ip)
            sender = Sender(
                "sendudp",
                profile,
                self.tx_local_host,
                self.send_host,
                self.inputs.logger)
            receiver = Receiver(
                "recvudp",
                profile,
                self.rx_local_host,
                self.recv_host,
                self.inputs.logger)
            receiver.start()
            sender.start()
            sender.stop()
            receiver.stop()
            print sender.sent, receiver.recv
            time.sleep(1)
        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res.vn1_vm1_fixture.orch.get_host_of_vm(
                self.res.vn1_vm1_fixture.vm_obj)]['host_ip']
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name']
        time.sleep(300)
        # Verifying flow series table
        src_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        dst_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn2_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = '(' + 'sourcevn=' + src_vn + ') AND (destvn=' + dst_vn + ')'
        for ip in self.inputs.collector_ips:
            self.logger.info('setup_time= %s' % (start_time))
            # Quering flow sreies table
            self.logger.info(
                "Verifying flowSeriesTable through opserver %s" %
                (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowSeriesTable',
                start_time=start_time,
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'sum(packets)',
                    'sport',
                    'dport',
                    'T=1'],
                where_clause=query,
                sort=2,
                limit=5,
                sort_fields=['sum(packets)'])
            assert self.res1
Пример #12
0
class BaseResource(fixtures.Fixture):
   
    __metaclass__ = Singleton
     
    def setUp(self,inputs,connections):
        super(BaseResource , self).setUp()
        self.inputs = inputs
        self.connections = connections
        self.setup_common_objects(self.inputs , self.connections)

    def cleanUp(self):
        super(BaseResource, self).cleanUp() 

    def setup_common_objects(self, inputs , connections):
  
    	self.inputs = inputs

        #self.inputs.set_af('dual')
        self.connections = connections
        self.logger = self.inputs.logger
        #(self.vn1_name, self.vn1_subnets)= ("vn1", ["192.168.1.0/24"])
        #(self.vn2_name, self.vn2_subnets)= ("vn2", ["192.168.2.0/24"])
        #(self.fip_vn_name, self.fip_vn_subnets)= ("fip_vn", ['100.1.1.0/24'])
        (self.vn1_name, self.vn2_name, self.fip_vn_name)= ("vn1", "vn2", "fip_vn")
        (self.vn1_vm1_name, self.vn1_vm2_name)=( 'vn1_vm1', 'vn1_vm2')
        self.vn2_vm1_name= 'vn2_vm1'
        self.vn2_vm2_name= 'vn2_vm2'
        self.fvn_vm1_name= 'fvn_vm1'

        # Configure 3 VNs, one of them being Floating-VN
        self.vn1_fixture=self.useFixture( VNFixture(project_name= self.inputs.project_name,
                            connections= self.connections, inputs= self.inputs,
                            vn_name= self.vn1_name))

        self.vn2_fixture=self.useFixture( VNFixture(project_name= self.inputs.project_name,
                            connections= self.connections, inputs= self.inputs,
                            vn_name= self.vn2_name))

        self.fvn_fixture=self.useFixture( VNFixture(project_name= self.inputs.project_name,
                            connections= self.connections, inputs= self.inputs,
                            vn_name= self.fip_vn_name))

        # 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]
        # Configure 6 VMs in VN1, 1 VM in VN2, and 1 VM in FVN
        self.vn1_vm1_fixture=self.useFixture(VMFixture(project_name= self.inputs.project_name,
                                connections= self.connections, vn_obj= self.vn1_fixture.obj,
                                vm_name= self.vn1_vm1_name,image_name='ubuntu-traffic',
				flavor='contrail_flavor_medium', node_name=compute_1))

        self.vn1_vm2_fixture=self.useFixture(VMFixture(project_name= self.inputs.project_name,
                                connections= self.connections, vn_obj= self.vn1_fixture.obj,
                                vm_name= self.vn1_vm2_name , image_name='ubuntu-traffic',
				flavor='contrail_flavor_medium'))

        self.vn2_vm2_fixture=self.useFixture(VMFixture(project_name= self.inputs.project_name,
                            connections= self.connections, vn_obj= self.vn2_fixture.obj,
                            vm_name= self.vn2_vm2_name, image_name='ubuntu-traffic', flavor='contrail_flavor_medium',
                            node_name=compute_2))
#
        self.fvn_vm1_fixture=self.useFixture(VMFixture(project_name= self.inputs.project_name,
                                connections= self.connections, vn_obj= self.fvn_fixture.obj,
                                vm_name= self.fvn_vm1_name))

        self.multi_intf_vm_fixture = self.useFixture(VMFixture(connections=self.connections,
                                     vn_objs=[self.vn1_fixture.obj , self.vn2_fixture.obj],
                                     vm_name='mltf_vm',
                                     project_name=self.inputs.project_name))
    
        self.verify_common_objects()
    #end setup_common_objects

    def verify_common_objects(self):
        assert self.vn1_fixture.verify_on_setup()
        assert self.vn2_fixture.verify_on_setup()
        assert self.fvn_fixture.verify_on_setup()
        assert self.vn1_vm1_fixture.verify_on_setup()
        assert self.vn1_vm2_fixture.verify_on_setup()
        assert self.fvn_vm1_fixture.verify_on_setup()
        assert self.vn2_vm2_fixture.verify_on_setup()
        assert self.multi_intf_vm_fixture.verify_on_setup()
    #end verify_common_objects

    def start_traffic(self):
        # installing traffic package in vm
        self.vn1_vm1_fixture.install_pkg("Traffic")
        self.vn2_vm2_fixture.install_pkg("Traffic")
        self.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
                            self.tx_vm_node_ip, self.inputs.host_data[
                            self.tx_vm_node_ip]['username'], self.inputs.host_data[
                            self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
                            self.rx_vm_node_ip, self.inputs.host_data[
                            self.rx_vm_node_ip]['username'], self.inputs.host_data[
                            self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.vn1_vm1_fixture.local_ip,
                            self.vn1_vm1_fixture.vm_username,
                            self.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.vn2_vm2_fixture.local_ip,
                            self.vn2_vm2_fixture.vm_username,
                            self.vn2_vm2_fixture.vm_password)
        # Create traffic stream
        self.logger.info("Creating streams...")
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.vn1_vm1_fixture.vm_ip,
            dst=self.vn2_vm2_fixture.vm_ip,
            dport=9000)

        profile = StandardProfile(
            stream=stream,
            size=100,
            count=10,
            listener=self.vn2_vm2_fixture.vm_ip)
        self.sender = Sender(
            "sendudp",
            profile,
            self.tx_local_host,
            self.send_host,
            self.inputs.logger)
        self.receiver = Receiver(
            "recvudp",
            profile,
            self.rx_local_host,
            self.recv_host,
            self.inputs.logger)
        self.receiver.start()
        self.sender.start()
        time.sleep(10)

    def stop_traffic(self):
        self.sender.stop()
        self.receiver.stop()
        self.logger.info("Sent traffic: %s"%(self.sender.sent))
        self.logger.info("Received traffic: %s"%(self.receiver.recv))
Пример #13
0
    def test_verify_flow_tables(self):
        '''
          Description:  Test to validate flow tables

            1.Creat 2 vn and 1 vm in each vn
            2.Create policy between vns
            3.send 100 udp packets from vn1 to vn2
            4.Verify in vrouter uve that active flow matches with the agent introspect - fails otherwise
            5.Query flowrecord table for the flow and verify packet count mtches 100 - fails otherwise
            6.Query flow series table or the flow and verify packet count mtches 100 - fails otherwise

         Maintainer: [email protected]
        '''
        vn1_name = self.res.vn1_name
        vn1_fq_name = '%s:%s:%s' % (
            self.inputs.project_fq_name[0], self.inputs.project_fq_name[1], self.res.vn1_name)
        vn1_subnets = self.res.vn1_fixture.get_cidrs(af='v4')
        vn2_name = self.res.vn2_name
        vn2_fq_name = '%s:%s:%s' % (
            self.inputs.project_fq_name[0], self.inputs.project_fq_name[1], self.res.vn2_name)
        vn2_subnets = self.res.vn2_fixture.get_cidrs(af='v4')
        policy1_name = 'policy1'
        policy2_name = 'policy2'
        result = True
        rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn1_name,
                'dest_network': vn2_name,
            },
        ]
        rev_rules = [
            {
                'direction': '<>', 'simple_action': 'pass',
                'protocol': 'udp',
                'source_network': vn2_name,
                'dest_network': vn1_name,
            },
        ]
        policy1_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy1_name,
                rules_list=rules,
                inputs=self.inputs,
                connections=self.connections))
        policy2_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy2_name,
                rules_list=rev_rules,
                inputs=self.inputs,
                connections=self.connections))
        vn1_fixture = self.res.vn1_fixture
        vn1_fixture.bind_policies(
            [policy1_fixture.policy_fq_name], vn1_fixture.vn_id)
        self.addCleanup(
            vn1_fixture.unbind_policies, vn1_fixture.vn_id, [
                policy1_fixture.policy_fq_name])

        assert vn1_fixture.verify_on_setup()
        vn2_fixture = self.res.vn2_fixture
        vn2_fixture.bind_policies(
            [policy2_fixture.policy_fq_name], vn2_fixture.vn_id)
        assert vn2_fixture.verify_on_setup()
        self.addCleanup(
            vn2_fixture.unbind_policies, vn2_fixture.vn_id, [
                policy2_fixture.policy_fq_name])
#        self.res.verify_common_objects()
        # start_time=self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.verify_on_setup()
        self.res.vn2_vm2_fixture.verify_on_setup()
        self.res.fvn_vm1_fixture.verify_on_setup()
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn2_vm2_fixture.install_pkg("Traffic")
        self.res.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip, self.inputs.host_data[
                self.tx_vm_node_ip]['username'], self.inputs.host_data[
                self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip, self.inputs.host_data[
                self.rx_vm_node_ip]['username'], self.inputs.host_data[
                self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.res.vn1_vm1_fixture.local_ip,
                              self.res.vn1_vm1_fixture.vm_username,
                              self.res.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.res.vn2_vm2_fixture.local_ip,
                              self.res.vn2_vm2_fixture.vm_username,
                              self.res.vn2_vm2_fixture.vm_password)
        pkts_before_traffic = self.analytics_obj.get_inter_vn_stats(
            self.inputs.collector_ips[0],
            src_vn=vn1_fq_name,
            other_vn=vn2_fq_name,
            direction='in')
        if not pkts_before_traffic:
            pkts_before_traffic = 0

        self.res.vn1_vm1_fixture.wait_till_vm_is_up()
        self.res.vn1_vm2_fixture.wait_till_vm_is_up()
        # Create traffic stream
        self.logger.info("Creating streams...")
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.res.vn1_vm1_fixture.vm_ip,
            dst=self.res.vn2_vm2_fixture.vm_ip,
            dport=9000)

        profile = StandardProfile(
            stream=stream,
            size=100,
            count=10,
            listener=self.res.vn2_vm2_fixture.vm_ip)
        sender = Sender(
            "sendudp",
            profile,
            self.tx_local_host,
            self.send_host,
            self.inputs.logger)
        receiver = Receiver(
            "recvudp",
            profile,
            self.rx_local_host,
            self.recv_host,
            self.inputs.logger)
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        receiver.start()
        sender.start()
        time.sleep(10)
        # Poll to make usre traffic flows, optional
        # sender.poll()
        # receiver.poll()
        sender.stop()
        receiver.stop()
        print sender.sent, receiver.recv
        for vn in [self.res.vn1_fixture.vn_fq_name,\
                    self.res.vn2_fixture.vn_fq_name]:
                 
            #ACL count        
            if not (int(self.analytics_obj.get_acl\
                    (self.inputs.collector_ips[0],vn)) > 0):
                    self.logger.error("Acl counts not received from Agent uve \
                                in %s vn uve"%(vn))
                    result = result and False

            if not (int(self.analytics_obj.get_acl\
                    (self.inputs.collector_ips[0], vn, tier = 'Config')) > 0):
                    self.logger.error("Acl counts not received from Config uve \
                                in %s vn uve"%(vn))
                    result = result and False

            #Bandwidth usage        
            if not (int(self.analytics_obj.get_bandwidth_usage\
                    (self.inputs.collector_ips[0], vn, direction = 'out')) > 0):
                    self.logger.error("Bandwidth not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

            if not (int(self.analytics_obj.get_bandwidth_usage\
                    (self.inputs.collector_ips[0], vn, direction = 'in')) > 0):
                    self.logger.error("Bandwidth not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

            #Flow count
            if not (int(self.analytics_obj.get_flow\
                    (self.inputs.collector_ips[0], vn, direction = 'egress')) > 0):
                    self.logger.error("egress flow  not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

            if not (int(self.analytics_obj.get_flow\
                    (self.inputs.collector_ips[0], vn, direction = 'ingress')) > 0):
                    self.logger.error("ingress flow  not shown  \
                                in %s vn uve"%(vn))
                    result = result and False
                   
            #VN stats
            vns = [self.res.vn1_fixture.vn_fq_name,\
                    self.res.vn2_fixture.vn_fq_name]
            vns.remove(vn)
            other_vn = vns[0]        
            if not (self.analytics_obj.get_vn_stats\
                    (self.inputs.collector_ips[0], vn, other_vn)):
                    self.logger.error("vn_stats   not shown  \
                                in %s vn uve"%(vn))
                    result = result and False

        assert "sender.sent == receiver.recv", "UDP traffic to ip:%s failed" % self.res.vn2_vm2_fixture.vm_ip
        # Verifying the vrouter uve for the active flow
        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res.vn1_vm1_fixture.orch.get_host_of_vm(
                self.res.vn1_vm1_fixture.vm_obj)]['host_ip']
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name']
        self.logger.info(
            "Waiting for the %s vrouter uve to be updated with active flows" %
            (vm_host))
        time.sleep(60)
        self.flow_record = self.analytics_obj.get_flows_vrouter_uve(
            vrouter=vm_host)
        self.logger.info(
            "Active flow in vrouter uve = %s" %
            (self.flow_record))
        if (self.flow_record > 0):
            self.logger.info("Flow records  updated")
            result = result and True
        else:
            self.logger.warn("Flow records NOT updated")
            result = result and False

#        assert ( self.flow_record > 0)
#        self.logger.info("Waiting for inter-vn stats to be updated...")
#        time.sleep(60)
        pkts_after_traffic = self.analytics_obj.get_inter_vn_stats(
            self.inputs.collector_ips[0],
            src_vn=vn1_fq_name,
            other_vn=vn2_fq_name,
            direction='in')
        if not pkts_after_traffic:
            pkts_after_traffic = 0
        self.logger.info("Verifying that the inter-vn stats updated")
        self.logger.info(
            "Inter vn stats before traffic %s" %
            (pkts_before_traffic))
        self.logger.info(
            "Inter vn stats after traffic %s" %
            (pkts_after_traffic))
        if ((pkts_after_traffic - pkts_before_traffic) >= 10):
            self.logger.info("Inter vn stats updated")
            result = result and True
        else:
            self.logger.warn("Inter vn stats NOT updated")
            result = result and False

        self.logger.info("Waiting for flow records to be expired...")
        time.sleep(224)
        self.flow_record = self.analytics_obj.get_flows_vrouter_uve(
            vrouter=vm_host)
#        if ( self.flow_record > 0):
#            self.logger.info("Flow records  updated")
#            result = result and True
#        else:
#            self.logger.warn("Flow records NOT updated")
#            result = result and False
        self.logger.debug(
            "Active flow in vrouter uve = %s" %
            (self.flow_record))
#        assert ( self.flow_record == 0)
        # Verifying flow series table
        src_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        dst_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn2_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = '(' + 'sourcevn=' + src_vn + ') AND (destvn=' + dst_vn + ')'
        for ip in self.inputs.collector_ips:
            self.logger.info(
                "Verifying flowRecordTable through opserver %s.." %
                (ip))
            self.res2 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowRecordTable',
                start_time=start_time,
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'setup_time',
                    'teardown_time',
                    'agg-packets'],
                where_clause=query)

            self.logger.info("Query output: %s" % (self.res2))
            assert self.res2
            if self.res2:
                r = self.res2[0]
                s_time = r['setup_time']
                e_time = r['teardown_time']
                agg_pkts = r['agg-packets']
                assert (agg_pkts == sender.sent)
            self.logger.info(
                'setup_time= %s,teardown_time= %s' %
                (s_time, e_time))
            self.logger.info("Records=\n%s" % (self.res2))
            # Quering flow sreies table
            self.logger.info(
                "Verifying flowSeriesTable through opserver %s" %
                (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowSeriesTable',
                start_time=str(s_time),
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'sum(packets)'],
                where_clause=query)
            self.logger.info("Query output: %s" % (self.res1))
            assert self.res1
            if self.res1:
                r1 = self.res1[0]
                sum_pkts = r1['sum(packets)']
                assert (sum_pkts == sender.sent)
            self.logger.info("Flow series Records=\n%s" % (self.res1))
            assert (sum_pkts == agg_pkts)

        assert result
        return True
Пример #14
0
    def test_verify_flow_series_table_query_range(self):
        ''' Test to validate flow series table for query range

        '''
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn1_vm2_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn1_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip, self.inputs.host_data[
                self.tx_vm_node_ip]['username'], self.inputs.host_data[
                self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip, self.inputs.host_data[
                self.rx_vm_node_ip]['username'], self.inputs.host_data[
                self.rx_vm_node_ip]['password'])

        self.send_host = Host(self.res.vn1_vm1_fixture.local_ip,
                              self.res.vn1_vm1_fixture.vm_username,
                              self.res.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.res.vn1_vm2_fixture.local_ip,
                              self.res.vn1_vm2_fixture.vm_username,
                              self.res.vn1_vm2_fixture.vm_password)

        # Create traffic stream
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        self.logger.info("Creating streams...")
        dport = 11000
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.res.vn1_vm1_fixture.vm_ip,
            dst=self.res.vn1_vm2_fixture.vm_ip,
            dport=dport)

        startport = 10000
        profile = ContinuousSportRange(
            stream=stream,
            listener=self.res.vn1_vm2_fixture.vm_ip,
            startport=10000,
            endport=dport,
            pps=100)
        sender = Sender(
            'sname',
            profile,
            self.tx_local_host,
            self.send_host,
            self.inputs.logger)
        receiver = Receiver(
            'rname',
            profile,
            self.rx_local_host,
            self.recv_host,
            self.inputs.logger)
        receiver.start()
        sender.start()
        time.sleep(30)
        sender.stop()
        receiver.stop()
        print sender.sent, receiver.recv
        time.sleep(1)

        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res. vn1_vm1_fixture.orch.get_host_of_vm(
                self.res.vn1_vm1_fixture.vm_obj)]['host_ip']
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name']
        time.sleep(30)
        # Verifying flow series table
        src_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        dst_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = '(sourcevn=%s) AND (destvn=%s) AND protocol= 17 AND (sport = 10500 < 11000)' % (
            src_vn, dst_vn)
        for ip in self.inputs.collector_ips:
            self.logger.info('setup_time= %s' % (start_time))
            # Quering flow sreies table

            self.logger.info(
                "Verifying flowSeriesTable through opserver %s" %
                (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowSeriesTable',
                start_time=start_time,
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'sum(packets)',
                    'sport',
                    'dport',
                    'T=1'],
                where_clause=query)
            assert self.res1
            for elem in self.res1:
                if ((elem['sport'] < 10500) or (elem['sport'] > 11000)):
                    self.logger.warn(
                        "Out of range element (range:sport > 15500 and sport < 16000):%s" %
                        (elem))
                    self.logger.warn("Test Failed")
                    result = False
                    assert result
        return True
Пример #15
0
class BaseResource(with_metaclass(Singleton, BaseSanityResource)):
    def setUp(self, inputs, connections):
        super(BaseResource, self).setUp(inputs, connections)
        self.setup_common_objects(self.inputs, self.connections)

    def cleanUp(self):
        super(BaseResource, self).cleanUp()

    def setup_common_objects(self, inputs, connections):
        (self.vn2_name, self.fip_vn_name) = (get_random_name("vn2"),
                                             get_random_name("fip_vn"))
        self.vn2_vm2_name = get_random_name('vn2_vm2')
        self.fvn_vm1_name = get_random_name('fvn_vm1')

        self.vn2_fixture = self.useFixture(
            VNFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      inputs=self.inputs,
                      vn_name=self.vn2_name))

        self.fvn_fixture = self.useFixture(
            VNFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      inputs=self.inputs,
                      vn_name=self.fip_vn_name))

        # Making sure VM falls on diffrent compute host
        self.orch = self.connections.orch
        host_list = self.orch.get_hosts()
        compute_2 = host_list[0]
        if len(host_list) > 1:
            compute_2 = host_list[1]

        self.vn2_vm2_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=self.vn2_fixture.obj,
                      vm_name=self.vn2_vm2_name,
                      image_name='ubuntu-traffic',
                      node_name=compute_2))
        self.fvn_vm1_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=self.fvn_fixture.obj,
                      vm_name=self.fvn_vm1_name))
        self.multi_intf_vm_fixture = self.useFixture(
            VMFixture(connections=self.connections,
                      vn_objs=[self.vn1_fixture.obj, self.vn2_fixture.obj],
                      vm_name='mltf_vm',
                      project_name=self.inputs.project_name))

        self.verify_common_objects()

    #end setup_common_objects

    def verify_common_objects(self):
        super(BaseResource, self).verify_sanity_common_objects()
        assert self.vn2_fixture.verify_on_setup()
        assert self.fvn_fixture.verify_on_setup()
        assert self.fvn_vm1_fixture.wait_till_vm_is_up()
        assert self.vn2_vm2_fixture.wait_till_vm_is_up()
        assert self.multi_intf_vm_fixture.wait_till_vm_is_up()

    #end verify_common_objects

    def start_traffic(self):
        # installing traffic package in vm
        self.vn1_vm1_fixture.install_pkg("Traffic")
        self.vn2_vm2_fixture.install_pkg("Traffic")
        self.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip,
            self.inputs.host_data[self.tx_vm_node_ip]['username'],
            self.inputs.host_data[self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip,
            self.inputs.host_data[self.rx_vm_node_ip]['username'],
            self.inputs.host_data[self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.vn1_vm1_fixture.local_ip,
                              self.vn1_vm1_fixture.vm_username,
                              self.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.vn2_vm2_fixture.local_ip,
                              self.vn2_vm2_fixture.vm_username,
                              self.vn2_vm2_fixture.vm_password)
        # Create traffic stream
        self.logger.info("Creating streams...")
        stream = Stream(protocol="ip",
                        proto="udp",
                        src=self.vn1_vm1_fixture.vm_ip,
                        dst=self.vn2_vm2_fixture.vm_ip,
                        dport=9000)

        profile = StandardProfile(stream=stream,
                                  size=100,
                                  count=10,
                                  listener=self.vn2_vm2_fixture.vm_ip)
        self.sender = Sender("sendudp", profile, self.tx_local_host,
                             self.send_host, self.inputs.logger)
        self.receiver = Receiver("recvudp", profile, self.rx_local_host,
                                 self.recv_host, self.inputs.logger)
        self.receiver.start()
        self.sender.start()
        time.sleep(10)

    def stop_traffic(self):
        self.sender.stop()
        self.receiver.stop()
        self.logger.info("Sent traffic: %s" % (self.sender.sent))
        self.logger.info("Received traffic: %s" % (self.receiver.recv))
Пример #16
0
 def test_agent_crash_dns_malformed_received(self):
     '''Verify that Agent do not crash on sending a malformed DNS packet.
        This Test case specifically test following Bug
        Bug Id 1566067 : "Agent crash at BindUtil::DnsClass"
        Steps:
         1. Create a VN with IPAM having Virtual DNS configured.
         2. Create a VM and send a DNS query from VM to DNS server. DNS server should 
            have the Qclass field as any value other than "01"
         3. Verify that no crash happens when this malformed DNS packet reaches the server
     Pass criteria: Vrouter agent should not crash on receiving a malformed DNS packet
     Maintainer: [email protected]'''
     vm_list = ['vm1', 'vm2']
     vn_name = 'vn1'
     vn_nets = {'vn1' : '10.10.10.0/24'}
     dns_server_name = 'vdns1'
     domain_name = 'juniper.net'
     ttl = 100
     ipam_name = 'ipam1'
     dns_data = VirtualDnsType(
         domain_name=domain_name, dynamic_records_from_client=True,
         default_ttl_seconds=ttl, record_order='random', reverse_resolution=True)
     vdns_fixt1 = self.useFixture(VdnsFixture(self.inputs, self.connections, 
         vdns_name=dns_server_name, dns_data=dns_data))
     result, msg = vdns_fixt1.verify_on_setup()
     self.assertTrue(result, msg)
     dns_server = IpamDnsAddressType(
         virtual_dns_server_name=vdns_fixt1.vdns_fq_name)
     ipam_mgmt_obj = IpamType(
         ipam_dns_method='virtual-dns-server', ipam_dns_server=dns_server)
     # Associate IPAM with  VDNS server Object
     ipam_fixt1 = self.useFixture(IPAMFixture(ipam_name, vdns_obj=vdns_fixt1.obj, 
             connections=self.connections, ipamtype=ipam_mgmt_obj))
     # Launch  VM with VN Created above.
     vn_fixt = self.useFixture(VNFixture(self.connections, self.inputs, vn_name=vn_name,
                  subnets=[vn_nets['vn1']], ipam_fq_name=ipam_fixt1.fq_name, option='contrail'))
     vm_fixture1 = self.useFixture(VMFixture(project_name=self.inputs.project_name, 
                 connections=self.connections, vn_obj=vn_fixt.obj, vm_name=vm_list[0],
                 image_name = "ubuntu-traffic"))
     assert vm_fixture1.verify_vm_launched()
     assert vm_fixture1.verify_on_setup()
     assert vm_fixture1.wait_till_vm_is_up()
     # DNS payload with 1 query and qclass as "04" instead of "01"
     filters = '\'(src host %s and dst host %s and port 1234)\'' \
                 % (vm_fixture1.vm_ip,vn_fixt.get_dns_ip(ipam_fq_name = ipam_fixt1.fq_name))
     session, pcap = start_tcpdump_for_vm_intf(self, vm_fixture1, vn_fixt.vn_fq_name, filters = filters)
     dnsPayload = '\x12\x34\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04'
     streamObj = Stream(protocol="ip", sport=1234, dport=53, proto='udp', src=vm_fixture1.vm_ip,
             dst=vn_fixt.get_dns_ip(ipam_fq_name =ipam_fixt1.fq_name))
     profile_kwargs = {'stream': streamObj, 'count' : 10, 'payload': dnsPayload}
     profileObj = StandardProfile(**profile_kwargs)
     tx_vm_node_ip = vm_fixture1.vm_node_ip
     send_node = Host(
             tx_vm_node_ip,
             self.inputs.host_data[tx_vm_node_ip]['username'],
             self.inputs.host_data[tx_vm_node_ip]['password'])
     send_host = Host(vm_fixture1.local_ip,
                          vm_fixture1.vm_username, vm_fixture1.vm_password)
     sender = Sender("senddns", profileObj, send_node, send_host, self.inputs.logger)
     sender.start()
     sleep(1)
     sender.poll()
     if not sender.sent:
         self.logger.error("Failed to Transmit packet")
         assert False, "Failed to Transmit packet"
     sender.stop()
     sleep(2)
     stop_tcpdump_for_vm_intf(self, session, pcap)
     sleep(2)
     # grep in pcap file with source port (1234) 
     assert verify_tcpdump_count(self, session, pcap, grep_string="1234", exp_count=10)
Пример #17
0
class BaseResource(fixtures.Fixture):

    __metaclass__ = Singleton

    def setUp(self, inputs, connections):
        super(BaseResource, self).setUp()
        self.inputs = inputs
        self.connections = connections
        self.setup_common_objects(self.inputs, self.connections)

    def cleanUp(self):
        super(BaseResource, self).cleanUp()

    def setup_common_objects(self, inputs, connections):

        self.inputs = inputs

        #self.inputs.set_af('dual')
        self.connections = connections
        self.orch = self.connections.orch
        self.logger = self.inputs.logger
        #(self.vn1_name, self.vn1_subnets)= ("vn1", ["192.168.1.0/24"])
        #(self.vn2_name, self.vn2_subnets)= ("vn2", ["192.168.2.0/24"])
        #(self.fip_vn_name, self.fip_vn_subnets)= ("fip_vn", ['100.1.1.0/24'])
        (self.vn1_name, self.vn2_name, self.fip_vn_name)= (get_random_name("vn1"), \
      get_random_name("vn2"),get_random_name("fip_vn"))
        (self.vn1_vm1_name, self.vn1_vm2_name) = (get_random_name('vn1_vm1'),
                                                  get_random_name('vn1_vm2'))
        self.vn2_vm1_name = get_random_name('vn2_vm1')
        self.vn2_vm2_name = get_random_name('vn2_vm2')
        self.fvn_vm1_name = get_random_name('fvn_vm1')

        # Configure 3 VNs, one of them being Floating-VN
        self.vn1_fixture = self.useFixture(
            VNFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      inputs=self.inputs,
                      vn_name=self.vn1_name))

        self.vn2_fixture = self.useFixture(
            VNFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      inputs=self.inputs,
                      vn_name=self.vn2_name))

        self.fvn_fixture = self.useFixture(
            VNFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      inputs=self.inputs,
                      vn_name=self.fip_vn_name))

        # Making sure VM falls on diffrent compute host
        host_list = self.orch.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]
    # Configure 6 VMs in VN1, 1 VM in VN2, and 1 VM in FVN
        self.vn1_vm1_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=self.vn1_fixture.obj,
                      vm_name=self.vn1_vm1_name,
                      image_name='ubuntu-traffic',
                      flavor='contrail_flavor_medium',
                      node_name=compute_1))

        self.vn1_vm2_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=self.vn1_fixture.obj,
                      vm_name=self.vn1_vm2_name,
                      image_name='ubuntu-traffic',
                      flavor='contrail_flavor_medium'))

        self.vn2_vm2_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=self.vn2_fixture.obj,
                      vm_name=self.vn2_vm2_name,
                      image_name='ubuntu-traffic',
                      flavor='contrail_flavor_medium',
                      node_name=compute_2))
        #
        self.fvn_vm1_fixture = self.useFixture(
            VMFixture(project_name=self.inputs.project_name,
                      connections=self.connections,
                      vn_obj=self.fvn_fixture.obj,
                      vm_name=self.fvn_vm1_name))

        self.multi_intf_vm_fixture = self.useFixture(
            VMFixture(connections=self.connections,
                      vn_objs=[self.vn1_fixture.obj, self.vn2_fixture.obj],
                      vm_name='mltf_vm',
                      project_name=self.inputs.project_name))

        self.verify_common_objects()

    #end setup_common_objects

    def verify_common_objects(self):
        assert self.vn1_fixture.verify_on_setup()
        assert self.vn2_fixture.verify_on_setup()
        assert self.fvn_fixture.verify_on_setup()
        assert self.vn1_vm1_fixture.verify_on_setup()
        assert self.vn1_vm2_fixture.verify_on_setup()
        assert self.fvn_vm1_fixture.verify_on_setup()
        assert self.vn2_vm2_fixture.verify_on_setup()
        assert self.multi_intf_vm_fixture.verify_on_setup()

    #end verify_common_objects

    def start_traffic(self):
        # installing traffic package in vm
        self.vn1_vm1_fixture.install_pkg("Traffic")
        self.vn2_vm2_fixture.install_pkg("Traffic")
        self.fvn_vm1_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.vn2_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip,
            self.inputs.host_data[self.tx_vm_node_ip]['username'],
            self.inputs.host_data[self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip,
            self.inputs.host_data[self.rx_vm_node_ip]['username'],
            self.inputs.host_data[self.rx_vm_node_ip]['password'])
        self.send_host = Host(self.vn1_vm1_fixture.local_ip,
                              self.vn1_vm1_fixture.vm_username,
                              self.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.vn2_vm2_fixture.local_ip,
                              self.vn2_vm2_fixture.vm_username,
                              self.vn2_vm2_fixture.vm_password)
        # Create traffic stream
        self.logger.info("Creating streams...")
        stream = Stream(protocol="ip",
                        proto="udp",
                        src=self.vn1_vm1_fixture.vm_ip,
                        dst=self.vn2_vm2_fixture.vm_ip,
                        dport=9000)

        profile = StandardProfile(stream=stream,
                                  size=100,
                                  count=10,
                                  listener=self.vn2_vm2_fixture.vm_ip)
        self.sender = Sender("sendudp", profile, self.tx_local_host,
                             self.send_host, self.inputs.logger)
        self.receiver = Receiver("recvudp", profile, self.rx_local_host,
                                 self.recv_host, self.inputs.logger)
        self.receiver.start()
        self.sender.start()
        time.sleep(10)

    def stop_traffic(self):
        self.sender.stop()
        self.receiver.stop()
        self.logger.info("Sent traffic: %s" % (self.sender.sent))
        self.logger.info("Received traffic: %s" % (self.receiver.recv))
    def test_config_add_change_while_control_nodes_go_down(self):
        """Tests related to configuration add, change, and delete while switching from normal mode
           to headless and back i.e. control nodes go down and come online."""

        if len(self.inputs.compute_ips) < 2:
            raise unittest.SkipTest("This test needs atleast 2 compute nodes.")
        else:
            self.logger.info("Required resources are in place to run the test.")

        result = True
        topology_class_name = None

        self.compute_fixture_dict = {}
        for each_compute in self.inputs.compute_ips:
            self.compute_fixture_dict[each_compute] = self.useFixture(
                ComputeNodeFixture(
                    connections=self.connections,
                    node_ip=each_compute,
                    username=self.inputs.username,
                    password=self.inputs.password))
            mode = self.compute_fixture_dict[
                each_compute].get_agent_headless_mode()
            if mode is False:
                self.compute_fixture_dict[
                    each_compute].set_agent_headless_mode()
        #
        # Get config for test from topology
        result = True
        msg = []
        if not topology_class_name:
            topology_class_name = test_headless_vrouter_topo.sdn_headless_vrouter_topo

        self.logger.info("Scenario for the test used is: %s" %
                         (topology_class_name))
        #
        # Create a list of compute node IP's and pass it to topo if you want to pin
        # a vm to a particular node
        topo_obj = topology_class_name(
            compute_node_list=self.inputs.compute_ips)
        #
        # Test setup: Configure policy, VN, & VM
        # return {'result':result, 'msg': err_msg, 'data': [self.topo, config_topo]}
        # Returned topo is of following format:
        # config_topo= {'policy': policy_fixt, 'vn': vn_fixture, 'vm': vm_fixture}
        topo = {}
        topo_objs = {}
        config_topo = {}
        setup_obj = self.useFixture(
            sdnTopoSetupFixture(self.connections, topo_obj))
        out = setup_obj.sdn_topo_setup()
        self.assertEqual(out['result'], True, out['msg'])
        if out['result']:
            topo_objs, config_topo, vm_fip_info = out['data']

        # Start Test
        proj = config_topo.keys()
        vms = config_topo[proj[0]]['vm'].keys()
        src_vm = config_topo[proj[0]]['vm'][vms[0]]
        dest_vm = config_topo[proj[0]]['vm'][vms[1]]
        flow_cache_timeout = 180

        # Setup Traffic.
        stream = Stream(protocol="ip", proto="icmp",
                        src=src_vm.vm_ip, dst=dest_vm.vm_ip)
        profile = ContinuousProfile(stream=stream, count=0, capfilter="icmp")

        tx_vm_node_ip = src_vm.vm_node_ip
        rx_vm_node_ip = dest_vm.vm_node_ip

        tx_local_host = Host(
            tx_vm_node_ip,
            self.inputs.username,
            self.inputs.password)
        rx_local_host = Host(
            rx_vm_node_ip,
            self.inputs.username,
            self.inputs.password)

        send_host = Host(
            src_vm.local_ip,
            src_vm.vm_username,
            src_vm.vm_password)
        recv_host = Host(
            dest_vm.local_ip,
            dest_vm.vm_username,
            dest_vm.vm_password)

        sender = Sender("icmp", profile, tx_local_host,
                        send_host, self.inputs.logger)
        receiver = Receiver("icmp", profile, rx_local_host,
                            recv_host, self.inputs.logger)

        receiver.start()
        sender.start()

        #self.start_ping(src_vm, dest_vm)

        flow_index_list = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)

        headless_vr_utils.stop_all_control_services(self)
        self.addCleanup(self.inputs.start_service, 'supervisor-control', self.inputs.bgp_ips)
        time.sleep(10)
        headless_vr_utils.check_through_tcpdump(self, dest_vm, src_vm)

        flow_index_list2 = headless_vr_utils.get_flow_index_list(
            self,
            src_vm,
            dest_vm)

        if set(flow_index_list) == set(flow_index_list2):
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        receiver.stop()
        sender.stop()
        project1_instance = config_topo['project1']['project']['project1']
        project1_instance.get_project_connections()
        vnet2_instance = config_topo['project1']['vn']['vnet2']

        # add VM to existing VN
        VM22_fixture = self.useFixture(
            VMFixture(
                connections=project1_instance.project_connections,
                vn_obj=vnet2_instance.obj,
                vm_name='VM22',
                project_name=project1_instance.project_name))

        # create new IPAM
        ipam3_obj = self.useFixture(
            IPAMFixture(
                project_obj=project1_instance,
                name='ipam3'))
        ipam4_obj = self.useFixture(
            IPAMFixture(
                project_obj=project1_instance,
                name='ipam4'))

        # create new VN
        VN3_fixture = self.useFixture(
            VNFixture(
                project_name=project1_instance.project_name,
                connections=project1_instance.project_connections,
                vn_name='VN3',
                inputs=project1_instance.inputs,
                subnets=['10.3.1.0/24'],
                ipam_fq_name=ipam3_obj.fq_name))

        VN4_fixture = self.useFixture(
            VNFixture(
                project_name=project1_instance.project_name,
                connections=project1_instance.project_connections,
                vn_name='VN4',
                inputs=project1_instance.inputs,
                subnets=['10.4.1.0/24'],
                ipam_fq_name=ipam4_obj.fq_name))

        # create policy
        policy_name = 'policy34'
        rules = []
        rules = [{'direction': '<>',
                  'protocol': 'icmp',
                  'dest_network': VN4_fixture.vn_fq_name,
                  'source_network': VN3_fixture.vn_fq_name,
                  'dst_ports': 'any',
                  'simple_action': 'pass',
                  'src_ports': 'any'},
                 {'direction': '<>',
                  'protocol': 'icmp',
                  'dest_network': VN3_fixture.vn_fq_name,
                  'source_network': VN4_fixture.vn_fq_name,
                  'dst_ports': 'any',
                  'simple_action': 'pass',
                  'src_ports': 'any'}]

        policy34_fixture = self.useFixture(
            PolicyFixture(
                policy_name=policy_name,
                rules_list=rules,
                inputs=project1_instance.inputs,
                connections=project1_instance.project_connections))

        # create VN to policy mapping in a dict of policy list.
        vn_policys = {
            VN3_fixture.vn_name: [policy_name],
            VN4_fixture.vn_name: [policy_name]}

        # create a policy object list of policies to be attached to a vm
        policy_obj_dict = {}
        policy_obj_dict[VN3_fixture.vn_name] = [policy34_fixture.policy_obj]
        policy_obj_dict[VN4_fixture.vn_name] = [policy34_fixture.policy_obj]

        # vn fixture dictionary.
        vn_obj_dict = {}
        vn_obj_dict[VN3_fixture.vn_name] = VN3_fixture
        vn_obj_dict[VN4_fixture.vn_name] = VN4_fixture

        # attach policy to VN
        VN3_policy_fixture = self.useFixture(
            VN_Policy_Fixture(
                connections=project1_instance.project_connections,
                vn_name=VN3_fixture.vn_name,
                policy_obj=policy_obj_dict,
                vn_obj=vn_obj_dict,
                vn_policys=vn_policys[
                    VN3_fixture.vn_name],
                project_name=project1_instance.project_name))

        VN4_policy_fixture = self.useFixture(
            VN_Policy_Fixture(
                connections=project1_instance.project_connections,
                vn_name=VN4_fixture.vn_name,
                policy_obj=policy_obj_dict,
                vn_obj=vn_obj_dict,
                vn_policys=vn_policys[
                    VN4_fixture.vn_name],
                project_name=project1_instance.project_name))

        # add VM to new VN
        VM31_fixture = self.useFixture(
            VMFixture(
                connections=project1_instance.project_connections,
                vn_obj=VN3_fixture.obj,
                vm_name='VM31',
                project_name=project1_instance.project_name))

        VM41_fixture = self.useFixture(
            VMFixture(
                connections=project1_instance.project_connections,
                vn_obj=VN4_fixture.obj,
                vm_name='VM41',
                project_name=project1_instance.project_name))

        # verification routines.
        test_flag = 0
        if ((VN3_fixture.verify_vn_in_api_server()) and
                (VN3_fixture.verify_vn_not_in_agent()) and
                (VN3_fixture.verify_vn_policy_in_api_server()['result'])):
            self.logger.info(
                "Verification of VN3 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VN3 FAILED while control nodes down.")
            test_flag = 1

        if ((VN4_fixture.verify_vn_in_api_server()) and
                (VN4_fixture.verify_vn_not_in_agent()) and
                (VN4_fixture.verify_vn_policy_in_api_server()['result'])):
            self.logger.info(
                "Verification of VN4 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VN4 FAILED while control nodes down.")
            test_flag = 1

        if ((VM22_fixture.verify_vm_launched()) and
                (VM22_fixture.verify_vm_in_api_server())):
            self.logger.info(
                "Verification of VM22 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VM22 FAILED while control nodes down.")
            test_flag = 1

        if ((VM31_fixture.verify_vm_launched()) and
                (VM31_fixture.verify_vm_in_api_server())):
            self.logger.info(
                "Verification of VM31 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VM31 FAILED while control nodes down.")
            test_flag = 1

        if ((VM41_fixture.verify_vm_launched()) and
                (VM41_fixture.verify_vm_in_api_server())):
            self.logger.info(
                "Verification of VM41 PASSED while control nodes down.")
        else:
            self.logger.error(
                "Verification of VM41 FAILED while control nodes down.")
            test_flag = 1

        # start all control services.
        headless_vr_utils.start_all_control_services(self)

        # if something went wrong in the controller down state bail out here.
        if test_flag == 1:
            self.logger.error("Verifications and Test failed while the controllers were down in \
                               headless state of agent. Check earlier error logs")
            return False

        # wait for 3 to 5 sec for configuration sync from control nodes to the
        # agents.
        time.sleep(5)

        # wait till VM's are up.
        VM22_fixture.wait_till_vm_is_up()
        VM31_fixture.wait_till_vm_is_up()
        VM41_fixture.wait_till_vm_is_up()

        # verify vm config gets downloaded to the agents.
        if ((VM22_fixture.verify_vm_in_agent()) and
                (VM31_fixture.verify_vm_in_agent()) and
                (VM41_fixture.verify_vm_in_agent())):
            self.logger.info("VM verification on the agent PASSED")
        else:
            self.logger.error("VM verification on the agent FAILED")
            return False

        # check ping success between the two VM's
        assert config_topo['project1']['vm']['VM11'].ping_with_certainty(
            VM22_fixture.vm_ip, expectation=True)
        assert VM31_fixture.ping_with_certainty(
            VM41_fixture.vm_ip,
            expectation=True)
        assert VM41_fixture.ping_with_certainty(
            VM31_fixture.vm_ip,
            expectation=True)

        # verification routines.
        if ((VN3_fixture.verify_on_setup()) and
                (VN4_fixture.verify_on_setup()) and
                (VM22_fixture.verify_on_setup()) and
                (VM31_fixture.verify_on_setup()) and
                (VM41_fixture.verify_on_setup())):
            self.logger.info(
                "All verifications passed after controllers came up in headless agent mode")
        else:
            self.logger.error(
                "Verifications FAILED after controllers came up in headless agent mode")
            return False

        return True
    def test_verify_flow_series_table_query_range(self):
        ''' Test to validate flow series table for query range

        '''
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn1_vm2_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn1_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip, self.inputs.host_data[
                self.tx_vm_node_ip]['username'], self.inputs.host_data[
                self.tx_vm_node_ip]['password'])
        self.rx_local_host = Host(
            self.rx_vm_node_ip, self.inputs.host_data[
                self.rx_vm_node_ip]['username'], self.inputs.host_data[
                self.rx_vm_node_ip]['password'])

        self.send_host = Host(self.res.vn1_vm1_fixture.local_ip,
                              self.res.vn1_vm1_fixture.vm_username,
                              self.res.vn1_vm1_fixture.vm_password)
        self.recv_host = Host(self.res.vn1_vm2_fixture.local_ip,
                              self.res.vn1_vm2_fixture.vm_username,
                              self.res.vn1_vm2_fixture.vm_password)
        # Create traffic stream
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))

        self.logger.info("Creating streams...")
        dport = 11000
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.res.vn1_vm1_fixture.vm_ip,
            dst=self.res.vn1_vm2_fixture.vm_ip,
            dport=dport)

        startport = 10000
        profile = ContinuousSportRange(
            stream=stream,
            listener=self.res.vn1_vm2_fixture.vm_ip,
            startport=10000,
            endport=dport,
            pps=100)
        sender = Sender(
            'sname',
            profile,
            self.tx_local_host,
            self.send_host,
            self.inputs.logger)
        receiver = Receiver(
            'rname',
            profile,
            self.rx_local_host,
            self.recv_host,
            self.inputs.logger)
        receiver.start()
        sender.start()
        time.sleep(30)
        sender.stop()
        receiver.stop()
        print sender.sent, receiver.recv
        time.sleep(1)

        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res. vn1_vm1_fixture.nova_h.get_nova_host_of_vm(
                self.res.vn1_vm1_fixture.vm_obj)]['host_ip']
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]['name']
        time.sleep(30)
        # Verifying flow series table
        src_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        dst_vn = 'default-domain' + ':' + \
            self.inputs.project_name + ':' + self.res.vn1_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = '(sourcevn=%s) AND (destvn=%s) AND protocol= 17 AND (sport = 10500 < 11000)' % (
            src_vn, dst_vn)
        for ip in self.inputs.collector_ips:
            self.logger.info('setup_time= %s' % (start_time))
            # Quering flow sreies table

            self.logger.info(
                "Verifying flowSeriesTable through opserver %s" %
                (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                'FlowSeriesTable',
                start_time=start_time,
                end_time='now',
                select_fields=[
                    'sourcevn',
                    'sourceip',
                    'destvn',
                    'destip',
                    'sum(packets)',
                    'sport',
                    'dport',
                    'T=1'],
                where_clause=query)
            assert self.res1
            for elem in self.res1:
                if ((elem['sport'] < 10500) or (elem['sport'] > 11000)):
                    self.logger.warn(
                        "Out of range element (range:sport > 15500 and sport < 16000):%s" %
                        (elem))
                    self.logger.warn("Test Failed")
                    result = False
                    assert result
        return True
Пример #20
0
    def test_traffic_connections_while_control_nodes_go_down(self):
        """Tests related to connections and traffic while switching from normal mode to headless and back
           i.e. control nodes go down and come online."""

        if len(self.inputs.compute_ips) < 2:
            raise unittest.SkipTest("This test needs atleast 2 compute nodes.")
        else:
            self.logger.info(
                "Required resources are in place to run the test.")

        result = True
        topology_class_name = None

        self.compute_fixture_dict = {}
        for each_compute in self.inputs.compute_ips:
            self.compute_fixture_dict[each_compute] = self.useFixture(
                ComputeNodeFixture(connections=self.connections,
                                   node_ip=each_compute,
                                   username=self.inputs.username,
                                   password=self.inputs.password))
            mode = self.compute_fixture_dict[
                each_compute].get_agent_headless_mode()
            if mode is False:
                self.compute_fixture_dict[
                    each_compute].set_agent_headless_mode()
        #
        # Get config for test from topology
        result = True
        msg = []
        if not topology_class_name:
            topology_class_name = test_headless_vrouter_topo.sdn_headless_vrouter_topo

        self.logger.info("Scenario for the test used is: %s" %
                         (topology_class_name))
        #
        # Create a list of compute node IP's and pass it to topo if you want to pin
        # a vm to a particular node
        topo_obj = topology_class_name(
            compute_node_list=self.inputs.compute_ips)
        #
        # Test setup: Configure policy, VN, & VM
        # return {'result':result, 'msg': err_msg, 'data': [self.topo, config_topo]}
        # Returned topo is of following format:
        # config_topo= {'policy': policy_fixt, 'vn': vn_fixture, 'vm': vm_fixture}
        topo = {}
        topo_objs = {}
        config_topo = {}
        setup_obj = self.useFixture(
            sdnTopoSetupFixture(self.connections, topo_obj))
        out = setup_obj.sdn_topo_setup()
        self.assertEqual(out['result'], True, out['msg'])
        if out['result']:
            topo_objs, config_topo, vm_fip_info = out['data']

        # Start Test
        proj = config_topo.keys()
        vms = config_topo[proj[0]]['vm'].keys()
        src_vm = config_topo[proj[0]]['vm'][vms[0]]
        dest_vm = config_topo[proj[0]]['vm'][vms[1]]
        flow_cache_timeout = 180

        # Setup Traffic.
        stream = Stream(protocol="ip",
                        proto="icmp",
                        src=src_vm.vm_ip,
                        dst=dest_vm.vm_ip)
        profile = ContinuousProfile(stream=stream, count=0, capfilter="icmp")

        tx_vm_node_ip = src_vm.vm_node_ip
        rx_vm_node_ip = dest_vm.vm_node_ip

        tx_local_host = Host(tx_vm_node_ip, self.inputs.username,
                             self.inputs.password)
        rx_local_host = Host(rx_vm_node_ip, self.inputs.username,
                             self.inputs.password)

        send_host = Host(src_vm.local_ip, src_vm.vm_username,
                         src_vm.vm_password)
        recv_host = Host(dest_vm.local_ip, dest_vm.vm_username,
                         dest_vm.vm_password)

        sender = Sender("icmp", profile, tx_local_host, send_host,
                        self.inputs.logger)
        receiver = Receiver("icmp", profile, rx_local_host, recv_host,
                            self.inputs.logger)

        receiver.start()
        sender.start()
        self.logger.info("Waiting for 5 sec for traffic to be setup ...")
        time.sleep(5)

        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)

        headless_vr_utils.stop_all_control_services(self)
        self.addCleanup(self.inputs.start_service,
                        'contrail-control',
                        self.inputs.bgp_ips,
                        container='control')

        headless_vr_utils.check_through_tcpdump(self, dest_vm, src_vm)

        flow_index_list2 = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)

        if flow_index_list == flow_index_list2:
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout)

        # verify_flow_is_not_recreated
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)

        if flow_index_list == flow_index_list2:
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        receiver.stop()
        sender.stop()

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout + 5)

        # verify_flow_is_cleared
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)
        if not len(flow_index_list):
            self.logger.info("No flows are present")
        else:
            self.logger.error("Flows are still present.")
            return False

        # start_ping
        receiver.start()
        sender.start()
        self.logger.info("Waiting for 5 sec for traffic to be setup ...")
        time.sleep(5)
        # verify_flow_is_recreated
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)
        if (flow_index_list[0] and flow_index_list[1]):
            self.logger.info("Flows are recreated.")
        else:
            self.logger.error("Flows are still absent.")
            return False

        headless_vr_utils.start_all_control_services(self)

        headless_vr_utils.check_through_tcpdump(self, dest_vm, src_vm)

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout + 5)

        flow_index_list2 = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)

        if flow_index_list == flow_index_list2:
            self.logger.info("Flow indexes have not changed.")
        else:
            self.logger.error(
                "Flow indexes have changed. Test Failed, Exiting")
            return False

        receiver.stop()
        sender.stop()

        # wait_for_flow_cache_timeout
        time.sleep(flow_cache_timeout + 5)

        # verify_flow_is_cleared
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)
        if not len(flow_index_list):
            self.logger.info("No flows are present")
        else:
            self.logger.error("Flows are still present.")
            return False

        # start_ping
        receiver.start()
        sender.start()
        self.logger.info("Waiting for 5 sec for traffic to be setup ...")
        time.sleep(5)

        # verify_flow_is_recreated
        flow_index_list = headless_vr_utils.get_flow_index_list(
            self, src_vm, dest_vm)
        if (flow_index_list[0] and flow_index_list[1]):
            self.logger.info("Flows are recreated.")
        else:
            self.logger.error("Flows are still absent.")
            return False

        receiver.stop()
        sender.stop()

        return True
    def test_verify_flow_series_table_query_range(self):
        """ Test to validate flow series table for query range

        """
        # installing traffic package in vm
        self.res.vn1_vm1_fixture.install_pkg("Traffic")
        self.res.vn1_vm2_fixture.install_pkg("Traffic")

        self.tx_vm_node_ip = self.res.vn1_vm1_fixture.vm_node_ip
        self.rx_vm_node_ip = self.res.vn1_vm2_fixture.vm_node_ip
        self.tx_local_host = Host(
            self.tx_vm_node_ip,
            self.inputs.host_data[self.tx_vm_node_ip]["username"],
            self.inputs.host_data[self.tx_vm_node_ip]["password"],
        )
        self.rx_local_host = Host(
            self.rx_vm_node_ip,
            self.inputs.host_data[self.rx_vm_node_ip]["username"],
            self.inputs.host_data[self.rx_vm_node_ip]["password"],
        )

        self.send_host = Host(
            self.res.vn1_vm1_fixture.local_ip,
            self.res.vn1_vm1_fixture.vm_username,
            self.res.vn1_vm1_fixture.vm_password,
        )
        self.recv_host = Host(
            self.res.vn1_vm2_fixture.local_ip,
            self.res.vn1_vm2_fixture.vm_username,
            self.res.vn1_vm2_fixture.vm_password,
        )

        # Create traffic stream
        start_time = self.analytics_obj.getstarttime(self.tx_vm_node_ip)
        self.logger.info("start time= %s" % (start_time))
        self.logger.info("Creating streams...")
        dport = 11000
        stream = Stream(
            protocol="ip",
            proto="udp",
            src=self.res.vn1_vm1_fixture.vm_ip,
            dst=self.res.vn1_vm2_fixture.vm_ip,
            dport=dport,
        )

        startport = 10000
        profile = ContinuousSportRange(
            stream=stream, listener=self.res.vn1_vm2_fixture.vm_ip, startport=10000, endport=dport, pps=100
        )
        sender = Sender("sname", profile, self.tx_local_host, self.send_host, self.inputs.logger)
        receiver = Receiver("rname", profile, self.rx_local_host, self.recv_host, self.inputs.logger)
        receiver.start()
        sender.start()
        time.sleep(30)
        sender.stop()
        receiver.stop()
        print sender.sent, receiver.recv
        time.sleep(1)

        vm_node_ip = self.res.vn1_vm1_fixture.inputs.host_data[
            self.res.vn1_vm1_fixture.orch.get_host_of_vm(self.res.vn1_vm1_fixture.vm_obj)
        ]["host_ip"]
        vm_host = self.res.vn1_vm1_fixture.inputs.host_data[vm_node_ip]["name"]
        time.sleep(30)
        # Verifying flow series table
        src_vn = "default-domain" + ":" + self.inputs.project_name + ":" + self.res.vn1_name
        dst_vn = "default-domain" + ":" + self.inputs.project_name + ":" + self.res.vn1_name
        # creating query: '(sourcevn=default-domain:admin:vn1) AND
        # (destvn=default-domain:admin:vn2)'
        query = "(sourcevn=%s) AND (destvn=%s) AND protocol= 17 AND (sport = 10500 < 11000)" % (src_vn, dst_vn)
        for ip in self.inputs.collector_ips:
            self.logger.info("setup_time= %s" % (start_time))
            # Quering flow sreies table

            self.logger.info("Verifying flowSeriesTable through opserver %s" % (ip))
            self.res1 = self.analytics_obj.ops_inspect[ip].post_query(
                "FlowSeriesTable",
                start_time=start_time,
                end_time="now",
                select_fields=["sourcevn", "sourceip", "destvn", "destip", "sum(packets)", "sport", "dport", "T=1"],
                where_clause=query,
            )
            assert self.res1
            for elem in self.res1:
                if (elem["sport"] < 10500) or (elem["sport"] > 11000):
                    self.logger.warn("Out of range element (range:sport > 15500 and sport < 16000):%s" % (elem))
                    self.logger.warn("Test Failed")
                    result = False
                    assert result
        return True