From 5f0238032fcbd89248a8b89c74b3f10043ec0950 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Thu, 26 Jan 2017 00:58:13 +0100 Subject: [PATCH 1/2] test: Specify alternate container runtime When running integration tests on the host, we can now specify an alternate runtime by setting the RUNTIME variable. For example: make localintegration RUNTIME=cc-oci-runtime to use Clear Containers instead of runC. Obviously, runC is still the default. Signed-off-by: Samuel Ortiz --- test/helpers.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/helpers.bash b/test/helpers.bash index e221acb3..33d66d65 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -21,9 +21,10 @@ PAUSE_BINARY=${PAUSE_BINARY:-${OCID_ROOT}/cri-o/pause/pause} SECCOMP_PROFILE=${SECCOMP_PROFILE:-${OCID_ROOT}/cri-o/seccomp.json} # Name of the default apparmor profile. APPARMOR_PROFILE=${APPARMOR_PROFILE:-ocid-default} -# Path of the runc binary. -RUNC_PATH=$(command -v runc || true) -RUNC_BINARY=${RUNC_PATH:-/usr/local/sbin/runc} +# Runtime +RUNTIME=${RUNTIME:-runc} +RUNTIME_PATH=$(command -v $RUNTIME || true) +RUNTIME_BINARY=${RUNTIME_PATH:-/usr/local/sbin/runc} # Path of the apparmor_parser binary. APPARMOR_PARSER_BINARY=${APPARMOR_PARSER_BINARY:-/sbin/apparmor_parser} # Path of the apparmor profile for test. @@ -135,7 +136,7 @@ function start_ocid() { "$BIN2IMG_BINARY" --root "$TESTDIR/ocid" --runroot "$TESTDIR/ocid-run" --source-binary "$PAUSE_BINARY" fi "$COPYIMG_BINARY" --root "$TESTDIR/ocid" --runroot "$TESTDIR/ocid-run" --image-name=redis --import-from=dir:"$ARTIFACTS_PATH"/redis-image --add-name=docker://docker.io/library/redis:latest --signature-policy="$INTEGRATION_ROOT"/policy.json - "$OCID_BINARY" --conmon "$CONMON_BINARY" --listen "$OCID_SOCKET" --runtime "$RUNC_BINARY" --root "$TESTDIR/ocid" --runroot "$TESTDIR/ocid-run" --seccomp-profile "$seccomp" --apparmor-profile "$apparmor" --cni-config-dir "$OCID_CNI_CONFIG" --signature-policy "$INTEGRATION_ROOT"/policy.json config >$OCID_CONFIG + "$OCID_BINARY" --conmon "$CONMON_BINARY" --listen "$OCID_SOCKET" --runtime "$RUNTIME_BINARY" --root "$TESTDIR/ocid" --runroot "$TESTDIR/ocid-run" --seccomp-profile "$seccomp" --apparmor-profile "$apparmor" --cni-config-dir "$OCID_CNI_CONFIG" --signature-policy "$INTEGRATION_ROOT"/policy.json config >$OCID_CONFIG "$OCID_BINARY" --debug --config "$OCID_CONFIG" & OCID_PID=$! wait_until_reachable From 5569f8b2e1893d6fcb0c68509df9e6bbcf7e5bc9 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Thu, 26 Jan 2017 10:21:59 +0100 Subject: [PATCH 2/2] test: Update and organize README Document the alternate runtime selection when running integratiom tests on the host, and at the same time rganize the file a little better. Signed-off-by: Samuel Ortiz --- test/README.md | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/test/README.md b/test/README.md index 1730a15c..f61976f1 100644 --- a/test/README.md +++ b/test/README.md @@ -13,25 +13,21 @@ Integration tests are written in *bash* using the ## Running integration tests +### Containerized tests + The easiest way to run integration tests is with Docker: ``` $ make integration ``` -Alternatively, you can run integration tests directly on your host through make: -``` -$ sudo make localintegration -``` -Or you can just run them directly using bats -``` -$ sudo bats test -``` + To run a single test bucket: ``` $ make integration TESTFLAGS="runtimeversion.bats" ``` +### On your host -To run them on your host, you will need to setup a development environment plus +To run the integration tests on your host, you will first need to setup a development environment plus [bats](https://github.com/sstephenson/bats#installing-bats-from-source) For example: ``` @@ -41,6 +37,33 @@ $ cd bats $ ./install.sh /usr/local ``` +Then you can run the tests on your host: +``` +$ sudo make localintegration +``` + +To run a single test bucket: +``` +$ make localintegration TESTFLAGS="runtimeversion.bats" +``` + +Or you can just run them directly using bats +``` +$ sudo bats test +``` + +#### Runtime selection +Tests on the host will run with `runc` as the default runtime. +However you can select other OCI compatible runtimes by setting +the `RUNTIME` environment variable. + +For example one could use the [Clear Containers](https://github.com/01org/cc-oci-runtime/wiki/Installation) +runtime instead of `runc`: + +``` +make localintegration RUNTIME=cc-oci-runtime +``` + ## Writing integration tests [Helper functions]