@SuppressWarnings("unchecked") public static ContainerDescription createContainerDescription(ContainerState state) { ContainerDescription containerDescription = new ContainerDescription();
validate(hostSpec); hostSpec.uri = getDockerHostUri(hostSpec.hostState);
long startTime = Utils.getNowMicrosUtc(); ContainerDescription desc1 = new ContainerDescription(); desc1.image = image1; doPost(desc1, ContainerDescriptionService.FACTORY_LINK); ContainerDescription desc2 = new ContainerDescription(); desc2.documentSelfLink = "image"; desc2.image = image1; long timeAfterDesc1 = Utils.getNowMicrosUtc(); desc1 = new ContainerDescription(); desc1.image = image2; doPost(desc1, ContainerDescriptionService.FACTORY_LINK); ContainerDescription desc3 = new ContainerDescription(); desc3.documentSelfLink = "image2"; desc3.image = image2;
ConfigurationUtil.initialize(config); ContainerDescription containerDescription = new ContainerDescription(); containerDescription.name = "testContainer"; containerDescription.image = "registry.hub.docker.com/nginx";
assertNotNull(service, "service"); ContainerDescription description = new ContainerDescription();
ContainerDescription patch = new ContainerDescription(); patch.links = newLinksList .toArray(new String[newLinksList
host, new ContainerDescription());
host, new ContainerDescription());
public static ContainerDescription createContainerDescription(String name, boolean isCloned, boolean exposePorts) { ContainerDescription containerDesc = new ContainerDescription(); containerDesc.documentSelfLink = CONTAINER_DESC_LINK_NAME; containerDesc.name = name;
assertEquals(0, descs.size()); ContainerDescription desc = new ContainerDescription(); desc.image = image1; desc = doPost(desc, ContainerDescriptionService.FACTORY_LINK);
private void initObjectsWithTwoContainers() throws Throwable { ContainerDescription firstContainer = new ContainerDescription(); firstContainer.name = "testContainer1"; firstContainer.image = "registry.hub.docker.com/nginx"; firstContainer.tenantLinks.add("/tenants/qe/groups/dftyguhijokpl"); ContainerDescription secondContainer = new ContainerDescription(); secondContainer.name = "testContainer2"; secondContainer.image = "registry.hub.docker.com/kitematic/hello-world-nginx";
host, new ContainerDescription());
}).when(host).sendRequest(Mockito.any(Operation.class)); ContainerDescription containerDescription = new ContainerDescription(); containerDescription.networks = Collections.singletonMap("some-network", null);
String testSelfLink = "test-link234"; ContainerDescription desc = new ContainerDescription(); desc.documentSelfLink = testSelfLink; desc.image = image1; ContainerDescription updatedDesc = new ContainerDescription(); updatedDesc.documentSelfLink = testSelfLink; updatedDesc.image = image2; assertTrue(ServiceDocument.isDeleted(descs.get(0))); desc = new ContainerDescription(); desc.documentSelfLink = testSelfLink; desc.image = image1;
host, new ContainerDescription());
@Test public void testPutExpanded() throws Throwable { ContainerDescription container = new ContainerDescription(); container.name = "container"; container.image = "registry.hub.docker.com/kitematic/hello-world-nginx"; container = doPost(container, ContainerDescriptionService.FACTORY_LINK); ComponentDescription containerComponent = new ComponentDescription(); containerComponent.name = "container"; container.name = "updated"; containerComponent.updateServiceDocument(container); containerComponent.type = ResourceType.CONTAINER_TYPE.getContentType(); CompositeDescription cd = new CompositeDescription(); cd.name = "testComposite"; cd = doPost(cd, CompositeDescriptionFactoryService.SELF_LINK); // Make PUT but as expanded state, so that components are also updated CompositeDescriptionExpanded cdUpdate = new CompositeDescriptionExpanded(); cdUpdate.documentSelfLink = cd.documentSelfLink; cdUpdate.name = cd.name; cdUpdate.componentDescriptions = new ArrayList<>(); cdUpdate.componentDescriptions.add(containerComponent); cdUpdate = doPut(cdUpdate); // Explicitly search for document to validate that the list returns the right document kind CompositeDescription foundCd = searchForDocument(CompositeDescription.class, cd.documentSelfLink); assertEquals(Utils.buildKind(CompositeDescription.class), foundCd.documentKind); container = getDocument(ContainerDescription.class, container.documentSelfLink); assertEquals("updated", container.name); }
private CompositeDescription createCompositeDescription(String name) throws Throwable { ContainerDescription firstContainer = new ContainerDescription(); firstContainer.name = "testContainer"; firstContainer.image = "registry.hub.docker.com/nginx"; firstContainer._cluster = 1; firstContainer.maximumRetryCount = 1; firstContainer.privileged = true; firstContainer.affinity = new String[] { "cond1", "cond2" }; firstContainer.customProperties = new HashMap<String, String>(); firstContainer.customProperties.put("key1", "value1"); firstContainer.customProperties.put("key2", "value2"); ContainerDescription createdFirstContainer = doPost(firstContainer, ContainerDescriptionService.FACTORY_LINK); ContainerDescription secondContainer = new ContainerDescription(); secondContainer.name = "testContainer2"; secondContainer.image = "registry.hub.docker.com/kitematic/hello-world-nginx"; ContainerDescription createdSecondContainer = doPost(secondContainer, ContainerDescriptionService.FACTORY_LINK); CompositeDescription composite = new CompositeDescription(); composite.name = "name"; composite.customProperties = new HashMap<String, String>(); composite.customProperties.put("key1", "value1"); composite.customProperties.put("key2", "value2"); composite.descriptionLinks = new ArrayList<String>(); composite.descriptionLinks.add(createdFirstContainer.documentSelfLink); composite.descriptionLinks.add(createdSecondContainer.documentSelfLink); return doPost(composite, CompositeDescriptionService.FACTORY_LINK); }
@Test public void testEvaluateBindingsRecursively() { /** * A has a binding to B and B has a binding to C */ ContainerDescription firstDescription = new ContainerDescription(); firstDescription.name = "A"; ContainerDescription secondDescription = new ContainerDescription(); secondDescription.name = "B"; ContainerDescription thirdDescription = new ContainerDescription(); thirdDescription.name = "C"; thirdDescription.memoryLimit = 5L; List<Binding> aBindings = Arrays .asList(binding(Arrays.asList("memory_limit"), "B~memory_limit")); Binding.ComponentBinding aComponentBinding = new Binding.ComponentBinding("A", aBindings); List<Binding> bBindings = Arrays .asList(binding(Arrays.asList("memory_limit"), "C~memory_limit")); Binding.ComponentBinding bComponentBinding = new Binding.ComponentBinding("B", bBindings); CompositeTemplate compositeTemplate = createCompositeTemplate(Arrays .asList(firstDescription, secondDescription, thirdDescription), Arrays.asList(bComponentBinding, aComponentBinding)); BindingEvaluator.evaluateBindings(compositeTemplate); firstDescription = (ContainerDescription) compositeTemplate.components.get("A").data; secondDescription = (ContainerDescription) compositeTemplate.components.get("B").data; thirdDescription = (ContainerDescription) compositeTemplate.components.get("C").data; assertEquals(firstDescription.memoryLimit, thirdDescription.memoryLimit); assertEquals(secondDescription.memoryLimit, thirdDescription.memoryLimit); }
@Test public void testEvaluateComplexBindingsRecursively() { /** * A has a binding to B and B has a binding to C */ ContainerDescription firstDescription = new ContainerDescription(); firstDescription.name = "A"; ContainerDescription secondDescription = new ContainerDescription(); secondDescription.name = "B"; ContainerDescription thirdDescription = new ContainerDescription(); thirdDescription.name = "C"; thirdDescription.memoryLimit = 5L; List<Binding> aBindings = Arrays .asList(binding(Arrays.asList("memory_limit"), "B~memory_swap_limit")); Binding.ComponentBinding aComponentBinding = new Binding.ComponentBinding("A", aBindings); List<Binding> bBindings = Arrays .asList(binding(Arrays.asList("memory_swap_limit"), "C~memory_limit")); Binding.ComponentBinding bComponentBinding = new Binding.ComponentBinding("B", bBindings); CompositeTemplate compositeTemplate = createCompositeTemplate(Arrays .asList(firstDescription, secondDescription, thirdDescription), Arrays.asList(bComponentBinding, aComponentBinding)); BindingEvaluator.evaluateBindings(compositeTemplate); firstDescription = (ContainerDescription) compositeTemplate.components.get("A").data; secondDescription = (ContainerDescription) compositeTemplate.components.get("B").data; thirdDescription = (ContainerDescription) compositeTemplate.components.get("C").data; assertEquals(firstDescription.memoryLimit, thirdDescription.memoryLimit); assertEquals(secondDescription.memorySwapLimit, thirdDescription.memoryLimit); }
@Before public void initObjects() throws Throwable { ContainerDescription firstContainer = new ContainerDescription(); firstContainer.name = "testContainer"; firstContainer.image = "registry.hub.docker.com/nginx"; firstContainer._cluster = 1; firstContainer.maximumRetryCount = 1; firstContainer.privileged = true; firstContainer.affinity = new String[] { "cond1", "cond2" }; firstContainer.customProperties = new HashMap<String, String>(); firstContainer.customProperties.put("key1", "value1"); firstContainer.customProperties.put("key2", "value2"); createdFirstContainer = doPost(firstContainer, ContainerDescriptionService.FACTORY_LINK); ContainerDescription secondContainer = new ContainerDescription(); secondContainer.name = "testContainer2"; secondContainer.image = "registry.hub.docker.com/kitematic/hello-world-nginx"; createdSecondContainer = doPost(secondContainer, ContainerDescriptionService.FACTORY_LINK); CompositeDescription composite = new CompositeDescription(); composite.name = "testComposite"; composite.customProperties = new HashMap<String, String>(); composite.customProperties.put("key1", "value1"); composite.customProperties.put("key2", "value2"); composite.descriptionLinks = new ArrayList<String>(); composite.descriptionLinks.add(createdFirstContainer.documentSelfLink); composite.descriptionLinks.add(createdSecondContainer.documentSelfLink); createdComposite = doPost(composite, CompositeDescriptionService.FACTORY_LINK); }