示例#1
0
    def test_for_bad_node_in_lsp_data(self):

        err_msg = "No Node with name Y in Model"

        with self.assertRaises(ModelException) as context:
            FlexModel.load_model_file('test/parallel_link_model_bad_node_in_lsp.csv')
        self.assertIn(err_msg, context.exception.args[0])
示例#2
0
 def test_interface_fields_missing_model_file_load(self):
     err_msg = 'node_name, remote_node_name, name, cost, capacity, circuit_id must be defined for line'
     with self.assertRaises(ModelException) as context:
         FlexModel.load_model_file(
             'test/interface_field_info_missing_routing_topology_multidigraph.csv'
         )
     self.assertTrue(err_msg in err_msg in context.exception.args[0])
    def test_unroutable_demand(self):
        node_a = Node(name="nodeA", lat=0, lon=0)
        node_b = Node(name="nodeB", lat=0, lon=0)
        node_d = Node(name="nodeD")
        interface_a = Interface(
            name="inerfaceA-to-B",
            cost=4,
            capacity=100,
            node_object=node_a,
            remote_node_object=node_b,
            circuit_id=1,
        )
        interface_b = Interface(
            name="inerfaceB-to-A",
            cost=4,
            capacity=100,
            node_object=node_b,
            remote_node_object=node_a,
            circuit_id=1,
        )
        dmd_a_d = Demand(node_a, node_d, traffic=10)
        model = FlexModel(
            interface_objects=set([interface_a, interface_b]),
            node_objects=set([node_a, node_b, node_d]),
            demand_objects=set([dmd_a_d]),
            rsvp_lsp_objects=set([]),
        )
        model.update_simulation()

        self.assertEqual(dmd_a_d.path, "Unrouted")
示例#4
0
    def test_mismatched_circuit_id(self):
        """
        Check that each circuit_id value appears exactly twice in the model file
        """
        msg = ("Each circuit_id value must appear exactly twice; the following circuit_id values do not meet "
               "that criteria:")

        with self.assertRaises(ModelException) as context:
            FlexModel.load_model_file('test/parallel_link_model_bad_circuit_id.csv')
        self.assertIn(msg, context.exception.args[0])
示例#5
0
    def test_get_non_failed_nodes(self):
        model = FlexModel.load_model_file(
            "test/parallel_link_model_test_topology.csv")
        model.update_simulation()

        model.fail_node("A")
        model.fail_node("G")
        model.update_simulation()

        node_b = model.get_node_object("B")
        node_c = model.get_node_object("C")
        node_d = model.get_node_object("D")
        node_e = model.get_node_object("E")
        node_f = model.get_node_object("F")
        node_x = model.get_node_object("X")
        node_h = model.get_node_object("H")
        node_y = model.get_node_object("Y")

        unfailed_node_list = [
            node_b,
            node_c,
            node_d,
            node_e,
            node_f,
            node_x,
            node_h,
            node_y,
        ]

        self.assertEqual(set(model.get_non_failed_node_objects()),
                         set(unfailed_node_list))
示例#6
0
    def test_remove_interface_from_srlg(self):
        model = FlexModel.load_model_file(
            "test/parallel_link_model_test_topology.csv")
        model.update_simulation()
        int_a_b = model.get_interface_object("A-to-B", "A")
        int_b_a = int_a_b.get_remote_interface(model)

        model.add_srlg("new_srlg")
        model.update_simulation()

        int_a_b.add_to_srlg("new_srlg", model)
        model.update_simulation()

        srlg = model.get_srlg_object("new_srlg")

        self.assertIn(int_a_b, srlg.interface_objects)
        self.assertIn(int_b_a, srlg.interface_objects)
        self.assertIn(srlg, int_a_b.srlgs)
        self.assertIn(srlg, int_b_a.srlgs)

        int_b_a.remove_from_srlg("new_srlg", model)
        model.update_simulation()

        self.assertNotIn(int_a_b, srlg.interface_objects)
        self.assertNotIn(int_b_a, srlg.interface_objects)
        self.assertNotIn(srlg, int_a_b.srlgs)
        self.assertNotIn(srlg, int_b_a.srlgs)
示例#7
0
    def test_int_in_SRLG_failed_node(self):
        model = FlexModel.load_model_file(
            "test/parallel_link_model_test_topology.csv")
        model.update_simulation()

        int_a_b = model.get_interface_object("A-to-B", "A")
        int_b_a = int_a_b.get_remote_interface(model)

        int_a_b.add_to_srlg("new_srlg", model, create_if_not_present=True)
        int_a_b.add_to_srlg("new_srlg_2", model, create_if_not_present=True)
        new_srlg = model.get_srlg_object("new_srlg")

        model.fail_node("A")
        model.fail_srlg("new_srlg")
        model.update_simulation()

        self.assertTrue(new_srlg.failed)
        self.assertTrue(int_a_b.failed)

        model.unfail_srlg("new_srlg")
        model.update_simulation()

        # int_a_b and int_b_a should stay failed since Node('A') is also failed
        self.assertTrue(int_a_b.failed)
        self.assertTrue(int_b_a.failed)
示例#8
0
    def test_int_in_two_SRLGs(self):
        model = FlexModel.load_model_file(
            "test/parallel_link_model_test_topology.csv")
        int_a_b = model.get_interface_object("A-to-B", "A")
        model.update_simulation()

        int_a_b.add_to_srlg("new_srlg", model, create_if_not_present=True)
        int_a_b.add_to_srlg("new_srlg_2", model, create_if_not_present=True)
        new_srlg = model.get_srlg_object("new_srlg")
        new_srlg_2 = model.get_srlg_object("new_srlg_2")

        model.fail_srlg("new_srlg")
        model.fail_srlg("new_srlg_2")
        model.update_simulation()

        self.assertTrue(new_srlg.failed)
        self.assertTrue(new_srlg_2.failed)
        self.assertTrue(int_a_b.failed)

        model.unfail_srlg("new_srlg")
        model.update_simulation()

        # node_a should stay failed since it's part of another SRLG
        # that is still failed
        self.assertTrue(int_a_b.failed)
示例#9
0
    def test_failed_int_node_srlg(self):
        model = FlexModel.load_model_file(
            "test/parallel_link_model_test_topology.csv")
        model.update_simulation()
        int_a_b = model.get_interface_object("A-to-B", "A")
        int_b_a = int_a_b.get_remote_interface(model)
        node_a = model.get_node_object("A")

        model.add_srlg("new_srlg")
        model.update_simulation()

        int_a_b.add_to_srlg("new_srlg", model)
        model.update_simulation()

        srlg = model.get_srlg_object("new_srlg")

        model.fail_node("A")
        model.fail_srlg("new_srlg")
        model.update_simulation()

        self.assertTrue(int_a_b.failed)
        self.assertTrue(int_b_a.failed)

        # Unfail the SRLG, int_a_b and int_b_a should stay failed
        model.unfail_srlg("new_srlg")
        model.update_simulation()

        self.assertFalse(srlg.failed)
        self.assertTrue(node_a.failed)
        self.assertTrue(int_a_b.failed)
        self.assertTrue(int_b_a.failed)
示例#10
0
    def test_get_bad_srlg_no_exception(self):
        model = FlexModel.load_model_file(
            "test/parallel_link_model_test_topology.csv")

        bad_srlg = model.get_srlg_object("bad_srlg", raise_exception=False)

        self.assertEqual(bad_srlg, None)
    def test_node_in_two_srlgs(self):
        model = FlexModel.load_model_file(
            'test/parallel_link_model_test_topology.csv')
        node_a = model.get_node_object('A')
        model.update_simulation()

        node_a.add_to_srlg('new_srlg', model, create_if_not_present=True)
        node_a.add_to_srlg('new_srlg_2', model, create_if_not_present=True)
        new_srlg = model.get_srlg_object('new_srlg')
        new_srlg_2 = model.get_srlg_object('new_srlg_2')

        model.fail_srlg('new_srlg')
        model.fail_srlg('new_srlg_2')
        model.update_simulation()

        self.assertTrue(new_srlg.failed)
        self.assertTrue(new_srlg_2.failed)
        self.assertTrue(node_a.failed)

        model.unfail_srlg('new_srlg')
        model.update_simulation()

        # node_a should stay failed since it's part of another SRLG
        # that is still failed
        self.assertTrue(node_a.failed)
    def test_interface_in_failed_srlg(self):
        model = FlexModel.load_model_file(
            'test/parallel_link_model_test_topology.csv')
        model.update_simulation()
        int_a_b = model.get_interface_object('A-to-B', 'A')
        int_b_a = int_a_b.get_remote_interface(model)

        model.add_srlg('new_srlg')
        model.update_simulation()

        int_a_b.add_to_srlg('new_srlg', model)
        model.update_simulation()

        srlg = model.get_srlg_object('new_srlg')

        self.assertIn(int_a_b, srlg.interface_objects)
        self.assertIn(int_b_a, srlg.interface_objects)
        self.assertIn(srlg, int_a_b.srlgs)
        self.assertIn(srlg, int_b_a.srlgs)
        self.assertFalse(int_a_b.failed)
        self.assertFalse(int_b_a.failed)

        model.fail_srlg('new_srlg')
        model.update_simulation()

        self.assertTrue(int_a_b.failed)
        self.assertTrue(int_b_a.failed)
示例#13
0
    def test_get_bad_dmd(self):
        model = FlexModel.load_model_file('test/parallel_link_model_test_topology.csv')
        model.update_simulation()

        with self.assertRaises(ModelException) as context:
            model.get_demand_object('F', 'A', 'bad_demand')
        self.assertIn('no matching demand', context.exception.args[0])
示例#14
0
    def test_get_ckt(self):
        model = FlexModel.load_model_file('test/parallel_link_model_test_topology.csv')
        model.update_simulation()

        ckt = model.get_circuit_object_from_interface('A-to-B', 'A')

        self.assertIn(ckt, model.circuit_objects)
示例#15
0
    def test_bad_ckt(self):
        model = FlexModel.load_model_file('test/parallel_link_model_test_topology.csv')
        model.update_simulation()

        with self.assertRaises(ModelException) as context:
            model.get_circuit_object_from_interface('A-to-Z', 'A')
        self.assertTrue('specified interface does not exist' in context.exception.args[0])
    def test_remove_shortcuts_node_b(self):

        model = FlexModel.load_model_file(
            'test/igp_shortcuts_model_mult_lsps_in_path.csv')

        node_b = model.get_node_object('B')

        node_b.igp_shortcuts_enabled = False

        model.update_simulation()

        # Get LSP objects
        lsp_b_d_1 = model.get_rsvp_lsp('B', 'D', 'lsp_b_d_1')
        lsp_b_d_2 = model.get_rsvp_lsp('B', 'D', 'lsp_b_d_2')
        lsp_c_e_1 = model.get_rsvp_lsp('C', 'E', 'lsp_c_e_1')
        lsp_d_f_1 = model.get_rsvp_lsp('D', 'F', 'lsp_d_f_1')

        dmd_a_f_1 = model.get_demand_object('A', 'F', 'dmd_a_f_1')
        dmd_d_f_1 = model.get_demand_object('D', 'F', 'dmd_d_f_1')

        # Half the traffic from dmd_a_f_1 should be on lsp_c_e_1
        self.assertEqual(lsp_c_e_1.traffic_on_lsp(model), 5.0)

        # dmd_a_f_1 should be the only demand on lsp_c_e_1
        self.assertEqual(lsp_c_e_1.demands_on_lsp(model), [dmd_a_f_1])

        # dmd_d_f_1 should be the only demand on lsp_d_f_1
        self.assertEqual(lsp_d_f_1.demands_on_lsp(model), [dmd_d_f_1])

        # LSPs from B to D should have no demands and no traffic
        self.assertEqual(lsp_b_d_1.demands_on_lsp(model), [])
        self.assertEqual(lsp_b_d_2.demands_on_lsp(model), [])
        self.assertEqual(lsp_b_d_1.traffic_on_lsp(model), 0)
        self.assertEqual(lsp_b_d_2.traffic_on_lsp(model), 0)
