def test_register_everything(self): """ Check that we can register a service which listens on multiple ports. """ for i in range(64): response = register("testService", 12312 + i) self.assertEqual(response, "OK")
def test_withdraw_altport(self): """ Withdrawing services on other ports should not affect this one, even if they have the same name. """ response = register("testService1", 12311) self.assertEqual(response, "OK") response = register("testService1", 12312) self.assertEqual(response, "OK") svcs = list(broker("testService1")) self.assertEqual(len(svcs), 2) withdraw("testService1", 12312) svcs = list(broker("testService1")) self.assertEqual(len(svcs), 1)
def test_search(self): """ Test that when we have 400 services (test/0, test/1 etc) that we search for "test/", we can get them all. """ test_svcs = ["test/{}".format(i) for i in range(400)] for svc in test_svcs: response = register(svc, 1211) if response != "OK": raise ValueError(response) response_svcs = search("test/") self.assertEqual(set(response_svcs), set(test_svcs))
def test_withdraw(self): """ Check that withdrawn services are no longer visible in BROKER. """ response = register("testService1", 12311) self.assertEqual(response, "OK") svcs = list(broker("testService1")) self.assertEqual(len(svcs), 1) withdraw("testService1", 12311) svcs = list(broker("testService1")) self.assertEqual(len(svcs), 0)
def test_cmd_invalidates(self): """ Check that the command invalidates everything previously registered and that nothing is returned for previously valid command. """ response = register("clearTestService", 1101) if response != "OK": raise ValueError(response) svcs = list(broker("clearTestService")) if len(svcs) != 1: raise ValueError(len(svcs)) self.assertEqual(clearall(), "OK") svcs = list(broker("clearTestService")) self.assertEqual(len(svcs), 0)
def setUp(self): clearall() register("ReservedTestService", 11819) register("AnotherReservedTestService", 11820) register("MultiReservedTestService", 11821) register("MultiReservedTestService", 11822)
def test_register(self): """ Check that we can register a basic service. """ response = register("testService", 12311) self.assertEqual(response, "OK")