org.cloudfoundry.operations.applications.PushApplicationManifestRequest Java Examples

The following examples show how to use org.cloudfoundry.operations.applications.PushApplicationManifestRequest. 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 File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
public void setupTaskWithNonExistentApplicationRetrievalFails(Resource resource) throws IOException {
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack(deploymentProperties.getBuildpack())
					.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
					.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
					.environmentVariable("SPRING_APPLICATION_JSON", "{}")
					.healthCheckType(ApplicationHealthCheck.NONE)
					.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
					.name("test-application")
					.noRoute(true)
					.services(Collections.emptySet())
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	givenRequestStopApplication("test-application", Mono.empty());

	givenRequestGetApplication("test-application", Mono.error(new UnsupportedOperationException()));
}
 
Example #2
Source File: CloudFoundryAppDeployerTest.java    From spring-cloud-app-broker with Apache License 2.0 6 votes vote down vote up
private ArgumentMatcher<PushApplicationManifestRequest> matchesManifest(ApplicationManifest expectedManifest) {
	return new ArgumentMatcher<PushApplicationManifestRequest>() {
		@Override
		public boolean matches(PushApplicationManifestRequest request) {
			if (request.getManifests().size() == EXPECTED_MANIFESTS) {
				return request.getManifests().get(0).equals(expectedManifest);
			}

			return false;
		}

		@Override
		public String toString() {
			return expectedManifest.toString();
		}
	};
}
 
Example #3
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
private void setupFailedPush(Resource resource) throws IOException{
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(
			PushApplicationManifestRequest.builder()
					.manifest(ApplicationManifest.builder()
							.path(resource.getFile().toPath())
							.buildpack(deploymentProperties.getBuildpack())
							.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
							.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
							.environmentVariable("SPRING_APPLICATION_JSON", "{}")
							.healthCheckType(ApplicationHealthCheck.NONE)
							.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
							.name("test-application")
							.noRoute(true)
							.services(Collections.emptySet())
							.build())
					.stagingTimeout(this.deploymentProperties.getStagingTimeout())
					.startupTimeout(this.deploymentProperties.getStartupTimeout())
					.build(), Mono.error(new UnsupportedOperationException()));
}
 
Example #4
Source File: CloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
private Mono<Void> pushApplication(String name, AppDeploymentRequest request) {
	if (!pushTaskAppsEnabled()) {
		return Mono.empty();
	}

	return requestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(getApplication(request))
			.docker(Docker.builder().image(getDockerImage(request)).build())
			.buildpack(buildpack(request))
			.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
			.disk(diskQuota(request))
			.environmentVariables(getEnvironmentVariables(name, request))
			.healthCheckType(ApplicationHealthCheck.NONE)
			.memory(memory(request))
			.name(name)
			.noRoute(true)
			.services(servicesToBind(request))
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build());
}
 
Example #5
Source File: CloudFoundryAppDeployer.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
private Mono<Void> pushApplication(DeployApplicationRequest request, Map<String, String> deploymentProperties,
	Resource appResource) {
	ApplicationManifest manifest = buildAppManifest(request, deploymentProperties, appResource);

	LOG.debug("Pushing app manifest. manifest={}", manifest.toString());

	PushApplicationManifestRequest applicationManifestRequest =
		PushApplicationManifestRequest.builder()
			.manifest(manifest)
			.stagingTimeout(this.defaultDeploymentProperties.getStagingTimeout())
			.startupTimeout(this.defaultDeploymentProperties.getStartupTimeout())
			.noStart(!start(deploymentProperties))
			.build();

	Mono<Void> requestPushApplication;
	if (deploymentProperties.containsKey(DeploymentProperties.TARGET_PROPERTY_KEY)) {
		String space = deploymentProperties.get(DeploymentProperties.TARGET_PROPERTY_KEY);
		requestPushApplication = pushManifestInSpace(applicationManifestRequest, space);
	}
	else {
		requestPushApplication = pushManifest(applicationManifestRequest);
	}

	return requestPushApplication
		.doOnSuccess(v -> LOG.info("Success pushing app manifest. appName={}", request.getName()))
		.doOnError(e -> LOG.error(String.format("Error pushing app manifest. appName=%s, " + ERROR_LOG_TEMPLATE,
			request.getName(), e.getMessage()), e));
}
 
