def verify_uflow(self, vizd_obj, flow_type, exp_res):
     logging.info('verify <%s> data' % (flow_type))
     vns = VerificationOpsSrv('127.0.0.1', vizd_obj.get_opserver_port())
     res = vns.post_query('StatTable.UFlowData.flow',
         start_time='-1m', end_time='now',
         select_fields=['name', 'flow.flowtype', 'flow.sip', 'flow.sport'],
         where_clause = 'name=*')
     res = sorted([OrderedDict(sorted(r.items())) \
                  for r in res if r['flow.flowtype'] == flow_type])
     exp_res = sorted([OrderedDict(sorted(r.items())) for r in exp_res])
     logging.info('Expected Result: ' + str(exp_res))
     logging.info('Result: ' + str(res))
     if res != exp_res:
         return False
     return True
Пример #2
0
 def verify_uflow(self, vizd_obj, flow_type, exp_res):
     logging.info('verify <%s> data' % (flow_type))
     vns = VerificationOpsSrv('127.0.0.1', vizd_obj.get_opserver_port())
     res = vns.post_query(
         'StatTable.UFlowData.flow',
         start_time='-1m',
         end_time='now',
         select_fields=['name', 'flow.flowtype', 'flow.sip', 'flow.sport'],
         where_clause='name=*')
     res = sorted([OrderedDict(sorted(r.items())) \
                  for r in res if r['flow.flowtype'] == flow_type])
     exp_res = sorted([OrderedDict(sorted(r.items())) for r in exp_res])
     logging.info('Expected Result: ' + str(exp_res))
     logging.info('Result: ' + str(res))
     if res != exp_res:
         return False
     return True
    def test_03_ipfix(self):
        '''
        This test starts redis,vizd,opserver and qed
        It uses the test class' cassandra instance
        Then it feeds IPFIX packets to the collector
        and queries for them
        '''
        logging.info("*** test_03_ipfix ***")
        if StatsTest._check_skip_test() is True:
            return True
        
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.bind(("", 0))
        ipfix_port = sock.getsockname()[1]
        sock.close()

        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        vizd_obj = self.useFixture(
            AnalyticsFixture(logging,
                             builddir,
                             self.__class__.cassandra_port,
                             ipfix_port))
        assert vizd_obj.verify_on_setup()
        assert vizd_obj.verify_collector_obj_count()
        collectors = [vizd_obj.get_collector()]
        
        UDP_IP = "127.0.0.1"
        f1 = open(builddir + '/opserver/test/data/ipfix_t.data')
        sock.sendto(f1.read(), (UDP_IP, ipfix_port))
        f2 = open(builddir + '/opserver/test/data/ipfix_d.data')
        sock.sendto(f2.read(), (UDP_IP, ipfix_port))
        sock.close()

        logging.info("Verifying IPFIX data")
        vns = VerificationOpsSrv('127.0.0.1', vizd_obj.get_opserver_port())
        res = vns.post_query("StatTable.UFlowData.flow",
            start_time="-5m", end_time="now",
            select_fields=["name", "flow.flowtype", "flow.sip", "flow.sport"],
            where_clause = 'name=*')
        logging.info("Rssult: " + str(res))
        assert(self.verify_ipfix(res))

        return True