Skip to content

Commit

Permalink
Merge pull request #600 from utam0k/improvement/integration-test-refa…
Browse files Browse the repository at this point in the history
…ctoring-1

clean up the shell script for youki integration test.
  • Loading branch information
YJDoc2 committed Jan 10, 2022
2 parents 9dd1c9d + b02f1b8 commit 0fdd344
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/integration_tests_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ jobs:
uses: Swatinem/rust-cache@v1
- run: sudo apt-get -y update
- run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev
- name: Build
run: ./build.sh
- name: Validate tests on runc
run: cd ./crates/integration_test && ./tests.sh run runc
run: cd ./crates/integration_test && sudo ./tests.sh run runc
- name: Validate tests on youki
run: cd ./crates/integration_test && ./tests.sh run ./youki
run: cd ./crates/integration_test && sudo ./tests.sh run ../../youki
4 changes: 2 additions & 2 deletions crates/integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ This provides a test suite to test low level OCI spec compliant container runtim

## Usage

```sh
```console
# in root folder
$ ./build.sh
$ cd youki_integration_test
$ cd crates/youki_integration_test
$ cp ../youki .
$ ./build.sh
# currently root access is required
Expand Down
49 changes: 29 additions & 20 deletions crates/integration_test/tests.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
#!/bin/bash
cd ../../
./build.sh --release
cp ./youki ./crates/integration_test/youki
cp ./youki_integration_test ./crates/integration_test/youki_integration_test
cp ./runtimetest_tool ./crates/integration_test/runtimetest
cd ./crates/integration_test

RUNTIME=./youki
set -e

# syntax is
# test.sh build
# test.sh run
# test.sh run runtime-name
# test.sh runtime-name

if [[ "$1" = "build" ]]; then
exit 0
if test "$(id -u)" != 0; then
echo "Please run as root"
exit 1
fi

PROJECT_ROOT=$(git rev-parse --show-toplevel)
LOGFILE="$PROJECT_ROOT/crates/integration_test/test_log.log"
YOUKI_INTEGRATION_TEST=$PROJECT_ROOT/youki_integration_test
RUNTIMETEST_TOOL=$PROJECT_ROOT/runtimetest_tool

if [ ! -e $YOUKI_INTEGRATION_TEST ]; then
echo "$YOUKI_INTEGRATION_TEST was not found, please try to build."
exit 1
fi

if [ ! -e $RUNTIMETEST_TOOL ]; then
echo "$RUNTIMETEST_TOOL was not found, please try to build."
exit 1
fi

# if second argument is non-empty, consider it as runtime name
# else the consider first argument as runtime name
RUNTIME=$PROJECT_ROOT/youki
if [[ -n "$2" ]]; then
RUNTIME="$2"
RUNTIME=$2
elif [[ -n "$1" ]]; then
RUNTIME="$1"
RUNTIME=$1
fi

touch $LOGFILE

logfile="./test_log.log"
touch $logfile
sudo ./youki_integration_test run --runtime "$RUNTIME" --runtimetest "./runtimetest" > $logfile
if [ 0 -ne $(grep "not ok" $logfile | wc -l ) ]; then
cat $logfile
# FIXME: Tests should pass even if the log level is debug.
YOUKI_LOG_LEVEL="error" $YOUKI_INTEGRATION_TEST run --runtime $RUNTIME --runtimetest $RUNTIMETEST_TOOL > $LOGFILE
if [ 0 -ne $(grep "not ok" $LOGFILE | wc -l ) ]; then
cat $LOGFILE
exit 1
fi
echo "Validation successful for runtime $RUNTIME"

echo "Validation successful for runtime $RUNTIME"

0 comments on commit 0fdd344

Please sign in to comment.