Example #6
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void deployResource(CloudFoundryAppDeployer deployer, Resource resource) throws IOException {
	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
			ApplicationDetail.builder()
					.diskQuota(0)
					.id("test-application-id")
					.instances(1)
					.memoryLimit(0)
					.name("test-application")
					.requestedState("RUNNING")
					.runningInstances(0)
					.stack("test-stack")
					.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack(deploymentProperties.getBuildpack())
					.disk(1024)
					.instances(1)
					.memory(1024)
					.name("test-application-id")
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	deployer.deploy(
			new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
					Collections.EMPTY_MAP));

}
 
Example #7
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private void setupTaskWithNonExistentApplicationAndStoppingApplicationFails(Resource resource) throws IOException {
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(
			PushApplicationManifestRequest.builder()
					.manifest(ApplicationManifest.builder()
							.path(resource.getFile().toPath())
							.buildpack(deploymentProperties.getBuildpack())
							.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
							.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
							.environmentVariable("SPRING_APPLICATION_JSON", "{}")
							.healthCheckType(ApplicationHealthCheck.NONE)
							.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
							.name("test-application")
							.noRoute(true)
							.services(Collections.emptySet())
							.build())
					.stagingTimeout(this.deploymentProperties.getStagingTimeout())
					.startupTimeout(this.deploymentProperties.getStartupTimeout())
					.build(), Mono.empty());

	givenRequestGetApplication("test-application", Mono.just(ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(1)
			.stack("test-stack")
			.build()));

	givenRequestStopApplication("test-application", Mono.error(new UnsupportedOperationException()));
}
 
Example #8
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private void setupTaskWithNonExistentApplicationAndRetrievingApplicationSummaryFails(Resource resource) throws IOException {
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(
			PushApplicationManifestRequest.builder()
					.manifest(ApplicationManifest.builder()
							.path(resource.getFile().toPath())
							.buildpack(deploymentProperties.getBuildpack())
							.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
							.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
							.environmentVariable("SPRING_APPLICATION_JSON", "{}")
							.healthCheckType(ApplicationHealthCheck.NONE)
							.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
							.name("test-application")
							.noRoute(true)
							.services(Collections.emptySet())
							.build())
					.stagingTimeout(this.deploymentProperties.getStagingTimeout())
					.startupTimeout(this.deploymentProperties.getStartupTimeout())
					.build(), Mono.empty());

	givenRequestGetApplication("test-application", Mono.just(ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(1)
			.stack("test-stack")
			.build()));

	givenRequestStopApplication("test-application", Mono.empty());

	givenRequestGetApplicationSummary("test-application-id", Mono.error(new UnsupportedOperationException()));

}
 
Example #9
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<Void> pushApplicationWithServiceParameters(ApplicationManifest manifest,
	AppDeploymentRequest request, String deploymentId) {

	logger.debug("Pushing application manifest with no start");

	return requestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(manifest)
		.noStart(true)
		.build())
		.doOnSuccess(v -> logger.info("Done uploading bits for {}", deploymentId))
		.doOnError(e -> logger.error(String.format("Error creating app %s.  Exception Message %s", deploymentId, e.getMessage())))

		.thenMany(Flux.fromStream(bindParameterizedServiceInstanceRequests(request, deploymentId)))
		.flatMap(bindRequest -> this.operations.services()
			.bind(bindRequest)
			.doOnSuccess(bv -> logger.info("Done binding service {} for {}", bindRequest.getServiceInstanceName(), deploymentId))
			.doOnError(e -> logger.error("Error: {} binding service {}", e.getMessage(), bindRequest.getServiceInstanceName())))

		.then(this.operations.applications()
			.start(StartApplicationRequest.builder()
				.name(deploymentId)
				.stagingTimeout(this.deploymentProperties.getStagingTimeout())
				.startupTimeout(this.deploymentProperties.getStartupTimeout())
				.build())
			.doOnSuccess(sv -> logger.info("Started app for {} ", deploymentId))
			.doOnError(e -> logger.error("Error: {} starting app for {}.", e.getMessage(), deploymentId)))

		.doOnError(e -> logger.error(String.format("Error: %s creating app %s", e.getMessage(), deploymentId), e));
}
 
