test: replace bash CNI plugin with a custom bridge
Because we need a working CNI plugin to setup a correct netns so sandbox_run can grab a working IP address. Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
2ac2832686
commit
5947698818
5 changed files with 42 additions and 46 deletions
19
Dockerfile
19
Dockerfile
|
@ -76,6 +76,23 @@ RUN set -x \
|
||||||
&& cp bin/* /opt/cni/bin/ \
|
&& cp bin/* /opt/cni/bin/ \
|
||||||
&& rm -rf "$GOPATH"
|
&& 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
|
# Install crictl
|
||||||
ENV CRICTL_COMMIT 16e6fe4d7199c5689db4630a9330e6a8a12cecd1
|
ENV CRICTL_COMMIT 16e6fe4d7199c5689db4630a9330e6a8a12cecd1
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
|
@ -87,8 +104,6 @@ RUN set -x \
|
||||||
&& cp "$GOPATH"/bin/crictl /usr/bin/ \
|
&& cp "$GOPATH"/bin/crictl /usr/bin/ \
|
||||||
&& rm -rf "$GOPATH"
|
&& 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
|
# Make sure we have some policy for pulling images
|
||||||
RUN mkdir -p /etc/containers
|
RUN mkdir -p /etc/containers
|
||||||
COPY test/policy.json /etc/containers/policy.json
|
COPY test/policy.json /etc/containers/policy.json
|
||||||
|
|
|
@ -151,8 +151,6 @@
|
||||||
repo: https://github.com/containernetworking/plugins
|
repo: https://github.com/containernetworking/plugins
|
||||||
dest: /root/src/github.com/containernetworking/plugins
|
dest: /root/src/github.com/containernetworking/plugins
|
||||||
version: "{{ cni_commit }}"
|
version: "{{ cni_commit }}"
|
||||||
async: 600
|
|
||||||
poll: 10
|
|
||||||
- name: Git fetch the PR
|
- name: Git fetch the PR
|
||||||
shell: "git fetch origin +refs/pull/{{ pullrequest }}/head:refs/remotes/origin/pr/{{ pullrequest }}"
|
shell: "git fetch origin +refs/pull/{{ pullrequest }}/head:refs/remotes/origin/pr/{{ pullrequest }}"
|
||||||
args:
|
args:
|
||||||
|
@ -225,10 +223,18 @@
|
||||||
regexp: 'execute time bats --tap \$TESTS'
|
regexp: 'execute time bats --tap \$TESTS'
|
||||||
state: present
|
state: present
|
||||||
when: xunit
|
when: xunit
|
||||||
- name: Copy plugin args so tests dont hang
|
- name: git clone cni test repo
|
||||||
shell: "cp test/plugin_test_args.bash /opt/cni/bin/"
|
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:
|
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
|
# k8s builds with go1.8.x, rhel, fedora don't have it yet
|
||||||
- name: install Golang upstream in Fedora/RHEL
|
- name: install Golang upstream in Fedora/RHEL
|
||||||
shell: |
|
shell: |
|
||||||
|
|
|
@ -407,8 +407,18 @@ function prepare_plugin_test_args_network_conf() {
|
||||||
cat >$CRIO_CNI_CONFIG/10-plugin-test-args.conf <<-EOF
|
cat >$CRIO_CNI_CONFIG/10-plugin-test-args.conf <<-EOF
|
||||||
{
|
{
|
||||||
"cniVersion": "0.2.0",
|
"cniVersion": "0.2.0",
|
||||||
"name": "crionet",
|
"name": "crionet_test_args",
|
||||||
"type": "plugin_test_args.bash"
|
"type": "bridge-custom",
|
||||||
|
"bridge": "cni0",
|
||||||
|
"isGateway": true,
|
||||||
|
"ipMasq": true,
|
||||||
|
"ipam": {
|
||||||
|
"type": "host-local",
|
||||||
|
"subnet": "$1",
|
||||||
|
"routes": [
|
||||||
|
{ "dst": "0.0.0.0/0" }
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,8 @@ load helpers
|
||||||
[ "$FOUND_K8S_POD_NAMESPACE" = "redhat.test.crio" ]
|
[ "$FOUND_K8S_POD_NAMESPACE" = "redhat.test.crio" ]
|
||||||
[ "$FOUND_K8S_POD_NAME" = "podsandbox1" ]
|
[ "$FOUND_K8S_POD_NAME" = "podsandbox1" ]
|
||||||
|
|
||||||
|
rm -rf /tmp/plugin_test_args.out
|
||||||
|
|
||||||
cleanup_pods
|
cleanup_pods
|
||||||
stop_crio
|
stop_crio
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue