-
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.
Signed-off-by: csviri <[email protected]>
- Loading branch information
Showing
2 changed files
with
81 additions
and
66 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
141 changes: 75 additions & 66 deletions
141
src/test/java/io/csviri/operator/resourceglue/sample/webpage/WebPageSampleTest.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 |
---|---|---|
@@ -1,69 +1,78 @@ | ||
package io.csviri.operator.resourceglue.sample.webpage; | ||
|
||
public class WebPageSampleTest { | ||
|
||
// todo | ||
|
||
// @RegisterExtension | ||
// LocallyRunOperatorExtension extension = | ||
// LocallyRunOperatorExtension.builder() | ||
// .withReconciler(new GlueReconciler()) | ||
// .withReconciler(new GlueOperatorReconciler()) | ||
// .build(); | ||
// | ||
// @Test | ||
// void webPageCRUD() { | ||
// TestUtils.createOrUpdate(extension, "/sample/webpage/webpage.crd.yml"); | ||
// TestUtils.createOrUpdate(extension, "/sample/webpage/webpage.operator.yaml"); | ||
// var webPage = TestUtils.createOrUpdate(extension, "/sample/webpage/webpage.sample.yaml"); | ||
// | ||
// await().untilAsserted(() -> { | ||
// var deployment = extension.get(Deployment.class, webPage.getMetadata().getName()); | ||
// var configMap = extension.get(ConfigMap.class, webPage.getMetadata().getName()); | ||
// var service = extension.get(Service.class, webPage.getMetadata().getName()); | ||
// var ingress = extension.get(Ingress.class, webPage.getMetadata().getName()); | ||
// | ||
// assertThat(ingress).isNull(); | ||
// assertThat(deployment).isNotNull(); | ||
// assertThat(service).isNotNull(); | ||
// assertThat(configMap).isNotNull(); | ||
// assertThat(configMap.getData().get("index.html")).contains("Hello World!"); | ||
// }); | ||
// | ||
// setExposed(webPage); | ||
// setNewHtml(webPage); | ||
// extension.replace(webPage); | ||
// | ||
// await().untilAsserted(() -> { | ||
// var ingress = extension.get(Ingress.class, webPage.getMetadata().getName()); | ||
// var configMap = extension.get(ConfigMap.class, webPage.getMetadata().getName()); | ||
// | ||
// assertThat(configMap.getData().get("index.html")).contains("Hello World 2!"); | ||
// assertThat(ingress).isNotNull(); | ||
// }); | ||
// | ||
// extension.delete(webPage); | ||
// | ||
// await().untilAsserted(() -> { | ||
// var deployment = extension.get(Deployment.class, webPage.getMetadata().getName()); | ||
// assertThat(deployment).isNull(); | ||
// }); | ||
// } | ||
// | ||
// private void setNewHtml(GenericKubernetesResource webPage) { | ||
// ((HashMap<String, Object>) webPage.getAdditionalProperties().get("spec")).put("html", """ | ||
// <html> | ||
// <head> | ||
// <title>Hello Operator World</title> | ||
// </head> | ||
// <body> | ||
// Hello World 2! | ||
// </body> | ||
// </html> | ||
// """); | ||
// } | ||
// | ||
// private void setExposed(GenericKubernetesResource webPage) { | ||
// ((HashMap<String, Object>) webPage.getAdditionalProperties().get("spec")).put("exposed", true); | ||
// } | ||
import java.util.HashMap; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.csviri.operator.resourceglue.TestBase; | ||
import io.csviri.operator.resourceglue.TestUtils; | ||
import io.fabric8.kubernetes.api.model.ConfigMap; | ||
import io.fabric8.kubernetes.api.model.GenericKubernetesResource; | ||
import io.fabric8.kubernetes.api.model.Service; | ||
import io.fabric8.kubernetes.api.model.apps.Deployment; | ||
import io.fabric8.kubernetes.api.model.networking.v1.Ingress; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
@QuarkusTest | ||
public class WebPageSampleTest extends TestBase { | ||
|
||
@Test | ||
void webPageCRUD() { | ||
|
||
createOrUpdate(TestUtils.load("/sample/webpage/webpage.crd.yml")); | ||
createOrUpdate(TestUtils.load("/sample/webpage/webpage.operator.yaml")); | ||
var webPage = createOrUpdate(TestUtils.load("/sample/webpage/webpage.sample.yaml")); | ||
|
||
await().untilAsserted(() -> { | ||
var deployment = get(Deployment.class, webPage.getMetadata().getName()); | ||
var configMap = get(ConfigMap.class, webPage.getMetadata().getName()); | ||
var service = get(Service.class, webPage.getMetadata().getName()); | ||
var ingress = get(Ingress.class, webPage.getMetadata().getName()); | ||
|
||
assertThat(ingress).isNull(); | ||
assertThat(deployment).isNotNull(); | ||
assertThat(service).isNotNull(); | ||
assertThat(configMap).isNotNull(); | ||
assertThat(configMap.getData().get("index.html")).contains("Hello World!"); | ||
}); | ||
|
||
setExposed(webPage); | ||
setNewHtml(webPage); | ||
update(webPage); | ||
|
||
await().untilAsserted(() -> { | ||
var ingress = get(Ingress.class, webPage.getMetadata().getName()); | ||
var configMap = get(ConfigMap.class, webPage.getMetadata().getName()); | ||
|
||
assertThat(configMap.getData().get("index.html")).contains("Hello World 2!"); | ||
assertThat(ingress).isNotNull(); | ||
}); | ||
|
||
delete(webPage); | ||
|
||
await().untilAsserted(() -> { | ||
var deployment = get(Deployment.class, webPage.getMetadata().getName()); | ||
assertThat(deployment).isNull(); | ||
}); | ||
} | ||
|
||
private void setNewHtml(GenericKubernetesResource webPage) { | ||
((HashMap<String, Object>) webPage.getAdditionalProperties().get("spec")).put("html", """ | ||
<html> | ||
<head> | ||
<title>Hello Operator World</title> | ||
</head> | ||
<body> | ||
Hello World 2! | ||
</body> | ||
</html> | ||
"""); | ||
} | ||
|
||
private void setExposed(GenericKubernetesResource webPage) { | ||
((HashMap<String, Object>) webPage.getAdditionalProperties().get("spec")).put("exposed", true); | ||
} | ||
} |