Example #10
Source File: CloudFoundryAppDeployer.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<Void> pushApplicationWithNoServiceParameters(ApplicationManifest manifest, String deploymentId) {
	logger.debug("Pushing application manifest");
	return requestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(manifest)
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build())
		.doOnSuccess(v -> logger.info("Done uploading bits for {}", deploymentId))
		.doOnError(e -> logger.error("Error: {} creating app {}", e.getMessage(), deploymentId));
}
 
Example #11
Source File: CloudFoundryDeployAppStep.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
private void deployCFApp(Release replacingRelease) {
	ApplicationManifest applicationManifest = this.cfManifestApplicationDeployer.getCFApplicationManifest(replacingRelease);
	logger.debug("Manifest = " + ArgumentSanitizer.sanitizeYml(replacingRelease.getManifest().getData()));
	// Deploy the application
	String applicationName = applicationManifest.getName();
	Map<String, String> appDeploymentData = new HashMap<>();
	appDeploymentData.put(applicationManifest.getName(), applicationManifest.toString());
	this.platformCloudFoundryOperations.getCloudFoundryOperations(replacingRelease.getPlatformName())
			.applications().pushManifest(
			PushApplicationManifestRequest.builder()
					.manifest(applicationManifest)
					.stagingTimeout(CloudFoundryManifestApplicationDeployer.STAGING_TIMEOUT)
					.startupTimeout(CloudFoundryManifestApplicationDeployer.STARTUP_TIMEOUT)
					.build())
			.doOnSuccess(v -> logger.info("Done uploading bits for {}", applicationName))
			.doOnError(e -> logger.error(
					String.format("Error creating app %s.  Exception Message %s", applicationName,
							e.getMessage())))
			.timeout(CloudFoundryManifestApplicationDeployer.PUSH_REQUEST_TIMEOUT)
			.doOnSuccess(item -> {
				logger.info("Successfully deployed {}", applicationName);
				AppDeployerData appDeployerData = new AppDeployerData();
				appDeployerData.setReleaseName(replacingRelease.getName());
				appDeployerData.setReleaseVersion(replacingRelease.getVersion());
				appDeployerData.setDeploymentDataUsingMap(appDeploymentData);
				this.appDeployerDataRepository.save(appDeployerData);
			})
			.doOnError(error -> {
				if (CloudFoundryManifestApplicationDeployer.isNotFoundError().test(error)) {
					logger.warn("Unable to deploy application. It may have been destroyed before start completed: " + error.getMessage());
				}
				else {
					logger.error(String.format("Failed to deploy %s", applicationName + ". " + error.getMessage()));
				}
			})
			.block();
}
 
Example #12
Source File: CloudFoundryReleaseManager.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
public Release install(Release newRelease) {
	Release release = this.releaseRepository.save(newRelease);
	ApplicationManifest applicationManifest = this.cfManifestApplicationDeployer.getCFApplicationManifest(release);
	Assert.isTrue(applicationManifest != null, "CF Application Manifest must be set");
	logger.debug("Manifest = " + ArgumentSanitizer.sanitizeYml(newRelease.getManifest().getData()));
	// Deploy the application
	String applicationName = applicationManifest.getName();
	Map<String, String> appDeploymentData = new HashMap<>();
	appDeploymentData.put(applicationManifest.getName(), applicationManifest.toString());
	this.platformCloudFoundryOperations.getCloudFoundryOperations(newRelease.getPlatformName())
			.applications().pushManifest(
			PushApplicationManifestRequest.builder()
					.manifest(applicationManifest)
					.stagingTimeout(CloudFoundryManifestApplicationDeployer.STAGING_TIMEOUT)
					.startupTimeout(CloudFoundryManifestApplicationDeployer.STARTUP_TIMEOUT)
					.build())
			.doOnSuccess(v -> logger.info("Done uploading bits for {}", applicationName))
			.doOnError(e -> logger.error(
					String.format("Error creating app %s.  Exception Message %s", applicationName,
							e.getMessage())))
			.timeout(CloudFoundryManifestApplicationDeployer.PUSH_REQUEST_TIMEOUT)
			.doOnSuccess(item -> {
				logger.info("Successfully deployed {}", applicationName);
				saveAppDeployerData(release, appDeploymentData);

				// Update Status in DB
				updateInstallComplete(release);
			})
			.doOnError(error -> {
				if (CloudFoundryManifestApplicationDeployer.isNotFoundError().test(error)) {
					logger.warn("Unable to deploy application. It may have been destroyed before start completed: " + error.getMessage());
				}
				else {
					logger.error(String.format("Failed to deploy %s", applicationName));
				}
			})
			.block();
	// Store updated state in in DB and compute status
	return status(this.releaseRepository.save(release));
}
 
