Commit Graph

62 Commits

Author SHA1 Message Date
Patrick Ohly
41f23f52d0 test: fix ginkgolinter issues
All of these issues were reported by https://github.com/nunnatsa/ginkgolinter.
Fixing these issues is useful (several expressions get simpler, using
framework.ExpectNoError is better because it has additional support for
failures) and a necessary step for enabling that linter in our golangci-lint
invocation.
2023-02-22 19:36:05 +01:00
Antonio Ojea
5d8f745e86 e2e dns don't fail if configmap does not exist
don't fail on cleanup if the configmap for kube-dns does not exist

Change-Id: Ia56d9f590baba374e0b687aeda71d547899b1713
2022-12-18 19:23:36 +00:00
Patrick Ohly
2f6c4f5eab e2e: use Ginkgo context
All code must use the context from Ginkgo when doing API calls or polling for a
change, otherwise the code would not return immediately when the test gets
aborted.
2022-12-16 20:14:04 +01:00
Patrick Ohly
d4729008ef e2e: simplify test cleanup
ginkgo.DeferCleanup has multiple advantages:
- The cleanup operation can get registered if and only if needed.
- No need to return a cleanup function that the caller must invoke.
- Automatically determines whether a context is needed, which will
  simplify the introduction of context parameters.
- Ginkgo's timeline shows when it executes the cleanup operation.
2022-12-13 08:09:01 +01:00
Patrick Ohly
dfdf88d4fa e2e: adapt to moved code
This is the result of automatically editing source files like this:

    go install golang.org/x/tools/cmd/goimports@latest
    find ./test/e2e* -name "*.go" | xargs env PATH=$GOPATH/bin:$PATH ./e2e-framework-sed.sh

with e2e-framework-sed.sh containing this:

