|
| 1 | +package io.quarkus.it.kubernetes; |
| 2 | + |
| 3 | +import static org.assertj.core.api.Assertions.assertThat; |
| 4 | + |
| 5 | +import java.io.IOException; |
| 6 | +import java.nio.file.Path; |
| 7 | +import java.util.List; |
| 8 | + |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | +import org.junit.jupiter.api.extension.RegisterExtension; |
| 11 | + |
| 12 | +import io.fabric8.kubernetes.api.model.HasMetadata; |
| 13 | +import io.fabric8.kubernetes.api.model.apps.Deployment; |
| 14 | +import io.quarkus.builder.Version; |
| 15 | +import io.quarkus.maven.dependency.Dependency; |
| 16 | +import io.quarkus.test.ProdBuildResults; |
| 17 | +import io.quarkus.test.ProdModeTestResults; |
| 18 | +import io.quarkus.test.QuarkusProdModeTest; |
| 19 | + |
| 20 | +public class OpenshiftWithEnvFromConfigMapWithPrefixTest { |
| 21 | + |
| 22 | + @RegisterExtension |
| 23 | + static final QuarkusProdModeTest config = new QuarkusProdModeTest() |
| 24 | + .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) |
| 25 | + .setApplicationName("env-from-config-map-with-prefix") |
| 26 | + .setApplicationVersion("0.1-SNAPSHOT") |
| 27 | + .withConfigurationResource("openshift-with-env-from-configmap-with-prefix.properties") |
| 28 | + .overrideConfigKey("quarkus.openshift.deployment-kind", "Deployment") |
| 29 | + .setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-openshift", Version.getVersion()))); |
| 30 | + |
| 31 | + @ProdBuildResults |
| 32 | + private ProdModeTestResults prodModeTestResults; |
| 33 | + |
| 34 | + @Test |
| 35 | + public void assertGeneratedResources() throws IOException { |
| 36 | + Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); |
| 37 | + assertThat(kubernetesDir) |
| 38 | + .isDirectoryContaining(p -> p.getFileName().endsWith("openshift.json")) |
| 39 | + .isDirectoryContaining(p -> p.getFileName().endsWith("openshift.yml")); |
| 40 | + List<HasMetadata> kubernetesList = DeserializationUtil |
| 41 | + .deserializeAsList(kubernetesDir.resolve("openshift.yml")); |
| 42 | + assertThat(kubernetesList).filteredOn(i -> i instanceof Deployment).singleElement() |
| 43 | + .isInstanceOfSatisfying(Deployment.class, d -> { |
| 44 | + assertThat(d.getMetadata()).satisfies(m -> { |
| 45 | + assertThat(m.getName()).isEqualTo("env-from-config-map-with-prefix"); |
| 46 | + }); |
| 47 | + |
| 48 | + assertThat(d.getSpec()).satisfies(deploymentSpec -> { |
| 49 | + assertThat(deploymentSpec.getTemplate()).satisfies(t -> { |
| 50 | + assertThat(t.getSpec()).satisfies(podSpec -> { |
| 51 | + assertThat(podSpec.getContainers()).singleElement().satisfies(container -> { |
| 52 | + |
| 53 | + assertThat(container.getEnvFrom()).satisfies(env -> { |
| 54 | + |
| 55 | + assertThat(env).anyMatch(item -> item.getPrefix().equals("QUARKUS") && |
| 56 | + item.getConfigMapRef().getName().equals("my-config-map")); |
| 57 | + |
| 58 | + }); |
| 59 | + }); |
| 60 | + }); |
| 61 | + }); |
| 62 | + }); |
| 63 | + }); |
| 64 | + } |
| 65 | +} |
0 commit comments