diff options
author | Chuck Lantz <clantz@microsoft.com> | 2022-12-16 20:47:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-16 20:47:21 +0300 |
commit | bf058dc49492b3a102a28ed25764a517fcebfb40 (patch) | |
tree | 6ccc831064fab57ea6fa2f0c530202ac0d73ff08 /test | |
parent | 7fa90110d762797cc0b1c2fe8fcc028c9b813d56 (diff) |
Multi-distro support for common script, refactor, fixes (#326)
Diffstat (limited to 'test')
-rwxr-xr-x | test/common-utils/alpine.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/already-run.sh | 18 | ||||
-rwxr-xr-x | test/common-utils/alternate-values.sh | 19 | ||||
-rwxr-xr-x | test/common-utils/bionic.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/bullseye.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/buster.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/centos-7.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/fedora.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/focal.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/jammy.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/rocky-8.sh | 14 | ||||
-rwxr-xr-x | test/common-utils/rocky-9.sh | 14 | ||||
-rw-r--r-- | test/common-utils/scenarios.json | 115 | ||||
-rwxr-xr-x | test/common-utils/test.sh | 5 | ||||
-rwxr-xr-x | test/common-utils/username-default.sh | 15 | ||||
-rwxr-xr-x | test/common-utils/username-detected.sh | 14 |
16 files changed, 319 insertions, 7 deletions
diff --git a/test/common-utils/alpine.sh b/test/common-utils/alpine.sh new file mode 100755 index 0000000..c5ff866 --- /dev/null +++ b/test/common-utils/alpine.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${ID}" = "alpine" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/already-run.sh b/test/common-utils/already-run.sh new file mode 100755 index 0000000..39d6f9e --- /dev/null +++ b/test/common-utils/already-run.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "non-root user" test "$(whoami)" = "vscode" +check "jq" jq --version +check "curl" curl --version +check "git" git --version +check "zsh" zsh --version +check "ps" ps --version +check "Oh My Zsh! theme" test -e $HOME/.oh-my-zsh/custom/themes + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/alternate-values.sh b/test/common-utils/alternate-values.sh new file mode 100755 index 0000000..d208a27 --- /dev/null +++ b/test/common-utils/alternate-values.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "non-root user" id alternate +check "running as root" test "$(whoami)" = "root" +check "jq" jq --version +check "curl" curl --version +check "git" git --version +check "ps" ps --version +check "no zsh" bash -c '! zsh --version' +check "No Oh My Zsh!" test ! -e /home/alternate/.oh-my-zsh/custom/themes/devcontainers.zsh-theme + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/bionic.sh b/test/common-utils/bionic.sh new file mode 100755 index 0000000..349b4c3 --- /dev/null +++ b/test/common-utils/bionic.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${VERSION_CODENAME}" = "bionic" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/bullseye.sh b/test/common-utils/bullseye.sh new file mode 100755 index 0000000..5a396a7 --- /dev/null +++ b/test/common-utils/bullseye.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${VERSION_CODENAME}" = "bullseye" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/buster.sh b/test/common-utils/buster.sh new file mode 100755 index 0000000..9fd2f40 --- /dev/null +++ b/test/common-utils/buster.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${VERSION_CODENAME}" = "buster" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/centos-7.sh b/test/common-utils/centos-7.sh new file mode 100755 index 0000000..a81ae2f --- /dev/null +++ b/test/common-utils/centos-7.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${VERSION_ID}" = "7" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/fedora.sh b/test/common-utils/fedora.sh new file mode 100755 index 0000000..b32a7f1 --- /dev/null +++ b/test/common-utils/fedora.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${ID}" = "fedora" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/focal.sh b/test/common-utils/focal.sh new file mode 100755 index 0000000..28d8b8b --- /dev/null +++ b/test/common-utils/focal.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${VERSION_CODENAME}" = "focal" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/jammy.sh b/test/common-utils/jammy.sh new file mode 100755 index 0000000..f11cac6 --- /dev/null +++ b/test/common-utils/jammy.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${VERSION_CODENAME}" = "jammy" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/rocky-8.sh b/test/common-utils/rocky-8.sh new file mode 100755 index 0000000..f6606db --- /dev/null +++ b/test/common-utils/rocky-8.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${PLATFORM_ID}" = "platform:el8" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/rocky-9.sh b/test/common-utils/rocky-9.sh new file mode 100755 index 0000000..c4b5244 --- /dev/null +++ b/test/common-utils/rocky-9.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +check "non-root user" test "$(whoami)" = "devcontainer" +check "distro" test "${PLATFORM_ID}" = "platform:el9" + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/scenarios.json b/test/common-utils/scenarios.json index aa36fcb..9b0bc85 100644 --- a/test/common-utils/scenarios.json +++ b/test/common-utils/scenarios.json @@ -1,10 +1,111 @@ { - "configure_zsh_as_default_shell": { - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", - "features": { - "common-utils": { - "configureZshAsDefaultShell": true - } + "bionic": { + "image": "ubuntu:bionic", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "focal": { + "image": "ubuntu:focal", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "jammy": { + "image": "ubuntu:jammy", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "buster": { + "image": "debian:buster", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "bullseye": { + "image": "debian:bullseye", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "centos-7": { + "image": "centos:7", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "rocky-8": { + "image": "rockylinux:8", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "rocky-9": { + "image": "rockylinux:9", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "fedora": { + "image": "fedora", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "alpine": { + "image": "alpine", + "remoteUser": "devcontainer", + "features": { + "common-utils": {} + } + }, + "alternate-values": { + "image": "debian:bullseye", + "features": { + "common-utils": { + "username": "alternate", + "userUid": "1001", + "userGid": "1002", + "upgradePackages": false, + "installZsh": false, + "nonFreePackages": true + } + } + }, + "username-default": { + "image": "debian:bullseye", + "features": { + "common-utils": {} + } + }, + "username-detected": { + "image": "node", + "features": { + "common-utils": {} + } + }, + "already-run": { + "image": "mcr.microsoft.com/devcontainers/base:jammy", + "features": { + "common-utils": {} + } + }, + "configure_zsh_as_default_shell": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "common-utils": { + "configureZshAsDefaultShell": true + } + } } - } } diff --git a/test/common-utils/test.sh b/test/common-utils/test.sh index 1282015..5e16a33 100755 --- a/test/common-utils/test.sh +++ b/test/common-utils/test.sh @@ -8,6 +8,11 @@ source dev-container-features-test-lib # Definition specific tests check "jq" jq --version check "curl" curl --version +check "git" git --version +check "zsh" zsh --version +check "ps" ps --version +check "Oh My Zsh! theme" test -e $HOME/.oh-my-zsh/custom/themes/devcontainers.zsh-theme +check "zsh theme symlink" test -e $HOME/.oh-my-zsh/custom/themes/codespaces.zsh-theme # Report result reportResults
\ No newline at end of file diff --git a/test/common-utils/username-default.sh b/test/common-utils/username-default.sh new file mode 100755 index 0000000..49784b7 --- /dev/null +++ b/test/common-utils/username-default.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +# .oh-my-zsh folder would only exist if user defaulting worked +check "non-root user" ls /home/vscode/.oh-my-zsh + + +# Report result +reportResults
\ No newline at end of file diff --git a/test/common-utils/username-detected.sh b/test/common-utils/username-detected.sh new file mode 100755 index 0000000..39c1b29 --- /dev/null +++ b/test/common-utils/username-detected.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +. /etc/os-release +# .oh-my-zsh folder would only exist if user detection worked +check "non-root user" ls /home/node/.oh-my-zsh + +# Report result +reportResults
\ No newline at end of file |