Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #736 from 01org/topic/cri-o-tests
Browse files Browse the repository at this point in the history
CRI-O integration tests
  • Loading branch information
Sebastien Boeuf authored Mar 28, 2017
2 parents 65dba07 + 6a44918 commit 0378ba6
Show file tree
Hide file tree
Showing 10 changed files with 486 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .ci/ci-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ pkgs+=" lcov"
# chronic(1)
pkgs+=" moreutils"

# CRI-O
pkgs+=" libseccomp2"
pkgs+=" libseccomp-dev"
pkgs+=" seccomp"
pkgs+=" libdevmapper-dev"
pkgs+=" libdevmapper1.02.1"
pkgs+=" libgpgme11"
pkgs+=" libgpgme11-dev"

# qemu-lite won't be built
# some unit tests need qemu-system
if [ "$nested" != "Y" ]
Expand Down
8 changes: 8 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ $(GENERATED_FILES): %: %.in Makefile
DOCKER_ENGINE_FEDORA_VERSION="$(DOCKER_ENGINE_FEDORA_VERSION)" \
DOCKER_UBUNTU_VERSION="$(DOCKER_UBUNTU_VERSION)" \
DOCKER_ENGINE_UBUNTU_VERSION="$(DOCKER_ENGINE_UBUNTU_VERSION)" \
CRIO_CACHE="$(CRIO_CACHE)" \
abs_builddir="$(abs_builddir)" \
$(top_srcdir)/data/genfile.sh "$<" "$@"

Expand Down Expand Up @@ -397,6 +398,13 @@ docker-tests: cc-oci-runtime tests/lib/test-common.bash
@$(BATS_PATH) -t $(srcdir)/tests/integration/docker
endif

if CRIO_TESTS
CHECK_DEPS += crio-tests
GENERATED_FILES += tests/lib/test-crio.bats
crio-tests: cc-oci-runtime cc-proxy cc-shim tests/lib/test-crio.bats
@$(BATS_PATH) -t $(srcdir)/tests/integration/cri-o
endif

#### tests ####
if BUILD_TESTS

Expand Down
32 changes: 32 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ AS_IF([test x"$run_docker_tests" = x"yes"],
[AC_SUBST([DOCKER_TESTS], [0])])
AM_CONDITIONAL([DOCKER_TESTS], [test x"$run_docker_tests" = x"yes"])

# CRI-O integration tests
AC_ARG_ENABLE(crio-tests, AS_HELP_STRING([--disable-crio-tests],
[disable CRI-O tests @<:@default=no@:>@]))

AS_IF([test x"$enable_crio_tests" = x"yes" -o x"$enable_crio_tests" = x""],
[run_crio_tests=yes],
[run_crio_tests=no])

AS_IF([test x"$run_crio_tests" = x"yes"],
[AC_SUBST([CRIO_TESTS], [1])],
[AC_SUBST([CRIO_TESTS], [0])])
AM_CONDITIONAL([CRIO_TESTS], [test x"$run_crio_tests" = x"yes"])

# Checks for libraries.
source $srcdir/versions.txt

Expand Down Expand Up @@ -305,6 +318,21 @@ AC_ARG_WITH([cc-image],
]
)

# CRI-O artifacts
DEFAULT_CRIO_CACHE=$localstatedir/lib/$PACKAGE_NAME/cri-o/cache
AC_ARG_WITH([crio-cache],
[AS_HELP_STRING([--with-crio-cache=[[CACHE-PATH]]],
[CRIO cache directory])
],
[
CONTAINERS_IMG=$with_crio_cache
AC_SUBST([CRIO_CACHE])
],
[
AC_SUBST([CRIO_CACHE],[$DEFAULT_CRIO_CACHE])
]
)

