@Test public void testCreateClusterWithIntercept() throws Throwable { ContainerHostSpec hostSpec = new ContainerHostSpec(); hostSpec.hostState = new ComputeState(); hostSpec.hostState.id = UUID.randomUUID().toString(); hostSpec.hostState.address = "test"; hostSpec.hostState.customProperties = new HashMap<>(); hostSpec.hostState.customProperties.put(ContainerHostService .HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, "API"); hostSpec.hostState.customProperties.put(ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, "DOCKER"); ClusterDto dto = doPostWithProjectHeader(hostSpec, ClusterService.SELF_LINK, project .documentSelfLink, ClusterDto.class); ComputeState computeState = getDocument(ComputeState.class, dto.nodeLinks.get(0)); assertTrue(computeState.tenantLinks.contains(project.documentSelfLink)); }
@Test public void testCreateRegistryThroughRegistryHostconfigServiceWithIntercept() throws Throwable { String uuid = UUID.randomUUID().toString(); RegistryHostSpec hostSpec = new RegistryHostSpec(); hostSpec.hostState = new RegistryState(); hostSpec.hostState.address = uuid; hostSpec.hostState.name = uuid; hostSpec.hostState.endpointType = RegistryState.DOCKER_REGISTRY_ENDPOINT_TYPE; hostSpec.acceptHostAddress = true; String[] registryLink = new String[1]; Operation put = Operation.createPut(host, RegistryHostConfigService.SELF_LINK) .setReferer("/") .addRequestHeader(OperationUtil.PROJECT_ADMIRAL_HEADER, project.documentSelfLink) .setBodyNoCloning(hostSpec) .setCompletion((o, ex) -> { if (ex != null) { host.log(Level.SEVERE, "Failed to create registry: %s", Utils.toString(ex)); host.failIteration(ex); } else { registryLink[0] = o.getResponseHeader(Operation.LOCATION_HEADER); host.completeIteration(); } }); host.testStart(1); host.send(put); host.testWait(); assertNotNull("Registry link must not be null after creation.", registryLink[0]); RegistryState registryState = getDocument(RegistryState.class, registryLink[0]); assertTrue(registryState.tenantLinks.contains(project.documentSelfLink)); }