Skip to content

Commit

Permalink
test: Add initial cri-containerd tests
Browse files Browse the repository at this point in the history
Run a few integration test and cri-tools tests.

Fixes: clearcontainers#916

Signed-off-by: Jose Carlos Venegas Munoz <[email protected]>
  • Loading branch information
jcvenegas committed Mar 28, 2018
1 parent b2430c4 commit 578087d
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ if [ "$ID" == "ubuntu" ] && [ "$MAJOR" -ge 17 ]; then
export CRIO_STORAGE_DRIVER_OPTS="--storage-driver=devicemapper"
fi

sudo -E PATH="$PATH" bash -c "make cri-containerd"
sudo -E PATH="$PATH" bash -c "make check"


# Currently, Openshift tests only work on Fedora.
# We should delete this condition, when it works for Ubuntu.
if [ "$ID" == fedora ]; then
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ all: functional checkcommits integration
checkcommits:
cd cmd/checkcommits && make

cri-containerd:
./integration/cri-containerd/test.sh

clean:
cd cmd/checkcommits && make clean

Expand Down
92 changes: 92 additions & 0 deletions integration/cri-containerd/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eE
set -x

# Runtime to be used for testing.
RUNTIME=${RUNTIME:-cc-runtime}
# Variable to change project to test (eg. kata or clear-contaienrs)
PROJECT_ORG="${PROJECT:-clear-containers}"
readonly runtime_bin=$(command -v "${RUNTIME}")

#cri-containerd configuration test variables
CRITEST=${GOPATH}/bin/critest
readonly tmp_dir=$(mktemp -t -d test-cri-containerd.XXXX)
export REPORT_DIR="${tmp_dir}"


info() {
echo -e "\e[1mINFO\e[0m: $*"
}


cleanup() {
rm -rf "${tmp_dir}"
}

err_report() {
cat "${REPORT_DIR}/cri-containerd.log"
cat "${REPORT_DIR}/containerd.log"
}

trap err_report ERR
trap cleanup EXIT

info "testing using runtime: ${runtime_bin}"

# make sure cri-containerd test install the proper installation for testing
rm -f "${CRITEST}"

info "Configure runtime to use network bridged mode"
# FIXME: cri-containerd fails using macvtap.
sudo sed -r -i -e 's/^(internetworking_model=).*/\1"bridged"/g' \
/usr/share/defaults/${PROJECT_ORG}/configuration.toml


cri_containerd_repo="github.com/containerd/cri-containerd"

pushd "${GOPATH}/src/${cri_containerd_repo}"

info "Starting test for cri-tools"
sudo -E PATH="${PATH}" \
FOCUS="runtime should support basic operations on container" \
REPORT_DIR="${REPORT_DIR}" \
CRI_CONTAINERD_FLAGS="$CRI_CONTAINERD_FLAGS" \
make test-cri

passing_test=(
TestClearContainersCreate
TestContainerStats
TestContainerListStatsWithIdFilter
TestContainerListStatsWithSandboxIdFilterd
TestContainerListStatsWithIdSandboxIdFilter
TestDuplicateName
TestImageLoad
TestImageFSInfo
TestSandboxCleanRemove
)

info "Starting integration tests"
for t in "${passing_test[@]}"
do
sudo -E PATH="${PATH}" FOCUS="${t}"\
CRI_CONTAINERD_FLAGS="$CRI_CONTAINERD_FLAGS"\
make test-integration
done

popd

0 comments on commit 578087d

Please sign in to comment.