AC_ARG_ENABLE([autogopath],
AS_HELP_STRING([--enable-autogopath], [Set GOPATH variable for you, used when packaging @<:@default=false@:>@]),
[case "${enableval}" in
Expand All @@ -323,6 +351,9 @@ dnl === Summary ===============================================================
AS_IF([test x"$disable_docker_tests" = xno],
[enable_docker_tests=yes], [enable_docker_tests=no])

AS_IF([test x"$disable_crio_tests" = xno],
[enable_crio_tests=yes], [enable_crio_tests=no])

AC_MSG_RESULT([
cc-oci-runtime - $VERSION
Expand All @@ -344,6 +375,7 @@ cc-oci-runtime - $VERSION
Unit tests : $enable_tests
Functional tests : $run_functional_tests
Docker tests : $run_docker_tests
CRI-O tests : $run_crio_tests
Cppcheck : $enable_cppcheck
Valgrind : $VALGRIND_ENABLED
Code coverage : $CODE_COVERAGE_ENABLED
Expand Down
1 change: 1 addition & 0 deletions data/genfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ ${SED} \
-e 's|@DOCKER_ENGINE_FEDORA_VERSION@|'"${DOCKER_ENGINE_FEDORA_VERSION}"'|g' \
-e 's|@DOCKER_UBUNTU_VERSION@|'"${DOCKER_UBUNTU_VERSION}"'|g' \
-e 's|@DOCKER_ENGINE_UBUNTU_VERSION@|'"${DOCKER_ENGINE_UBUNTU_VERSION}"'|g' \
-e 's|@CRIO_CACHE@|'"${CRIO_CACHE}"'|g' \
-e 's|@ABS_BUILDDIR@|'"${abs_builddir}"'|g' \
"${in_file}" > "${out_file}"
64 changes: 64 additions & 0 deletions tests/data/container_redis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"metadata": {
"name": "podsandbox1-redis"
},
"image": {
"image": "docker://redis:3.2.3"
},
"args": [
"docker-entrypoint.sh",
"redis-server"
],
"working_dir": "/data",
"envs": [
{
"key": "PATH",
"value": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
},
{
"key": "TERM",
"value": "xterm"
},
{
"key": "REDIS_VERSION",
"value": "3.2.3"
},
{
"key": "REDIS_DOWNLOAD_URL",
"value": "http://download.redis.io/releases/redis-3.2.3.tar.gz"
},
{
"key": "REDIS_DOWNLOAD_SHA1",
"value": "92d6d93ef2efc91e595c8bf578bf72baff397507"
}
],
"labels": {
"tier": "backend"
},
"annotations": {
"pod": "podsandbox1"
},
"readonly_rootfs": false,
"log_path": "container.log",
"stdin": false,
"stdin_once": false,
"tty": false,
"linux": {
"resources": {
"cpu_period": 10000,
"cpu_quota": 20000,
"cpu_shares": 512,
"memory_limit_in_bytes": 88000000,
"oom_score_adj": 30
},
"capabilities": {
"add_capabilities": [
"sys_admin"
]
},
"user": {
"uid": 0,
"gid": 0
}
}
}
7 changes: 7 additions & 0 deletions tests/data/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": [
{
"type": "insecureAcceptAnything"
}
]
}
64 changes: 64 additions & 0 deletions tests/data/sandbox_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"metadata": {
"name": "podsandbox1",
"uid": "redhat-test-ocid",
"namespace": "redhat.test.ocid",
"attempt": 1
},
"hostname": "ocic_host",
"log_directory": ".",
"dns_options": {
"servers": [
"server1.redhat.com",
"server2.redhat.com"
],
"searches": [
"8.8.8.8"
]
},
"port_mappings": [
{
"name": "port_map1",
"protocol": 1,
"container_port": 80,
"host_port": 4888,
"host_ip": "192.168.0.33"
},
{
"name": "port_map2",
"protocol": 2,
"container_port": 81,
"host_port": 4889,
"host_ip": "192.168.0.33"
}
],
"resources": {
"cpu": {
"limits": 3,
"requests": 2
},
"memory": {
"limits": 50000000,
"requests": 2000000
}
},
"labels": {
"group": "test"
},
"annotations": {
"owner": "hmeng",
"security.alpha.kubernetes.io/sysctls": "kernel.shm_rmid_forced=1,net.ipv4.ip_local_port_range=1024 65000",
"security.alpha.kubernetes.io/unsafe-sysctls": "kernel.msgmax=8192" ,
"security.alpha.kubernetes.io/seccomp/pod": "unconfined"
},
"linux": {
"cgroup_parent": "/ocid-podsandbox1",
"security_context": {
"namespace_options": {
"host_network": false,
"host_pid": false,
"host_ipc": false
}
}
}
}
29 changes: 29 additions & 0 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## cc-oci-runtime integration tests

### Docker

1. Enable the Docker integration tests:

```
./autogen.sh --enable-docker-tests
```

2. Run the Docker integration tests:

```
sudo -E make docker-tests
```

### CRI-O

1. Enable the CRI-O integration tests:

```
./autogen.sh --enable-crio-tests
```

2. Run the CRI-O integration tests:

```
sudo -E make crio-tests
```
58 changes: 58 additions & 0 deletions tests/integration/cri-o/container.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bats
# *-*- Mode: sh; sh-basic-offset: 8; indent-tabs-mode: nil -*-*

# This file is part of cc-oci-runtime.
#
# Copyright (C) 2017 Intel Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

SRC="${BATS_TEST_DIRNAME}/../../lib/"
TESTDATA="${BATS_TEST_DIRNAME}/../../data/"

setup() {
source $SRC/test-crio.bats
}

function teardown() {
cleanup_test
}

@test "CRI-O redis container start and remove" {
start_ocid
run ocic pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
run ocic ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
ctr_id="$output"
run ocic ctr start --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
run ocic ctr remove --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
run ocic pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run ocic pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
cleanup_ctrs
cleanup_pods
stop_ocid
}
Loading

0 comments on commit 0378ba6

Please sign in to comment.