예제 #1
0
 def test_progress(self):
     err, res = command.get_progress(test_topo[0][3], port, 100000)
     print(res)
     self.assertIsNone(err)
     self.assertGreater(res['progress'], 0)
     err, res = command.get_progress(test_topo[0][2], port, 100000)
     print(res)
     self.assertIsNone(err)
     self.assertGreater(res['progress'], 0)
예제 #2
0
 def test_speed(self):
     time.sleep(20)
     # 20s * 200 * 10^6bit/s / 8bit/byte = 500 * 10^6 bytes
     err, res = command.get_progress(test_topo[0][3], port, 0)
     self.assertIsNone(err)
     self.assertGreater(res['progress'], 500000000 * 0.8)
     self.assertLess(res['progress'], 500000000 / 0.8)
     err, res = command.get_progress(test_topo[0][2], port, 0)
     self.assertIsNone(err)
     self.assertGreater(res['progress'], 500000000 * 0.8)
     self.assertLess(res['progress'], 500000000 / 0.8)
예제 #3
0
 def test_speed(self):
     time.sleep(20)
     # 20s * 200 * 10^6bit/s / 8bit/byte = 500 * 10^6 bytes
     for i in range(0, 20):
         elapse = time.time() - self.start_time[i]
         err, res = command.get_progress(test_topo[0][3], port, i)
         self.assertIsNone(err)
         self.assertGreater(res['progress'],
                            200000000 / 20 * elapse / 8 * 0.8)
         self.assertLess(res['progress'], 200000000 / 20 * elapse / 8 / 0.8)
         err, res = command.get_progress(test_topo[0][2], port, i)
         self.assertIsNone(err)
         self.assertGreater(res['progress'],
                            200000000 / 20 * elapse / 8 * 0.8)
         self.assertLess(res['progress'], 200000000 / 20 * elapse / 8 / 0.8)
예제 #4
0
    def test_clean_restart(self):
        err = command.clean_all(test_topo[0][2], port)
        self.assertIsNone(err)
        err = command.clean_all(test_topo[0][3], port)
        self.assertIsNone(err)

        err = command.receive(test_topo[0][3], port, 0, 1000)
        self.assertIsNone(err)
        err = command.send(test_topo[0][2], port, 0, test_topo[0][3], 1000,
                           1000000)
        self.assertIsNone(err)
        time.sleep(5)
        err, res = command.get_progress(test_topo[0][3], port, 0)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
        err, res = command.get_progress(test_topo[0][2], port, 0)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
예제 #5
0
def test_issue():
    commands = parse("issue2.log")
    id_ip_map = {}
    cur_time = 0
    for command_time in commands:
        if command_time > cur_time:
            time.sleep(command_time - cur_time)
            cur_time = command_time

        for command_item in commands[command_time]:
            print(command_item)
            if command_item["type"] == "cleanAll":
                err = command.clean_all(command_item["host"], port)
                if err:
                    print(cur_time)
                    print(command_item)
                    print(err)
            elif command_item["type"] == "progress":
                err = command.get_progress(command_item["host"], port,
                                           command_item["id"])
                if err:
                    print(cur_time)
                    print(command_item)
                    print(err)
            elif command_item["type"] == "updateRate":
                err = command.update_rate(command_item["host"], port,
                                          command_item["id"],
                                          command_item["rate"])
                if err:
                    print(cur_time)
                    print(command_item)
                    print(err)
            elif command_item["type"] == "receive":
                err = command.receive(command_item["host"], port,
                                      command_item["id"], command_item["port"])
                if err:
                    print(cur_time)
                    print(command_item)
                    print(err)
                id_ip_map[command_item["id"]] = command_item["host"]
            elif command_item["type"] == "send":
                if id_ip_map.get(command_item["id"], None) is None:
                    print("id_ip_map is none")
                err = command.send(command_item["host"], port,
                                   command_item["id"],
                                   id_ip_map[command_item["id"]],
                                   command_item["port"], command_item["rate"])
                if err:
                    print(cur_time)
                    print(command_item)
                    print(err)
예제 #6
0
    def test_issue(self):
        err = command.receive("192.168.1.13", port, 0, 1000)
        self.assertIsNone(err)
        err = command.send("192.168.1.7", port, 0, "10.10.10.12", 1000, 16666666)
        self.assertIsNone(err)
        err = command.receive("192.168.1.10", port, 1, 1001)
        self.assertIsNone(err)
        err = command.send("192.168.1.4", port, 1, "10.10.10.9", 1001, 16666666)
        self.assertIsNone(err)
        err = command.receive("192.168.1.13", port, 2, 1002)
        self.assertIsNone(err)
        err = command.send("192.168.1.7", port, 2, "10.10.10.12", 1002, 16666666)
        self.assertIsNone(err)

        time.sleep(10)
        err, res = command.get_progress("192.168.1.7", port, 0)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
        err, res = command.get_progress("192.168.1.7", port, 2)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
        err, res = command.get_progress("192.168.1.4", port, 1)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
예제 #7
0
    def test_port_reuse(self):
        # Use a different transfer ID and the same port number
        # DCCastHost will try to create NORM instance but fail at NORMStartReceiver
        err = command.receive(test_topo[0][3], port, 1, 1000)
        self.assertEqual(err, "Timeout when waiting for response")
        err = command.send(test_topo[0][2], port, 1, test_topo[0][3], 1000,
                           1000000)
        self.assertEqual(err, "Timeout when waiting for response")

        # If we use a different port, we should see transmission
        err = command.receive(test_topo[0][3], port, 1, 1001)
        self.assertEqual(err, None)
        err = command.send(test_topo[0][2], port, 1, test_topo[0][3], 1001,
                           1000000)
        self.assertEqual(err, None)

        time.sleep(5)

        err, res = command.get_progress(test_topo[0][3], port, 1)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
        err, res = command.get_progress(test_topo[0][2], port, 1)
        self.assertIsNone(err)
        self.assertGreater(res['progress'], 0)
예제 #8
0
    time.sleep(30)

    err = command.terminate(nodes[0], 9080, 0)
    if err:
        print(err)
        break
    err = command.terminate(nodes[1], 9080, 0)
    if err:
        print(err)
        break

    end_time = time.time()

    time.sleep(5)

    err, res_sender = command.get_progress(nodes[0], 9080, 0)
    if err:
        print(err)
        break

    err, res_receiver = command.get_progress(nodes[1], 9080, 0)
    if err:
        print(err)
        break

    expected = m * (end_time - start_time)

    success = True
    print("Expect {} bits".format(expected))
    print("Sender sends {} bits".format(res_sender["progress"] * 8))
    print("Receiver receives {} bits".format(res_receiver["progress"] * 8))
예제 #9
0
time.sleep(30)

end_time = time.time()

total_count = 0

for i in range(num_sender):
    err = command.terminate(nodes[0], 9080, i)
    if err:
        print(err)
    err = command.terminate(nodes[1], 9080, i)
    if err:
        print(err)

    err, receive_res = command.get_progress(nodes[1], 9080, i)
    if err:
        print(err)
    print(
        "Node {} transfer {} receives {} bytes | expected speed: {} | actual speed: {}"
        .format(1, i, receive_res["progress"], bandwidth // num_sender,
                receive_res["progress"] * 8 // (end_time - start_time)))
    total_count += receive_res["progress"]

    err, send_res = command.get_progress(nodes[0], 9080, i)
    if err:
        print(err)
    print(
        "Node {} transfer {} send {} bytes | expected speed: {} | actual speed: {}"
        .format(0, i, send_res["progress"], bandwidth // num_sender,
                send_res["progress"] * 8 // (end_time - start_time)))