@Test public void getPlatformFailed () { applicationSummary_1 = builder_1.instances(10) .runningInstances(0) .requestedState(CLOUDFOUNDRY_APPLICATION_STARTED) .build(); applicationSummary_2 = builder_2.instances(20) .runningInstances(0) .requestedState(CLOUDFOUNDRY_APPLICATION_STARTED) .build(); Flux<ApplicationSummary> applicationsFlux = Flux.just(applicationSummary_1, applicationSummary_2); doReturn(applications).when(cloudFoundryOperations).applications(); doReturn(applicationsFlux).when(applications).list(); assertEquals(PlatformHealth.FAILED, cfp.getPlatformHealth()); }
@Override public PlatformHealth getPlatformHealth () { Flux<ApplicationSummary> runningInstances = cloudFoundryOperations.applications() .list() .filter(a -> a.getRequestedState().equals(CloudFoundryConstants.CLOUDFOUNDRY_APPLICATION_STARTED)); if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() == 0) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.FAILED; } else if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() < a.getInstances()) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.DEGRADED; } return PlatformHealth.OK; }
CloudFoundryPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Flux<ApplicationSummary> runningInstances = cloudFoundryOperations.applications() .list() .filter(a -> a.getRequestedState().equals(CloudFoundryConstants.CLOUDFOUNDRY_APPLICATION_STARTED)); if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() == 0) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.FAILED; } else if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() < a.getInstances()) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.DEGRADED; } return PlatformHealth.OK; } }
CloudFoundryPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Flux<ApplicationSummary> runningInstances = cloudFoundryOperations.applications() .list() .filter(a -> a.getRequestedState().equals(CloudFoundryConstants.CLOUDFOUNDRY_APPLICATION_STARTED)); if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() == 0) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.FAILED; } else if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() < a.getInstances()) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.DEGRADED; } return PlatformHealth.OK; } @Autowired  CloudFoundryPlatform(); }
CloudFoundryPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Flux<ApplicationSummary> runningInstances = cloudFoundryOperations.applications() .list() .filter(a -> a.getRequestedState().equals(CloudFoundryConstants.CLOUDFOUNDRY_APPLICATION_STARTED)); if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() == 0) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.FAILED; } else if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() < a.getInstances()) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.DEGRADED; } return PlatformHealth.OK; } @Autowired  CloudFoundryPlatform(); boolean isChaosEngine(String applicationName); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateRoster(); void restageApplication(RestageApplicationRequest restageApplicationRequest); }
CloudFoundryPlatform extends Platform { @Override public PlatformHealth getPlatformHealth () { Flux<ApplicationSummary> runningInstances = cloudFoundryOperations.applications() .list() .filter(a -> a.getRequestedState().equals(CloudFoundryConstants.CLOUDFOUNDRY_APPLICATION_STARTED)); if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() == 0) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.FAILED; } else if (runningInstances.filter(a -> a.getInstances() > 0) .filter(a -> a.getRunningInstances() < a.getInstances()) .hasElements() .blockOptional() .orElseThrow(EMPTY_RESPONSE.asChaosException())) { return PlatformHealth.DEGRADED; } return PlatformHealth.OK; } @Autowired  CloudFoundryPlatform(); boolean isChaosEngine(String applicationName); @Override ApiStatus getApiStatus(); @Override PlatformLevel getPlatformLevel(); @Override PlatformHealth getPlatformHealth(); @Override List<Container> generateRoster(); void restageApplication(RestageApplicationRequest restageApplicationRequest);  }