@Test public void generateRoster () { GcpComputeInstanceContainer expected = GcpComputeInstanceContainer.builder() .withUniqueIdentifier("12345678901234567890") .build(); InstanceClient.AggregatedListInstancesPagedResponse response = mock(InstanceClient.AggregatedListInstancesPagedResponse.class); Instance instance = Instance.newBuilder().setId("12345678901234567890").build(); Iterable<InstancesScopedList> iterableInstances = List.of(InstancesScopedList.newBuilder() .addInstances(instance) .build()); doReturn(iterableInstances).when(response).iterateAll(); doReturn(response).when(instanceClient).aggregatedListInstances(projectName); assertThat(gcpComputePlatform.generateRoster(), containsInAnyOrder(expected)); verify(gcpComputePlatform).isNotFiltered(instance); }
@Override protected List<Container> generateRoster () { log.debug("Generating roster of GCP Compute instances"); InstanceClient.AggregatedListInstancesPagedResponse instances = getInstanceClient().aggregatedListInstances( getProjectName()); return StreamSupport.stream(instances.iterateAll().spliterator(), false) .map(InstancesScopedList::getInstancesList) .filter(Objects::nonNull) .flatMap(Collection::stream) .filter(not(this::isMe)) .filter(this::isNotFiltered) .map(this::createContainerFromInstance) .peek(container -> log.info("Created container {}", v(DATADOG_CONTAINER_KEY, container))) .collect(Collectors.toList()); }
GcpComputePlatform extends Platform implements SshBasedExperiment<GcpComputeInstanceContainer> { @Override protected List<Container> generateRoster () { log.debug("Generating roster of GCP Compute instances"); InstanceClient.AggregatedListInstancesPagedResponse instances = getInstanceClient().aggregatedListInstances( getProjectName()); return StreamSupport.stream(instances.iterateAll().spliterator(), false) .map(InstancesScopedList::getInstancesList) .filter(Objects::nonNull) .flatMap(Collection::stream) .filter(not(this::isMe)) .filter(this::isNotFiltered) .map(this::createContainerFromInstance) .peek(container -> log.info("Created container {}", v(DATADOG_CONTAINER_KEY, container))) .collect(Collectors.toList()); } }
GcpComputePlatform extends Platform implements SshBasedExperiment<GcpComputeInstanceContainer> { @Override protected List<Container> generateRoster () { log.debug("Generating roster of GCP Compute instances"); InstanceClient.AggregatedListInstancesPagedResponse instances = getInstanceClient().aggregatedListInstances( getProjectName()); return StreamSupport.stream(instances.iterateAll().spliterator(), false) .map(InstancesScopedList::getInstancesList) .filter(Objects::nonNull) .flatMap(Collection::stream) .filter(not(this::isMe)) .filter(this::isNotFiltered) .map(this::createContainerFromInstance) .peek(container -> log.info("Created container {}", v(DATADOG_CONTAINER_KEY, container))) .collect(Collectors.toList()); }  }
GcpComputePlatform extends Platform implements SshBasedExperiment<GcpComputeInstanceContainer> { @Override protected List<Container> generateRoster () { log.debug("Generating roster of GCP Compute instances"); InstanceClient.AggregatedListInstancesPagedResponse instances = getInstanceClient().aggregatedListInstances( getProjectName()); return StreamSupport.stream(instances.iterateAll().spliterator(), false) .map(InstancesScopedList::getInstancesList) .filter(Objects::nonNull) .flatMap(Collection::stream) .filter(not(this::isMe)) .filter(this::isNotFiltered) .map(this::createContainerFromInstance) .peek(container -> log.info("Created container {}", v(DATADOG_CONTAINER_KEY, container))) .collect(Collectors.toList()); }  void setRoutableCIDRBlocks(Collection<String> routableCIDRBlocks); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); Collection<Items> getIncludeFilter(); void setIncludeFilter(Map<String, String> includeFilter); Collection<Items> getExcludeFilter(); void setExcludeFilter(Map<String, String> excludeFilter); @Override boolean isContainerRecycled(Container container); String stopInstance(GcpComputeInstanceContainer container); ContainerHealth isContainerRunning(GcpComputeInstanceContainer gcpComputeInstanceContainer); String simulateMaintenance(GcpComputeInstanceContainer container); String setTags(GcpComputeInstanceContainer container, List<String> tags); String setTagsSafe(GcpComputeInstanceContainer container, List<String> newTags, String oldFingerprint); boolean isContainerGroupAtCapacity(GcpComputeInstanceContainer container); boolean checkTags(GcpComputeInstanceContainer container, List<String> expectedTags); void startInstance(GcpComputeInstanceContainer container); String restartContainer(GcpComputeInstanceContainer container); String getBestEndpoint(String privateIPAddress, String publicIPAddress); boolean isAddressRoutable(String privateIPAddress); String getLatestInstanceId(String instanceName, String zone); Fingerprint<List<String>> getFirewallTags(GcpComputeInstanceContainer container); void setProjectId(String projectId); @Override String getEndpoint(GcpComputeInstanceContainer container); @Override SSHCredentials getSshCredentials(GcpComputeInstanceContainer container); @Override String getRunningDirectory(); @Override void recycleContainer(GcpComputeInstanceContainer container); String recreateInstanceInInstanceGroup(GcpComputeInstanceContainer container); boolean isOperationComplete(String operationId); }
GcpComputePlatform extends Platform implements SshBasedExperiment<GcpComputeInstanceContainer> { @Override protected List<Container> generateRoster () { log.debug("Generating roster of GCP Compute instances"); InstanceClient.AggregatedListInstancesPagedResponse instances = getInstanceClient().aggregatedListInstances( getProjectName()); return StreamSupport.stream(instances.iterateAll().spliterator(), false) .map(InstancesScopedList::getInstancesList) .filter(Objects::nonNull) .flatMap(Collection::stream) .filter(not(this::isMe)) .filter(this::isNotFiltered) .map(this::createContainerFromInstance) .peek(container -> log.info("Created container {}", v(DATADOG_CONTAINER_KEY, container))) .collect(Collectors.toList()); }  void setRoutableCIDRBlocks(Collection<String> routableCIDRBlocks); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); Collection<Items> getIncludeFilter(); void setIncludeFilter(Map<String, String> includeFilter); Collection<Items> getExcludeFilter(); void setExcludeFilter(Map<String, String> excludeFilter); @Override boolean isContainerRecycled(Container container); String stopInstance(GcpComputeInstanceContainer container); ContainerHealth isContainerRunning(GcpComputeInstanceContainer gcpComputeInstanceContainer); String simulateMaintenance(GcpComputeInstanceContainer container); String setTags(GcpComputeInstanceContainer container, List<String> tags); String setTagsSafe(GcpComputeInstanceContainer container, List<String> newTags, String oldFingerprint); boolean isContainerGroupAtCapacity(GcpComputeInstanceContainer container); boolean checkTags(GcpComputeInstanceContainer container, List<String> expectedTags); void startInstance(GcpComputeInstanceContainer container); String restartContainer(GcpComputeInstanceContainer container); String getBestEndpoint(String privateIPAddress, String publicIPAddress); boolean isAddressRoutable(String privateIPAddress); String getLatestInstanceId(String instanceName, String zone); Fingerprint<List<String>> getFirewallTags(GcpComputeInstanceContainer container); void setProjectId(String projectId); @Override String getEndpoint(GcpComputeInstanceContainer container); @Override SSHCredentials getSshCredentials(GcpComputeInstanceContainer container); @Override String getRunningDirectory(); @Override void recycleContainer(GcpComputeInstanceContainer container); String recreateInstanceInInstanceGroup(GcpComputeInstanceContainer container); boolean isOperationComplete(String operationId);  }