def setUp(self): super(Abstract, self).setUp() for isl in (self.isl_alpha_beta, self.isl_beta_alpha): isl_info = share.isl_info_payload(isl) command = share.command(isl_info) self.assertTrue(messageclasses.MessageItem(command).handle())
def do_push_alot(iteration): if iteration % num_proc == 0: sys.stdout.write(" {}".format(iteration)) sys.stdout.flush() cf = copy.deepcopy(create_flow) cf[u'payload'][u'operation'] = "PUSH" messageclasses.MessageItem(**cf).handle()
def test_time_update_on_isl_discovery(self): sw_alpha = make_datapath_id(1) sw_beta = make_datapath_id(2) isl_alpha_beta = model.InterSwitchLink( model.NetworkEndpoint(sw_alpha, 2), model.NetworkEndpoint(sw_beta, 2), None) self.assertTrue(make_switch_add(sw_alpha)) self.assertTrue(make_switch_add(sw_beta)) update_point_a = model.TimeProperty.now(milliseconds_precission=True) message = share.command(share.payload_isl_info(isl_alpha_beta)) message['timestamp'] = update_point_a.as_java_timestamp() self.assertTrue(messageclasses.MessageItem(**message).handle()) recovered = model.TimeProperty.new_from_java_timestamp( message['timestamp']) self.assertEquals(update_point_a.value, recovered.value) with neo4j_connect.begin() as tx: isl = isl_utils.fetch(tx, isl_alpha_beta) neo4j_connect.pull(isl) db_ctime = model.TimeProperty.new_from_db(isl['time_create']) self.assertEqual(update_point_a.value, db_ctime.value) db_mtime = model.TimeProperty.new_from_db(isl['time_modify']) self.assertEqual(update_point_a.value, db_mtime.value) # one more update update_point_b = model.TimeProperty.now(milliseconds_precission=True) self.assertNotEqual(update_point_a.value, update_point_b.value) message['timestamp'] = update_point_b.as_java_timestamp() self.assertTrue(messageclasses.MessageItem(**message).handle()) with neo4j_connect.begin() as tx: isl = isl_utils.fetch(tx, isl_alpha_beta) neo4j_connect.pull(isl) db_ctime = model.TimeProperty.new_from_db(isl['time_create']) self.assertEqual(update_point_a.value, db_ctime.value) db_mtime = model.TimeProperty.new_from_db(isl['time_modify']) self.assertEqual(update_point_b.value, db_mtime.value)
def make_port_down(endpoint): payload = { 'clazz': messageclasses.MT_PORT, 'state': 'DOWN', 'switch_id': endpoint.dpid, 'port_no': endpoint.port} command = share.command(payload) return messageclasses.MessageItem(command).handle()
def make_switch_remove(dpid): payload = { 'clazz': messageclasses.MT_SWITCH, 'state': 'REMOVED', 'switch_id': dpid, 'address': '172.16.0.64', 'hostname': 'test-sw-{}'.format(dpid.replace(':', '')), 'description': 'test switch', 'controller': '172.16.0.1'} command = share.command(payload) return messageclasses.MessageItem(command).handle()
def make_isl_failed(source): command = share.command({ 'clazz': messageclasses.MT_ISL, 'state': 'FAILED', 'latency_ns': 20, 'speed': 1000, 'available_bandwidth': 1000, 'path': [ { 'switch_id': source.dpid, 'port_no': source.port}]}) return messageclasses.MessageItem(command).handle()
def make_isl_moved(isl): command = share.command({ 'clazz': messageclasses.MT_ISL, 'state': 'MOVED', 'latency_ns': 20, 'speed': 1000, 'available_bandwidth': 1000, 'path': [{ 'switch_id': isl.source.dpid, 'port_no': isl.source.port }, { 'switch_id': isl.dest.dpid, 'port_no': isl.dest.port }] }) return messageclasses.MessageItem(**command).handle()
def make_feature_toggle_request(payload): data = payload.copy() data['clazz'] = ( 'org.openkilda.messaging.command.system.FeatureToggleRequest') message = share.command(data) return messageclasses.MessageItem(**message).handle()
def exec_isl_discovery(isl, **fields): payload = isl_info_payload(isl, **fields) return messageclasses.MessageItem(command(payload)).handle()
def feed_service(self, message, can_fail=False): result = messageclasses.MessageItem(message).handle() if not can_fail: self.assertTrue(result)
def feed_message(message): return messageclasses.MessageItem(message).handle()
{'switch_id': 'DE:AD:BE:EF:33:33:33:33', 'port_no': 8}] }] print('Hello World') print("TEST #1 & #2 - create flow, get segments, spot check some of the values.") flow_utils.store_flow(flow1) result = flow_utils.fetch_flow_segments(flow1['flowid'], flow1['cookie']) print("Validate #1 - Length of segments should be 2: %d" % len(result)) for i,val in enumerate(result): print("Validate #3.* - seq_id should be %d: is: %d" % (flow1['flowpath']['path'][i*2]['seq_id'], val['seq_id'])) print("TEST #3 - create isls, validate bandwidth.") for isl in isls1: mc = messageclasses.MessageItem(payload=isl) mc.create_isl() for i,isl in enumerate(messageclasses.MessageItem.fetch_isls()): print("Validate #3.* - available_bandwidth should be %d: is: %d" % ((-3000+isls1[i]['available_bandwidth']), isl['available_bandwidth'])) print("TEST #4 - remove flow, validate bandwidth.") flow_utils.remove_flow(flow1) result = flow_utils.fetch_flow_segments(flow1['flowid'], flow1['cookie']) print("Validate #4.1 - should have no flow segments: %s " % result) for i,isl in enumerate(messageclasses.MessageItem.fetch_isls()): print("Validate #4.* - available_bandwidth should be %d: is: %d" % ((isls1[i]['available_bandwidth']), isl['available_bandwidth'])) # CREATE INDEX ON :switch(name);