cri-o/test
Mrunal Patel d0fd1f5fa8 Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667
We need this to pick up a fix for attach test.
This change brings in changes to the crictl CLI
requiring changes to the integration tests.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2018-01-29 19:25:49 -08:00
..
bin2img Move to new github.com/sirupsen/logrus. 2017-08-07 11:50:04 -04:00
checkseccomp seccomp: use Prctl() from x/sys/unix 2017-07-18 15:34:23 +02:00
copyimg Move to new github.com/sirupsen/logrus. 2017-08-07 11:50:04 -04:00
hooks Add support for oci-hooks to libkpod 2017-09-05 07:39:31 -04:00
testdata container_create: set cpuset cpus|mems 2017-12-20 19:20:57 +01:00
apparmor.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
cgroups.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
command.bats Report error when arguments given to crio command 2017-10-31 16:15:54 -04:00
ctr.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
ctr_seccomp.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
default_mounts.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
helpers.bash Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
hooks.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
image.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
image_remove.bats Use crictl instead of crioctl in image integration tests 2017-12-14 14:23:53 -05:00
image_volume.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
inspect.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
namespaces.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
network.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
pod.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
policy.json Add image pull with signature integration test 2017-09-11 13:34:30 +02:00
README.md Merge pull request #1264 from wking/test-readme-plugins-moved-from-cni 2018-01-18 23:58:08 +01:00
redhat_sigstore.yaml Add image pull with signature integration test 2017-09-11 13:34:30 +02:00
registries.conf libkpod/image/copy.go: Add pull by short-name 2017-09-14 08:33:10 -05:00
restore.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
runtimeversion.bats replace crioctl with crictl 2017-11-20 13:46:52 +08:00
selinux.bats Bump up cri-tools to f1a58d681c056f259802f5cae2fe1fbcc6b28667 2018-01-29 19:25:49 -08:00
test_runner.sh add tests skeleton 2016-09-24 00:37:07 +02:00

CRIO Integration Tests

Integration tests provide end-to-end testing of CRIO.

Note that integration tests do not replace unit tests.

As a rule of thumb, code should be tested thoroughly with unit tests. Integration tests on the other hand are meant to test a specific feature end to end.

Integration tests are written in bash using the bats framework.

Running integration tests

Containerized tests

The easiest way to run integration tests is with Docker:

$ make integration

To run a single test bucket:

$ make integration TESTFLAGS="runtimeversion.bats"

On your host

To run the integration tests on your host, you will first need to setup a development environment plus bats For example:

$ cd ~/go/src/github.com
$ git clone https://github.com/sstephenson/bats.git
$ cd bats
$ ./install.sh /usr/local

You will also need to install the CNI plugins as the the default pod test template runs without host networking:

$ cd "$GOPATH/src/github.com/containernetworking"
$ git clone https://github.com/containernetworking/plugins.git
$ cd plugins
$ git checkout -q dcf7368eeab15e2affc6256f0bb1e84dd46a34de
$ ./build.sh
$ mkdir -p /opt/cni/bin
$ cp bin/* /opt/cni/bin/

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 runtime instead of runc:

make localintegration RUNTIME=cc-runtime

Writing integration tests

Helper functions are provided in order to facilitate writing tests.

#!/usr/bin/env bats

# This will load the helpers.
load helpers

# setup is called at the beginning of every test.
function setup() {
}

# teardown is called at the end of every test.
function teardown() {
	cleanup_test
}

@test "crictl runtimeversion" {
	start_crio
	crictl runtimeversion
	[ "$status" -eq 0 ]
}