Java Code Examples for org.springframework.cloud.deployer.spi.app.AppStatus

The following examples show how to use org.springframework.cloud.deployer.spi.app.AppStatus. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud-skipper   Source File: HealthCheckStep.java    License: Apache License 2.0 6 votes vote down vote up
public boolean isHealthy(Release replacingRelease) {
	AppDeployerData replacingAppDeployerData = this.appDeployerDataRepository
			.findByReleaseNameAndReleaseVersionRequired(
					replacingRelease.getName(), replacingRelease.getVersion());
	Map<String, String> appNamesAndDeploymentIds = (replacingAppDeployerData!= null) ?
			replacingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP;
	AppDeployer appDeployer = this.deployerRepository
			.findByNameRequired(replacingRelease.getPlatformName())
			.getAppDeployer();
	logger.debug("Getting status for apps in replacing release {}-v{}", replacingRelease.getName(),
			replacingRelease.getVersion());
	for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) {
		AppStatus status = appDeployer.status(appNameAndDeploymentId.getValue());
		if (status.getState() == DeploymentState.deployed) {
			return true;
		}
	}
	return false;
}
 
Example 2
Source Project: spring-cloud-skipper   Source File: Status.java    License: Apache License 2.0 6 votes vote down vote up
@JsonIgnore
public String getPlatformStatusPrettyPrint() {
	List<AppStatus> appStatusList = getAppStatusList();
	StringBuffer statusMsg = new StringBuffer();

	for (AppStatus appStatus : appStatusList) {
		statusMsg.append("[" + appStatus.getDeploymentId() + "]");
		if (appStatus.getInstances().isEmpty()) {
			statusMsg.append(", State = [" + appStatus.getState() + "]\n");
		}
		else {
			statusMsg.append(", State = [");
			for (AppInstanceStatus appInstanceStatus : appStatus.getInstances().values()) {
				statusMsg.append(appInstanceStatus.getId() + "=" + appInstanceStatus.getState() + "\n");
			}
			statusMsg.setLength(statusMsg.length() - 1);
			statusMsg.append("]\n");
		}
	}
	return statusMsg.toString();
}
 
Example 3
private AppStatus createAppStatus(ApplicationDetail applicationDetail, String deploymentId) {
	logger.trace("Gathering instances for " + applicationDetail);
	logger.trace("InstanceDetails: " + applicationDetail.getInstanceDetails());

	AppStatus.Builder builder = AppStatus.of(deploymentId);

	int i = 0;
	for (InstanceDetail instanceDetail : applicationDetail.getInstanceDetails()) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, instanceDetail, i++));
	}
	for (; i < applicationDetail.getInstances(); i++) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, null, i));
	}

	return builder.build();
}
 
Example 4
public AppStatus status(Release release) {
	logger.info("Checking application status for the release: " + release.getName());
	ApplicationManifest applicationManifest = CloudFoundryApplicationManifestUtils.updateApplicationName(release);
	String applicationName = applicationManifest.getName();
	AppStatus appStatus = null;
	try {
		appStatus = getStatus(applicationName, release.getPlatformName())
				.doOnSuccess(v -> logger.info("Successfully computed status [{}] for {}", v,
						applicationName))
				.doOnError(e -> logger.error(
						String.format("Failed to compute status for %s", applicationName)))
				.block();
	}
	catch (Exception timeoutDueToBlock) {
		logger.error("Caught exception while querying for status of {}", applicationName, timeoutDueToBlock);
		appStatus = createErrorAppStatus(applicationName);
	}
	return appStatus;
}
 
Example 5
@RequestMapping
public PagedResources<AppStatusResource> list(PagedResourcesAssembler<AppStatus> assembler) {
	List<AppStatus> values = new ArrayList<>();

	for (ApplicationDefinition applicationDefinition : this.applicationDefinitionRepository.findAll()) {
		String key = forApplicationDefinition(applicationDefinition);
		String id = this.deploymentIdRepository.findOne(key);
		if (id != null) {
			values.add(appDeployer.status(id));
		}
	}

	Collections.sort(values, new Comparator<AppStatus>() {
		@Override
		public int compare(AppStatus o1, AppStatus o2) {
			return o1.getDeploymentId().compareTo(o2.getDeploymentId());
		}
	});
	return assembler.toResource(new PageImpl<>(values), statusAssembler);
}
 
