Commit Graph

60 Commits

Author SHA1 Message Date
Amim Knabben
9a8a74f79a Rolling back network policy tests 2021-01-27 18:58:52 -05:00
Amim Knabben
131c35d074 Removing network_policy.go file 2021-01-25 14:02:51 -05:00
Kubernetes Prow Robot
fec1a366c3
Merge pull request #91592 from jayunit100/netpol-impl2
new NetworkPolicy Validation suite
2020-12-23 05:56:27 -08:00
jay vyas
36ae8fd91a import the netpol testing package so that ownership is attributed correctly in the network policy testing suit 2020-12-23 07:40:47 -05:00
Antonio Ojea
60f739ac17 e2e network policy enclose IPv6 destinations
We moved to DNS destination to IP:Port, so we need to be sure
that IPv6 addresses are enclosed in square brackets with that
format.
2020-11-25 10:56:24 +01:00
Kubernetes Prow Robot
1c403c311e
Merge pull request #95453 from danwinship/egress-networkpolicy-tests
Don't depend on DNS in NetworkPolicy tests
2020-11-03 11:44:04 -08:00
Kubernetes Prow Robot
ffb233ff2d
Merge pull request #95155 from cmluciano/cml/netpolapie2e
netpol: Add CRUD tests for NetworkPolicy API
2020-10-21 13:08:50 -07:00
Christopher M. Luciano
62ac60c4b5
netpol: Add CRUD tests for NetworkPolicy API
CRUD operations are the extent of conformance testing that we can add
for NetworkPolicy tests since we require a 3rd party plugin like CNI
for enforcement.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
2020-10-19 13:22:42 -04:00
Dan Winship
3b9f358eb9 Don't depend on DNS in NetworkPolicy tests
The NetworkPolicy tests work by trying to connect to a service by its
name, which means that for the tests that involved creating egress
policies, it had to always create an extra rule allowing egress for
DNS, but this assumed that DNS was running on UDP port 53. If it was
running somewhere else (eg if you changed the CoreDNS pods to use port
5353 to avoid needing to give them the NET_BIND_SERVICE capability)
then the NetworkPolicy tests would fail.

Fix this by making the tests connect to their services by IP rather
than by name, and removing all the DNS special-case rules. There are
other tests that ensure that Service DNS works.
2020-10-09 16:16:43 -04:00
Jamo Luhrsen
ae63d6495d Collect debugs before framework.Failf
having framework.DumpDebugInfo after the FailF was
a noop and we are losing those potentially helpful
logs when we need them the most (on a failure)

Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
2020-09-25 13:22:24 -07:00
Federico Paolinelli
345cab6ee9 Add tests for SCTP network policies.
Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
2020-08-31 10:39:29 +02:00
Antonio Ojea
f9a5e5a283 support ipv6 in e2e policy tests 2020-08-12 13:01:07 +02:00
Laszlo Janosi
3ce43a1c96 Add e2e test for SCTP Service, Pod and Endpoint creation.
Add SCTP NetworkPolicy test.
2020-05-28 19:51:27 +00:00
Shaun Crampton
73fe9c9915 Avoid early exit when collecting post-E2E failure logs.
collectPodsAndNetworkPolicies() is called to collect diagnostics
after a failure.  Previously, if it encountered a failure in getting
the logs it would call Failf(), discarding the rest of the diagnostics
immediately.
2020-05-04 14:32:04 +01:00
Kubernetes Prow Robot
4e45845530
Merge pull request #90095 from agadelshin/87893-ingress-egress-test
Add test for ingress/egress combination
2020-04-25 05:57:28 -07:00
Artur Gadelshin
bf30bdddb1 add error check for network policy test 2020-04-15 11:47:02 +02:00
Kubernetes Prow Robot
c894c7b121
Merge pull request #88393 from abhiraut/e2e-exc-multiple
Add e2e test for stacked NetworkPolicies with overlapping CIDR
2020-04-13 13:37:48 -07:00
Artur Gadelshin
4164b5c892 Add egress check to deny-all policy 2020-04-13 09:40:49 +02:00
Artur Gadelshin
875f80e3a3 Add test for ingress/egress combination 2020-04-12 23:36:16 +02:00
Kubernetes Prow Robot
184fe990aa
Merge pull request #89592 from dcbw/e2e-np-previous-logs
e2e/network: get previous pod logs on NetworkPolicy test failure
2020-03-30 14:20:40 -07:00
Dan Williams
fe74d08e60 e2e/network: get previous pod logs on NetworkPolicy test failure
Sometimes the pod has already been cleaned up by the time the test
tried to grab the logs.