Example #13
Source File: CloudFoundryService.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
public Mono<Void> pushBrokerApp(String appName, Path appPath, String brokerClientId,
	List<String> appBrokerProperties) {
	return cloudFoundryOperations.applications().pushManifest(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.environmentVariables(appBrokerDeployerEnvironmentVariables(brokerClientId))
			.putAllEnvironmentVariables(propertiesToEnvironment(appBrokerProperties))
			.name(appName)
			.path(appPath)
			.memory(1024)
			.build())
		.build())
		.doOnSuccess(v -> LOG.info("Success pushing broker app. appName={}", appName))
		.doOnError(e -> LOG.error(String.format("Error pushing broker app. appName=%s, error=%s", appName,
			e.getMessage()), e));
}
 
Example #14
Source File: CloudFoundryAppDeployerTest.java    From spring-cloud-app-broker with Apache License 2.0 5 votes vote down vote up
@Test
void deployAppWithStartOption() {
	DeployApplicationRequest request = DeployApplicationRequest.builder()
		.name(APP_NAME)
		.path(APP_PATH)
		.property(CloudFoundryDeploymentProperties.START_PROPERTY_KEY, "false")
		.serviceInstanceId(SERVICE_INSTANCE_ID)
		.build();

	StepVerifier.create(appDeployer.deploy(request))
		.assertNext(response -> assertThat(response.getName()).isEqualTo(APP_NAME))
		.verifyComplete();

	then(operationsApplications).should().pushManifest(argThat(PushApplicationManifestRequest::getNoStart));
}
 
Example #15
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployDockerResource() {
	Resource resource = new DockerResource("somecorp/someimage:latest");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.docker(Docker.builder().image("somecorp/someimage:latest").build())
			.disk(1024)
			.environmentVariables(defaultEnvironmentVariables())
			.instances(1)
			.memory(1024)
			.name("test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(
		new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
			Collections.emptyMap()));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #16
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithGroup() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-group-test-application")).willReturn(
		"test-group-test-application-id");

	givenRequestGetApplication("test-group-test-application-id", Mono.error(new IllegalArgumentException()),
		Mono.just(ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-group-test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-group-test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack(deploymentProperties.getBuildpack())
			.disk(1024)
			.environmentVariable("SPRING_CLOUD_APPLICATION_GROUP", "test-group")
			.environmentVariable("SPRING_APPLICATION_JSON", "{}")
			.environmentVariable("SPRING_APPLICATION_INDEX", "${vcap.application.instance_index}")
			.environmentVariable("SPRING_CLOUD_APPLICATION_GUID",
				"${vcap.application.name}:${vcap.application.instance_index}")
			.instances(1)
			.memory(1024)
			.name("test-group-test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(
		new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
			Collections.singletonMap(GROUP_PROPERTY_KEY, "test-group")));

	assertThat(deploymentId, equalTo("test-group-test-application-id"));
}
 