Example 6
@Override
public AppStatus status(String id) {
	logger.info("Checking status of {}", id);
	DeploymentKey key = new DeploymentKey(id);
	Builder builder = AppStatus.of(id);
	for (Entry<String, StreamClustersInfoReportData> entry : yarnCloudAppService.getClustersStates(key.applicationId).entrySet()) {
		if (ObjectUtils.nullSafeEquals(entry.getKey(), key.getClusterId())) {
			ClustersInfoReportData data = entry.getValue();
			List<String> members = entry.getValue().getMembers();
			for (int i = 0 ; i < data.getProjectionAny(); i++) {
				Map<String, String> attributes = new HashMap<>();
				if (i < members.size()) {
					attributes.put("container", members.get(i));
					attributes.put("guid", members.get(i));
				}
				InstanceStatus instanceStatus = new InstanceStatus(key.getClusterId() + "-" + i, i < data.getCount(), attributes);
				builder.with(instanceStatus);
			}
			break;
		}
	}
	return builder.build();
}
 
Example 7
/**
 * Tests that an app which takes a long time to deploy is correctly reported as deploying.
 * Test that such an app can be undeployed.
 */
@Test
public void testDeployingStateCalculationAndCancel() {
	Map<String, String> properties = new HashMap<>();
	properties.put("initDelay", "" + 1000 * 60 * 60); // 1hr
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deploying))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));

}
 
Example 8
private AppStatus buildAppStatus(String id, App app) {
	logger.debug("Deployment " + id + " has " + app.getTasksRunning() + "/" + app.getInstances() + " tasks running");
	AppStatus.Builder result = AppStatus.of(id);
	int requestedInstances = app.getInstances();
	int actualInstances = 0;
	if (app.getTasks() != null) {
		for (Task task : app.getTasks()) {
			result.with(MarathonAppInstanceStatus.up(app, task));
			actualInstances++;
		}
	}
	for (int i = actualInstances; i < requestedInstances; i++) {
		result.with(MarathonAppInstanceStatus.down(app));
	}
	return result.build();
}
 
Example 9
private AppStatus createAppStatus(ApplicationDetail applicationDetail, String deploymentId) {
	logger.trace("Gathering instances for " + applicationDetail);
	logger.trace("InstanceDetails: " + applicationDetail.getInstanceDetails());

	AppStatus.Builder builder = AppStatus.of(deploymentId);

	int i = 0;
	for (InstanceDetail instanceDetail : applicationDetail.getInstanceDetails()) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, instanceDetail, i++));
	}
	for (; i < applicationDetail.getInstances(); i++) {
		builder.with(new CloudFoundryAppInstanceStatus(applicationDetail, null, i));
	}

	return builder.build();
}
 
Example 10
@SuppressWarnings("unchecked")
@Test
public void statusOfCrashedApplicationIsFailed() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder().state("CRASHED").index("1").build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.failed));
}
 
Example 11
@SuppressWarnings("unchecked")
@Test
public void statusOfDownApplicationIsDeploying() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder().state("DOWN").index("1").build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deploying));
}
 
Example 12
@SuppressWarnings("unchecked")
@Test
public void statusOfFlappingApplicationIsDeployed() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder().state("FLAPPING").index("1").build())
		.build()));

	AppStatus status = deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deployed));
}
 
Example 13
@SuppressWarnings("unchecked")
@Test
public void statusOfRunningApplicationIsDeployed() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder().state("RUNNING").index("1").build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deployed));
	assertThat(status.getInstances().get("test-application-0").toString(),
		equalTo("CloudFoundryAppInstanceStatus[test-application-0 : deployed]"));
	assertThat(status.getInstances().get("test-application-0").getAttributes(),
		equalTo(Collections.singletonMap("guid", "test-application:0")));
}
 
Example 14
@SuppressWarnings("unchecked")
@Test
public void statusOfStartingApplicationIsDeploying() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder().state("STARTING").index("1").build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.deploying));
}
 
