resourcePool.name = clusterName; } else { resourcePool.name = buildPlacementZoneDefaultName(hostType, hostState.address);
@Test public void testGetVchCluster() throws Throwable { final String projectLink = buildProjectLink("test-vch-project"); PlacementZoneUtil.buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS); ContainerHostSpec hostSpec = createContainerHostSpec(Collections.singletonList(projectLink), ContainerHostType.VCH); // mark the host as vch hostSpec.hostState.customProperties.put(PROPERTY_NAME_DRIVER, VMWARE_VIC_DRIVER1); ClusterDto clusterDto = createCluster(hostSpec); assertNotNull(clusterDto.nodeLinks); assertNotNull(clusterDto.nodes); assertEquals(1, clusterDto.nodes.size()); // verify the whole compute object is returned ComputeState vchHost = clusterDto.nodes.values().iterator().next(); assertNotNull(vchHost.customProperties); assertTrue(vchHost.customProperties.size() > 0); }
@Test public void testCreateVchCluster() throws Throwable { final String projectLink = buildProjectLink("test-vch-project"); final String placementZoneName = PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS); ContainerHostSpec hostSpec = createContainerHostSpec(Collections.singletonList(projectLink), ContainerHostType.VCH); verifyCluster(createCluster(hostSpec), ClusterType.VCH, placementZoneName, projectLink); }
@Test public void testDeleteVchCluster() throws Throwable { final String projectLink = buildProjectLink("test-vch-project"); final String placementZoneName = PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS); ContainerHostSpec hostSpec = createContainerHostSpec(Collections.singletonList(projectLink), ContainerHostType.VCH); ClusterDto clusterDto = createCluster(hostSpec); verifyCluster(clusterDto, ClusterType.VCH, placementZoneName, projectLink); Map<String, ClusterDto> allClustersExpand = getClustersExpand(); assertTrue(allClustersExpand.keySet().size() == 2); assertTrue(allClustersExpand.keySet().contains(clusterDto.documentSelfLink)); Map<String, ComputeState> allComputesExpand = getAllComputeExpand(); assertTrue(allComputesExpand.keySet().size() == 1); List<String> placementZonesLinks = getPlacementZonesLinks(); assertEquals(2, placementZonesLinks.size()); List<String> placementsLinks = getPlacementsLinks(); assertEquals(2, placementsLinks.size()); deleteCluster(Service.getId(clusterDto.documentSelfLink)); allClustersExpand = getClustersExpand(); assertTrue(allClustersExpand.keySet().size() == 1); assertTrue(!allClustersExpand.keySet().contains(clusterDto.documentSelfLink)); allComputesExpand = getAllComputeExpand(); assertTrue(allComputesExpand.keySet().isEmpty()); placementZonesLinks = getPlacementZonesLinks(); assertEquals(1, placementZonesLinks.size()); placementsLinks = getPlacementsLinks(); assertEquals(1, placementsLinks.size()); }
@Test(expected = LocalizableValidationException.class) public void testAddHostInVCHCluster() throws Throwable { final String projectLinkVCH = buildProjectLink("test-vch-project"); PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS); ContainerHostSpec hostSpecVCH = createContainerHostSpec( Collections.singletonList(projectLinkVCH), ContainerHostType.VCH); ClusterDto clusterVCH = createCluster(hostSpecVCH); ContainerHostSpec hostSpecDocker1 = createContainerHostSpec(projectLinkVCH); addHostInCluster(Service.getId(clusterVCH.documentSelfLink), hostSpecDocker1); }
@Test public void testDeleteDockerCluster() throws Throwable { final String projectLink = buildProjectLink("test-docker-project"); final String placementZoneName = PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); ContainerHostSpec hostSpec = createContainerHostSpec(Collections.singletonList(projectLink), ContainerHostType.DOCKER); ClusterDto clusterDto = createCluster(hostSpec); verifyCluster(clusterDto, ClusterType.DOCKER, placementZoneName, projectLink); Map<String, ClusterDto> allClustersExpand = getClustersExpand(); assertTrue(allClustersExpand.keySet().size() == 2); assertTrue(allClustersExpand.keySet().contains(clusterDto.documentSelfLink)); Map<String, ComputeState> allComputesExpand = getAllComputeExpand(); assertTrue(allComputesExpand.keySet().size() == 1); List<String> placementZonesLinks = getPlacementZonesLinks(); assertEquals(2, placementZonesLinks.size()); List<String> placementsLinks = getPlacementsLinks(); assertEquals(2, placementsLinks.size()); deleteCluster(Service.getId(clusterDto.documentSelfLink)); allClustersExpand = getClustersExpand(); assertTrue(allClustersExpand.keySet().size() == 1); assertTrue(!allClustersExpand.keySet().contains(clusterDto.documentSelfLink)); allComputesExpand = getAllComputeExpand(); assertTrue(allComputesExpand.keySet().isEmpty()); placementZonesLinks = getPlacementZonesLinks(); assertEquals(1, placementZonesLinks.size()); placementsLinks = getPlacementsLinks(); assertEquals(1, placementsLinks.size()); }
@Test public void testGetSingleHostsInCluster() throws Throwable { final String projectLinkDocker = buildProjectLink("test-docker-project"); PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); ContainerHostSpec hostSpecDocker = createContainerHostSpec( Collections.singletonList(projectLinkDocker), ContainerHostType.DOCKER); final String projectLinkVCH = buildProjectLink("test-vch-project"); PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS); ContainerHostSpec hostSpecVCH = createContainerHostSpec( Collections.singletonList(projectLinkVCH), ContainerHostType.VCH); ClusterDto clusterDocker = createCluster(hostSpecDocker); ClusterDto clusterVCH = createCluster(hostSpecVCH); ComputeState cs = getSingleHostInOneCluster( Service.getId(clusterDocker.documentSelfLink), Service.getId(clusterDocker.nodeLinks.get(0)), false); assertNotNull(cs); assertEquals(clusterDocker.nodeLinks.get(0), cs.documentSelfLink); cs = getSingleHostInOneCluster( Service.getId(clusterVCH.documentSelfLink), Service.getId(clusterDocker.nodeLinks.get(0)), true); assertTrue(cs == null); }
@Test public void testCreateDockerCluster() throws Throwable { final String projectLink = buildProjectLink("test-docker-project"); final String placementZoneName = PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); ContainerHostSpec hostSpec = createContainerHostSpec(Collections.singletonList(projectLink), ContainerHostType.DOCKER); ClusterDto clusterDto = createCluster(hostSpec); verifyCluster(clusterDto, ClusterType.DOCKER, placementZoneName, projectLink); // create the host with the specified id assertNotNull(hostSpec.hostState.id); assertNotEquals("", hostSpec.hostState.id); ComputeState host = getDocument(ComputeState.class, clusterDto.nodeLinks.get(0)); assertEquals(hostSpec.hostState.id, host.id); }
@Test public void testGetOneCluster() throws Throwable { final String projectLinkDocker = buildProjectLink("test-docker-project"); final String placementZoneNameDocker = PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); ContainerHostSpec hostSpecDocker = createContainerHostSpec( Collections.singletonList(projectLinkDocker), ContainerHostType.DOCKER); ClusterDto clusterDocker = createCluster(hostSpecDocker); clusterDocker = getOneCluster(Service.getId(clusterDocker.documentSelfLink)); assertNotNull(clusterDocker); assertEquals(placementZoneNameDocker, clusterDocker.name); }
final String projectLinkDocker = buildProjectLink("test-docker-project"); final String placementZoneNameDocker = PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); .buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS);
final String projectLinkDocker = buildProjectLink("test-docker-project"); PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); .buildPlacementZoneDefaultName(ContainerHostType.VCH, COMPUTE_ADDRESS);
final String projectLinkDocker = buildProjectLink("test-docker-project"); PlacementZoneUtil .buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS);
@Test public void testPatchCluster() throws Throwable { final String name1 = "name_1"; final String details1 = "details_1"; final String name2 = "name_2"; final String details2 = "details_2"; final String projectLinkDocker = buildProjectLink("test-docker-project"); PlacementZoneUtil.buildPlacementZoneDefaultName(ContainerHostType.DOCKER, COMPUTE_ADDRESS); ContainerHostSpec hostSpecDocker = createContainerHostSpec( Collections.singletonList(projectLinkDocker), ContainerHostType.DOCKER, name1, details1); ClusterDto clusterDocker = createCluster(hostSpecDocker); clusterDocker = getOneCluster(Service.getId(clusterDocker.documentSelfLink)); assertNotNull(clusterDocker); assertEquals(name1, clusterDocker.name); assertEquals(details1, clusterDocker.details); ClusterDto patchClusterDto = new ClusterDto(); patchClusterDto.name = name2; patchClusterDto.details = details2; patchClusterDto.documentSelfLink = clusterDocker.documentSelfLink; patchClusterDto = patchCluster(patchClusterDto); assertNotNull(patchClusterDto); assertEquals(name2, patchClusterDto.name); assertEquals(details2, patchClusterDto.details); clusterDocker = getOneCluster(Service.getId(clusterDocker.documentSelfLink)); assertNotNull(clusterDocker); assertEquals(name2, clusterDocker.name); assertEquals(details2, clusterDocker.details); }