@Test public void createSingleContainerFromApplicationSummary () { ApplicationSummary applicationSummary; String name = UUID.randomUUID().toString(); String applicationId = UUID.randomUUID().toString(); Integer instances = new Random().nextInt(5) + 5; Integer index = new Random().nextInt(instances); applicationSummary = ApplicationSummary.builder() .instances(instances) .name(name) .id(applicationId) .diskQuota(0) .memoryLimit(0) .requestedState(CLOUDFOUNDRY_APPLICATION_STARTED) .runningInstances(instances) .build(); CloudFoundryContainer expectedContainer = CloudFoundryContainer.builder() .applicationId(applicationId) .name(name) .instance(index) .build(); CloudFoundryContainer actualContainer = cloudFoundryContainerPlatform.createSingleContainerFromApplicationSummary(applicationSummary, index); assertEquals(expectedContainer, actualContainer); verify(containerManager, times(1)).offer(actualContainer); reset(containerManager); assertSame(actualContainer, cloudFoundryContainerPlatform.createSingleContainerFromApplicationSummary(applicationSummary, index)); verify(containerManager, times(0)).offer(actualContainer); }
CloudFoundryContainer createSingleContainerFromApplicationSummary (ApplicationSummary applicationSummary, Integer index) { CloudFoundryContainer container = containerManager.getMatchingContainer(CloudFoundryContainer.class, applicationSummary .getName() + "-" + index); if (container == null) { container = CloudFoundryContainer.builder() .applicationId(applicationSummary.getId()) .name(applicationSummary.getName()) .instance(index) .platform(this) .build(); log.debug("Created Cloud Foundry Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), v("ApplicationSummary", applicationSummary)); containerManager.offer(container); } else { log.debug("Found existing Cloud Foundry Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { CloudFoundryContainer createSingleContainerFromApplicationSummary (ApplicationSummary applicationSummary, Integer index) { CloudFoundryContainer container = containerManager.getMatchingContainer(CloudFoundryContainer.class, applicationSummary .getName() + "-" + index); if (container == null) { container = CloudFoundryContainer.builder() .applicationId(applicationSummary.getId()) .name(applicationSummary.getName()) .instance(index) .platform(this) .build(); log.debug("Created Cloud Foundry Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), v("ApplicationSummary", applicationSummary)); containerManager.offer(container); } else { log.debug("Found existing Cloud Foundry Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { CloudFoundryContainer createSingleContainerFromApplicationSummary (ApplicationSummary applicationSummary, Integer index) { CloudFoundryContainer container = containerManager.getMatchingContainer(CloudFoundryContainer.class, applicationSummary .getName() + "-" + index); if (container == null) { container = CloudFoundryContainer.builder() .applicationId(applicationSummary.getId()) .name(applicationSummary.getName()) .instance(index) .platform(this) .build(); log.debug("Created Cloud Foundry Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), v("ApplicationSummary", applicationSummary)); containerManager.offer(container); } else { log.debug("Found existing Cloud Foundry Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } @Autowired  CloudFoundryContainerPlatform(); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { CloudFoundryContainer createSingleContainerFromApplicationSummary (ApplicationSummary applicationSummary, Integer index) { CloudFoundryContainer container = containerManager.getMatchingContainer(CloudFoundryContainer.class, applicationSummary .getName() + "-" + index); if (container == null) { container = CloudFoundryContainer.builder() .applicationId(applicationSummary.getId()) .name(applicationSummary.getName()) .instance(index) .platform(this) .build(); log.debug("Created Cloud Foundry Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), v("ApplicationSummary", applicationSummary)); containerManager.offer(container); } else { log.debug("Found existing Cloud Foundry Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container); }
CloudFoundryContainerPlatform extends CloudFoundryPlatform implements SshBasedExperiment<CloudFoundryContainer> { CloudFoundryContainer createSingleContainerFromApplicationSummary (ApplicationSummary applicationSummary, Integer index) { CloudFoundryContainer container = containerManager.getMatchingContainer(CloudFoundryContainer.class, applicationSummary .getName() + "-" + index); if (container == null) { container = CloudFoundryContainer.builder() .applicationId(applicationSummary.getId()) .name(applicationSummary.getName()) .instance(index) .platform(this) .build(); log.debug("Created Cloud Foundry Container {} from {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container), v("ApplicationSummary", applicationSummary)); containerManager.offer(container); } else { log.debug("Found existing Cloud Foundry Container {}", v(DataDogConstants.DATADOG_CONTAINER_KEY, container)); } return container; } @Autowired  CloudFoundryContainerPlatform(); @Override boolean isContainerRecycled(Container container); ContainerHealth checkHealth(String applicationId, Integer instanceId); @Override List<Container> generateRoster(); void restartInstance(RestartApplicationInstanceRequest restartApplicationInstanceRequest); @Override String getEndpoint(CloudFoundryContainer container); @Override SSHCredentials getSshCredentials(CloudFoundryContainer container); @Override void recycleContainer(CloudFoundryContainer container);  }