Example 15
@SuppressWarnings("unchecked")
@Test
public void statusOfUnknownApplicationIsUnknown() {
	givenRequestGetApplication("test-application-id", Mono.just(ApplicationDetail.builder()
		.diskQuota(0)
		.id("test-application-id")
		.instances(1)
		.memoryLimit(0)
		.name("test-application")
		.requestedState("RUNNING")
		.runningInstances(1)
		.stack("test-stack")
		.instanceDetail(InstanceDetail.builder().state("UNKNOWN").index("1").build())
		.build()));

	AppStatus status = this.deployer.status("test-application-id");

	assertThat(status.getState(), equalTo(DeploymentState.unknown));
}
 
Example 16
@Test
public void testFailureToCallShutdownOnUndeploy() {
	Map<String, String> properties = new HashMap<>();
	// disable shutdown endpoint
	properties.put("endpoints.shutdown.enabled", "false");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deployed))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
Example 17
@Test
// was triggered by GH-50 and subsequently GH-55
public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() {
	Map<String, String> properties = new HashMap<>();
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true"));

	AppDeployer deployer = appDeployer();
	String deploymentId = deployer.deploy(request);
	AppStatus appStatus = deployer.status(deploymentId);
	assertTrue(appStatus.getInstances().size() > 0);
	for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) {
		Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes();
		assertFalse(attributes.containsKey("stdout"));
		assertFalse(attributes.containsKey("stderr"));
	}
	deployer.undeploy(deploymentId);
}
 
Example 18
@Test
public void testFailureToCallShutdownOnUndeploy() {
	Map<String, String> properties = new HashMap<>();
	// disable shutdown endpoint
	properties.put("endpoints.shutdown.enabled", "false");
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);

	log.info("Deploying {}...", request.getDefinition().getName());

	String deploymentId = appDeployer().deploy(request);
	Timeout timeout = deploymentTimeout();
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(deployed))), timeout.maxAttempts, timeout.pause));

	log.info("Undeploying {}...", deploymentId);

	timeout = undeploymentTimeout();
	appDeployer().undeploy(deploymentId);
	assertThat(deploymentId, eventually(hasStatusThat(
			Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause));
}
 
Example 19
@Test
// was triggered by GH-50 and subsequently GH-55
public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() {
	Map<String, String> properties = new HashMap<>();
	AppDefinition definition = new AppDefinition(randomName(), properties);
	Resource resource = testApplication();
	AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true"));

	AppDeployer deployer = appDeployer();
	String deploymentId = deployer.deploy(request);
	AppStatus appStatus = deployer.status(deploymentId);
	assertTrue(appStatus.getInstances().size() > 0);
	for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) {
		Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes();
		assertFalse(attributes.containsKey("stdout"));
		assertFalse(attributes.containsKey("stderr"));
	}
	deployer.undeploy(deploymentId);
}
 
Example 20
@Test
public void testDuplicateDeploy() throws Exception {
	repository.save(new StreamDefinition("myStream", "time | log"));

	mockMvc.perform(post("/streams/deployments/myStream")
			.accept(MediaType.APPLICATION_JSON)).andDo(print())
			.andExpect(status().isCreated());

	ArgumentCaptor<UploadRequest> uploadRequestCaptor = ArgumentCaptor.forClass(UploadRequest.class);
	verify(skipperClient, times(1)).upload(uploadRequestCaptor.capture());

	Package pkg = SkipperPackageUtils.loadPackageFromBytes(uploadRequestCaptor);
	assertNotNull(findChildPackageByName(pkg, "log"));
	assertNotNull(findChildPackageByName(pkg, "time"));

	streamStatusInfo.getStatus().setPlatformStatusAsAppStatusList(Arrays.asList(
			AppStatus.of("myStream.time-v1").generalState(DeploymentState.deploying).build(),
			AppStatus.of("myStream.log-v1").generalState(DeploymentState.deployed).build()));

	// Attempt to deploy already deployed stream
	mockMvc.perform(post("/streams/deployments/myStream")
			.accept(MediaType.APPLICATION_JSON)).andDo(print())
			.andExpect(status().isConflict());
}
 
Example 21
private DeploymentState getStreamDeploymentState(String streamName) {
	DeploymentState state = null;
	try {
		Info info = this.skipperClient.status(streamName);
		if (info.getStatus().getPlatformStatus() == null) {
			return getDeploymentStateFromStatusInfo(info);
		}
		List<AppStatus> appStatusList = deserializeAppStatus(info.getStatus().getPlatformStatus());
		Set<DeploymentState> deploymentStateList = appStatusList.stream().map(AppStatus::getState)
				.collect(Collectors.toSet());
		state = StreamDeployerUtil.aggregateState(deploymentStateList);
	}
	catch (ReleaseNotFoundException e) {
		// a defined stream but unknown to skipper is considered to be in an undeployed state
		if (streamDefinitionExists(streamName)) {
			state = DeploymentState.undeployed;
		}
	}
	return state;
}
 
