-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves: #17582
- Loading branch information
Showing
6 changed files
with
154 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithMultiplePortsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.Service; | ||
import io.fabric8.kubernetes.api.model.apps.Deployment; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class KubernetesWithMultiplePortsTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(GreetingResource.class)) | ||
.setApplicationName("kubernetes-with-multiple-ports") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource("kubernetes-with-multiple-ports.properties"); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void assertGeneratedResources() throws IOException { | ||
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); | ||
assertThat(kubernetesDir) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json")) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml")); | ||
List<HasMetadata> kubernetesList = DeserializationUtil | ||
.deserializeAsList(kubernetesDir.resolve("kubernetes.yml")); | ||
|
||
assertThat(kubernetesList).hasSize(2); | ||
|
||
assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).singleElement().satisfies(i -> { | ||
assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { | ||
assertThat(d.getMetadata()).satisfies(m -> { | ||
assertThat(m.getName()).isEqualTo("kubernetes-with-multiple-ports"); | ||
}); | ||
|
||
assertThat(d.getSpec()).satisfies(deploymentSpec -> { | ||
assertThat(deploymentSpec.getTemplate()).satisfies(t -> { | ||
assertThat(t.getSpec()).satisfies(podSpec -> { | ||
assertThat(podSpec.getContainers()).singleElement().satisfies(container -> { | ||
assertThat(container.getPorts()).hasSize(2); | ||
assertThat(container.getPorts()).filteredOn(cp -> cp.getContainerPort() == 8080).singleElement() | ||
.satisfies(c -> assertThat(c.getName()).isEqualTo("http")); | ||
assertThat(container.getPorts()).filteredOn(cp -> cp.getContainerPort() == 5005).singleElement() | ||
.satisfies(c -> assertThat(c.getName()).isEqualTo("remote")); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
assertThat(kubernetesList).filteredOn(i -> "Service".equals(i.getKind())).singleElement().satisfies(i -> { | ||
assertThat(i).isInstanceOfSatisfying(Service.class, s -> { | ||
assertThat(s.getSpec()).satisfies(spec -> { | ||
assertEquals("NodePort", spec.getType()); | ||
assertThat(spec.getPorts()).hasSize(2); | ||
assertThat(spec.getPorts()).filteredOn(sp -> sp.getPort() == 8080).singleElement().satisfies(p -> { | ||
assertThat(p.getNodePort()).isEqualTo(30000); | ||
}); | ||
assertThat(spec.getPorts()).filteredOn(sp -> sp.getPort() == 5005).singleElement().satisfies(p -> { | ||
assertThat(p.getNodePort()).isEqualTo(31000); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...ernetes/quarkus-standard-way/src/test/resources/kubernetes-with-multiple-ports.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
quarkus.kubernetes.ports.http.name=http | ||
quarkus.kubernetes.ports.http.host-port=8080 | ||
quarkus.kubernetes.ports.http.container-port=8080 | ||
quarkus.kubernetes.ports.http.node-port=30000 | ||
quarkus.kubernetes.ports.remote.name=http | ||
quarkus.kubernetes.ports.remote.host-port=5005 | ||
quarkus.kubernetes.ports.remote.container-port=5005 | ||
quarkus.kubernetes.ports.remote.node-port=31000 | ||
quarkus.kubernetes.service-type=NodePort |