diff --git a/Dockerfile b/Dockerfile index ce4b4af1..7bb06579 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,23 @@ RUN set -x \ && cp bin/* /opt/cni/bin/ \ && rm -rf "$GOPATH" +# Install custom CNI bridge test plugin +# XXX: this plugin is meant to be a replacement for the old "test_plugin_args.bash" +# we need this in testing because sandbox_run now gather IP address and the mock +# plugin wasn't able to properly setup the net ns. +# The bridge is based on the same commit as the one above. +#ENV CNI_COMMIT 6bfe036c38c8e1410f1acaa4b2ee16f1851472e4 +ENV CNI_TEST_BRANCH custom-bridge +RUN set -x \ + && export GOPATH="$(mktemp -d)" \ + && git clone https://github.com/runcom/plugins.git "$GOPATH/src/github.com/containernetworking/plugins" \ + && cd "$GOPATH/src/github.com/containernetworking/plugins" \ + && git checkout -q "$CNI_TEST_BRANCH" \ + && ./build.sh \ + && mkdir -p /opt/cni/bin \ + && cp bin/bridge /opt/cni/bin/bridge-custom \ + && rm -rf "$GOPATH" + # Install crictl ENV CRICTL_COMMIT 16e6fe4d7199c5689db4630a9330e6a8a12cecd1 RUN set -x \ @@ -87,8 +104,6 @@ RUN set -x \ && cp "$GOPATH"/bin/crictl /usr/bin/ \ && rm -rf "$GOPATH" -COPY test/plugin_test_args.bash /opt/cni/bin/plugin_test_args.bash - # Make sure we have some policy for pulling images RUN mkdir -p /etc/containers COPY test/policy.json /etc/containers/policy.json diff --git a/contrib/test/crio-integration-playbook.yaml b/contrib/test/crio-integration-playbook.yaml index 0ad67aa4..77492cf5 100644 --- a/contrib/test/crio-integration-playbook.yaml +++ b/contrib/test/crio-integration-playbook.yaml @@ -151,8 +151,6 @@ repo: https://github.com/containernetworking/plugins dest: /root/src/github.com/containernetworking/plugins version: "{{ cni_commit }}" - async: 600 - poll: 10 - name: Git fetch the PR shell: "git fetch origin +refs/pull/{{ pullrequest }}/head:refs/remotes/origin/pr/{{ pullrequest }}" args: @@ -225,10 +223,18 @@ regexp: 'execute time bats --tap \$TESTS' state: present when: xunit - - name: Copy plugin args so tests dont hang - shell: "cp test/plugin_test_args.bash /opt/cni/bin/" + - name: git clone cni test repo + git: + repo: https://github.com/runcom/plugins + dest: /root/src/github.com/containernetworking/plugins + version: "custom-bridge" + force: yes + - name: Build cni test networking + shell: ./build.sh args: - chdir: /root/src/github.com/kubernetes-incubator/cri-o/ + chdir: /root/src/github.com/containernetworking/plugins + - name: cp custom-bridge to opt bin + shell: cp /root/src/github.com/containernetworking/plugins/bin/bridge /opt/cni/bin/bridge-custom # k8s builds with go1.8.x, rhel, fedora don't have it yet - name: install Golang upstream in Fedora/RHEL shell: | diff --git a/test/helpers.bash b/test/helpers.bash index e203283b..3cccb056 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -407,8 +407,18 @@ function prepare_plugin_test_args_network_conf() { cat >$CRIO_CNI_CONFIG/10-plugin-test-args.conf <<-EOF { "cniVersion": "0.2.0", - "name": "crionet", - "type": "plugin_test_args.bash" + "name": "crionet_test_args", + "type": "bridge-custom", + "bridge": "cni0", + "isGateway": true, + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "$1", + "routes": [ + { "dst": "0.0.0.0/0" } + ] + } } EOF diff --git a/test/network.bats b/test/network.bats index c0629cf9..8121ca48 100644 --- a/test/network.bats +++ b/test/network.bats @@ -85,6 +85,8 @@ load helpers [ "$FOUND_K8S_POD_NAMESPACE" = "redhat.test.crio" ] [ "$FOUND_K8S_POD_NAME" = "podsandbox1" ] + rm -rf /tmp/plugin_test_args.out + cleanup_pods stop_crio } diff --git a/test/plugin_test_args.bash b/test/plugin_test_args.bash deleted file mode 100755 index fad0d943..00000000 --- a/test/plugin_test_args.bash +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -if [[ -z "${CNI_ARGS}" ]]; then - exit 1 -fi - -IFS=';' read -ra array <<< "${CNI_ARGS}" -for arg in "${array[@]}"; do - IFS='=' read -ra item <<< "${arg}" - if [[ "${item[0]}" = "K8S_POD_NAMESPACE" ]]; then - K8S_POD_NAMESPACE="${item[1]}" - elif [[ "${item[0]}" = "K8S_POD_NAME" ]]; then - K8S_POD_NAME="${item[1]}" - fi -done - -if [[ -z "${CNI_CONTAINERID}" ]]; then - exit 1 -elif [[ -z "${K8S_POD_NAMESPACE}" ]]; then - exit 1 -elif [[ -z "${K8S_POD_NAME}" ]]; then - exit 1 -fi - -echo "FOUND_CNI_CONTAINERID=${CNI_CONTAINERID}" >> /tmp/plugin_test_args.out -echo "FOUND_K8S_POD_NAMESPACE=${K8S_POD_NAMESPACE}" >> /tmp/plugin_test_args.out -echo "FOUND_K8S_POD_NAME=${K8S_POD_NAME}" >> /tmp/plugin_test_args.out - -cat <<-EOF -{ - "cniVersion": "0.2.0", - "ip4": { - "ip": "1.1.1.1/24" - } -} -EOF -