Example #17
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithMultipleRoutes() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id",
			Mono.error(new IllegalArgumentException()),
			Mono.just(ApplicationDetail.builder()
					.diskQuota(0)
					.id("test-application-id")
					.instances(1)
					.memoryLimit(0)
					.name("test-application")
					.requestedState("RUNNING")
					.runningInstances(0)
					.stack("test-stack")
					.build()));

	this.deploymentProperties.setBuildpack("test-buildpack");
	this.deploymentProperties.setDisk("0");
	this.deploymentProperties.setHealthCheck(ApplicationHealthCheck.NONE);
	this.deploymentProperties.setRoutes(Sets.newHashSet("route1.test-domain", "route2.test-domain"));
	this.deploymentProperties.setInstances(0);
	this.deploymentProperties.setMemory("0");

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack("test-buildpack")
					.disk(0)
					.routes(Sets.newHashSet(
							Route.builder().route("route1.test-domain").build(),
							Route.builder().route("route2.test-domain").build()
					))
					.environmentVariables(defaultEnvironmentVariables())
					.healthCheckType(ApplicationHealthCheck.NONE)
					.instances(0)
					.memory(0)
					.name("test-application-id")
					.service("test-service-2")
					.service("test-service-1")
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(new AppDeploymentRequest(
			new AppDefinition("test-application", Collections.emptyMap()),
			resource,
			Collections.emptyMap()));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #18
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithCustomDeploymentProperties() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	this.deploymentProperties.setBuildpack("test-buildpack");
	this.deploymentProperties.setDisk("0");
	this.deploymentProperties.setDomain("test-domain");
	this.deploymentProperties.setHealthCheck(ApplicationHealthCheck.NONE);
	this.deploymentProperties.setHost("test-host");
	this.deploymentProperties.setInstances(0);
	this.deploymentProperties.setMemory("0");

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack("test-buildpack")
			.disk(0)
			.domain("test-domain")
			.environmentVariables(defaultEnvironmentVariables())
			.healthCheckType(ApplicationHealthCheck.NONE)
			.host("test-host")
			.instances(0)
			.memory(0)
			.name("test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(
		new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
			Collections.emptyMap()));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #19
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithInvalidRoutePathProperty() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id",
			Mono.error(new IllegalArgumentException()),
			Mono.just(ApplicationDetail.builder()
							  .diskQuota(0)
							  .id("test-application-id")
							  .instances(1)
							  .memoryLimit(0)
							  .name("test-application")
							  .requestedState("RUNNING")
							  .runningInstances(0)
							  .stack("test-stack")
							  .build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
										.manifest(ApplicationManifest.builder()
														  .path(resource.getFile().toPath())
														  .buildpack("test-buildpack")
														  .disk(0)
														  .environmentVariables(defaultEnvironmentVariables())
														  .healthCheckType(ApplicationHealthCheck.NONE)
														  .instances(0)
														  .memory(0)
														  .name("test-application-id")
														  .noRoute(false)
														  .host("test-host")
														  .domain("test-domain")
														  .routePath("/test-route-path")
														  .service("test-service-2")
														  .service("test-service-1")
														  .build())
										.stagingTimeout(this.deploymentProperties.getStagingTimeout())
										.startupTimeout(this.deploymentProperties.getStartupTimeout())
										.build(), Mono.empty());
	try {
		this.deployer.deploy(new AppDeploymentRequest(
				new AppDefinition("test-application", Collections.emptyMap()),
				resource,
				FluentMap.<String, String>builder()
						.entry(BUILDPACK_PROPERTY_KEY, "test-buildpack")
						.entry(AppDeployer.DISK_PROPERTY_KEY, "0")
						.entry(DOMAIN_PROPERTY, "test-domain")
						.entry(HEALTHCHECK_PROPERTY_KEY, "none")
						.entry(HOST_PROPERTY, "test-host")
						.entry(COUNT_PROPERTY_KEY, "0")
						.entry(AppDeployer.MEMORY_PROPERTY_KEY, "0")
						.entry(NO_ROUTE_PROPERTY, "false")
						.entry(ROUTE_PATH_PROPERTY, "test-route-path")
						.build()));
		fail("Illegal Argument exception is expected.");
	}
	catch (IllegalArgumentException e) {
		assertThat(e.getMessage(), equalTo(
				"Cloud Foundry routes must start with \"/\". Route passed = [test-route-path]."));
	}
}
 
