Skip to content

Commit

Permalink
Merge pull request #11 from hallyn/test
Browse files Browse the repository at this point in the history
test: fix the basic test
  • Loading branch information
tych0 authored Apr 23, 2019
2 parents 0f77e5b + fde8a20 commit e654cdd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ 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
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
Expand Down
2 changes: 1 addition & 1 deletion test/basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions test/crio.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
23 changes: 19 additions & 4 deletions test/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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" &
Expand All @@ -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"
}

Expand Down

0 comments on commit e654cdd

Please sign in to comment.