sed -i \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecCommandInContainer(/e2epod.ExecCommandInContainer(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecCommandInContainerWithFullOutput(/e2epod.ExecCommandInContainerWithFullOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecShellInContainer(/e2epod.ExecShellInContainer(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecShellInPod(/e2epod.ExecShellInPod(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecShellInPodWithFullOutput(/e2epod.ExecShellInPodWithFullOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecWithOptions(/e2epod.ExecWithOptions(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.MatchContainerOutput(/e2eoutput.MatchContainerOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.PodClient(/e2epod.NewPodClient(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.PodClientNS(/e2epod.PodClientNS(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.TestContainerOutput(/e2eoutput.TestContainerOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.TestContainerOutputRegexp(/e2eoutput.TestContainerOutputRegexp(\1, /" \
    -e "s/framework.AddOrUpdateLabelOnNode\b/e2enode.AddOrUpdateLabelOnNode/" \
    -e "s/framework.AllNodes\b/e2edebug.AllNodes/" \
    -e "s/framework.AllNodesReady\b/e2enode.AllNodesReady/" \
    -e "s/framework.ContainerResourceGatherer\b/e2edebug.ContainerResourceGatherer/" \
    -e "s/framework.ContainerResourceUsage\b/e2edebug.ContainerResourceUsage/" \
    -e "s/framework.CreateEmptyFileOnPod\b/e2eoutput.CreateEmptyFileOnPod/" \
    -e "s/framework.DefaultPodDeletionTimeout\b/e2epod.DefaultPodDeletionTimeout/" \
    -e "s/framework.DumpAllNamespaceInfo\b/e2edebug.DumpAllNamespaceInfo/" \
    -e "s/framework.DumpDebugInfo\b/e2eoutput.DumpDebugInfo/" \
    -e "s/framework.DumpNodeDebugInfo\b/e2edebug.DumpNodeDebugInfo/" \
    -e "s/framework.EtcdUpgrade\b/e2eproviders.EtcdUpgrade/" \
    -e "s/framework.EventsLister\b/e2edebug.EventsLister/" \
    -e "s/framework.ExecOptions\b/e2epod.ExecOptions/" \
    -e "s/framework.ExpectNodeHasLabel\b/e2enode.ExpectNodeHasLabel/" \
    -e "s/framework.ExpectNodeHasTaint\b/e2enode.ExpectNodeHasTaint/" \
    -e "s/framework.GCEUpgradeScript\b/e2eproviders.GCEUpgradeScript/" \
    -e "s/framework.ImagePrePullList\b/e2epod.ImagePrePullList/" \
    -e "s/framework.KubectlBuilder\b/e2ekubectl.KubectlBuilder/" \
    -e "s/framework.LocationParamGKE\b/e2eproviders.LocationParamGKE/" \
    -e "s/framework.LogSizeDataTimeseries\b/e2edebug.LogSizeDataTimeseries/" \
    -e "s/framework.LogSizeGatherer\b/e2edebug.LogSizeGatherer/" \
    -e "s/framework.LogsSizeData\b/e2edebug.LogsSizeData/" \
    -e "s/framework.LogsSizeDataSummary\b/e2edebug.LogsSizeDataSummary/" \
    -e "s/framework.LogsSizeVerifier\b/e2edebug.LogsSizeVerifier/" \
    -e "s/framework.LookForStringInLog\b/e2eoutput.LookForStringInLog/" \
    -e "s/framework.LookForStringInPodExec\b/e2eoutput.LookForStringInPodExec/" \
    -e "s/framework.LookForStringInPodExecToContainer\b/e2eoutput.LookForStringInPodExecToContainer/" \
    -e "s/framework.MasterAndDNSNodes\b/e2edebug.MasterAndDNSNodes/" \
    -e "s/framework.MasterNodes\b/e2edebug.MasterNodes/" \
    -e "s/framework.MasterUpgradeGKE\b/e2eproviders.MasterUpgradeGKE/" \
    -e "s/framework.NewKubectlCommand\b/e2ekubectl.NewKubectlCommand/" \
    -e "s/framework.NewLogsVerifier\b/e2edebug.NewLogsVerifier/" \
    -e "s/framework.NewNodeKiller\b/e2enode.NewNodeKiller/" \
    -e "s/framework.NewResourceUsageGatherer\b/e2edebug.NewResourceUsageGatherer/" \
    -e "s/framework.NodeHasTaint\b/e2enode.NodeHasTaint/" \
    -e "s/framework.NodeKiller\b/e2enode.NodeKiller/" \
    -e "s/framework.NodesSet\b/e2edebug.NodesSet/" \
    -e "s/framework.PodClient\b/e2epod.PodClient/" \
    -e "s/framework.RemoveLabelOffNode\b/e2enode.RemoveLabelOffNode/" \
    -e "s/framework.ResourceConstraint\b/e2edebug.ResourceConstraint/" \
    -e "s/framework.ResourceGathererOptions\b/e2edebug.ResourceGathererOptions/" \
    -e "s/framework.ResourceUsagePerContainer\b/e2edebug.ResourceUsagePerContainer/" \
    -e "s/framework.ResourceUsageSummary\b/e2edebug.ResourceUsageSummary/" \
    -e "s/framework.RunHostCmd\b/e2eoutput.RunHostCmd/" \
    -e "s/framework.RunHostCmdOrDie\b/e2eoutput.RunHostCmdOrDie/" \
    -e "s/framework.RunHostCmdWithFullOutput\b/e2eoutput.RunHostCmdWithFullOutput/" \
    -e "s/framework.RunHostCmdWithRetries\b/e2eoutput.RunHostCmdWithRetries/" \
    -e "s/framework.RunKubectl\b/e2ekubectl.RunKubectl/" \
    -e "s/framework.RunKubectlInput\b/e2ekubectl.RunKubectlInput/" \
    -e "s/framework.RunKubectlOrDie\b/e2ekubectl.RunKubectlOrDie/" \
    -e "s/framework.RunKubectlOrDieInput\b/e2ekubectl.RunKubectlOrDieInput/" \
    -e "s/framework.RunKubectlWithFullOutput\b/e2ekubectl.RunKubectlWithFullOutput/" \
    -e "s/framework.RunKubemciCmd\b/e2ekubectl.RunKubemciCmd/" \
    -e "s/framework.RunKubemciWithKubeconfig\b/e2ekubectl.RunKubemciWithKubeconfig/" \
    -e "s/framework.SingleContainerSummary\b/e2edebug.SingleContainerSummary/" \
    -e "s/framework.SingleLogSummary\b/e2edebug.SingleLogSummary/" \
    -e "s/framework.TimestampedSize\b/e2edebug.TimestampedSize/" \
    -e "s/framework.WaitForAllNodesSchedulable\b/e2enode.WaitForAllNodesSchedulable/" \
    -e "s/framework.WaitForSSHTunnels\b/e2enode.WaitForSSHTunnels/" \
    -e "s/framework.WorkItem\b/e2edebug.WorkItem/" \
    "$@"

for i in "$@"; do
    # Import all sub packages and let goimports figure out which of those
    # are redundant (= already imported) or not needed.
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2enode "k8s.io/kubernetes/test/e2e/framework/node"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2epod "k8s.io/kubernetes/test/e2e/framework/pod"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2eproviders "k8s.io/kubernetes/test/e2e/framework/providers"' "$i"
    goimports -w "$i"
done
2022-10-06 08:19:47 +02:00
Dave Chen
857458cfa5 update ginkgo from v1 to v2 and gomega to 1.19.0
- update all the import statements
- run hack/pin-dependency.sh to change pinned dependency versions
- run hack/update-vendor.sh to update go.mod files and the vendor directory
- update the method signatures for custom reporters

Signed-off-by: Dave Chen <dave.chen@arm.com>
2022-07-08 10:44:46 +08:00
Kubernetes Prow Robot
8cd689e40d
Merge pull request #109283 from s-urbaniak/ratchet-e2e
test/e2e/framework: use restricted policy by default, default existing tests to privileged
2022-04-05 14:37:25 -07:00
Sergiusz Urbaniak
1495c9f2cd
test/e2e/*: default existing tests to privileged pod security policy
This is to ensure that all existing tests don't break when defaulting
the pod security policy to restricted in the e2e test framework.
2022-04-05 08:41:12 +02:00
Claudiu Belu
87123c49a0 tests: Enables a few Conformance tests for Windows
Some of these tests could not be run previously, especially on Windows
Docker containers. But now, by using Windows Containerd, we can finally
run them:

- HostNetwork=true tests: This can now be enabled on Windows Privileged Containers.
- /etc/hosts related tests: These were not supported because it required single
  file mappings, which is possible in Containerd.
- termination message as non-root user: Requires RunAsUsername, and single file
  mappings.
2022-03-06 09:36:39 -08:00
Pavithra Ramesh
fa3f4a69e5 Skip testing for Pod DNS records.
DNS records of the form *.pod.cluster.local are deprecated - https://github.com/kubernetes/dns/pull/335
Testing for their presence is not required.
2021-08-26 14:33:12 -07:00
Antonio Ojea
3790290c9b remove e2e miekg/dns dependency
miekg dependency was forking some of the golang standard library.
We can fork it directly into the third_party folder respecting
the LICENSE.
2021-01-22 18:27:25 +01:00
Antonio Ojea
97a13a0f87 e2e don't use hardcoded name for containers name 2020-10-17 11:44:45 +02:00
Kubernetes Prow Robot
7b40b3410b
Merge pull request #94595 from claudiubelu/tests/agnhost-usage-refactor-5
tests: Refactor agnhost image pod usage - network
2020-10-16 09:01:40 -07:00
jay vyas
1c5ad9b7e7 remove dns_common.go delete configmap stuff 2020-09-30 11:12:56 -04:00
Claudiu Belu
d37cbeb388 tests: Refactors agnhost image pod usage - network
A previous commit created a few agnhost related functions that creates agnhost
pods / containers for general purposes.

Refactors tests to use those functions.
2020-09-26 05:56:31 -07:00
tanjunchen
aa52bfe4d6 use e2epod.WaitForPodRunningInNamespaceSlow directly 2020-03-21 15:51:49 +08:00
Kenichi Omichi
2c8955fd4a Use e2epod.WaitForPodNameRunningInNamespace directly
WaitForPod*() are just wrapper functions for e2epod package, and they
made an invalid dependency to sub e2e framework from the core framework.
So this replaces WaitForPodRunning() with the e2epod function.
2020-03-17 00:13:14 +00:00
Mike Danese
aaf855c1e6 deref all calls to metav1.NewDeleteOptions that are passed to clients.
This is gross but because NewDeleteOptions is used by various parts of
storage that still pass around pointers, the return type can't be
changed without significant refactoring within the apiserver. I think
this would be good to cleanup, but I want to minimize apiserver side
changes as much as possible in the client signature refactor.
2020-03-05 14:59:46 -08:00
Mike Danese
c58e69ec79 automated refactor 2020-03-05 14:59:46 -08:00
Claudiu Belu
c57f20b712 tests: Replaces dnsutils image used with agnhost (part 4)
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:

- dnsutils

dnsmasq is a Linux specific binary. In order for the tests to also
pass on Windows, CoreDNS should be used instead.
2020-02-26 21:51:23 -08:00
Claudiu Belu
f7942290af tests: Replaces images used with agnhost (part 4)
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:

- resource-consumer-controller
- test-webserver
2020-02-18 16:29:49 -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
John Belamaric
bfe696b49c Use longer pod start timeouts for specific tests
The kubelet test here is using a one minute timeout, instead of the
normal framework.PodStartTimeout.

The DNS results validation functions pull several images including
the jessie-dnsutils which is a bit bigger than usual.
2020-02-06 16:41:10 -08:00
Mike Danese
968adfa993 cleanup req.Context() and ResponseWrapper 2020-01-29 08:50:45 -08:00
Mike Danese
d55d6175f8 refactor 2020-01-29 08:50:45 -08:00
tanjunchen
d51b72d9e9 fix staticcheck in test/e2e/network/ 2019-12-05 13:58:28 +08:00
hwdef
af16366001 use log func in test/e2e/network 2019-09-13 17:54:51 +08:00
Antonio Ojea
930a1321da
DNS e2e tests differentiate between IP family
The e2e DNS tests differentiate between IP family to
avoid false positives with dual stack clusters.
2019-08-27 12:57:40 +02:00
Claudiu Belu
a8c63d132b tests: Fixes DNS tests for Windows
A previous commit replaced the usage of hostname -i with getent hosts
in DNS probe commands (for testing IPv6), which breaks the Windows tests
(getent hosts is a Linux-specific command that looks into the /etc/hosts
file, which, on Windows, is not managed by Kubelet).

This commit addresses this issue by executing getent hosts on IPv6 clusters
and hostname -i on IPv4 clusters (Windows does not support IPv6 at this
moment).
2019-08-11 11:19:31 -07:00
SataQiu
5234f2e668 e2e: use framework.ExpectEqual() for test/e2e/network 2019-07-05 11:05:09 +08:00
Antonio Ojea
207c00aa8c
Add ipv6 support to the DNS e2e tests
Current DNS e2e test are only looking for A records, thus all IPv6
tests fail because we should look for AAAA records.

We can ask for both records in the same query, that allows us to
have the same tests for both scenarios.

` dig <name> A <name> AAAA`

In addition, the logic to find the hostname address has to be changed
because the command `hostname -i` fails in an IPv6 environemnt.
However, using `getent hosts $(hostname | ...)` give us the IPv6 adddress
of the current host.

Reference: https://github.com/kubernetes/kubernetes/issues/70248

Signed-off-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2019-06-25 23:44:17 +02:00
SataQiu
332be4b1e3 refactor: replace framework.Failf with e2elog.Failf 2019-06-19 17:52:35 +08: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
SataQiu
36bc97cbb8 fix some golint failures of e2e/network/[d-k]*.go 2019-04-08 18:27:08 +08:00
Claudiu Belu
fd03127cac tests: Adds retry for dig for ExternalName test
The network connection might not yet be established by the time the
container starts, causing the dig command to fail.

Retrying the dig command will solve this issue. This approach is similar
to the other DNS Conformance tests.
2019-03-03 21:28:47 -08:00
Pavithra Ramesh
19e1fcc242 Remove 'norecurse' flag in dns tests.
dnsmasq 2.79 introduced a change to respond to all norecurse queries with ServFail.
This is to prevent cache snooping where an adversary can figure out if a particular hostname has been looked up or not.
These tests do not need the norecurse flag, hence removing it.
2018-12-03 14:27:39 -08:00
Sandeep Rajan
4c8a65ac01 configure cluster domain via flags 2018-11-01 12:27:54 -04:00
k8s-ci-robot
f9c744acb8
Merge pull request #70242 from bclau/fixes-dns-false-positives
tests: Fixes DNS tests false positives
2018-10-30 12:22:58 -07:00
k8s-ci-robot
0768fa5604
Merge pull request #70188 from rajansandeep/ipv6tests
Extend DNS ConfigMap tests to support IPv6
2018-10-29 12:08:03 -07:00
Sandeep Rajan
9e8bd5ccca extend tests to support ipv6 functionality
ipv6 tests for configmap
2018-10-29 12:34:00 -04:00
Claudiu Belu
fb8d2f7ef5 tests: Fixes DNS tests false positives
If dig fails to reach the DNS, it will output errors to stdout, which
can cause the test -n to falsely pass:

ubuntu@ubuntu:~$ dig +notcp +noall +answer +search kubernetes.default A
;; connection timed out; no servers could be reached
command terminated with exit code 9

ubuntu@ubuntu:~$ test -n "$(dig +notcp +noall +answer +search kubernetes.default A)" && echo OK
OK

This patch solves this issue by making sure the dig command actually succeeds
before checking its output.
2018-10-21 14:29:15 -07:00
Justin Santa Barbara
ed7840ad50 e2e: speed up DNS tests
Poll a little more often, and use PollImmediate instead of Poll.
2018-10-10 19:33:57 -07:00
Louis Lepper
70650cbff4 Output more context with the log messages, and general style tweaks 2018-08-21 20:52:47 +10:00
Louis Lepper
624a5630f2 Make error messages more helpful in some e2e tests
Related to issues 34059 and 10322
2018-08-21 07:11:37 +10:00
hangaoshuai
57b4c1e7cf use const v1.ProtocolTCP replace of string TCP in test/e2e/network/ 2018-08-15 11:26:00 +08:00
Davanum Srinivas
0965db0ccf
Remove unused images
Change-Id: I6be2d14df736f5ae592d7e95713445b3d1c67a16
2018-07-30 18:40:17 -04:00
tanshanshan
fa75413b38 fix log format 2018-07-23 16:39:01 +08:00