def test_three_sw_case(self): tf1 = TF('sw001', [1,2]) tf1.rules.append( {'in_ports' : [1]} ) tf1.rules.append( {'in_ports' : [2]} ) tf1.rules[0]['out_ports'] = [2] tf1.rules[1]['out_ports'] = [1] tf1.end_ports = [1] tf2 = TF('sw002', [2,3]) tf2.rules.append( {'in_ports' : [2]} ) tf2.rules.append( {'in_ports' : [3]} ) tf2.rules[0]['out_ports'] = [3] tf2.rules[1]['out_ports'] = [2] tf2.end_ports = [] tf3 = TF('sw003', [3,1]) tf3.rules.append( {'in_ports' : [3]} ) tf3.rules.append( {'in_ports' : [1]} ) tf3.rules[0]['out_ports'] = [1] tf3.rules[1]['out_ports'] = [3] tf3.end_ports = [1] tf_list = [tf1, tf2, tf3] plink = [Edge(tf1.name, 2, tf2.name, 2),Edge(tf2.name, 3, tf3.name, 3)] self.nu.generate_network_model(tf_list, plink) self.nu.generate_nusmv_input() ret = self.nu.run_reachability('sw001_1','sw003_1') assert ret == True
def test_one_sw_case(self): """ _____ 2 1 | |== ==| sw1 | 3 |_____|== """ old_sw1 = TF('sw1',[1,2,3]) old_sw1.rules.append( {'in_ports' : [1]} ) old_sw1.rules.append( {'in_ports' : [2]} ) old_sw1.rules[0]['out_ports'] = [2] old_sw1.rules[1]['out_ports'] = [1] old_sw1.end_ports = [1,2] new_sw1 = TF('sw1',[1,2,3]) new_sw1.rules.append( {'in_ports' : [1]} ) new_sw1.rules.append( {'in_ports' : [3]} ) new_sw1.rules[0]['out_ports'] = [3] new_sw1.rules[1]['out_ports'] = [1] new_sw1.end_ports = [1,3] plink = [] sw_list = [old_sw1] updater = ConsistentUpdater(sw_list, plink) init_sw_set = {'sw1':old_sw1} final_sw_set = {'sw1':new_sw1} phi = {'reach':[{'src':'sw1_1','dst':'sw1_2'}]} comment = updater.order_update(init_sw_set, final_sw_set, phi) assert comment == '::wait::update_sw1'
def test_one_two_case(self): """ _____ _____ 3 1 | | 2 | |== ==| sw1 |===| sw2 | 4 |_____| |_____|== """ old_sw1 = TF('sw1',[1,2]) old_sw1.rules.append( {'in_ports' : [1]} ) old_sw1.rules.append( {'in_ports' : [2]} ) old_sw1.rules[0]['out_ports'] = [2] old_sw1.rules[1]['out_ports'] = [1] old_sw1.end_ports = [1] old_sw2 = TF('sw2',[2,3,4]) old_sw2.rules.append( {'in_ports' : [2]} ) old_sw2.rules.append( {'in_ports' : [3]} ) old_sw2.rules[0]['out_ports'] = [3] old_sw2.rules[1]['out_ports'] = [2] old_sw2.end_ports = [3] new_sw1 = TF('sw1',[1,2]) new_sw1.rules.append( {'in_ports' : [1]} ) new_sw1.rules.append( {'in_ports' : [2]} ) new_sw1.rules[0]['out_ports'] = [2] new_sw1.rules[1]['out_ports'] = [1] new_sw1.end_ports = [1] new_sw2 = TF('sw2',[2,3,4]) new_sw2.rules.append( {'in_ports' : [2]} ) new_sw2.rules.append( {'in_ports' : [4]} ) new_sw2.rules[0]['out_ports'] = [4] new_sw2.rules[1]['out_ports'] = [2] new_sw2.end_ports = [4] plink = [Edge('sw1',2,'sw2',2)] sw_list = [old_sw1,old_sw2] updater = ConsistentUpdater(sw_list, plink) init_sw_set = {'sw1':old_sw1, 'sw2':old_sw2} final_sw_set = {'sw1':new_sw1, 'sw2':new_sw2} phi = {'reach':[{'src':'sw1_1','dst':'sw1_2'}]} comment = updater.order_update(init_sw_set, final_sw_set, phi) print comment assert comment == '::wait::update_sw2'
def test_four_sw_case(self): """ _____ 2 _____ 4 _____ 1 | |===| 2 |===| | 1 ==| sw1 | |_____| | sw4 |== | | | | | | _____ | | | | 3 | 3 | 5 | | |_____|===|_____|===|_____| """ old_sw1 = TF('sw1',[1,2,3]) old_sw1.rules.append( {'in_ports' : [1]} ) old_sw1.rules.append( {'in_ports' : [2]} ) old_sw1.rules[0]['out_ports'] = [2] old_sw1.rules[1]['out_ports'] = [1] old_sw1.end_ports = [1] old_sw2 = TF('sw2',[2,4]) old_sw2.rules.append( {'in_ports' : [2]} ) old_sw2.rules.append( {'in_ports' : [4]} ) old_sw2.rules[0]['out_ports'] = [4] old_sw2.rules[1]['out_ports'] = [2] old_sw2.end_ports = [] old_sw4 = TF('sw4',[1,4,5]) old_sw4.rules.append( {'in_ports' : [1]} ) old_sw4.rules.append( {'in_ports' : [4]} ) old_sw4.rules[0]['out_ports'] = [4] old_sw4.rules[1]['out_ports'] = [1] old_sw4.end_ports = [1] new_sw1 = TF('sw1',[1,2,3]) new_sw1.rules.append( {'in_ports' : [1]} ) new_sw1.rules.append( {'in_ports' : [3]} ) new_sw1.rules[0]['out_ports'] = [3] new_sw1.rules[1]['out_ports'] = [1] new_sw1.end_ports = [1] new_sw3 = TF('sw3',[3,5]) new_sw3.rules.append( {'in_ports' : [3]} ) new_sw3.rules.append( {'in_ports' : [5]} ) new_sw3.rules[0]['out_ports'] = [5] new_sw3.rules[1]['out_ports'] = [3] new_sw3.end_ports = [] new_sw4 = TF('sw4',[1,4,5]) new_sw4.rules.append( {'in_ports' : [1]} ) new_sw4.rules.append( {'in_ports' : [5]} ) new_sw4.rules[0]['out_ports'] = [5] new_sw4.rules[1]['out_ports'] = [1] new_sw4.end_ports = [1] plink = [Edge('sw1',2,'sw2',2),Edge('sw2',4,'sw4',4),Edge('sw1',3,'sw3',3),Edge('sw3',5,'sw4',5)] sw_list = [old_sw1,old_sw2,new_sw3,new_sw4] updater = ConsistentUpdater(sw_list, plink) init_sw_set = {'sw1':old_sw1, 'sw2':old_sw2,'sw4':old_sw4} final_sw_set = {'sw1':new_sw1, 'sw3':new_sw3, 'sw4':new_sw4} phi = {'reach':[{'src':'sw1_1','dst':'sw4_1'}]} comment = updater.order_update(init_sw_set, final_sw_set, phi) print comment assert comment == '::wait::update_sw2'