Пример #1
0
    def test_reservation_server_multi(self):
        """Test reservation server, expecting multiple reservations"""
        num_clients = 4
        s = Server(num_clients)
        addr = s.start()

        def reserve(num):
            c = Client(addr)
            # time.sleep(random.randint(0,5))     # simulate varying start times
            resp = c.register({'node': num})
            self.assertEqual(resp, 'OK')
            c.await_reservations()
            c.close()

        # start/register clients
        threads = [None] * num_clients
        for i in range(num_clients):
            threads[i] = threading.Thread(target=reserve, args=(i, ))
            threads[i].start()

        # wait for clients to complete
        for i in range(num_clients):
            threads[i].join()
        print("all done")

        # get list of reservations
        c = Client(addr)
        reservations = c.get_reservations()
        self.assertEqual(len(reservations), num_clients)

        # request server stop
        c.request_stop()
        time.sleep(1)
        self.assertEqual(s.done, True)
    def test_reservation_server_multi(self):
        # start reservation server expecting num_clients reservations
        num_clients = 4
        s = Server(num_clients)
        addr = s.start()

        def reserve(num):
            c = Client(addr)
            #time.sleep(random.randint(0,5))     # simulate varying start times
            resp = c.register({'node':num})
            self.assertEqual(resp, 'OK')
            c.await_reservations()
            c.close()

        # start/register clients
        threads = [None] * num_clients
        for i in range(num_clients):
            threads[i] = threading.Thread(target=reserve, args=(i,))
            threads[i].start()

        # wait for clients to complete
        for i in range(num_clients):
            threads[i].join()
        print("all done")

        # get list of reservations
        c = Client(addr)
        reservations = c.get_reservations()
        self.assertEquals(len(reservations), num_clients)

        # request server stop
        c.request_stop()
        self.assertEquals(s.done, True)
Пример #3
0
 def reserve(num):
     c = Client(addr)
     # time.sleep(random.randint(0,5))     # simulate varying start times
     resp = c.register({'node': num})
     self.assertEqual(resp, 'OK')
     c.await_reservations()
     c.close()
 def reserve(num):
     c = Client(addr)
     #time.sleep(random.randint(0,5))     # simulate varying start times
     resp = c.register({'node':num})
     self.assertEqual(resp, 'OK')
     c.await_reservations()
     c.close()
  def test_reservation_server(self):
    """Test reservation server, expecting 1 reservation"""
    s = Server(1)
    addr = s.start()

    # add first reservation
    c = Client(addr)
    resp = c.register({'node': 1})
    self.assertEqual(resp, 'OK')

    # get list of reservations
    reservations = c.get_reservations()
    self.assertEqual(len(reservations), 1)

    # should return immediately with list of reservations
    reservations = c.await_reservations()
    self.assertEqual(len(reservations), 1)

    # request server stop
    c.request_stop()
    self.assertEqual(s.done, True)
    def test_reservation_server(self):
        # start reservation server expecting 1 reservation
        s = Server(1)
        addr = s.start()

        # add first reservation
        c = Client(addr)
        resp = c.register({'node':1})
        self.assertEqual(resp, 'OK')

        # get list of reservations
        reservations = c.get_reservations()
        self.assertEquals(len(reservations), 1)

        # should return immediately with list of reservations
        reservations = c.await_reservations()
        self.assertEquals(len(reservations), 1)

        # request server stop
        c.request_stop()
        self.assertEquals(s.done, True)