From b85fe5ab90c73124f77a847dcd3351b22ab7b98c Mon Sep 17 00:00:00 2001 From: baude Date: Tue, 31 Oct 2017 15:43:12 -0500 Subject: [PATCH] Fix conmon and runc paths for kpod tests Tests for kpod create and run were failing because the conmon binary was being hardcoded. We added a --conmon global optioni for kpod so we could pass in the conmon path from the helpers file during tests Signed-off-by: baude --- cmd/kpod/common.go | 6 ++++-- cmd/kpod/create.go | 6 +----- cmd/kpod/main.go | 4 ++++ cmd/kpod/run.go | 1 + test/helpers.bash | 2 +- test/kpod_run.bats | 4 ---- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cmd/kpod/common.go b/cmd/kpod/common.go index ceb46401..915069bb 100644 --- a/cmd/kpod/common.go +++ b/cmd/kpod/common.go @@ -49,7 +49,7 @@ func getRuntime(c *cli.Context) (*libpod.Runtime, error) { options.GraphDriverName = config.Storage options.GraphDriverOptions = config.StorageOptions - return libpod.NewRuntime(libpod.WithStorageConfig(options)) + return libpod.NewRuntime(libpod.WithStorageConfig(options), libpod.WithConmonPath(config.Conmon), libpod.WithOCIRuntime(config.Runtime)) } func shutdownStores() { @@ -82,7 +82,9 @@ func getConfig(c *cli.Context) (*libkpod.Config, error) { if c.GlobalIsSet("runroot") { config.RunRoot = c.GlobalString("runroot") } - + if c.GlobalIsSet("conmon") { + config.Conmon = c.GlobalString("conmon") + } if c.GlobalIsSet("storage-driver") { config.Storage = c.GlobalString("storage-driver") } diff --git a/cmd/kpod/create.go b/cmd/kpod/create.go index 3f11f8a9..30dcb8ef 100644 --- a/cmd/kpod/create.go +++ b/cmd/kpod/create.go @@ -154,7 +154,7 @@ func createCmd(c *cli.Context) error { if err != nil { return err } - + defer runtime.Shutdown(false) imageName, err := createImage.GetFQName() if err != nil { return err @@ -174,10 +174,6 @@ func createCmd(c *cli.Context) error { return err } - if err := ctr.Create(); err != nil { - return err - } - if c.String("cidfile") != "" { libpod.WriteFile(ctr.ID(), c.String("cidfile")) } else { diff --git a/cmd/kpod/main.go b/cmd/kpod/main.go index b820244c..b8a7b0cb 100644 --- a/cmd/kpod/main.go +++ b/cmd/kpod/main.go @@ -94,6 +94,10 @@ func main() { Name: "config, c", Usage: "path of a config file detailing container server configuration options", }, + cli.StringFlag{ + Name: "conmon", + Usage: "path of the conmon binary", + }, cli.StringFlag{ Name: "log-level", Usage: "log messages above specified level: debug, info, warn, error (default), fatal or panic", diff --git a/cmd/kpod/run.go b/cmd/kpod/run.go index 070f5f48..ef92dae0 100644 --- a/cmd/kpod/run.go +++ b/cmd/kpod/run.go @@ -48,6 +48,7 @@ func runCmd(c *cli.Context) error { if err != nil { return err } + defer runtime.Shutdown(false) logrus.Debug("spec is ", runtimeSpec) imageName, err := createImage.GetFQName() diff --git a/test/helpers.bash b/test/helpers.bash index 5989e4ab..3f4c9be0 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -99,7 +99,7 @@ CRIO_CNI_PLUGIN=${CRIO_CNI_PLUGIN:-/opt/cni/bin/} POD_CIDR="10.88.0.0/16" POD_CIDR_MASK="10.88.*.*" -KPOD_OPTIONS="--root $TESTDIR/crio $STORAGE_OPTIONS --runroot $TESTDIR/crio-run --runtime ${RUNTIME_BINARY}" +KPOD_OPTIONS="--root $TESTDIR/crio $STORAGE_OPTIONS --runroot $TESTDIR/crio-run --runtime ${RUNTIME_BINARY} --conmon ${CONMON_BINARY}" cp "$CONMON_BINARY" "$TESTDIR/conmon" diff --git a/test/kpod_run.bats b/test/kpod_run.bats index 4f54c8df..4945691a 100644 --- a/test/kpod_run.bats +++ b/test/kpod_run.bats @@ -2,10 +2,6 @@ load helpers -function teardown() { - cleanup_test -} - ALPINE="docker.io/library/alpine:latest" @test "run a container based on local image" {