示例#17
0
 def test_get_unfailed_ints_2(self):
     model = FlexModel.load_model_file(
         'test/parallel_link_model_test_topology.csv')
     model.update_simulation()
     model.fail_interface('A-to-B', 'A')
     model.update_simulation()
     self.assertEqual(len(model.get_unfailed_interface_objects()), 38)
示例#18
0
    def test_remove_shortcuts_node_b(self):

        model = FlexModel.load_model_file(
            "test/igp_shortcuts_model_mult_lsps_in_path.csv")

        node_b = model.get_node_object("B")

        node_b.igp_shortcuts_enabled = False

        model.update_simulation()

        # Get LSP objects
        lsp_b_d_1 = model.get_rsvp_lsp("B", "D", "lsp_b_d_1")
        lsp_b_d_2 = model.get_rsvp_lsp("B", "D", "lsp_b_d_2")
        lsp_c_e_1 = model.get_rsvp_lsp("C", "E", "lsp_c_e_1")
        lsp_d_f_1 = model.get_rsvp_lsp("D", "F", "lsp_d_f_1")

        dmd_a_f_1 = model.get_demand_object("A", "F", "dmd_a_f_1")
        dmd_d_f_1 = model.get_demand_object("D", "F", "dmd_d_f_1")

        # Half the traffic from dmd_a_f_1 should be on lsp_c_e_1
        self.assertEqual(lsp_c_e_1.traffic_on_lsp(model), 5.0)

        # dmd_a_f_1 should be the only demand on lsp_c_e_1
        self.assertEqual(lsp_c_e_1.demands_on_lsp(model), [dmd_a_f_1])

        # dmd_d_f_1 should be the only demand on lsp_d_f_1
        self.assertEqual(lsp_d_f_1.demands_on_lsp(model), [dmd_d_f_1])

        # LSPs from B to D should have no demands and no traffic
        self.assertEqual(lsp_b_d_1.demands_on_lsp(model), [])
        self.assertEqual(lsp_b_d_2.demands_on_lsp(model), [])
        self.assertEqual(lsp_b_d_1.traffic_on_lsp(model), 0)
        self.assertEqual(lsp_b_d_2.traffic_on_lsp(model), 0)
    def test_model_load_flex_model(self):
        model = FlexModel.load_model_file(
            "test/manual_lsp_metric_test_flex_model.csv")
        model.update_simulation()
        lsp_b_d_1 = model.get_rsvp_lsp("B", "D", "lsp_b_d_1")
        lsp_b_d_2 = model.get_rsvp_lsp("B", "D", "lsp_b_d_2")
        lsp_b_d_3 = model.get_rsvp_lsp("B", "D", "lsp_b_d_3")
        lsp_b_d_4 = model.get_rsvp_lsp("B", "D", "lsp_b_d_4")

        self.assertEqual(lsp_b_d_1.manual_metric, 10)
        self.assertEqual(lsp_b_d_1.effective_metric(model), 10)
        self.assertEqual(lsp_b_d_1.topology_metric(model), 20)
        self.assertNotEqual(lsp_b_d_1.path, "Unrouted")
        self.assertEqual(lsp_b_d_1.configured_setup_bandwidth, 2)
        self.assertEqual(lsp_b_d_1.setup_bandwidth, 2)

        self.assertEqual(lsp_b_d_2.manual_metric, 9)
        self.assertEqual(lsp_b_d_2.effective_metric(model), 9)
        self.assertEqual(lsp_b_d_2.topology_metric(model), 20)
        self.assertNotEqual(lsp_b_d_2.path, "Unrouted")
        self.assertIsNone(lsp_b_d_2.configured_setup_bandwidth)

        self.assertEqual(lsp_b_d_3.manual_metric, "not set")
        self.assertEqual(lsp_b_d_3.topology_metric(model), 20)
        self.assertEqual(lsp_b_d_3.effective_metric(model), 20)
        self.assertEqual(lsp_b_d_3.configured_setup_bandwidth, 3)
        self.assertEqual(lsp_b_d_3.setup_bandwidth, 3)
        self.assertNotEqual(lsp_b_d_3.path, "Unrouted")

        self.assertEqual(lsp_b_d_4.manual_metric, "not set")
        self.assertEqual(lsp_b_d_4.topology_metric(model), 20)
        self.assertEqual(lsp_b_d_4.effective_metric(model), 20)
        self.assertNotEqual(lsp_b_d_4.path, "Unrouted")