Example 22
@Override
public AppStatus getAppStatus(String appDeploymentId) {
	// iteration through a real platform statuses one by one
	// is too expensive instead we rely on what skipper
	// already knows about it.
	return this.skipperClient.list(null)
		.stream()
		.flatMap(r -> {
			Info info = r.getInfo();
			if (info != null) {
				Status status = info.getStatus();
				if (status != null) {
					return status.getAppStatusList().stream();
				}
			}
			return Stream.empty();
		})
		.filter(as -> ObjectUtils.nullSafeEquals(appDeploymentId, as.getDeploymentId()))
		.findFirst()
		.orElseThrow(() -> new NoSuchAppException(appDeploymentId));
}
 
Example 23
Source Project: spring-cloud-skipper   Source File: DeleteStep.java    License: Apache License 2.0 5 votes vote down vote up
public Release delete(Release release, AppDeployerData existingAppDeployerData,
		List<String> applicationNamesToDelete) {
	AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName())
			.getAppDeployer();

	Map<String, String> appNamesAndDeploymentIds = (existingAppDeployerData!= null) ?
			existingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP;

	for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) {
		if (applicationNamesToDelete.contains(appNameAndDeploymentId.getKey())) {
			AppStatus appStatus = appDeployer.status(appNameAndDeploymentId.getValue());
			if (appStatus.getState().equals(DeploymentState.deployed)) {
				appDeployer.undeploy(appNameAndDeploymentId.getValue());
			}
			else {
				logger.warn("For Release name {}, did not undeploy existing app {} as its status is not "
						+ "'deployed'.", release.getName(), appNameAndDeploymentId.getKey());
			}
		}
	}

	Status deletedStatus = new Status();
	deletedStatus.setStatusCode(StatusCode.DELETED);
	release.getInfo().setStatus(deletedStatus);
	release.getInfo().setDescription("Delete complete");
	this.releaseRepository.save(release);
	return release;
}
 
Example 24
@Override
public ReleaseAnalysisReport createReport(Release existingRelease, Release replacingRelease, boolean initial,
		boolean isForceUpdate, List<String> appNamesToUpgrade) {
	ReleaseAnalysisReport releaseAnalysisReport = this.releaseAnalyzer
			.analyze(existingRelease, replacingRelease, isForceUpdate, appNamesToUpgrade);
	List<String> applicationNamesToUpgrade = releaseAnalysisReport.getApplicationNamesToUpgrade();
	if (releaseAnalysisReport.getReleaseDifference().areEqual() && !isForceUpdate) {
		throw new SkipperException(
				"Package to upgrade has no difference than existing deployed/deleted package. Not upgrading.");
	}
	AppDeployerData existingAppDeployerData = this.appDeployerDataRepository
			.findByReleaseNameAndReleaseVersionRequired(
					existingRelease.getName(), existingRelease.getVersion());
	Map<String, String> existingAppNamesAndDeploymentIds = (existingAppDeployerData != null) ?
			existingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP;
	List<AppStatus> appStatuses = status(existingRelease).getInfo().getStatus().getAppStatusList();

	Map<String, Object> model = calculateAppCountsForRelease(replacingRelease, existingAppNamesAndDeploymentIds,
			applicationNamesToUpgrade, appStatuses);

	String manifestData = ManifestUtils.createManifest(replacingRelease.getPkg(), model);
	Manifest manifest = new Manifest();
	manifest.setData(manifestData);
	replacingRelease.setManifest(manifest);
	if (initial) {
		this.releaseRepository.save(replacingRelease);
	}
	return releaseAnalysisReport;
}
 
Example 25
public static AppStatus copyStatus(AppStatus appStatus) {
	AppStatus.Builder builder = AppStatus.of(appStatus.getDeploymentId());
	if (CollectionUtils.isEmpty(appStatus.getInstances())) {
		builder.generalState(appStatus.getState());
	}
	else {
		appStatus.getInstances().entrySet().stream().map(Map.Entry::getValue).forEach(e -> builder.with(
				new MutableAttributesAppInstanceStatus(e.getId(), e.getState(), e.getAttributes())));
	}
	return builder.build();
}
 