Example #20
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithApplicationDeploymentProperties() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack("test-buildpack")
			.disk(0)
			.environmentVariables(defaultEnvironmentVariables())
			.healthCheckType(ApplicationHealthCheck.NONE)
			.instances(0)
			.memory(0)
			.name("test-application-id")
			.noRoute(false)
			.host("test-host")
			.domain("test-domain")
			.routePath("/test-route-path")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(
		new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
			FluentMap.<String, String>builder().entry(BUILDPACK_PROPERTY_KEY, "test-buildpack")
				.entry(AppDeployer.DISK_PROPERTY_KEY, "0")
				.entry(DOMAIN_PROPERTY, "test-domain")
				.entry(HEALTHCHECK_PROPERTY_KEY, "none")
				.entry(HOST_PROPERTY, "test-host")
				.entry(COUNT_PROPERTY_KEY, "0")
				.entry(AppDeployer.MEMORY_PROPERTY_KEY, "0")
				.entry(NO_ROUTE_PROPERTY, "false")
				.entry(ROUTE_PATH_PROPERTY, "/test-route-path")
				.build()));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #21
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@Test
public void deployWithDeployerEnvironmentVariables() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
			ApplicationDetail.builder()
					.diskQuota(0)
					.id("test-application-id")
					.instances(1)
					.memoryLimit(0)
					.name("test-application")
					.requestedState("RUNNING")
					.runningInstances(0)
					.stack("test-stack")
					.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack("test-buildpack")
					.disk(0)
					.environmentVariables(defaultEnvironmentVariables())
					.healthCheckType(ApplicationHealthCheck.NONE)
					.instances(0)
					.memory(0)
					.name("test-application-id")
					.noRoute(false)
					.host("test-host")
					.domain("test-domain")
					.service("test-service-2")
					.service("test-service-1")
					.build())
			.build(), Mono.empty());


	CloudFoundryAppDeployer deployer = new CloudFoundryAppDeployer(this.applicationNameGenerator,
			bindDeployerProperties(FluentMap.<String,String>builder()
			.entry("env.JBP_CONFIG_SPRING_AUTO_RECONFIGURATION",CfEnvConfigurer.ENABLED_FALSE)
			.entry("env.SPRING_PROFILES_ACTIVE","cloud,foo")
			.build()), this.operations, this.runtimeEnvironmentInfo);

	AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(new AppDefinition("test-application",
			Collections.EMPTY_MAP), resource,
			FluentMap.<String, String>builder().entry(BUILDPACK_PROPERTY_KEY, "test-buildpack")
					.entry(AppDeployer.DISK_PROPERTY_KEY, "0")
					.entry(DOMAIN_PROPERTY, "test-domain")
					.entry(HEALTHCHECK_PROPERTY_KEY, "none")
					.entry(HOST_PROPERTY, "test-host")
					.entry(COUNT_PROPERTY_KEY, "0")
					.entry(AppDeployer.MEMORY_PROPERTY_KEY, "0")
					.entry(NO_ROUTE_PROPERTY, "false")
					.entry(ROUTE_PATH_PROPERTY, "/test-route-path")
					.build());

	assertThat(deployer.getEnvironmentVariables("test-application-id", appDeploymentRequest),allOf(
			hasEntry("JBP_CONFIG_SPRING_AUTO_RECONFIGURATION", CfEnvConfigurer.ENABLED_FALSE),
			hasEntry("SPRING_PROFILES_ACTIVE","cloud,foo"),
			hasKey("SPRING_APPLICATION_JSON"))
	);

	String deploymentId = deployer.deploy(appDeploymentRequest);

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #22
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithAdditionalPropertiesInSpringApplicationJson() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	Map<String, String> environmentVariables = new HashMap<>();
	environmentVariables.put("SPRING_APPLICATION_JSON", "{\"test-key-1\":\"test-value-1\"}");
	addGuidAndIndex(environmentVariables);

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack(deploymentProperties.getBuildpack())
			.disk(1024)
			.environmentVariables(environmentVariables)
			.instances(1)
			.memory(1024)
			.name("test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(new AppDeploymentRequest(
		new AppDefinition("test-application", Collections.singletonMap("test-key-1", "test-value-1")), resource,
		Collections.singletonMap("test-key-2", "test-value-2")));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #23
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithAdditionalProperties() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	Map<String, String> environmentVariables = new HashMap<>();
	environmentVariables.put("test-key-1", "test-value-1");
	addGuidAndIndex(environmentVariables);

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack(deploymentProperties.getBuildpack())
			.disk(1024)
			.environmentVariables(environmentVariables)
			.instances(1)
			.memory(1024)
			.name("test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(new AppDeploymentRequest(
		new AppDefinition("test-application", Collections.singletonMap("test-key-1", "test-value-1")), resource,
		FluentMap.<String, String>builder().entry("test-key-2", "test-value-2")
			.entry(CloudFoundryDeploymentProperties.USE_SPRING_APPLICATION_JSON_KEY, String.valueOf(false))
			.build()));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #24
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void givenRequestPushApplication(PushApplicationManifestRequest request, Mono<Void> response) {
	given(this.operations.applications()
		.pushManifest(any(PushApplicationManifestRequest.class)))
		.willReturn(response);
}
 
