diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/packages/ReactorPackages.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/packages/ReactorPackages.java index 01279e990b..9cb55f8709 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/packages/ReactorPackages.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/packages/ReactorPackages.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2026 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,9 @@ public Mono listDroplets(ListPackageDropletsRequest public Mono upload(UploadPackageRequest request) { Path bits = request.getBits(); - if (bits.toFile().isDirectory()) { + // bits is null when uploading via resource matching only (all files already cached on + // server) + if (bits != null && bits.toFile().isDirectory()) { return FileUtils.compress(bits) .map( temporaryFile -> diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/FeatureFlagsV3Test.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/FeatureFlagsV3Test.java index 40bcfa7fac..45289e4de5 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/FeatureFlagsV3Test.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/FeatureFlagsV3Test.java @@ -112,7 +112,7 @@ public void updateCustomErrorMessage() { .as(StepVerifier::create) .expectNext(newMessage) .expectComplete() - .verify(Duration.ofMinutes(5)); + .verify(Duration.ofMinutes(8)); } @Test diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/ResourceMatchTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/ResourceMatchTest.java index 4e3c2f1401..a06895d89a 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/ResourceMatchTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/ResourceMatchTest.java @@ -29,6 +29,7 @@ import org.cloudfoundry.client.v3.applications.Application; import org.cloudfoundry.client.v3.applications.ApplicationRelationships; import org.cloudfoundry.client.v3.applications.CreateApplicationRequest; +import org.cloudfoundry.client.v3.featureflags.GetFeatureFlagRequest; import org.cloudfoundry.client.v3.packages.CreatePackageRequest; import org.cloudfoundry.client.v3.packages.GetPackageRequest; import org.cloudfoundry.client.v3.packages.GetPackageResponse; @@ -40,8 +41,8 @@ import org.cloudfoundry.util.DelayTimeoutException; import org.cloudfoundry.util.ExceptionUtils; import org.cloudfoundry.util.ResourceMatchingUtilsV3; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import reactor.core.Exceptions; @@ -54,22 +55,23 @@ public class ResourceMatchTest extends AbstractIntegrationTest { @Autowired private Mono spaceId; + // enable resource_matching with: cf enable-feature-flag resource_matching @IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_9) @Test - @Disabled( - "Cloud Controller is configured not to cache resource smaller than 4k - Find a better" - + " way to test this") + @DisabledIf("resource_matching_disabled") public void upload() throws IOException { createAndUploadPackage() .flatMap(this::waitForReady) .then( ResourceMatchingUtilsV3.getMatchedResources( this.cloudFoundryClient, - new ClassPathResource("test-application.zip").getFile().toPath())) + new ClassPathResource("test-service-broker.jar") + .getFile() + .toPath())) .as(StepVerifier::create) .consumeNextWith(matchedResources -> assertThat(matchedResources).isNotEmpty()) .expectComplete() - .verify(Duration.ofMinutes(5)); + .verify(Duration.ofMinutes(10)); } private Mono createAndUploadPackage() { @@ -130,7 +132,7 @@ private Mono createAndUploadPackage() { .packageId(packageId) .bits( new ClassPathResource( - "test-application.zip") + "test-service-broker.jar") .getFile() .toPath()) .build()); @@ -168,4 +170,13 @@ private Mono waitForReady(String packageId) { "Package %s timed out during upload processing", packageId)); } + + boolean resource_matching_disabled() { + return !this.cloudFoundryClient + .featureFlagsV3() + .get(GetFeatureFlagRequest.builder().name("resource_matching").build()) + .map(response -> response.getEnabled()) + .onErrorReturn(false) + .block(); + } } diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java index fc93977098..fec5d0c3ef 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java @@ -53,7 +53,6 @@ import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest; import org.cloudfoundry.util.JobUtils; import org.cloudfoundry.util.PaginationUtils; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; @@ -177,8 +176,8 @@ public void delete() { } // TODO: Await resolution of https://github.com/cloudfoundry/cloud_controller_ng/issues/1876 + // Issue from 2020 is not closed, but test seems to run. @IfCloudFoundryVersion(greaterThan = CloudFoundryVersion.PCF_2_9) - @Disabled("Await https://github.com/cloudfoundry/cf-java-client/issues/1876") @Test public void deleteUnmappedRoutes() { String domainName = this.nameFactory.getDomainName();