From af692f611db0fc5504e12347e9947dc121663d0d Mon Sep 17 00:00:00 2001 From: baude Date: Wed, 20 Sep 2017 18:44:58 -0500 Subject: [PATCH 1/2] Refactor common variables in kpod tests Signed-off-by: baude --- test/helpers.bash | 3 +++ test/kpod.bats | 3 --- test/kpod_diff.bats | 3 --- test/kpod_export.bats | 4 ---- test/kpod_load.bats | 3 --- test/kpod_logs.bats | 3 --- test/kpod_mount.bats | 3 --- test/kpod_ps.bats | 3 --- test/kpod_pull.bats | 3 --- test/kpod_rename.bats | 3 --- test/kpod_rm.bats | 3 --- test/kpod_save.bats | 3 --- test/kpod_stats.bats | 3 --- test/kpod_stop.bats | 3 --- 14 files changed, 3 insertions(+), 40 deletions(-) diff --git a/test/helpers.bash b/test/helpers.bash index 6d185527..061b96be 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -60,6 +60,9 @@ PIDS_LIMIT=${PIDS_LIMIT:-1024} LOG_SIZE_MAX_LIMIT=${LOG_SIZE_MAX_LIMIT:--1} TESTDIR=$(mktemp -d) +ROOT="$TESTDIR/crio" +RUNROOT="$TESTDIR/crio-run" +KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS} --runtime ${RUNTIME_BINARY}" # kpod pull needs a configuration file for shortname pulls export REGISTRIES_CONFIG_PATH="$INTEGRATION_ROOT/registries.conf" diff --git a/test/kpod.bats b/test/kpod.bats index b88b65be..69418e1f 100644 --- a/test/kpod.bats +++ b/test/kpod.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs" function teardown() { cleanup_test diff --git a/test/kpod_diff.bats b/test/kpod_diff.bats index 50a82d5c..0b313a79 100644 --- a/test/kpod_diff.bats +++ b/test/kpod_diff.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test diff --git a/test/kpod_export.bats b/test/kpod_export.bats index 808d39ff..5083102f 100644 --- a/test/kpod_export.bats +++ b/test/kpod_export.bats @@ -3,10 +3,6 @@ load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" - @test "kpod export output flag" { start_crio diff --git a/test/kpod_load.bats b/test/kpod_load.bats index 61f9a2b8..74f28fa5 100644 --- a/test/kpod_load.bats +++ b/test/kpod_load.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test diff --git a/test/kpod_logs.bats b/test/kpod_logs.bats index d11b69c1..1e301556 100644 --- a/test/kpod_logs.bats +++ b/test/kpod_logs.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" function teardown() { cleanup_test diff --git a/test/kpod_mount.bats b/test/kpod_mount.bats index 517b627c..6910f2f2 100644 --- a/test/kpod_mount.bats +++ b/test/kpod_mount.bats @@ -7,9 +7,6 @@ function teardown() { load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" @test "mount" { start_crio diff --git a/test/kpod_ps.bats b/test/kpod_ps.bats index cd1be60c..b50cae18 100644 --- a/test/kpod_ps.bats +++ b/test/kpod_ps.bats @@ -3,9 +3,6 @@ load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" @test "kpod ps with no containers" { run ${KPOD_BINARY} ${KPOD_OPTIONS} ps diff --git a/test/kpod_pull.bats b/test/kpod_pull.bats index 2103eecc..59cc80d4 100644 --- a/test/kpod_pull.bats +++ b/test/kpod_pull.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT ${STORAGE_OPTS}" function teardown() { cleanup_test diff --git a/test/kpod_rename.bats b/test/kpod_rename.bats index 9419ce2d..19c06e3c 100644 --- a/test/kpod_rename.bats +++ b/test/kpod_rename.bats @@ -3,9 +3,6 @@ load helpers IMAGE="redis:alpine" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" NEW_NAME="rename-test" function teardown() { diff --git a/test/kpod_rm.bats b/test/kpod_rm.bats index b41f58dd..9a42beeb 100644 --- a/test/kpod_rm.bats +++ b/test/kpod_rm.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS --runtime $RUNTIME_BINARY" function teardown() { cleanup_test } diff --git a/test/kpod_save.bats b/test/kpod_save.bats index d961d69e..29a69d14 100644 --- a/test/kpod_save.bats +++ b/test/kpod_save.bats @@ -3,9 +3,6 @@ load helpers IMAGE="alpine:latest" -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test diff --git a/test/kpod_stats.bats b/test/kpod_stats.bats index c9f58cc9..a7a54d7a 100644 --- a/test/kpod_stats.bats +++ b/test/kpod_stats.bats @@ -2,9 +2,6 @@ load helpers -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT $STORAGE_OPTS" function teardown() { cleanup_test diff --git a/test/kpod_stop.bats b/test/kpod_stop.bats index 4532ff51..08b4c933 100644 --- a/test/kpod_stop.bats +++ b/test/kpod_stop.bats @@ -2,9 +2,6 @@ load helpers -ROOT="$TESTDIR/crio" -RUNROOT="$TESTDIR/crio-run" -KPOD_OPTIONS="--root $ROOT --runroot $RUNROOT --storage-driver vfs" function teardown() { cleanup_test } From 73b9e4c4304357a05fc4b50317f9327cb8a16540 Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 21 Sep 2017 09:55:56 -0500 Subject: [PATCH 2/2] BUGFIX: If runtime cannot be found, error out In the case where the runtime cannot be found, kpod should error out. This occurs in kpod ps when iterating through the containers to get details. Signed-off-by: baude --- cmd/kpod/common.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/kpod/common.go b/cmd/kpod/common.go index 1c1503e2..996bf0fc 100644 --- a/cmd/kpod/common.go +++ b/cmd/kpod/common.go @@ -4,6 +4,7 @@ import ( "os" "strings" + "fmt" is "github.com/containers/image/storage" "github.com/containers/storage" "github.com/fatih/camelcase" @@ -93,6 +94,10 @@ func getConfig(c *cli.Context) (*libkpod.Config, error) { if c.GlobalIsSet("runtime") { config.Runtime = c.GlobalString("runtime") } + if _, err := os.Stat(config.Runtime); os.IsNotExist(err) { + // path to runtime does not exist + return config, fmt.Errorf("invalid --runtime value %q", err) + } return config, nil }