示例#20
0
 def test_ckt_mismatch_int_capacity_file_load(self):
     err_msg = 'circuits_with_mismatched_interface_capacity'
     model = FlexModel.load_model_file(
         'test/mismatched_ckt_int_capacity_topology_parallel_links.csv')
     with self.assertRaises(ModelException) as context:
         model.update_simulation()
     self.assertTrue(err_msg in context.exception.args[0][1][0].keys())
示例#21
0
    def test_implied_node(self):
        model = FlexModel.load_model_file(
            'test/parallel_link_model_test_topology.csv')

        node_x = model.get_node_object('X')

        self.assertTrue(node_x in model.node_objects)
示例#22
0
 def test_failed_node_interfaces(self):
     model = FlexModel.load_model_file(
         'test/parallel_link_model_test_topology.csv')
     model.update_simulation()
     model.fail_node('A')
     model.update_simulation()
     self.assertEqual(len(model.get_failed_interface_objects()), 10)
示例#23
0
 def test_fail_node(self):
     model = FlexModel.load_model_file(
         'test/parallel_link_model_test_topology.csv')
     model.update_simulation()
     model.fail_node('A')
     model.update_simulation()
     self.assertTrue(model.get_node_object('A').failed)
 def setUpClass(self):
     self.model = FlexModel.load_model_file(
         "test/test_rsvp_3rd_lsp_2_paths_parallel_links.csv")
     self.lsp_a_e_1 = self.model.get_rsvp_lsp("A", "E", "lsp_a_e_1")
     self.lsp_a_e_2 = self.model.get_rsvp_lsp("A", "E", "lsp_a_e_2")
     self.lsp_a_e_3 = self.model.get_rsvp_lsp("A", "E", "lsp_a_e_3")
     self.model.update_simulation()
 def setUpClass(self):
     self.maxDiff = None
     self.node_a = Node(name='nodeA', lat=0, lon=0)
     self.node_b = Node(name='nodeB', lat=0, lon=0)
     self.interface_a = Interface(name='inerfaceA-to-B',
                                  cost=4,
                                  capacity=100,
                                  node_object=self.node_a,
                                  remote_node_object=self.node_b,
                                  circuit_id=1)
     self.interface_b = Interface(name='inerfaceB-to-A',
                                  cost=4,
                                  capacity=100,
                                  node_object=self.node_b,
                                  remote_node_object=self.node_a,
                                  circuit_id=1)
     self.rsvp_lsp_a = RSVP_LSP(source_node_object=self.node_a,
                                dest_node_object=self.node_b,
                                lsp_name='A-to-B')
     self.model = FlexModel(interface_objects=set(
         [self.interface_a, self.interface_b]),
                            node_objects=set([self.node_a, self.node_b]),
                            demand_objects=set([]),
                            rsvp_lsp_objects=set([self.rsvp_lsp_a]))
     self.demand = Demand(source_node_object=self.node_a,
                          dest_node_object=self.node_b,
                          traffic=10,
                          name='A-to-B')
    def test_model_load_flex_model(self):
        model = FlexModel.load_model_file(
            'test/lsp_manual_metric_test_flex_model.csv')
        model.update_simulation()
        lsp_b_d_1 = model.get_rsvp_lsp('B', 'D', 'lsp_b_d_1')
        lsp_b_d_2 = model.get_rsvp_lsp('B', 'D', 'lsp_b_d_2')
        lsp_b_d_3 = model.get_rsvp_lsp('B', 'D', 'lsp_b_d_3')
        lsp_b_d_4 = model.get_rsvp_lsp('B', 'D', 'lsp_b_d_4')

        self.assertEqual(lsp_b_d_1.manual_metric, 10)
        self.assertEqual(lsp_b_d_1.effective_metric(model), 10)
        self.assertEqual(lsp_b_d_1.topology_metric(model), 20)
        self.assertNotEqual(lsp_b_d_1.path, 'Unrouted')
        self.assertEqual(lsp_b_d_1.configured_setup_bandwidth, 2)
        self.assertEqual(lsp_b_d_1.setup_bandwidth, 2)

        self.assertEqual(lsp_b_d_2.manual_metric, 9)
        self.assertEqual(lsp_b_d_2.effective_metric(model), 9)
        self.assertEqual(lsp_b_d_2.topology_metric(model), 20)
        self.assertNotEqual(lsp_b_d_2.path, 'Unrouted')
        self.assertIsNone(lsp_b_d_2.configured_setup_bandwidth)

        self.assertEqual(lsp_b_d_3.manual_metric, 'not set')
        self.assertEqual(lsp_b_d_3.topology_metric(model), 20)
        self.assertEqual(lsp_b_d_3.effective_metric(model), 20)
        self.assertEqual(lsp_b_d_3.configured_setup_bandwidth, 3)
        self.assertEqual(lsp_b_d_3.setup_bandwidth, 3)
        self.assertNotEqual(lsp_b_d_3.path, 'Unrouted')

        self.assertEqual(lsp_b_d_4.manual_metric, 'not set')
        self.assertEqual(lsp_b_d_4.topology_metric(model), 20)
        self.assertEqual(lsp_b_d_4.effective_metric(model), 20)
        self.assertNotEqual(lsp_b_d_4.path, 'Unrouted')
