def test_flow_stats(self): """Check the update method in the GaugeFlowStatsLogger class""" # add an ofproto attribute to the datapath datapath = create_mock_datapath(0) ofp_attr = {'ofproto': ofproto} datapath.configure_mock(**ofp_attr) # add the datapath as an attribute to the config dp_attr = {'dp': datapath} self.conf.configure_mock(**dp_attr) logger = watcher.GaugeFlowTableLogger(self.conf, '__name__', mock.Mock()) logger._running = True instructions = [parser.OFPInstructionGotoTable(1)] msg = flow_stats_msg(datapath, instructions) rcv_time = time.time() rcv_time_str = logger._rcv_time(rcv_time) logger.update(rcv_time, msg) log_str = self.get_file_contents("{}--flowtable--{}.json".format( datapath.name, rcv_time_str)) yaml_dict = yaml_load( log_str)['OFPFlowStatsReply']['body'][0]['OFPFlowStats'] compare_flow_msg(msg, yaml_dict, self)
def test_flow_stats(self): """Check the update method in the GaugeFlowStatsLogger class""" #add an ofproto attribute to the datapath datapath = create_mock_datapath(0) ofp_attr = {'ofproto': ofproto} datapath.configure_mock(**ofp_attr) #add the datapath as an attribute to the config dp_attr = {'dp' : datapath} self.conf.configure_mock(**dp_attr) logger = watcher.GaugeFlowTableLogger(self.conf, '__name__', mock.Mock()) instructions = [parser.OFPInstructionGotoTable(1)] msg = flow_stats_msg(datapath, instructions) logger.update(time.time(), datapath.dp_id, msg) log_str = self.get_file_contents() #only parse the message part of the log text str_to_find = "msg: " index = log_str.find(str_to_find) #discard the start of the log text log_str = log_str[index + len(str_to_find):] json_dict = json.loads(log_str)['OFPFlowStatsReply']['body'][0]['OFPFlowStats'] compare_flow_msg(msg, json_dict, self)
def test_flow_stats(self): """Check the update method in the GaugeFlowStatsLogger class""" #add an ofproto attribute to the datapath datapath = create_mock_datapath(0) ofp_attr = {'ofproto': ofproto} datapath.configure_mock(**ofp_attr) #add the datapath as an attribute to the config dp_attr = {'dp' : datapath} self.conf.configure_mock(**dp_attr) logger = watcher.GaugeFlowTableLogger(self.conf, '__name__', mock.Mock()) instructions = [parser.OFPInstructionGotoTable(1)] msg = flow_stats_msg(datapath, instructions) logger.update(time.time(), datapath.dp_id, msg) log_str = self.get_file_contents() yaml_dict = yaml.load(log_str)['msg']['OFPFlowStatsReply']['body'][0]['OFPFlowStats'] compare_flow_msg(msg, yaml_dict, self)