def test_call(self):
        """ Test calling the tags loader
        """

        vertex = _TestVertex()

        tag_1 = IPTag("127.0.0.1", 0, 0, 1, "localhost", 12345, True, "Test")
        tag_2 = IPTag("127.0.0.1", 0, 0, 2, "localhost", 54321, True, "Test")
        rip_tag_1 = ReverseIPTag("127.0.0.1", 3, 12345, 0, 0, 0, 0)
        rip_tag_2 = ReverseIPTag("127.0.0.1", 4, 12346, 0, 0, 0, 0)

        tags = Tags()
        tags.add_ip_tag(tag_1, vertex)
        tags.add_ip_tag(tag_2, vertex)
        tags.add_reverse_ip_tag(rip_tag_1, vertex)
        tags.add_reverse_ip_tag(rip_tag_2, vertex)

        txrx = _MockTransceiver()

        loader = TagsLoader()
        loader.__call__(txrx, tags)
        self.assertIn(tag_1, txrx.ip_tags)
        self.assertIn(tag_2, txrx.ip_tags)
        self.assertIn(rip_tag_1, txrx.reverse_ip_tags)
        self.assertIn(rip_tag_2, txrx.reverse_ip_tags)
    def test_call(self):
        """ Test calling the tags loader
        """

        vertex = _TestVertex()

        tag_1 = IPTag("127.0.0.1", 0, 0, 1, "localhost", 12345, True, "Test")
        tag_2 = IPTag("127.0.0.1", 0, 0, 2, "localhost", 54321, True, "Test")
        rip_tag_1 = ReverseIPTag("127.0.0.1", 3, 12345, 0, 0, 0, 0)
        rip_tag_2 = ReverseIPTag("127.0.0.1", 4, 12346, 0, 0, 0, 0)

        tags = Tags()
        tags.add_ip_tag(tag_1, vertex)
        tags.add_ip_tag(tag_2, vertex)
        tags.add_reverse_ip_tag(rip_tag_1, vertex)
        tags.add_reverse_ip_tag(rip_tag_2, vertex)

        txrx = _MockTransceiver()

        loader = TagsLoader()
        loader.__call__(txrx, tags)
        self.assertIn(tag_1, txrx.ip_tags)
        self.assertIn(tag_2, txrx.ip_tags)
        self.assertIn(rip_tag_1, txrx.reverse_ip_tags)
        self.assertIn(rip_tag_2, txrx.reverse_ip_tags)
コード例 #3
0
 def test_adding_a_iptag_to_tag_info(self):
     """
     check that adding a tag after initialisation works
     """
     tag_info = Tags()
     iptag = IPTag("", 0, 0, 1, "122.2.2.2", 1, False)
     machine_vertex = SimpleMachineVertex(None, "")
     tag_info.add_ip_tag(iptag, machine_vertex)
    def test_listener_creation(self):
        # Test of buffer manager listener creation problem, where multiple
        # listeners were being created for the buffer manager traffic from
        # individual boards, where it's preferred all traffic is received by
        # a single listener

        # Create two vertices
        v1 = _TestVertex(10, "v1", 256)
        v2 = _TestVertex(10, "v2", 256)

        # Create two tags - important thing is port=None
        t1 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=1, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')
        t2 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=2, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')

        # Create 'Tags' object and add tags
        t = Tags()
        t.add_ip_tag(t1, v1)
        t.add_ip_tag(t2, v2)

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(
            remote_host=None))
        connections.append(EIEIOConnection())

        # Create two placements and 'Placements' object
        pl1 = Placement(v1, 0, 1, 1)
        pl2 = Placement(v2, 0, 2, 1)
        pl = Placements([pl1, pl2])

        # Create transceiver
        trnx = Transceiver(version=5, connections=connections)
        # Alternatively, one can register a udp listener for testing via:
        # trnx.register_udp_listener(callback=None,
        #        connection_class=EIEIOConnection)

        # Create buffer manager
        bm = BufferManager(pl, t, trnx)

        # Register two listeners, and check the second listener uses the
        # first rather than creating a new one
        bm._add_buffer_listeners(vertex=v1)
        bm._add_buffer_listeners(vertex=v2)

        number_of_listeners = 0
        for i in bm._transceiver._udp_listenable_connections_by_class[
                EIEIOConnection]:
            # Check if listener is registered on connection - we only expect
            # one listener to be registered, as all connections can use the
            # same listener for the buffer manager
            if not i[1] is None:
                number_of_listeners += 1
            print i
        self.assertEqual(number_of_listeners, 1)
