|
|
@@ -8,6 +8,8 @@ Exercises service CRUD operations via the Coriolis REST API.
|
|
|
|
|
|
import socket
|
|
|
|
|
|
+from keystoneauth1.exceptions import http as http_exc
|
|
|
+
|
|
|
from coriolis.tests.integration import base
|
|
|
|
|
|
|
|
|
@@ -55,3 +57,35 @@ class ServiceTests(base.CoriolisIntegrationTestBase):
|
|
|
services = self._client.services.list()
|
|
|
ids = [s.id for s in services]
|
|
|
self.assertNotIn(svc.id, ids)
|
|
|
+ self.assertRaises(
|
|
|
+ http_exc.NotFound, self._client.services.get, svc.id)
|
|
|
+
|
|
|
+ def test_service_registration_conflict(self):
|
|
|
+ # ConductorServerEndpoint.register_service raises Conflict when a
|
|
|
+ # service with the same host / binary / topic is already registered.
|
|
|
+ hostname = socket.gethostname()
|
|
|
+ svc = self._create_service(
|
|
|
+ hostname, "conflict-binary", "coriolis_worker")
|
|
|
+
|
|
|
+ self.assertRaises(
|
|
|
+ http_exc.Conflict,
|
|
|
+ self._client.services.create,
|
|
|
+ host=hostname, binary="conflict-binary",
|
|
|
+ topic="coriolis_worker", regions=[])
|
|
|
+
|
|
|
+ self._client.services.delete(svc.id)
|
|
|
+
|
|
|
+ def test_service_registration_with_region(self):
|
|
|
+ # Creates a service with a mapped region.
|
|
|
+ region = self._client.regions.create("service-test-region")
|
|
|
+ self.addCleanup(
|
|
|
+ self._ignoreExc(self._client.regions.delete), region.id)
|
|
|
+
|
|
|
+ hostname = socket.gethostname()
|
|
|
+ svc = self._client.services.create(
|
|
|
+ host=hostname, binary="region-binary", topic="coriolis_worker",
|
|
|
+ regions=[region.id])
|
|
|
+ self.addCleanup(self._ignoreExc(self._client.services.delete), svc.id)
|
|
|
+
|
|
|
+ fetched = self._client.services.get(svc.id)
|
|
|
+ self.assertIn(region.id, fetched.mapped_regions)
|