Example 26
@Test
public void testFindNonExistentAppUnknownState() throws Exception {
	Info info = new Info();
	info.setStatus(new Status());
	info.getStatus().setStatusCode(StatusCode.UNKNOWN);
	info.getStatus().setPlatformStatusAsAppStatusList(
			Arrays.asList(AppStatus.of("ticktock5.log2-v1").generalState(DeploymentState.unknown).build()));

	when(this.skipperClient.status("ticktock5")).thenReturn(info);
	streamDefinitionRepository.save(new StreamDefinition("ticktock5", "time2|log2"));

	mockMvc.perform(get("/runtime/apps/ticktock5.log2-v1.").accept(MediaType.APPLICATION_JSON)).andDo(print())
			.andExpect(status().isNotFound())
			.andExpect(jsonPath("$[0].logref", is("NoSuchAppException")));
}
 
Example 27
Source Project: spring-cloud-skipper   Source File: ReleaseServiceTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testStatus() throws InterruptedException, IOException {
	String releaseName = "logrelease";
	InstallRequest installRequest = new InstallRequest();
	installRequest.setInstallProperties(createInstallProperties(releaseName));
	PackageIdentifier packageIdentifier = new PackageIdentifier();
	packageIdentifier.setPackageName("log");
	packageIdentifier.setPackageVersion("1.0.0");
	installRequest.setPackageIdentifier(packageIdentifier);
	Release release = install(installRequest);
	installRequest.setPackageIdentifier(packageIdentifier);
	assertThat(release).isNotNull();
	assertThat(release.getPkg().getMetadata().getVersion()).isEqualTo("1.0.0");

	Info info = this.releaseService.status(releaseName);
	assertThat(info).isNotNull();

	List<AppStatus> appStatuses = info.getStatus().getAppStatusList();
	assertThat(appStatuses).isNotNull();
	assertThat(appStatuses.size()).isEqualTo(1);

	AppStatus appStatus = appStatuses.iterator().next();
	assertThat(appStatus.getDeploymentId()).isEqualTo("logrelease.log-v1");
	assertThat(appStatus.getState()).isEqualTo(DeploymentState.deployed);
	assertThat(appStatus.getInstances().size()).isEqualTo(1);

	AppInstanceStatus appInstanceState = appStatus.getInstances().values().iterator().next();
	assertThat(appInstanceState.getAttributes().get(DefaultReleaseManager.SKIPPER_RELEASE_NAME_ATTRIBUTE)).isEqualTo("logrelease");
	assertThat(appInstanceState.getAttributes().get(DefaultReleaseManager.SKIPPER_RELEASE_VERSION_ATTRIBUTE)).isEqualTo("1");
	assertThat(appInstanceState.getAttributes().get(DefaultReleaseManager.SKIPPER_APPLICATION_NAME_ATTRIBUTE)).isEqualTo("log");
}
 
Example 28
protected boolean allAppsDeployed(List<AppStatus> appStatusList) {
	boolean allDeployed = true;
	for (AppStatus appStatus : appStatusList) {
		if (appStatus.getState() != DeploymentState.deployed) {
			allDeployed = false;
			break;
		}
	}
	return allDeployed;
}
 
Example 29
private List<Pair<String, List<AppStatus>>> getStreamStatusList(String[] streamNames) {
	Map<String, List<AppStatus>> streamStatuses = this.streamDeployer.getStreamStatuses(streamNames);
	List<Pair<String, List<AppStatus>>> streamStatusList = new ArrayList<>();
	streamStatuses.entrySet().forEach(entry -> {
		streamStatusList.add(Pair.of(entry.getKey(), entry.getValue()));
	});
	return streamStatusList;
}
 
Example 30
@Test
public void testNullCheckOnDeserializeAppStatus() {
	List<AppStatus> appStatusList = SkipperStreamDeployer.deserializeAppStatus(null);
	assertThat(appStatusList).isNotNull();
	assertThat(appStatusList.size()).isEqualTo(0);

	appStatusList = SkipperStreamDeployer.deserializeAppStatus("blah");
	assertThat(appStatusList).isNotNull();
	assertThat(appStatusList.size()).isEqualTo(0);
}