Search in sources :

Example 1 with Task

use of org.cloudfoundry.operations.applications.Task in project cf-java-client by cloudfoundry.

the class ApplicationsTest method runTask.

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_1_11)
@Test
public void runTask() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    String taskName = this.nameFactory.getTaskName();
    createApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, false).then(this.cloudFoundryOperations.applications().runTask(RunApplicationTaskRequest.builder().applicationName(applicationName).command("ls").disk(64).memory(64).taskName(taskName).build())).map(Task::getName).as(StepVerifier::create).expectNext(taskName).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : Task(org.cloudfoundry.operations.applications.Task) ClassPathResource(org.springframework.core.io.ClassPathResource) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with Task

use of org.cloudfoundry.operations.applications.Task in project cf-java-client by cloudfoundry.

the class ApplicationsTest method terminateTask.

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_1_11)
@Test
public void terminateTask() throws IOException {
    String applicationName = this.nameFactory.getApplicationName();
    String taskName = this.nameFactory.getTaskName();
    createApplication(this.cloudFoundryOperations, new ClassPathResource("test-application.zip").getFile().toPath(), applicationName, false).then(getLongLivedTaskId(this.cloudFoundryOperations, applicationName, taskName)).flatMap(sequenceId -> this.cloudFoundryOperations.applications().terminateTask(TerminateApplicationTaskRequest.builder().applicationName(applicationName).sequenceId(sequenceId).build()).thenReturn(sequenceId)).flatMapMany(sequenceId -> requestListTasks(this.cloudFoundryOperations, applicationName).filter(task -> sequenceId.equals(task.getSequenceId()))).map(Task::getState).as(StepVerifier::create).expectNext(TaskState.FAILED).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : StepVerifier(reactor.test.StepVerifier) GetApplicationManifestRequest(org.cloudfoundry.operations.applications.GetApplicationManifestRequest) PushApplicationRequest(org.cloudfoundry.operations.applications.PushApplicationRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Task(org.cloudfoundry.operations.applications.Task) ClassPathResource(org.springframework.core.io.ClassPathResource) Route(org.cloudfoundry.operations.applications.Route) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) ApplicationHealthCheck(org.cloudfoundry.operations.applications.ApplicationHealthCheck) TaskState(org.cloudfoundry.operations.applications.TaskState) CreateDomainRequest(org.cloudfoundry.operations.domains.CreateDomainRequest) RestartApplicationRequest(org.cloudfoundry.operations.applications.RestartApplicationRequest) DeleteApplicationRequest(org.cloudfoundry.operations.applications.DeleteApplicationRequest) ApplicationDetail(org.cloudfoundry.operations.applications.ApplicationDetail) ApplicationEnvironments(org.cloudfoundry.operations.applications.ApplicationEnvironments) ApplicationSummary(org.cloudfoundry.operations.applications.ApplicationSummary) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) Duration(java.time.Duration) Map(java.util.Map) GetApplicationEventsRequest(org.cloudfoundry.operations.applications.GetApplicationEventsRequest) RunApplicationTaskRequest(org.cloudfoundry.operations.applications.RunApplicationTaskRequest) CloudFoundryVersion(org.cloudfoundry.CloudFoundryVersion) GetApplicationEnvironmentsRequest(org.cloudfoundry.operations.applications.GetApplicationEnvironmentsRequest) ListApplicationTasksRequest(org.cloudfoundry.operations.applications.ListApplicationTasksRequest) CreateSharedDomainRequest(org.cloudfoundry.operations.domains.CreateSharedDomainRequest) CreateUserProvidedServiceInstanceRequest(org.cloudfoundry.operations.services.CreateUserProvidedServiceInstanceRequest) GetApplicationRequest(org.cloudfoundry.operations.applications.GetApplicationRequest) Path(java.nio.file.Path) ApplicationEvent(org.cloudfoundry.operations.applications.ApplicationEvent) GetServiceInstanceRequest(org.cloudfoundry.operations.services.GetServiceInstanceRequest) UnsetEnvironmentVariableApplicationRequest(org.cloudfoundry.operations.applications.UnsetEnvironmentVariableApplicationRequest) ServiceInstance(org.cloudfoundry.operations.services.ServiceInstance) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ApplicationManifest(org.cloudfoundry.operations.applications.ApplicationManifest) GetApplicationHealthCheckRequest(org.cloudfoundry.operations.applications.GetApplicationHealthCheckRequest) CreateServiceInstanceRequest(org.cloudfoundry.operations.services.CreateServiceInstanceRequest) Flux(reactor.core.publisher.Flux) BindServiceInstanceRequest(org.cloudfoundry.operations.services.BindServiceInstanceRequest) StartApplicationRequest(org.cloudfoundry.operations.applications.StartApplicationRequest) ListRoutesRequest(org.cloudfoundry.operations.routes.ListRoutesRequest) FluentMap(org.cloudfoundry.util.FluentMap) TerminateApplicationTaskRequest(org.cloudfoundry.operations.applications.TerminateApplicationTaskRequest) SetEnvironmentVariableApplicationRequest(org.cloudfoundry.operations.applications.SetEnvironmentVariableApplicationRequest) Collections(java.util.Collections) PushApplicationManifestRequest(org.cloudfoundry.operations.applications.PushApplicationManifestRequest) Task(org.cloudfoundry.operations.applications.Task) ClassPathResource(org.springframework.core.io.ClassPathResource) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

AbstractIntegrationTest (org.cloudfoundry.AbstractIntegrationTest)2 IfCloudFoundryVersion (org.cloudfoundry.IfCloudFoundryVersion)2 Task (org.cloudfoundry.operations.applications.Task)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 CloudFoundryVersion (org.cloudfoundry.CloudFoundryVersion)1 ApplicationDetail (org.cloudfoundry.operations.applications.ApplicationDetail)1 ApplicationEnvironments (org.cloudfoundry.operations.applications.ApplicationEnvironments)1 ApplicationEvent (org.cloudfoundry.operations.applications.ApplicationEvent)1 ApplicationHealthCheck (org.cloudfoundry.operations.applications.ApplicationHealthCheck)1 ApplicationManifest (org.cloudfoundry.operations.applications.ApplicationManifest)1 ApplicationSummary (org.cloudfoundry.operations.applications.ApplicationSummary)1 DeleteApplicationRequest (org.cloudfoundry.operations.applications.DeleteApplicationRequest)1 GetApplicationEnvironmentsRequest (org.cloudfoundry.operations.applications.GetApplicationEnvironmentsRequest)1 GetApplicationEventsRequest (org.cloudfoundry.operations.applications.GetApplicationEventsRequest)1 GetApplicationHealthCheckRequest (org.cloudfoundry.operations.applications.GetApplicationHealthCheckRequest)1