From bd2940861c282dfc39309bca94378c820ab7df7e Mon Sep 17 00:00:00 2001 From: Ian Lewis Date: Tue, 15 Jan 2019 16:41:01 +0900 Subject: End to end tests refs #3 (#10) * Separate docs for containerd 1.1 and 1.2 The configuration for the untrusted workload annotation and runtime class are different enough that it makes sense to separate the docs. Commands in docs are taken from scripts in the docs/scripts directory. These scripts can be used later for integration & doc tests (#3). The docs can be updated using the embedmd tool: https://github.com/campoy/embedmd * Add basic e2e tests refs #3 Added end-to-end tests based on the quickstart workflows for containerd 1.1 and containerd 1.2+. --- test/e2e/containerd-install.sh | 38 ++++++++++++++++++++++++++++++++++ test/e2e/crictl-install.sh | 17 +++++++++++++++ test/e2e/run-container.sh | 30 +++++++++++++++++++++++++++ test/e2e/runsc-install.sh | 8 +++++++ test/e2e/runtime-handler/install.sh | 24 +++++++++++++++++++++ test/e2e/runtime-handler/test.sh | 33 +++++++++++++++++++++++++++++ test/e2e/runtime-handler/usage.sh | 30 +++++++++++++++++++++++++++ test/e2e/shim-install.sh | 30 +++++++++++++++++++++++++++ test/e2e/untrusted-workload/install.sh | 24 +++++++++++++++++++++ test/e2e/untrusted-workload/test.sh | 33 +++++++++++++++++++++++++++++ test/e2e/untrusted-workload/usage.sh | 33 +++++++++++++++++++++++++++++ test/e2e/validate.sh | 17 +++++++++++++++ 12 files changed, 317 insertions(+) create mode 100755 test/e2e/containerd-install.sh create mode 100755 test/e2e/crictl-install.sh create mode 100755 test/e2e/run-container.sh create mode 100755 test/e2e/runsc-install.sh create mode 100755 test/e2e/runtime-handler/install.sh create mode 100755 test/e2e/runtime-handler/test.sh create mode 100755 test/e2e/runtime-handler/usage.sh create mode 100755 test/e2e/shim-install.sh create mode 100755 test/e2e/untrusted-workload/install.sh create mode 100755 test/e2e/untrusted-workload/test.sh create mode 100755 test/e2e/untrusted-workload/usage.sh create mode 100755 test/e2e/validate.sh (limited to 'test/e2e') diff --git a/test/e2e/containerd-install.sh b/test/e2e/containerd-install.sh new file mode 100755 index 000000000..154f7d7a5 --- /dev/null +++ b/test/e2e/containerd-install.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# A script to install containerd and CNI plugins for e2e testing + +wget -q --https-only \ + https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz \ + https://github.com/containernetworking/plugins/releases/download/v0.6.0/cni-plugins-amd64-v0.6.0.tgz + +sudo mkdir -p /etc/containerd /etc/cni/net.d /opt/cni/bin +sudo tar -xvf cni-plugins-amd64-v0.6.0.tgz -C /opt/cni/bin/ +sudo tar -xvf containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz -C / + +cat < /tmp/containerd-cri.log & + diff --git a/test/e2e/crictl-install.sh b/test/e2e/crictl-install.sh new file mode 100755 index 000000000..1d63c889b --- /dev/null +++ b/test/e2e/crictl-install.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# A sample script for installing crictl. + +set -ex + +{ # Step 1: Download crictl +wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.13.0/crictl-v1.13.0-linux-amd64.tar.gz +tar xf crictl-v1.13.0-linux-amd64.tar.gz +sudo mv crictl /usr/local/bin +} + +{ # Step 2: Configure crictl +cat < /tmp/containerd-cri.log & +} diff --git a/test/e2e/runtime-handler/test.sh b/test/e2e/runtime-handler/test.sh new file mode 100755 index 000000000..99f3565b6 --- /dev/null +++ b/test/e2e/runtime-handler/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Runs end-to-end tests for gvisor-containerd-shim to test the use of runtime +# handler. This should work on containerd 1.2+ + +# This is meant to be run in a VM as it makes a fairly invasive install of +# containerd. + +set -ex + +# Install containerd +. ./test/e2e/containerd-install.sh + +# Install gVisor +. ./test/e2e/runsc-install.sh + +# Install gvisor-containerd-shim +. ./test/e2e/shim-install.sh + +# Test installation/configuration +. ./test/e2e/runtime-handler/install.sh + +# Install crictl +. ./test/e2e/crictl-install.sh + +# Test usage +. ./test/e2e/runtime-handler/usage.sh + +# Run a container in the sandbox +. ./test/e2e/run-container.sh + +# Validate the pod and container +. ./test/e2e/validate.sh diff --git a/test/e2e/runtime-handler/usage.sh b/test/e2e/runtime-handler/usage.sh new file mode 100755 index 000000000..1f8a09757 --- /dev/null +++ b/test/e2e/runtime-handler/usage.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# A sample script for testing the gvisor-containerd-shim # using untrusted +# workload extension. + +set -ex + +{ # Step 1: Pull the nginx image +sudo crictl pull nginx +} + +{ # Step 2: Create sandbox.json +cat < /tmp/containerd-cri.log & +} diff --git a/test/e2e/untrusted-workload/test.sh b/test/e2e/untrusted-workload/test.sh new file mode 100755 index 000000000..6e312cf6d --- /dev/null +++ b/test/e2e/untrusted-workload/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Runs end-to-end tests for gvisor-containerd-shim to test using the +# untrusted workload extension. This should work on containerd 1.1+ + +# This is meant to be run in a VM as it makes a fairly invasive install of +# containerd. + +set -ex + +# Install containerd +. ./test/e2e/containerd-install.sh + +# Install gVisor +. ./test/e2e/runsc-install.sh + +# Install gvisor-containerd-shim +. ./test/e2e/shim-install.sh + +# Test installation/configuration +. ./test/e2e/untrusted-workload/install.sh + +# Install crictl +. ./test/e2e/crictl-install.sh + +# Test usage +. ./test/e2e/untrusted-workload/usage.sh + +# Run a container in the sandbox +. ./test/e2e/run-container.sh + +# Validate the pod and container +. ./test/e2e/validate.sh diff --git a/test/e2e/untrusted-workload/usage.sh b/test/e2e/untrusted-workload/usage.sh new file mode 100755 index 000000000..db8206964 --- /dev/null +++ b/test/e2e/untrusted-workload/usage.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# A sample script for testing the gvisor-containerd-shim # using untrusted +# workload extension. + +set -ex + +{ # Step 1: Pull the nginx image +sudo crictl pull nginx +} + +{ # Step 2: Create sandbox.json +cat <