Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions .github/scripts/resolve-capi-version.sh

This file was deleted.

20 changes: 20 additions & 0 deletions .github/scripts/resolve-latest-capi-chart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Prints the newest version of the capi Helm chart (ghcr.io/cloudfoundry/helm/capi) that
# kind-deployment deploys. Needs only curl and python3, the registry allows anonymous pulls.
#
# Only release versions (1.252.0) and chart revisions of a release (1.252.1-1) count. Other tags,
# such as 1.237.1-fix1, are skipped.
set -euo pipefail

repository="cloudfoundry/helm/capi"
token="$(curl -fsSL --retry 3 "https://ghcr.io/token?scope=repository:$repository:pull" |
python3 -c 'import json, sys; print(json.load(sys.stdin)["token"])')"

version="$(curl -fsSL --retry 3 -H "Authorization: Bearer $token" "https://ghcr.io/v2/$repository/tags/list?n=10000" |
python3 -c 'import json, sys; print("\n".join(json.load(sys.stdin)["tags"]))' |
grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$' | sort -V | tail -1)"

[ -n "$version" ] || { echo "No capi chart version found in ghcr.io/$repository" >&2; exit 1; }

echo "latest capi chart -> $version" >&2
echo "$version"
71 changes: 41 additions & 30 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: false
default: '[8, 11, 17, 21]'
preview:
description: 'Deploy the latest cf-deployment versions instead of the default ones'
description: 'Deploy the latest cf-deployment versions instead of the default ones (v3 job only)'
type: boolean
required: false
default: false
Expand All @@ -23,7 +23,7 @@ on:
required: false
default: '[8, 11, 17, 21]'
preview:
description: 'Deploy the latest cf-deployment versions instead of the default ones'
description: 'Deploy the latest cf-deployment versions instead of the default ones (v3 job only)'
type: boolean
required: false
default: false
Expand All @@ -50,54 +50,64 @@ jobs:
fail-fast: false
matrix:
java: ${{ fromJSON(inputs.java-versions || (github.event_name == 'schedule' && '[21]' || '[8, 11, 17, 21]')) }}
name: Java ${{ matrix.java }} integration test${{ (inputs.preview || github.event_name == 'schedule') && ' (preview)' || '' }}
api: [v2, v3]
include:
# Newer CAPI releases disable the CC v2 API, so the v2 tests (@RequiresV2Api, JUnit tag
# "v2") run against a dedicated, pinned CAPI. The capi chart 1.249.0 is the last one that
# serves v2: from 1.249.1-1 on, v2 is behind cloudController.config.temporaryEnableV2,
# which kind-deployment v0.26.0 doesn't set. Newer kind-deployment versions don't deploy
# these older charts any more (their capi values schema changed with 1.249.1-1).
# Keep capi-version in sync with SUPPORTED_API_VERSION (2.299.0) in CloudFoundryClient.java.
- api: v2
kind-deployment-ref: b42a88a35756595bd4108d2b525ded5b014a9515 # v0.26.0
capi-version: 1.249.0
test-selection: -Dgroups=v2
skip-v2-tests: 'false'
# All other tests run against the latest capi chart, with v2 disabled.
- api: v3
kind-deployment-ref: 6b6882c54a23bfd23982299052ae681f481ad231 # main, 2026-11-13
capi-version: latest
test-selection: -DexcludedGroups=v2
skip-v2-tests: 'true'
name: Java ${{ matrix.java }} ${{ matrix.api }} integration test${{ matrix.api == 'v3' && (inputs.preview || github.event_name == 'schedule') && ' (preview)' || '' }}
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
# Validation runs deploy the capi-release that matches SUPPORTED_API_VERSION. Preview runs
# (scheduled, or started by hand with `preview`) keep the latest versions.
- name: Resolve CAPI version
id: capi
if: ${{ !(inputs.preview || github.event_name == 'schedule') }}
env:
CAPI_VERSION: ${{ matrix.capi-version }}
run: |
# separate assignment, so that a failing resolver fails the step
version="$(.github/scripts/resolve-capi-version.sh)"
echo "version=$version" >> "$GITHUB_OUTPUT"
if [ "$CAPI_VERSION" = latest ]; then
# separate assignment, so that a failing resolver fails the step
CAPI_VERSION="$(.github/scripts/resolve-latest-capi-chart.sh)"
fi
echo "version=$CAPI_VERSION" >> "$GITHUB_OUTPUT"
# All components share one Postgres, which runs out of its default 100 connections during a full
# test run. Written first, the CAPI override below appends to the same file.
- name: Write PostgreSQL values override
# test run.
# The capi chart version overrides the one of kind-deployment (merged last by Helmfile), also in
# preview runs.
- name: Write values override
env:
CAPI_VERSION: ${{ steps.capi.outputs.version }}
run: |
cat > "$RUNNER_TEMP/cf-values.yaml" <<EOF
postgresql:
primary:
extendedConfiguration: |
max_connections = 500
EOF
# Overrides the capi chart version of kind-deployment (merged last by Helmfile).
# kind-deployment's helmfile passes cloudController.appDomains, which the capi chart only
# accepts from 1.241.0 on (1.240.0 fails its values schema), so older matches are raised to it.
- name: Write CAPI values override
if: ${{ steps.capi.outputs.version != '' }}
env:
MIN_CAPI_VERSION: 1.241.0
MATCHED_CAPI_VERSION: ${{ steps.capi.outputs.version }}
run: |
version="$(printf '%s\n%s\n' "$MIN_CAPI_VERSION" "$MATCHED_CAPI_VERSION" | sort -V | tail -1)"
if [ "$version" != "$MATCHED_CAPI_VERSION" ]; then
echo "::warning::capi-release $MATCHED_CAPI_VERSION matches SUPPORTED_API_VERSION but is too old for kind-deployment, deploying $version"
fi
cat >> "$RUNNER_TEMP/cf-values.yaml" <<EOF
charts:
capi:
version: $version
version: $CAPI_VERSION
EOF
# Every job gets its own Cloud Foundry on KinD, so the matrix can run in parallel.
- name: Set up Cloud Foundry
uses: cloudfoundry/kind-deployment/.github/actions/setup-cf@b42a88a35756595bd4108d2b525ded5b014a9515 # v0.26.0
with:
ref: b42a88a35756595bd4108d2b525ded5b014a9515
use-latest-versions: ${{ (inputs.preview || github.event_name == 'schedule') }}
ref: ${{ matrix.kind-deployment-ref }}
# The v2 job stays on its pinned versions, preview runs only affect the v3 job
use-latest-versions: ${{ matrix.api == 'v3' && (inputs.preview || github.event_name == 'schedule') }}
github-token: ${{ github.token }}
additional-values-files: ${{ runner.temp }}/cf-values.yaml
- name: Set up Java
Expand All @@ -121,6 +131,7 @@ jobs:
TEST_ADMIN_CLIENTSECRET: ${{ env.UAA_ADMIN_SECRET }}
TEST_SKIPSSLVALIDATION: 'true'
TEST_QUOTAS_ROUTES_RESERVED_PORTS: '50'
SKIP_V2_TESTS: ${{ matrix.skip-v2-tests }}
# kind-deployment has no metric registrar, which the log-cache metric tests need
SKIP_METRIC_REGISTRAR_TESTS: 'true'
run: ./mvnw -B -Pintegration-test test -Dgpg.skip
run: ./mvnw -B -Pintegration-test test -Dgpg.skip ${{ matrix.test-selection }}
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public interface CloudFoundryClient {
/**
* The currently supported Cloud Controller API version
*/
String SUPPORTED_API_VERSION = "2.291.0";
String SUPPORTED_API_VERSION = "2.299.0";

String SUPPORTED_API_VERSION_V3 = "3.225.0";
String SUPPORTED_API_VERSION_V3 = "3.237.0";

/**
* Main entry point to the Cloud Foundry Application Usage Events Client API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,32 @@
import org.junit.jupiter.api.extension.ExtensionContext;
import org.springframework.core.annotation.AnnotationUtils;

/**
* Evaluates {@link IfCloudFoundryVersion}. The V2 and V3 API have separate version numbers, so
* every {@link CloudFoundryVersion} is compared with the server version of its own API: a 2.x
* version with the V2 API version from {@code /v2/info}, a 3.x version with the V3 API version
* from the root endpoint.
*/
final class CloudFoundryVersionConditionalRule implements ExecutionCondition {

private final Version server;
/**
* Stands in for the V2 API version of a server that has the V2 API disabled. Only CAPI
* releases newer than every V2 version referenced by a {@link CloudFoundryVersion} can disable
* the V2 API, so such a server counts as newer than all of them.
*/
static final Version V2_DISABLED = Version.of(2, Integer.MAX_VALUE, 0);

private final Version serverV2;

CloudFoundryVersionConditionalRule(Version server) {
this.server = server;
private final Version serverV3;

/**
* @param serverV2 the V2 API version of the server, empty if the server has the V2 API disabled
* @param serverV3 the V3 API version of the server
*/
CloudFoundryVersionConditionalRule(Optional<Version> serverV2, Version serverV3) {
this.serverV2 = serverV2.orElse(V2_DISABLED);
this.serverV3 = serverV3;
}

@Override
Expand All @@ -41,10 +61,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
IfCloudFoundryVersion annotation =
AnnotationUtils.findAnnotation(element, IfCloudFoundryVersion.class);

boolean enabled =
Optional.ofNullable(annotation)
.map(c -> isTestEnabled(c, CloudFoundryVersionConditionalRule.this.server))
.orElse(true);
boolean enabled = Optional.ofNullable(annotation).map(this::isTestEnabled).orElse(true);

return enabled
? ConditionEvaluationResult.enabled("Test enabled")
Expand All @@ -55,33 +72,61 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
element));
}

