Skip to content

Commit a536ccf

Browse files
committed
Test NetworkPolicy plugin (if the kernel supports it)
1 parent eab186e commit a536ccf

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

test/extended/networking.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export SHELLOPTS
1616
#
1717
# The EmptyDir test is a canary; it will fail if mount propagation is
1818
# not properly configured on the host.
19-
NETWORKING_E2E_FOCUS="${NETWORKING_E2E_FOCUS:-etworking|EmptyDir volumes should support \(root,0644,tmpfs\)}"
19+
NETWORKING_E2E_FOCUS="${NETWORKING_E2E_FOCUS:-etworking|Feature:OSNetworkPolicy|EmptyDir volumes should support \(root,0644,tmpfs\)}"
2020
NETWORKING_E2E_SKIP="${NETWORKING_E2E_SKIP:-}"
2121

2222
DEFAULT_SKIP_LIST=(
@@ -313,6 +313,25 @@ function disable-selinux() {
313313
fi
314314
}
315315

316+
function kernel-supports-networkpolicy() {
317+
# There's really no good way to test this "correctly" if OVS isn't installed.
318+
# The mainline kernel got support for OVS NAT support in 4.6. RHEL kernels have
319+
# it in 3.10.0-514 and later.
320+
version="$(uname -r)"
321+
case "${version}" in
322+
3.10.0-*.el7.*)
323+
build=$(sed -e 's/.*-\([0-9]*\)\..*/\1/' <<< "${version}")
324+
if [[ "${build}" -lt 514 ]]; then
325+
return 1
326+
fi
327+
;;
328+
[0-3].*|4.[0-5].*)
329+
return 1
330+
;;
331+
esac
332+
return 0
333+
}
334+
316335
os::log::info "Starting 'networking' extended tests"
317336
if [[ -n "${CONFIG_ROOT}" ]]; then
318337
KUBECONFIG="$(get-kubeconfig-from-root "${CONFIG_ROOT}")"
@@ -377,11 +396,16 @@ else
377396
# Docker-in-docker is not compatible with selinux
378397
disable-selinux
379398

380-
# Skip the subnet tests during a minimal test run
399+
# Skip subnet and networkpolicy tests during a minimal test run
381400
if [[ -z "${NETWORKING_E2E_MINIMAL}" ]]; then
382401
# Ignore deployment errors for a given plugin to allow other plugins
383402
# to be tested.
384403
test-osdn-plugin "subnet" "redhat/openshift-ovs-subnet" "false" "false" || true
404+
if kernel-supports-networkpolicy; then
405+
test-osdn-plugin "networkpolicy" "redhat/openshift-ovs-networkpolicy" "false" "true" || true
406+
else
407+
os::log::warning "Skipping networkpolicy tests due to kernel version"
408+
fi
385409
fi
386410

387411
test-osdn-plugin "multitenant" "redhat/openshift-ovs-multitenant" "true" "false" || true

0 commit comments

Comments
 (0)