forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Knative: Do not set get action port to null in custom resources
Relates quarkusio#29962
- Loading branch information
Showing
6 changed files
with
126 additions
and
2 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
66 changes: 66 additions & 0 deletions
66
...way/src/test/java/io/quarkus/it/kubernetes/KnativeWithExistingDeploymentResourceTest.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,66 @@ | ||
|
||
package io.quarkus.it.kubernetes; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
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.apps.Deployment; | ||
import io.quarkus.kubernetes.spi.CustomProjectRootBuildItem; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class KnativeWithExistingDeploymentResourceTest { | ||
|
||
private static final String APP_NAME = "knative-with-existing-deployment-resource"; | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) | ||
.setApplicationName(APP_NAME) | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.withConfigurationResource(APP_NAME + ".properties") | ||
.addCustomResourceEntry(Path.of("src", "main", "kubernetes", "knative.yml"), | ||
"manifests/" + APP_NAME + "/knative.yml") | ||
.addBuildChainCustomizerEntries( | ||
new QuarkusProdModeTest.BuildChainCustomizerEntry( | ||
KubernetesWithCustomResourcesTest.CustomProjectRootBuildItemProducerProdMode.class, | ||
Collections.singletonList(CustomProjectRootBuildItem.class), Collections.emptyList())); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void assertGeneratedResources() throws IOException { | ||
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); | ||
assertThat(kubernetesDir) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml")); | ||
|
||
List<HasMetadata> kubernetesList = DeserializationUtil | ||
.deserializeAsList(kubernetesDir.resolve("knative.yml")); | ||
|
||
assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind()) | ||
&& "example".equals(i.getMetadata().getName())) | ||
.singleElement() | ||
.satisfies(e -> { | ||
assertThat(e).isInstanceOfSatisfying(Deployment.class, deployment -> { | ||
assertThat(deployment.getSpec().getTemplate().getSpec().getContainers()).allSatisfy(container -> { | ||
assertThat(container.getLivenessProbe().getHttpGet().getPort().getIntVal()).isEqualTo(8080); | ||
assertThat(container.getReadinessProbe().getHttpGet().getPort().getIntVal()).isEqualTo(8080); | ||
|
||
assertThat(container.getResources().getRequests().get("memory").getAmount()).isEqualTo("128"); | ||
assertThat(container.getResources().getLimits().get("memory").getAmount()).isEqualTo("768"); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
...rkus-standard-way/src/test/resources/knative-with-existing-deployment-resource.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,5 @@ | ||
# Configuration file | ||
quarkus.kubernetes.deployment-target=knative | ||
|
||
quarkus.knative.resources.limits.memory=768Mi | ||
quarkus.knative.resources.requests.memory=256Mi |
49 changes: 49 additions & 0 deletions
49
...rd-way/src/test/resources/manifests/knative-with-existing-deployment-resource/knative.yml
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,49 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: example | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: example | ||
template: | ||
metadata: | ||
labels: | ||
name: example | ||
spec: | ||
containers: | ||
- image: docker.io/group/app | ||
name: example | ||
livenessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /health/live | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 0 | ||
periodSeconds: 30 | ||
successThreshold: 1 | ||
timeoutSeconds: 10 | ||
readinessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /health/ready | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 0 | ||
periodSeconds: 30 | ||
successThreshold: 1 | ||
timeoutSeconds: 10 | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
env: | ||
- name: REGISTRY_AUTH_ANONYMOUS_READ_ACCESS_ENABLED | ||
value: "true" | ||
resources: | ||
limits: | ||
memory: 768Mi | ||
requests: | ||
memory: 128Mi |