Mar 27 16:19:38.066: INFO: Waiting for client-a-jt4tf to complete.
Mar 27 16:19:38.066: INFO: Waiting up to 5m0s for pod "client-a-jt4tf" in namespace "e2e-network-policy-c-9007" to be "success or failure"
Mar 27 16:19:38.072: INFO: Pod "client-a-jt4tf": Phase="Pending", Reason="", readiness=false. Elapsed: 6.270302ms
Mar 27 16:19:40.078: INFO: Pod "client-a-jt4tf": Phase="Pending", Reason="", readiness=false. Elapsed: 2.01233019s
Mar 27 16:19:42.086: INFO: Pod "client-a-jt4tf": Phase="Succeeded", Reason="", readiness=false. Elapsed: 4.020186873s
STEP: Saw pod success
Mar 27 16:19:42.086: INFO: Pod "client-a-jt4tf" satisfied condition "success or failure"
Mar 27 16:19:42.093: FAIL: Error getting container logs: the server could not find the requested resource (get pods client-a-jt4tf)

Full Stack Trace
github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/network.checkNoConnectivity(0xc00104adc0, 0xc0016b82c0, 0xc001666400, 0xc000c32000)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/network/network_policy.go:1457 +0x2a0
github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/network.testCannotConnect(0xc00104adc0, 0xc0016b82c0, 0x55587e9, 0x8, 0xc000c32000, 0x50)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/network/network_policy.go:1406 +0x1fc
github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/network.glob..func13.2.7()
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/test/e2e/network/network_policy.go:285 +0x883
github.com/openshift/origin/pkg/test/ginkgo.(*TestOptions).Run(0xc001e47830, 0xc001e50b70, 0x1, 0x1, 0x0, 0x0)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/pkg/test/ginkgo/cmd_runtest.go:59 +0x41f
main.newRunTestCommand.func1(0xc00121b900, 0xc001e50b70, 0x1, 0x1, 0x0, 0x0)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/cmd/openshift-tests/openshift-tests.go:238 +0x15d
github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).execute(0xc00121b900, 0xc001e50b30, 0x1, 0x1, 0xc00121b900, 0xc001e50b30)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:826 +0x460
github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc00121b180, 0x0, 0x60d2d00, 0x9887ec8)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:914 +0x2fb
github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).Execute(...)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:864
main.main.func1(0xc00121b180, 0x0, 0x0)
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/cmd/openshift-tests/openshift-tests.go:59 +0x9c
main.main()
    /go/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/cmd/openshift-tests/openshift-tests.go:60 +0x341
STEP: Cleaning up the pod client-a-jt4tf
STEP: Cleaning up the policy.
2020-03-27 13:47:28 -05:00
tanjunchen
bed22fbb44 WaitForPodReady is simply wrapper functions for e2epod package,
and they made an invalid dependency to sub e2e framework from the core framework.

So we can use e2epod.WaitTimeoutForPodReadyInNamespace to remove invalid dependency.

The main purpose of this pr is to handle the framework core package dependency subpackage pod.
2020-03-22 23:08:52 +08:00
tanjunchen
d18e6569e0 use e2epod.WaitForPodNotFoundInNamespace directly 2020-03-21 15:11:40 +08:00
Mike Danese
c58e69ec79 automated refactor 2020-03-05 14:59:46 -08:00
Abhishek Raut
f3038d5f5a Add e2e test for stacked NetworkPolicies with overlapping CIDR
Add a new e2e test to test multiple stacked NetworkPolicies with
Except clauses in IPBlock which overlaps with an allowed CIDR in
another NetworkPolicy. This test ensures that the order of the
creation of NetworkPolicies should not matter while evaluating
a Pods access to another Pod.
2020-02-21 15:32:04 -08:00
Kubernetes Prow Robot
468af72a15
Merge pull request #88301 from abhiraut/e2e-except
Add e2e test to test Except clause in NetworkPolicy
2020-02-20 16:30:41 -08:00
Abhishek Raut
a980a1fa24 Add e2e test to test Except clause in NetworkPolicy
Add a new e2e test to test the Except clauses in IPBlock CIDR
based NetworkPolicies. This test adds an egress rule which
allows client to connect to a CIDR which includes the
ServerPod's IP, however carves an except subnet which excludes
this ServerPod.
2020-02-20 11:32:00 -08:00
Quan Tian
92759ea642 NetworkPolicy e2e test should wait for Pod ready
The test "should enforce egress policy allowing traffic to a server in a
different namespace based on PodSelector and NamespaceSelector
[Feature:NetworkPolicy]" is flaky because it doesn't wait for the server
Pod to be ready before testing traffic via its service, then even the
NetworkPolicy allows it, the SYN packets will be rejected by iptables
because the service has no endpoints at that moment.

This PR fixes it by making it wait for Pods to be ready like other
tests.
2020-02-20 00:32:12 +08:00
Quan Tian
55b687054d Fix updated pod NetworkPolicy e2e test
The test "should allow ingress access from updated pod" fails regardless
of which CNI plugin is enabled. It's because the test assumes the client
Pod can recheck connectivity after updating its label, but the client
won't restart after the first failure, so the second check will always
fail. The PR creates a client Pod with OnFailure RestartPolicy to fix it.

