From bef27de81ffdea7431686f2a2fbc459a5aae0fc9 Mon Sep 17 00:00:00 2001 From: Hans Schulz Date: Tue, 11 Feb 2025 11:17:59 +0100 Subject: [PATCH 1/3] fix docker serialization and disk_quota --- .../applications/ApplicationManifestUtilsCommon.java | 6 +++++- .../operations/applications/ApplicationManifestUtilsV3.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsCommon.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsCommon.java index 932809d56a..79b50ab809 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsCommon.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsCommon.java @@ -423,7 +423,11 @@ static Map toApplicationYaml(_ApplicationManifestCommon applicat if (null != disk) { putIfPresent(yaml, "disk_quota", applicationManifest.getDisk().toString() + "M"); } - putIfPresent(yaml, "docker", applicationManifest.getDocker()); + putIfPresent( + yaml, + "docker", + applicationManifest.getDocker(), + ApplicationManifestUtilsCommon::toDockerYaml); putIfPresent(yaml, "domains", applicationManifest.getDomains()); putIfPresent(yaml, "env", applicationManifest.getEnvironmentVariables()); putIfPresent( diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java index fb7dc2e1bf..fffef8ad04 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java @@ -197,7 +197,7 @@ private static ManifestV3Process getProcess( asString(raw, "type", variables, builder::type); asString(raw, "command", variables, builder::command); - asString(raw, "disk", variables, builder::disk); + asString(raw, "disk_quota", variables, builder::disk); asString(raw, "health-check-http-endpoint", variables, builder::healthCheckHttpEndpoint); asInteger( raw, From b1a5fe57eb06788f00cf79a181ce06bcf78485b2 Mon Sep 17 00:00:00 2001 From: Hans Schulz Date: Thu, 13 Feb 2025 16:53:13 +0100 Subject: [PATCH 2/3] add test --- .../ApplicationManifestUtilsV3Test.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java diff --git a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java new file mode 100644 index 0000000000..d21970d27f --- /dev/null +++ b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java @@ -0,0 +1,59 @@ +package org.cloudfoundry.operations.applications; + +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import org.junit.jupiter.api.Test; + +class ApplicationManifestUtilsV3Test { + @Test + void testGenericApplication() throws IOException { + ManifestV3 manifest = + ManifestV3.builder() + .application( + ManifestV3Application.builder() + .name("test-app") + .buildpack("test-buildpack") + .command("test-command") + .disk(512) + .healthCheckHttpEndpoint("test-health-check-http-endpoint") + .instances(2) + .memory(512) + .randomRoute(true) + .stack("test-stack") + .timeout(120) + .environmentVariable("TEST_KEY_1", "test-value-1") + .service( + ManifestV3Service.builder() + .name("test-service-1") + .build()) + .build()) + .build(); + + assertSerializeDeserialize(manifest); + } + + @Test + void testWithDockerApp() throws IOException { + ManifestV3 manifest = + ManifestV3.builder() + .application( + ManifestV3Application.builder() + .name("test-app") + .docker(Docker.builder().image("test-image").build()) + .build()) + .build(); + + assertSerializeDeserialize(manifest); + } + + private void assertSerializeDeserialize(ManifestV3 manifest) throws IOException { + Path file = Files.createTempFile("test-manifest-", ".yml"); + ApplicationManifestUtilsV3.write(file, manifest); + ManifestV3 read = ApplicationManifestUtilsV3.read(file); + + assertEquals(manifest, read); + } +} From 8117875e16d72f38cdcbcb491f3a3f9b50907ebf Mon Sep 17 00:00:00 2001 From: Hans Schulz Date: Fri, 21 Feb 2025 21:18:16 +0100 Subject: [PATCH 3/3] fix readiness and health check type serialization --- .../applications/ApplicationManifestUtilsV3.java | 9 +++++++-- .../applications/ApplicationManifestUtilsV3Test.java | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java index fffef8ad04..942e1e9d74 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java @@ -315,8 +315,13 @@ private static Map toProcessYaml(ManifestV3Process process) { putIfPresent(yaml, "health-check-http-endpoint", process.getHealthCheckHttpEndpoint()); putIfPresent( yaml, "health-check-invocation-timeout", process.getHealthCheckInvocationTimeout()); - putIfPresent(yaml, "health-check-type", process.getHealthCheckType().getValue()); - putIfPresent(yaml, "readiness-health-check-type", process.getReadinessHealthCheckType()); + putIfPresent( + yaml, "health-check-type", process.getHealthCheckType(), HealthCheckType::getValue); + putIfPresent( + yaml, + "readiness-health-check-type", + process.getReadinessHealthCheckType(), + ReadinessHealthCheckType::getValue); putIfPresent( yaml, "readiness-health-check-http-endpoint", diff --git a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java index d21970d27f..fd7826d444 100644 --- a/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java +++ b/cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3Test.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.junit.jupiter.api.Test; class ApplicationManifestUtilsV3Test { @@ -25,6 +26,16 @@ void testGenericApplication() throws IOException { .stack("test-stack") .timeout(120) .environmentVariable("TEST_KEY_1", "test-value-1") + .processe( + ManifestV3Process.builder() + .type("web") + .command("test-command-1") + .readinessHealthCheckType( + ReadinessHealthCheckType.HTTP) + .readinessHealthCheckHttpEndpoint( + "test-readiness-health-check-http-endpoint") + .readinessHealthCheckInvocationTimeout(120) + .build()) .service( ManifestV3Service.builder() .name("test-service-1")