private void assertContainerRegistersAfterPoke(final HeliosClient client, final Job job) throws Exception { final JobId jobId = createJob(job); deployJob(jobId, testHost()); awaitTaskState(jobId, testHost(), HEALTHCHECKING); // wait a few seconds to see if the service gets registered Thread.sleep(3000); // shouldn't be registered, since we haven't poked it yet verify(registrar, never()).register(any(ServiceRegistration.class)); pokeAndVerifyRegistration(client, jobId, LONG_WAIT_SECONDS); final ServiceRegistration serviceRegistration = registrationCaptor.getValue(); final Map<String, Endpoint> registered = Maps.newHashMap(); for (final Endpoint endpoint : serviceRegistration.getEndpoints()) { registered.put(endpoint.getName(), endpoint); } assertEquals("wrong service", "foo_service", registered.get("foo_service").getName()); assertEquals("wrong protocol", "foo_proto", registered.get("foo_service").getProtocol()); }
@Test public void test() throws Exception { startDefaultMaster("--service-registry=" + registryAddress); verify(registrar, timeout((int) SECONDS.toMillis(LONG_WAIT_SECONDS))) .register(registrationCaptor.capture()); final ServiceRegistration registration = registrationCaptor.getValue(); final ServiceRegistration.Endpoint endpoint = getOnlyElement(registration.getEndpoints()); assertEquals("http", endpoint.getProtocol()); assertEquals("helios", endpoint.getName()); assertEquals(masterPort(), endpoint.getPort()); } }
for (final Endpoint endpoint : serviceRegistration.getEndpoints()) { registered.put(endpoint.getName(), endpoint);
final ServiceRegistration serviceRegistration = registrationCaptor.getValue(); assertEquals(1, serviceRegistration.getEndpoints().size()); final Endpoint registeredEndpoint = serviceRegistration.getEndpoints().get(0);