def test_with_standard_ips(): board_locations = {(x, y, z): (x, y, z) for x in range(2) for y in range(2) for z in range(3)} m = Machine.with_standard_ips("m", board_locations=board_locations) assert m.bmp_ips == { (0, 0): "192.168.0.0", (0, 1): "192.168.1.0", (1, 0): "192.168.5.0", (1, 1): "192.168.6.0", } assert m.spinnaker_ips == { (0, 0, 0): "192.168.0.1", (0, 0, 1): "192.168.0.9", (0, 0, 2): "192.168.0.17", (0, 1, 0): "192.168.1.1", (0, 1, 1): "192.168.1.9", (0, 1, 2): "192.168.1.17", (1, 0, 0): "192.168.5.1", (1, 0, 1): "192.168.5.9", (1, 0, 2): "192.168.5.17", (1, 1, 0): "192.168.6.1", (1, 1, 1): "192.168.6.9", (1, 1, 2): "192.168.6.17", }
def test_with_standard_ips(): board_locations = {(x, y, z): (x, y, z) for x in range(2) for y in range(2) for z in range(3)} m = Machine.with_standard_ips("m", board_locations=board_locations) assert m.bmp_ips == { (0, 0): "192.168.0.0", (0, 1): "192.168.1.0", (1, 0): "192.168.5.0", (1, 1): "192.168.6.0", } assert m.spinnaker_ips == { (0, 0, 0): "192.168.0.1", (0, 0, 1): "192.168.0.9", (0, 0, 2): "192.168.0.17", (0, 1, 0): "192.168.1.1", (0, 1, 1): "192.168.1.9", (0, 1, 2): "192.168.1.17", (1, 0, 0): "192.168.5.1", (1, 0, 1): "192.168.5.9", (1, 0, 2): "192.168.5.17", (1, 1, 0): "192.168.6.1", (1, 1, 1): "192.168.6.9", (1, 1, 2): "192.168.6.17", }
def big_m_with_hole(conn): """Add a larger 4x2 machine to the controller with board (2, 1, 0) dead.""" conn.machines = { "big_m": Machine.with_standard_ips(name="big_m", dead_boards=set([(2, 1, 0)]), board_locations={(x, y, z): (x * 10, y * 10, z * 10) for x in range(4) for y in range(2) for z in range(3) if (x, y, z) != (2, 1, 0)}), } return "big_m"
def test_with_standard_ips_bad_ias(): board_locations = {(x, y, z): (x, y, z) for x in range(2) for y in range(2) for z in range(3)} # Not IPv4 address with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="spinn-4") # Malformed IPv4 addresses with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="1.2.3") with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="-1.2.3.4") with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="256.2.3.4")
def test_with_standard_ips_bad_ias(): board_locations = {(x, y, z): (x, y, z) for x in range(2) for y in range(2) for z in range(3)} # Not IPv4 address with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="spinn-4") # Malformed IPv4 addresses with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="1.2.3") with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="-1.2.3.4") with pytest.raises(ValueError): Machine.with_standard_ips("m", board_locations=board_locations, base_ip="256.2.3.4")