示例#27
0
    def test_equality(self):
        model = FlexModel.load_model_file(
            'test/parallel_link_model_test_topology_igp_only.csv')
        model.update_simulation()
        ckt_1 = model.get_circuit_object_from_interface('A-to-B', 'A')
        int_a, int_b = ckt_1.get_circuit_interfaces(model)

        self.assertNotEqual(int_a, int_b)
示例#28
0
    def test_igp_shortcut_node_attributes(self):
        # The IGP shortcut attribute should be True
        model = FlexModel.load_model_file(
            "test/igp_shortcuts_model_mult_lsps_in_path.csv")

        node_b = model.get_node_object("B")

        self.assertTrue(node_b.igp_shortcuts_enabled)
示例#29
0
    def test_ckt_non_failure(self):
        model = FlexModel.load_model_file(
            'test/parallel_link_model_test_topology_igp_only.csv')
        model.update_simulation()

        ckt_1 = model.get_circuit_object_from_interface('A-to-B', 'A')

        self.assertFalse(ckt_1.failed(model))
示例#30
0
    def test_traffic_non_failed_int(self):
        model = FlexModel.load_model_file(
            'test/parallel_link_model_test_topology_igp_only.csv')
        model.update_simulation()

        int_b_e = model.get_interface_object('B-to-E', 'B')

        self.assertTrue(int_b_e.traffic, 10)