In addition to the above test that checks rule selector takes effect on
updated client pod, the PR adds a test "should deny ingress access to
updated pod" to ensure network policy selector can take effect on updated
server pod.
2020-02-14 00:12:19 +08:00
Mike Danese
25651408ae generated: run refactor 2020-02-08 12:30:21 -05:00
Mike Danese
3aa59f7f30 generated: run refactor 2020-02-07 18:16:47 -08:00
Kubernetes Prow Robot
652cc2ef40
Merge pull request #87073 from tanjunchen/migrate-to-skipper-002
e2e/network/:Use e2eskipper package
2020-01-13 13:59:09 -08:00
Quan Tian
e8017795d1 Fix GetPodLogs failures in NetworkPolicy e2e tests
GetPodLogs always fails when the tests fail, which is because the tests
specify wrong container names when getting logs.

When creating a client Pod, it specifies "<podName>-container" as
container name and "<podName>-" as Pod GenerateName. For instance,
podName "client-a" will result in "client-a-container" as the container
name and "client-a-vx5sv" as the actual Pod name, but it always uses the
actual Pod name to construct the container name when getting logs, e.g.
"client-a-vx5sv-container".

This patch fixes it by specifying the same static container name when
creating Pod and getting logs.
2020-01-13 19:04:24 +08:00
tanjunchen
586e1f2325 e2e/network/: Use e2eskipper package 2020-01-11 12:05:10 +08:00
hwdef
af16366001 use log func in test/e2e/network 2019-09-13 17:54:51 +08:00
Claudiu Belu
8812720148 tests: Skips Windows-unrelated tests on Windows
Skips IPv6 tests on Windows.
Skips sysctl tests on Windows.
Skips network policy tests on Windows.
Skips RunAsUser / FSGroup / file permissions related tests, as those are
not supported on Windows.
Skips the test "should preserve source pod IP for traffic thru service cluster IP"
on Windows, as it creates a Pod with HostNetwork=true, which is unsupported.

What works and what doesn't work on Windows has been documented here:
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md#windows--linux-considerations
2019-08-20 14:19:14 -07:00
tathagatachowdhury
f2c38e4d17 Added code for e2e tests for network policy. 2019-07-12 07:29:15 +00:00
Kubernetes Prow Robot
57416ef5ec
Merge pull request #78177 from MaysaMacedo/add-more-e2e-np-tests
Increase Network Policy tests coverage
2019-07-02 14:27:12 -07:00
Claudiu Belu
c752ea8134 tests: Replaces images used with agnhost (part 3)
Quite a few images are only used a few times in a few tests. Thus,
the images are being centralized into the agnhost image, reducing
the number of images that have to be pulled and used.

This PR replaces the usage of the following images with agnhost:

- audit-proxy
- crd-conversion-webhook
- entrypoint-tester
- inclusterclient
- iperf
- porter
- serve-hostname
2019-06-26 13:33:55 -07:00
Maysa Macedo
5fdddd31d2 Increase Network Policy tests coverage 2019-06-25 16:25:52 -04:00
SataQiu
332be4b1e3 refactor: replace framework.Failf with e2elog.Failf 2019-06-19 17:52:35 +08:00
Jorge Alarcon Ochoa
4969a05327 Refactored pod-related functions from framework/util.go
This a refactoring of framework/utils.go into framework/pod.

Signed-off-by: Jorge Alarcon Ochoa <alarcj137@gmail.com>
2019-05-30 09:30:26 -04:00
Kubernetes Prow Robot
472b9011d5
Merge pull request #77937 from MaysaMacedo/increase-e2e-np-tests
Increase coverage for e2e Network Policy tests
2019-05-29 11:26:39 -07:00
Maysa Macedo
b6f73bc82a Increase coverage for e2e Network Policy tests 2019-05-27 02:59:56 -04:00
toyoda
ba4119a07b use framework.ExpectNoError() for e2e/network 2019-05-15 13:33:13 +09:00
SataQiu
515f8342d3 fix golint failures of test/e2e/network 2019-05-11 22:29:40 +08:00
John Schnake
0c62f751b6 Move auth and network tests to use framework/log
This is part of the transition to using framework/log instead
of the Logf inside the framework package. This will help with
import size/cycles when importing the framework or subpackages.
2019-05-03 08:41:21 -05:00
Johannes M. Scheuermann
30098fd73f Make use of nc for Linux and Windows compatibility 2019-02-20 22:23:13 +01:00
Johannes M. Scheuermann
b515aa1d31 Use wget instead of curl for e2e network policy tests 2019-02-20 17:07:32 +01:00
Claudiu Belu
7cd4ebf3c3 tests: Makes tests' commands platform agnostic
Some commands used in tests are Linux specific and do not exist
or do not behave the same on Windows nodes. This can cause those
tests to fail on Windows nodes.

Replaces the mentioned commands with ones that behave the same on
both Linux and Windows.
2018-10-08 17:19:18 -07:00