[lxc-devel] [crio-lxc/master] test: fix the basic test

hallyn on Github lxc-bot at linuxcontainers.org
Tue Apr 23 01:52:02 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 502 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190422/3f526765/attachment.bin>
-------------- next part --------------
From fde8a208f2451311846d19cfaca2f2443a94150a Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge at hallyn.com>
Date: Mon, 22 Apr 2019 20:02:53 -0500
Subject: [PATCH] test: fix the basic test

They now pass.  Changes:

Copy in cni hooks from user.  can't create a pod without them.
Set a default cni hook.
Fix check for running container

Signed-off-by: Serge Hallyn <serge at hallyn.com>
---
 README.md         |  7 ++++++-
 test/basic.bats   |  2 +-
 test/crio.conf.in |  4 ++--
 test/helpers.bash | 23 +++++++++++++++++++----
 4 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 7aaaa5d..4e4e7d6 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ OpenSUSE tumbleweed should be uptodate.
 
 ## Tests
 
-To run the 'basic' test, you'll need to build cri-o.
+To run the 'basic' test, you'll need to build cri-o and CNI.
 
 ```
 mkdir ~/packages
@@ -30,6 +30,11 @@ cd packages
 git clone https://github.com/kubernetes-sigs/cri-o
 cd cri-o
 make
+cd ..
+git clone https://github.com/containernetworking/cni
+git clone https://github.com/containernetworking/plugins cni-plugins
+cd cni-plugins
+./build_linux.sh
 ```
 
 You'll also need crictl.  Download the tarball, extract it, and
diff --git a/test/basic.bats b/test/basic.bats
index 3f72848..b9a8c6d 100644
--- a/test/basic.bats
+++ b/test/basic.bats
@@ -14,5 +14,5 @@ function teardown() {
     crictl images
     podid=$(crictl pods | grep nginx-sandbox | awk '{ print $1 }')
     crictl create $podid test/basic-container-config.json test/basic-pod-config.json
-    [ "$(crictl ps -a)" | grep busybox ]
+    crictl ps -a | grep busybox
 }
diff --git a/test/crio.conf.in b/test/crio.conf.in
index 3fd7428..26c6963 100644
--- a/test/crio.conf.in
+++ b/test/crio.conf.in
@@ -264,9 +264,9 @@ registries = [
 [crio.network]
 
 # Path to the directory where CNI configuration files are located.
-network_dir = "CRIOLXC_TEST_DIR/cni"
+network_dir = "CRIOLXC_TEST_DIR/cni/net.d"
 
 # Paths to directories where CNI plugin binaries are located.
 plugin_dir = [
-	"CRIOLXC_TEST_DIR/cni-plugins",
+	"CRIOLXC_TEST_DIR/cni-plugins/bin",
 ]
diff --git a/test/helpers.bash b/test/helpers.bash
index db5319f..9b906db 100644
--- a/test/helpers.bash
+++ b/test/helpers.bash
@@ -16,9 +16,22 @@ function setup_crio {
         "$ROOT_DIR/test/crio.conf.in" > "$TEMP_DIR/crio.conf"
     # it doesn't like seccomp_profile = "", so let's make a bogus one
     echo "{}" > "$TEMP_DIR/seccomp.json"
-    # it doesn't like if these dirs don't exist, so make them
-    mkdir -p "$TEMP_DIR/cni"
-    mkdir -p "$TEMP_DIR/cni-plugins"
+    # It doesn't like if these dirs don't exist, so always them
+    # You can't start a pod without them, so if you're going to test
+    # basic.bats, then
+    #    cd ~/packages;  git clone https://github.com/containernetworking/cni
+    #    git clone https://github.com/containernetworking/plugins cni-plugins
+    #    cd cni-plugins; ./build_linux.sh
+    mkdir -p "$TEMP_DIR/cni/net.d"
+    mkdir -p /tmp/busybox # for the logfile as per log_directory in test/basic-pod-config.json
+    if [ -d ~/packages/cni-plugins ]; then
+        rsync -a ~/packages/cni-plugins $TEMP_DIR/
+        cat > $TEMP_DIR/cni/net.d/10-myptp.conf << EOF
+{"cniVersion":"0.3.1","name":"myptp","type":"ptp","ipMasq":true,"ipam":{"type":"host-local","subnet":"172.16.29.0/24","routes":[{"dst":"0.0.0.0/0"}]}}
+EOF
+    else
+        mkdir -p "$TEMP_DIR/cni-plugins"
+    fi
     # set up an insecure policy
     echo '{"default": [{"type": "insecureAcceptAnything"}]}' > "$TEMP_DIR/policy.json"
     "$CRIO_REPO/bin/crio" --config "$TEMP_DIR/crio.conf" &
@@ -39,7 +52,9 @@ function cleanup_tempdir {
 
 function crictl {
     # watch out for: https://github.com/kubernetes-sigs/cri-tools/issues/460
-    $(which crictl) --runtime-endpoint "$TEMP_DIR/crio.sock" $@
+    # If you need more debug output, set CRICTLDEBUG to -D
+    CRICTLDEBUG=""
+    $(which crictl) $(CRICTLDEBUG) --runtime-endpoint "$TEMP_DIR/crio.sock" $@
     echo "$output"
 }
 


More information about the lxc-devel mailing list