Example #25
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deployWithServiceParameters() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");
	given(this.services.bind(any(BindServiceInstanceRequest.class)))
		.willReturn(Mono.empty());
	given(this.applications.start(any(StartApplicationRequest.class)))
		.willReturn(Mono.empty());

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack(deploymentProperties.getBuildpack())
			.disk(1024)
			.environmentVariables(defaultEnvironmentVariables())
			.instances(1)
			.memory(1024)
			.name("test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(
		new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
			Collections.singletonMap(
				SERVICES_PROPERTY_KEY,"'test-service-3 foo:bar'"))
		);

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #26
Source File: CloudFoundryAppDeployerTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void deploy() throws IOException {
	Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar");

	given(this.applicationNameGenerator.generateAppName("test-application")).willReturn("test-application-id");

	givenRequestGetApplication("test-application-id", Mono.error(new IllegalArgumentException()), Mono.just(
		ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(0)
			.stack("test-stack")
			.build()));

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
		.manifest(ApplicationManifest.builder()
			.path(resource.getFile().toPath())
			.buildpack(deploymentProperties.getBuildpack())
			.disk(1024)
			.environmentVariables(defaultEnvironmentVariables())
			.instances(1)
			.memory(1024)
			.name("test-application-id")
			.service("test-service-2")
			.service("test-service-1")
			.build())
		.stagingTimeout(this.deploymentProperties.getStagingTimeout())
		.startupTimeout(this.deploymentProperties.getStartupTimeout())
		.build(), Mono.empty());

	String deploymentId = this.deployer.deploy(
		new AppDeploymentRequest(new AppDefinition("test-application", Collections.emptyMap()), resource,
			Collections.EMPTY_MAP));

	assertThat(deploymentId, equalTo("test-application-id"));
}
 
Example #27
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void setupTaskWithNonExistentApplicationBindingThreeServices(Resource resource) throws IOException {
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack(deploymentProperties.getBuildpack())
					.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
					.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
					.environmentVariable("SPRING_APPLICATION_JSON", "{}")
					.healthCheckType(ApplicationHealthCheck.NONE)
					.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
					.name("test-application")
					.noRoute(true)
					.service("test-service-instance-1")
					.service("test-service-instance-2")
					.service("test-service-instance-3")
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	givenRequestGetApplication("test-application", Mono.just(ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(1)
			.stack("test-stack")
			.build()));

	givenRequestStopApplication("test-application", Mono.empty());

	givenRequestGetApplicationSummary("test-application-id", Mono.just(SummaryApplicationResponse.builder()
			.id("test-application-id")
			.detectedStartCommand("test-command")
			.build()));

	givenRequestCreateTask("test-application-id",
				"test-command",
				this.deploymentProperties.getMemory(),
				"test-application",
				Mono.just(CreateTaskResponse.builder()
			.id("test-task-id")
			.memoryInMb(1024)
			.diskInMb(1024)
			.dropletId("1")
			.createdAt(new Date().toString())
			.updatedAt(new Date().toString())
			.sequenceId(1)
			.name("test-task-id")
			.state(TaskState.SUCCEEDED)
			.build()));
}
 