コード例 #5
0
    def test_add_iptag_then_locate_tag(self):
        """
        check that locating a iptag via get_ip_tags_for_vertex function
        """
        tag_info = Tags()
        iptag = IPTag("", 0, 0, 1, "122.2.2.2", 1, False)
        machine_vertex = SimpleMachineVertex(None, "")
        tag_info.add_ip_tag(iptag, machine_vertex)

        gotton_tag = tag_info.get_ip_tags_for_vertex(machine_vertex)
        self.assertEqual(gotton_tag[0], iptag)
コード例 #6
0
    def test_add_iptag_then_fail_to_locate(self):
        """
        test that asking for a invalid iptag returns a None value
        """
        tag_info = Tags()
        iptag = IPTag("", 0, 0, 1, "122.2.2.2", 1, False)
        machine_vertex = SimpleMachineVertex(None, "")
        machine_vertex_2 = SimpleMachineVertex(None, "")
        tag_info.add_ip_tag(iptag, machine_vertex)

        gotton_tag = tag_info.get_ip_tags_for_vertex(machine_vertex_2)
        self.assertEqual(gotton_tag, None)
コード例 #7
0
 def test_add_conflicting_reverse_ip_tag(self):
     tags = Tags()
     tag1 = ReverseIPTag("", 1, 23, 0, 0, 1, 1)
     tag2 = ReverseIPTag("", 1, 23, 0, 0, 1, 1)
     tag3 = IPTag("", 0, 7, 1, "122.2.2.3", 1, False)
     machine_vertex = SimpleMachineVertex(None, "")
     tags.add_reverse_ip_tag(tag1, machine_vertex)
     with self.assertRaises(PacmanInvalidParameterException) as e:
         tags.add_reverse_ip_tag(tag2, machine_vertex)
     self.assertIn("The tag has already been assigned on the given board",
                   str(e.exception))
     with self.assertRaises(PacmanInvalidParameterException) as e:
         tags.add_ip_tag(tag3, machine_vertex)
     self.assertIn("The tag has already been assigned to a reverse IP tag"
                   " on the given board", str(e.exception))
     with self.assertRaises(PacmanInvalidParameterException) as e:
         tags.add_reverse_ip_tag(tag3, machine_vertex)
     self.assertIn("Only add reverse IP tags with this method.",
                   str(e.exception))
    def test_listener_creation(self):
        # Test of buffer manager listener creation problem, where multiple
        # listeners were being created for the buffer manager traffic from
        # individual boards, where it's preferred all traffic is received by
        # a single listener

        # Create two vertices
        v1 = _TestVertex(10, "v1", 256)
        v2 = _TestVertex(10, "v2", 256)

        # Create two tags - important thing is port=None
        t1 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=1, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')
        t2 = IPTag(board_address='127.0.0.1', destination_x=0,
                   destination_y=2, tag=1, port=None, ip_address=None,
                   strip_sdp=True, traffic_identifier='BufferTraffic')

        # Create 'Tags' object and add tags
        t = Tags()
        t.add_ip_tag(t1, v1)
        t.add_ip_tag(t2, v2)

        # Create board connections
        connections = []
        connections.append(SCAMPConnection(
            remote_host=None))
        connections.append(EIEIOConnection())

        # Create two placements and 'Placements' object
        pl1 = Placement(v1, 0, 1, 1)
        pl2 = Placement(v2, 0, 2, 1)
        pl = Placements([pl1, pl2])

        # Create transceiver
        trnx = Transceiver(version=5, connections=connections)
        # Alternatively, one can register a udp listener for testing via:
        # trnx.register_udp_listener(callback=None,
        #        connection_class=EIEIOConnection)

        testdir = tempfile.mkdtemp()
        print(testdir)
        # Create buffer manager
        bm = BufferManager(
            placements=pl, tags=t, transceiver=trnx, extra_monitor_cores=None,
            packet_gather_cores_to_ethernet_connection_map=None,
            extra_monitor_to_chip_mapping=None, machine=None,
            fixed_routes=None, uses_advanced_monitors=True,
            report_folder=testdir)

        # Register two listeners, and check the second listener uses the
        # first rather than creating a new one
        bm._add_buffer_listeners(vertex=v1)
        bm._add_buffer_listeners(vertex=v2)

        number_of_listeners = 0
        for i in bm._transceiver._udp_listenable_connections_by_class[
                EIEIOConnection]:
            # Check if listener is registered on connection - we only expect
            # one listener to be registered, as all connections can use the
            # same listener for the buffer manager
            if not i[1] is None:
                number_of_listeners += 1
            print(i)
        self.assertEqual(number_of_listeners, 1)