private static boolean isTestEnabled(IfCloudFoundryVersion condition, Version server) {
private boolean isTestEnabled(IfCloudFoundryVersion condition) {
boolean enabled = true;

if (condition.lessThan() != UNSPECIFIED) {
enabled = enabled && server.lessThan(condition.lessThan().getVersion());
enabled =
enabled
&& server(condition.lessThan())
.isLowerThan(version(condition.lessThan()));
}

if (condition.lessThanOrEqualTo() != UNSPECIFIED) {
enabled =
enabled && server.lessThanOrEqualTo(condition.lessThanOrEqualTo().getVersion());
enabled
&& server(condition.lessThanOrEqualTo())
.isLowerThanOrEquivalentTo(
version(condition.lessThanOrEqualTo()));
}

if (condition.equalTo() != UNSPECIFIED) {
enabled = enabled && server.equals(condition.equalTo().getVersion());
enabled = enabled && server(condition.equalTo()).equals(version(condition.equalTo()));
}

if (condition.greaterThanOrEqualTo() != UNSPECIFIED) {
enabled =
enabled
&& server.greaterThanOrEqualTo(
condition.greaterThanOrEqualTo().getVersion());
&& server(condition.greaterThanOrEqualTo())
.isHigherThanOrEquivalentTo(
version(condition.greaterThanOrEqualTo()));
}

if (condition.greaterThan() != UNSPECIFIED) {
enabled = enabled && server.greaterThan(condition.greaterThan().getVersion());
enabled =
enabled
&& server(condition.greaterThan())
.isHigherThan(version(condition.greaterThan()));
}

return enabled;
}

private Version server(CloudFoundryVersion version) {
long major = version(version).majorVersion();
if (major == 2) {
return this.serverV2;
}
if (major == 3) {
return this.serverV3;
}
throw new IllegalArgumentException(
String.format(
"%s is neither a V2 (2.x) nor a V3 (3.x) API version: %s",
version, version(version)));
}

private static Version version(CloudFoundryVersion version) {
return version.getVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,11 @@ DefaultCloudFoundryOperations cloudFoundryOperations(
}

@Bean
CloudFoundryVersionConditionalRule cloudFoundryVersionConditionalRule(Version serverVersion) {
return new CloudFoundryVersionConditionalRule(serverVersion);
CloudFoundryVersionConditionalRule cloudFoundryVersionConditionalRule(
@Qualifier("admin") CloudFoundryClient cloudFoundryClient) {
return new CloudFoundryVersionConditionalRule(
serverVersionV2(cloudFoundryClient).blockOptional(),
serverVersionV3(cloudFoundryClient).block());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -43,14 +44,22 @@
* <pre>
* export SKIP_V2_TESTS=true
* </pre>
*
* <p>Tests annotated with this are also tagged with {@value #TAG}, so that they can be selected
* ({@code -Dgroups=v2}) or excluded ({@code -DexcludedGroups=v2}) on their own, e.g. to run them
* against a Cloud Foundry that still serves the V2 API.
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@ExtendWith(RequiresV2Api.V2ApiCondition.class)
@Tag(RequiresV2Api.TAG)
public @interface RequiresV2Api {

/** JUnit tag of all tests that require the V2 API. */
String TAG = "v2";

/** Environment variable name used to skip V2 API tests. */
String SKIP_V2_TESTS_ENV = "SKIP_V2_TESTS";

Expand Down
Loading