Search in sources :

Example 1 with IfCloudFoundryVersion

use of org.cloudfoundry.IfCloudFoundryVersion in project cf-java-client by cloudfoundry.

the class ApplicationsTest method uploadDroplet.

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_1_9)
@Test
public void uploadDroplet() {
    String applicationName = this.nameFactory.getApplicationName();
    this.spaceId.flatMap(spaceId -> createApplicationId(this.cloudFoundryClient, spaceId, applicationName)).flatMap(applicationId -> {
        try {
            return this.cloudFoundryClient.applicationsV2().uploadDroplet(UploadApplicationDropletRequest.builder().applicationId(applicationId).droplet(new ClassPathResource("test-droplet.tgz").getFile().toPath()).build()).flatMap(job -> JobUtils.waitForCompletion(this.cloudFoundryClient, Duration.ofMinutes(5), job));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }).as(StepVerifier::create).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) StepVerifier(reactor.test.StepVerifier) OperationUtils(org.cloudfoundry.util.OperationUtils) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) UploadApplicationRequest(org.cloudfoundry.client.v2.applications.UploadApplicationRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Duration(java.time.Duration) Map(java.util.Map) ZipExpectations.zipEquality(org.cloudfoundry.client.ZipExpectations.zipEquality) TerminateApplicationInstanceRequest(org.cloudfoundry.client.v2.applications.TerminateApplicationInstanceRequest) ListApplicationsRequest(org.cloudfoundry.client.v2.applications.ListApplicationsRequest) ListApplicationRoutesRequest(org.cloudfoundry.client.v2.applications.ListApplicationRoutesRequest) DownloadApplicationRequest(org.cloudfoundry.client.v2.applications.DownloadApplicationRequest) UploadApplicationDropletRequest(org.cloudfoundry.client.v2.applications.UploadApplicationDropletRequest) Set(java.util.Set) UploadApplicationResponse(org.cloudfoundry.client.v2.applications.UploadApplicationResponse) RestageApplicationRequest(org.cloudfoundry.client.v2.applications.RestageApplicationRequest) UpdateApplicationRequest(org.cloudfoundry.client.v2.applications.UpdateApplicationRequest) CreateServiceBindingResponse(org.cloudfoundry.client.v2.servicebindings.CreateServiceBindingResponse) CreateApplicationResponse(org.cloudfoundry.client.v2.applications.CreateApplicationResponse) SummaryApplicationRequest(org.cloudfoundry.client.v2.applications.SummaryApplicationRequest) ServiceBindingResource(org.cloudfoundry.client.v2.servicebindings.ServiceBindingResource) CloudFoundryClient(org.cloudfoundry.client.CloudFoundryClient) CreatePrivateDomainResponse(org.cloudfoundry.client.v2.privatedomains.CreatePrivateDomainResponse) CreateRouteRequest(org.cloudfoundry.client.v2.routes.CreateRouteRequest) Optional(java.util.Optional) RouteResource(org.cloudfoundry.client.v2.routes.RouteResource) AbstractApplicationResource(org.cloudfoundry.client.v2.applications.AbstractApplicationResource) Exceptions(reactor.core.Exceptions) TupleUtils.function(org.cloudfoundry.util.tuple.TupleUtils.function) TupleUtils.consumer(org.cloudfoundry.util.tuple.TupleUtils.consumer) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) CreateUserProvidedServiceInstanceRequest(org.cloudfoundry.client.v2.userprovidedserviceinstances.CreateUserProvidedServiceInstanceRequest) ServiceBindingEntity(org.cloudfoundry.client.v2.servicebindings.ServiceBindingEntity) ClassPathResource(org.springframework.core.io.ClassPathResource) Tuple2(reactor.util.function.Tuple2) CreateRouteResponse(org.cloudfoundry.client.v2.routes.CreateRouteResponse) ResourceUtils(org.cloudfoundry.util.ResourceUtils) DeleteApplicationRequest(org.cloudfoundry.client.v2.applications.DeleteApplicationRequest) CreatePrivateDomainRequest(org.cloudfoundry.client.v2.privatedomains.CreatePrivateDomainRequest) AssociateApplicationRouteRequest(org.cloudfoundry.client.v2.applications.AssociateApplicationRouteRequest) HashSet(java.util.HashSet) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry) GetApplicationRequest(org.cloudfoundry.client.v2.applications.GetApplicationRequest) CopyApplicationRequest(org.cloudfoundry.client.v2.applications.CopyApplicationRequest) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) GetApplicationPermissionsResponse(org.cloudfoundry.client.v2.applications.GetApplicationPermissionsResponse) CreateUserProvidedServiceInstanceResponse(org.cloudfoundry.client.v2.userprovidedserviceinstances.CreateUserProvidedServiceInstanceResponse) CloudFoundryVersion(org.cloudfoundry.CloudFoundryVersion) ApplicationInstanceInfo(org.cloudfoundry.client.v2.applications.ApplicationInstanceInfo) PaginationUtils(org.cloudfoundry.util.PaginationUtils) GetApplicationPermissionsRequest(org.cloudfoundry.client.v2.applications.GetApplicationPermissionsRequest) RemoveApplicationRouteRequest(org.cloudfoundry.client.v2.applications.RemoveApplicationRouteRequest) ApplicationEnvironmentRequest(org.cloudfoundry.client.v2.applications.ApplicationEnvironmentRequest) ListApplicationServiceBindingsRequest(org.cloudfoundry.client.v2.applications.ListApplicationServiceBindingsRequest) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ApplicationStatisticsRequest(org.cloudfoundry.client.v2.applications.ApplicationStatisticsRequest) AssociateApplicationRouteResponse(org.cloudfoundry.client.v2.applications.AssociateApplicationRouteResponse) Consumer(java.util.function.Consumer) UpdateApplicationResponse(org.cloudfoundry.client.v2.applications.UpdateApplicationResponse) CreateServiceBindingRequest(org.cloudfoundry.client.v2.servicebindings.CreateServiceBindingRequest) Flux(reactor.core.publisher.Flux) ApplicationInstancesResponse(org.cloudfoundry.client.v2.applications.ApplicationInstancesResponse) DownloadApplicationDropletRequest(org.cloudfoundry.client.v2.applications.DownloadApplicationDropletRequest) CreateApplicationRequest(org.cloudfoundry.client.v2.applications.CreateApplicationRequest) DelayUtils(org.cloudfoundry.util.DelayUtils) RemoveApplicationServiceBindingRequest(org.cloudfoundry.client.v2.applications.RemoveApplicationServiceBindingRequest) JobUtils(org.cloudfoundry.util.JobUtils) Collections(java.util.Collections) ApplicationInstancesRequest(org.cloudfoundry.client.v2.applications.ApplicationInstancesRequest) SummaryApplicationResponse(org.cloudfoundry.client.v2.applications.SummaryApplicationResponse) Assert(org.springframework.util.Assert) IOException(java.io.IOException) StepVerifier(reactor.test.StepVerifier) ClassPathResource(org.springframework.core.io.ClassPathResource) IfCloudFoundryVersion(org.cloudfoundry.IfCloudFoundryVersion) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with IfCloudFoundryVersion

use of org.cloudfoundry.IfCloudFoundryVersion 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 3 with IfCloudFoundryVersion

use of org.cloudfoundry.IfCloudFoundryVersion 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)3 IfCloudFoundryVersion (org.cloudfoundry.IfCloudFoundryVersion)3 IOException (java.io.IOException)2 Duration (java.time.Duration)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 CloudFoundryVersion (org.cloudfoundry.CloudFoundryVersion)2 Test (org.junit.Test)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TimeoutException (java.util.concurrent.TimeoutException)1 Consumer (java.util.function.Consumer)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)1