Example #28
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void setupTaskWithNonExistentApplicationBindingOneService(Resource resource) throws IOException {
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(PushApplicationManifestRequest.builder()
			.manifest(ApplicationManifest.builder()
					.path(resource.getFile().toPath())
					.buildpack(deploymentProperties.getBuildpack())
					.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
					.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
					.environmentVariable("SPRING_APPLICATION_JSON", "{}")
					.healthCheckType(ApplicationHealthCheck.NONE)
					.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
					.name("test-application")
					.noRoute(true)
					.service("test-service-instance-2")
					.build())
			.stagingTimeout(this.deploymentProperties.getStagingTimeout())
			.startupTimeout(this.deploymentProperties.getStartupTimeout())
			.build(), Mono.empty());

	givenRequestGetApplication("test-application", Mono.just(ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(1)
			.stack("test-stack")
			.build()));

	givenRequestStopApplication("test-application", Mono.empty());

	givenRequestGetApplicationSummary("test-application-id", Mono.just(SummaryApplicationResponse.builder()
			.id("test-application-id")

			.detectedStartCommand("test-command")
			.build()));

	givenRequestCreateTask("test-application-id",
				"test-command",
				this.deploymentProperties.getMemory(),
				"test-application",
				Mono.just(CreateTaskResponse.builder()
			.id("test-task-id")
			.memoryInMb(1024)
			.diskInMb(1024)
			.dropletId("1")
			.createdAt(new Date().toString())
			.updatedAt(new Date().toString())
			.sequenceId(1)
			.name("test-task-id")
			.state(TaskState.SUCCEEDED)
			.build()));
}
 
Example #29
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void setupTaskWithNonExistentApplication(Resource resource) throws IOException{
	givenRequestListApplications(Flux.empty());

	givenRequestPushApplication(
			PushApplicationManifestRequest.builder()
					.manifest(ApplicationManifest.builder()
							.path(resource.getFile().toPath())
							.buildpack(deploymentProperties.getBuildpack())
							.command("echo '*** First run of container to allow droplet creation.***' && sleep 300")
							.disk((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()))
							.environmentVariable("SPRING_APPLICATION_JSON", "{}")
							.healthCheckType(ApplicationHealthCheck.NONE)
							.memory((int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()))
							.name("test-application")
							.noRoute(true)
							.services(Collections.emptySet())
							.build())
					.stagingTimeout(this.deploymentProperties.getStagingTimeout())
					.startupTimeout(this.deploymentProperties.getStartupTimeout())
					.build(), Mono.empty());

	givenRequestGetApplication("test-application", Mono.just(ApplicationDetail.builder()
			.diskQuota(0)
			.id("test-application-id")
			.instances(1)
			.memoryLimit(0)
			.name("test-application")
			.requestedState("RUNNING")
			.runningInstances(1)
			.stack("test-stack")
			.build()));

	givenRequestStopApplication("test-application", Mono.empty());

	givenRequestGetApplicationSummary("test-application-id", Mono.just(SummaryApplicationResponse.builder()
			.id("test-application-id")
			.detectedStartCommand("test-command")
			.build()));

	givenRequestCreateTask("test-application-id",
				"test-command",
				this.deploymentProperties.getMemory(),
				"test-application",
				Mono.just(CreateTaskResponse.builder()
			.id("test-task-id")
			.memoryInMb(1024)
			.diskInMb(1024)
			.dropletId("1")
			.createdAt(new Date().toString())
			.updatedAt(new Date().toString())
			.sequenceId(1)
			.name("test-task-id")
			.state(TaskState.SUCCEEDED)
			.build()));
}
 
Example #30
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private void givenRequestPushApplication(PushApplicationManifestRequest request, Mono<Void> response) {
	given(this.operations.applications()
		.pushManifest(any(PushApplicationManifestRequest.class)))
		.willReturn(response);
}