diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 44bcba1..e45b1a9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -49,7 +49,7 @@ test:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker run --privileged -dit --name provs_test -v /var/run/docker.sock:/var/run/docker.sock $CI_REGISTRY_IMAGE
- docker inspect -f '{{.State.Running}}' provs_test
- - ./gradlew test -Dtestdockerwithoutsudo=true
+ - ./gradlew test -Dtestdockerwithoutsudo=true -DexcludeTags=containertest
artifacts:
when: on_failure
paths:
diff --git a/.run/test.run.xml b/.run/test.run.xml
new file mode 100644
index 0000000..fa20242
--- /dev/null
+++ b/.run/test.run.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/testall.run.xml b/.run/testall.run.xml
new file mode 100644
index 0000000..e24ff1e
--- /dev/null
+++ b/.run/testall.run.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/platforms/UbuntuHostDockerKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/platforms/UbuntuHostDockerKtTest.kt
index 44de8d2..15736b7 100644
--- a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/platforms/UbuntuHostDockerKtTest.kt
+++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/platforms/UbuntuHostDockerKtTest.kt
@@ -4,17 +4,17 @@ import org.domaindrivenarchitecture.provs.framework.core.ProvResult
import org.domaindrivenarchitecture.provs.framework.core.docker.containerRuns
import org.domaindrivenarchitecture.provs.framework.core.docker.exitAndRmContainer
import org.domaindrivenarchitecture.provs.framework.core.docker.runContainer
+import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
import org.domaindrivenarchitecture.provs.test.tags.NonCi
import org.domaindrivenarchitecture.provs.test.testLocal
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.condition.EnabledOnOs
-import org.junit.jupiter.api.condition.OS
internal class UbuntuHostDockerKtTest {
@Test
@NonCi
+ @ContainerTest
fun runAndCheckAndExitContainer() {
// when
val containerName = "testContainer"
diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3dKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3dKtTest.kt
index 6974650..1fc19fe 100644
--- a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3dKtTest.kt
+++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3dKtTest.kt
@@ -1,12 +1,9 @@
package org.domaindrivenarchitecture.provs.server.infrastructure
-import org.domaindrivenarchitecture.provs.framework.core.docker
+import org.domaindrivenarchitecture.provs.framework.core.*
import org.domaindrivenarchitecture.provs.framework.core.docker.containerExec
import org.domaindrivenarchitecture.provs.framework.core.docker.provideContainer
-import org.domaindrivenarchitecture.provs.framework.core.local
import org.domaindrivenarchitecture.provs.framework.core.processors.ContainerStartMode
-import org.domaindrivenarchitecture.provs.server.apple.appleConfig
-import org.domaindrivenarchitecture.provs.server.apple.checkAppleService
import org.domaindrivenarchitecture.provs.server.domain.applyK8sConfig
import org.domaindrivenarchitecture.provs.server.domain.installK3sAsContainers
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
@@ -53,7 +50,6 @@ internal class K3dKtTest {
""".trimIndent())
}
-
// when
installK3sAsContainers()
applyK8sConfig(appleConfig())
@@ -66,3 +62,67 @@ internal class K3dKtTest {
assertTrue(result.success)
}
}
+
+
+/**
+ * Checks if URL "$host/apple" is available and return text "apple"
+ */
+private fun Prov.checkAppleService(host: String = "127.0.0.1") = requireLast {
+ // repeat required as curl may return with "empty reply from server" or with "Recv failure: Connection reset by peer"
+ val res = repeatTaskUntilSuccess(12, 10) {
+ cmd("curl -m 30 $host/apple")
+ }.out?.trim()
+
+ if ("apple" == res) {
+ ProvResult(true, out = res)
+ } else {
+ ProvResult(false, err = "Url $host/apple did not return text \"apple\" but returned: $res")
+ }
+}
+
+
+fun appleConfig() =
+ """
+kind: Ingress
+apiVersion: networking.k8s.io/v1
+metadata:
+ name: apple-ingress
+ annotations:
+ kubernetes.io/ingress.class: "traefik"
+spec:
+ rules:
+ - http:
+ paths:
+ - path: /apple
+ pathType: Prefix
+ backend:
+ service:
+ name: apple-service
+ port:
+ number: 5678
+---
+
+kind: Pod
+apiVersion: v1
+metadata:
+ name: apple-app
+ labels:
+ app: apple
+spec:
+ containers:
+ - name: apple-app
+ image: hashicorp/http-echo
+ args:
+ - "-text=apple"
+---
+
+kind: Service
+apiVersion: v1
+metadata:
+ name: apple-service
+spec:
+ selector:
+ app: apple
+ ports:
+ - port: 5678 # Default port for image
+ """