aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamruddhi Khandale <skhandale@microsoft.com>2022-11-24 02:03:07 +0300
committerGitHub <noreply@github.com>2022-11-24 02:03:07 +0300
commit4b3ccf36eabcad859a13806a8dc47dfa651182a1 (patch)
tree31bebbe272b46d737093e1ea98bebf90b73f260b
parent188f1ef26bc8fa942d552dfaa8596091a8a39126 (diff)
Adds test coverage (#308)
* Add test coverage * temp: debug test * Update tests
-rwxr-xr-xtest/desktop-lite/test.sh4
-rw-r--r--test/docker-from-docker/docker_init.sh15
-rw-r--r--test/docker-from-docker/scenarios.json11
-rwxr-xr-xtest/docker-from-docker/test.sh2
-rw-r--r--test/docker-in-docker/azureDnsAutoDetectionDisabled.sh2
-rw-r--r--test/docker-in-docker/azureDnsAutoDetectionEnabled.sh2
-rw-r--r--test/docker-in-docker/dockerDefaultAddressPool.sh2
-rwxr-xr-xtest/docker-in-docker/test.sh7
-rwxr-xr-xtest/sshd/test.sh6
9 files changed, 45 insertions, 6 deletions
diff --git a/test/desktop-lite/test.sh b/test/desktop-lite/test.sh
index bd0a516..9009aa9 100755
--- a/test/desktop-lite/test.sh
+++ b/test/desktop-lite/test.sh
@@ -5,7 +5,9 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-echo 'NO TESTS FOR ME YET!'
+check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
+check "log-exists" bash -c "ls /tmp/container-init.log"
+check "fluxbox-exists" bash -c "ls -la ~/.fluxbox"
# Report result
reportResults \ No newline at end of file
diff --git a/test/docker-from-docker/docker_init.sh b/test/docker-from-docker/docker_init.sh
new file mode 100644
index 0000000..2164921
--- /dev/null
+++ b/test/docker-from-docker/docker_init.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+# Optional: Import test library
+source dev-container-features-test-lib
+
+check "docker-init-exists" bash -c "ls /usr/local/share/docker-init.sh"
+check "log-exists" bash -c "ls /tmp/vscr-docker-from-docker.log"
+check "log-contents-for-success" bash -c "cat /tmp/vscr-docker-from-docker.log | grep 'Success'"
+check "log-contents" bash -c "cat /tmp/vscr-docker-from-docker.log | grep 'Proxying /var/run/docker-host.sock to /var/run/docker.sock for vscode'"
+check "docker-ps" bash -c "docker ps"
+
+# Report result
+reportResults \ No newline at end of file
diff --git a/test/docker-from-docker/scenarios.json b/test/docker-from-docker/scenarios.json
new file mode 100644
index 0000000..196e00b
--- /dev/null
+++ b/test/docker-from-docker/scenarios.json
@@ -0,0 +1,11 @@
+{
+ "docker_init": {
+ "image": "mcr.microsoft.com/devcontainers/base",
+ "remoteUser": "vscode",
+ "features": {
+ "docker-from-docker": {
+ "version": "latest"
+ }
+ }
+ }
+}
diff --git a/test/docker-from-docker/test.sh b/test/docker-from-docker/test.sh
index 3a802b5..517737a 100755
--- a/test/docker-from-docker/test.sh
+++ b/test/docker-from-docker/test.sh
@@ -7,6 +7,8 @@ source dev-container-features-test-lib
# Definition specific tests
check "version" docker --version
+check "docker-init-exists" bash -c "ls /usr/local/share/docker-init.sh"
+check "docker-ps" bash -c "docker ps"
# Report result
reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh b/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh
index d3f4159..2415116 100644
--- a/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh
+++ b/test/docker-in-docker/azureDnsAutoDetectionDisabled.sh
@@ -6,7 +6,7 @@ set -e
source dev-container-features-test-lib
# Definition specific tests
-check "dns flag should not be present" test ! "$(ps -ax | grep -E 'dockerd.+\-\-dns')"
+check "dns flag should not be present" test ! "$(ps -ax | grep -v grep | grep -E 'dockerd.+\-\-dns')"
# Report result
reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh b/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh
index e63a1f3..87f158a 100644
--- a/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh
+++ b/test/docker-in-docker/azureDnsAutoDetectionEnabled.sh
@@ -6,7 +6,7 @@ set -e
source dev-container-features-test-lib
# Definition specific tests
-check "dns flag should be present" ps -ax | grep -E "dockerd.+\-\-dns"
+check "dns flag should be present" ps -ax | grep -v grep | grep -E "dockerd.+\-\-dns"
# Report result
reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/dockerDefaultAddressPool.sh b/test/docker-in-docker/dockerDefaultAddressPool.sh
index 8345357..219ad82 100644
--- a/test/docker-in-docker/dockerDefaultAddressPool.sh
+++ b/test/docker-in-docker/dockerDefaultAddressPool.sh
@@ -6,7 +6,7 @@ set -e
source dev-container-features-test-lib
# Definition specific tests
-check "default address pool setting set" ps -ax | grep -E "dockerd.+base=192.168.0.0/16,size=24"
+check "default address pool setting set" ps -ax | grep -v grep | grep -E "dockerd.+base=192.168.0.0/16,size=24"
# Report result
reportResults \ No newline at end of file
diff --git a/test/docker-in-docker/test.sh b/test/docker-in-docker/test.sh
index 3a802b5..1eebfd2 100755
--- a/test/docker-in-docker/test.sh
+++ b/test/docker-in-docker/test.sh
@@ -5,8 +5,13 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-# Definition specific tests
+# Feature specific tests
check "version" docker --version
+check "docker-init-exists" bash -c "ls /usr/local/share/docker-init.sh"
+check "log-exists" bash -c "ls /tmp/dockerd.log"
+check "log-for-completion" bash -c "cat /tmp/dockerd.log | grep 'Daemon has completed initialization'"
+check "log-contents" bash -c "cat /tmp/dockerd.log | grep 'API listen on /var/run/docker.sock'"
+check "docker-ps" bash -c "docker ps"
# Report result
reportResults \ No newline at end of file
diff --git a/test/sshd/test.sh b/test/sshd/test.sh
index bd0a516..6aac9e5 100755
--- a/test/sshd/test.sh
+++ b/test/sshd/test.sh
@@ -5,7 +5,11 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib
-echo 'NO TESTS FOR ME YET!'
+check "sshd-init-exists" bash -c "ls /usr/local/share/ssh-init.sh"
+check "sshd-log-exists" bash -c "ls /tmp/sshd.log"
+check "sshd-log-contents" bash -c "cat /tmp/sshd.log | grep 'Starting OpenBSD Secure Shell server'"
+check "sshd-log-has-sshd" bash -c "cat /tmp/sshd.log | grep 'sshd'"
+check "sshd" bash -c "ps -aux | grep -v grep | grep sshd"
# Report result
reportResults \ No newline at end of file