Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make go test ./... succeed by default #16914

Merged
merged 3 commits into from Aug 10, 2021
Merged

Make go test ./... succeed by default #16914

merged 3 commits into from Aug 10, 2021

Conversation

twpayne
Copy link
Contributor

@twpayne twpayne commented Jul 16, 2021

This PR makes

$ go test ./...

succeed by default. Before, it would fail due to many unit tests actually being integration tests needing a running etcd server and the requirement for various linker flags to be present to set various test configuration variables.

See the individual commits for more details.

@twpayne twpayne added release-note/misc This PR makes changes that have no direct user impact. area/build Anything to do with the build, more general then area/CI labels Jul 16, 2021
@twpayne twpayne requested review from a team July 16, 2021 11:40
@twpayne twpayne requested review from a team as code owners July 16, 2021 11:40
@twpayne twpayne requested a review from a team July 16, 2021 11:40
@maintainer-s-little-helper
Copy link

Commit 98e2a21de19a9cb29cc0f1f46565c8bade4d0f72 does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@maintainer-s-little-helper
Copy link

Commit 98e2a21de19a9cb29cc0f1f46565c8bade4d0f72 does not contain "Signed-off-by".

Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin

@twpayne
Copy link
Contributor Author

twpayne commented Jul 16, 2021

Oh, @maintainer-s-little-helper, commit 98e2a21 is no longer part of this PR, so I'm not sure why you're complaining about it.

@twpayne
Copy link
Contributor Author

twpayne commented Jul 16, 2021

test-me-please

@twpayne
Copy link
Contributor Author

twpayne commented Aug 9, 2021

test-me-please

Job 'Cilium-PR-K8s-1.19-kernel-5.4' failed and has not been observed before, so may be related to your PR:

Click to show.

Test Name

K8sDatapathConfig AutoDirectNodeRoutes Check connectivity with sockops and direct routing

Failure Output

FAIL: Error creating resource /home/jenkins/workspace/Cilium-PR-K8s-1.19-kernel-5.4/src/github.com/cilium/cilium/test/k8sT/manifests/l3-policy-demo.yaml: Cannot retrieve cilium pod cilium-zz755 policy revision: cannot get revision from json output '': could not parse JSON from command "kubectl exec -n kube-system cilium-zz755 -- cilium policy get -o json"

If it is a flake, comment /mlh new-flake Cilium-PR-K8s-1.19-kernel-5.4 so I can create a new GitHub issue to track it.

Job 'Cilium-PR-K8s-1.16-net-next' failed and has not been observed before, so may be related to your PR:

Click to show.

Test Name

K8sDatapathConfig Host firewall With VXLAN

Failure Output

FAIL: Failed to reach 10.0.0.46:80 from testclient-host-k6q5d

If it is a flake, comment /mlh new-flake Cilium-PR-K8s-1.16-net-next so I can create a new GitHub issue to track it.

@twpayne
Copy link
Contributor Author

twpayne commented Aug 9, 2021

ci-l4lb test failure is:

ERROR: failed to create cluster: failed to pull image "kindest/node:v1.21.1@sha256:fae9a58f17f18f06aeac9772ca8b5ac680ebbed985e266f711d936e91d113bad": command "docker pull kindest/node:v1.21.1@sha256:fae9a58f17f18f06aeac9772ca8b5ac680ebbed985e266f711d936e91d113bad" failed with error: exit status 1

Command Output: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

@twpayne
Copy link
Contributor Author

twpayne commented Aug 9, 2021

ConformanceEKS (ci-eks) failure looks like a flake, I've opened #17102.

@twpayne
Copy link
Contributor Author

twpayne commented Aug 9, 2021

k8s-1.19-kernel-5.4 (test-1.19-5.4) failure is #16852.

Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing to check on the make -C test build target. Not sure why you're hitting so much turmoil in the CI, is the tree in general this unstable? 🤔

test/Makefile Show resolved Hide resolved
// Copyright 2017 Authors of Cilium
// Copyright 2017-2021 Authors of Cilium

// +build integration_tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice if we could figure out a way to allow both go test ./... and also ginkgo -focus ... without adding this extra -tags integration_tests boilerplate argument for every time a developer wants to run ginkgo 🤔

At the same time, I personally have macros wrapped around the ginkgo invocations anyway so it doesn't directly affect me. And I'd probably rather that unit-testing is the easiest type of testing in order to encourage developers to write more of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice if we could figure out a way to allow both go test ./... and also ginkgo -focus ... without adding this extra -tags integration_tests boilerplate argument for every time a developer wants to run ginkgo 🤔

Agree, I'd prefer this as well, but I can't find a mechanism to do it, short of providing our own ginkgo binary.

@twpayne
Copy link
Contributor Author

twpayne commented Aug 9, 2021

Not sure why you're hitting so much turmoil in the CI, is the tree in general this unstable? 🤔

In my personal experience, yes, the tree has been this unstable, but perhaps I've just been unlucky.

Before this commit, running the standard go command

    go test ./...

would fail because a number of unit tests were in fact integration
tests, typically requiring an etcd server to be running.

This PR adds an integration_test build flag to all such tests and
renames the unit-tests make target to integration-tests and sets this
flag.

With this commit "go test ./..." succeeds and runs a large subset of the
unit tests, completing in less than 15 seconds on a eight core machine
and a fully populated cache. "make integration-tests" in the same
configuration takes about nine minutes as it tests packages serially and
does not use or Go's test result cache.

Unfortunately, the bundling of many tests into gopkg.in/check.v1 suites
means that unit tests in many packages are coupled to integration
tests. This commit makes no attempt to unpick such coupling and so the
set of tests run by go test ./... is smaller than it could potentially
be. Improving this is left for a follow-up commit.

Signed-off-by: Tom Payne <tom@isovalent.com>
@twpayne twpayne added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Aug 10, 2021
@twpayne
Copy link
Contributor Author

twpayne commented Aug 10, 2021

Gilberto is on PTO for a bit, this has multiple approvals, so marking as ready-to-merge.

Copy link
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@gandro gandro merged commit 42b776f into cilium:master Aug 10, 2021
@twpayne twpayne deleted the twpayne/pr/go-test branch August 10, 2021 17:34
joestringer pushed a commit that referenced this pull request Aug 13, 2021
PR #16914 missed a couple of places where the integration_test build tag
needs to be set.

Signed-off-by: Tom Payne <tom@isovalent.com>
krishgobinath pushed a commit to krishgobinath/cilium that referenced this pull request Oct 20, 2021
PR cilium#16914 missed a couple of places where the integration_test build tag
needs to be set.

Signed-off-by: Tom Payne <tom@isovalent.com>
gandro added a commit to gandro/cilium that referenced this pull request Nov 29, 2021
This will skip the test when running the tests standalone (i.e. via `go
test` and not via Makefile). See cilium#17536 for more details about this
particular file, which applied the same principle to the benchmark in
that test suite.

See also cilium#16914

Reported-by: Hemanth Malla <hemanth.malla@datadoghq.com>
Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
qmonnet pushed a commit that referenced this pull request Nov 30, 2021
This will skip the test when running the tests standalone (i.e. via `go
test` and not via Makefile). See #17536 for more details about this
particular file, which applied the same principle to the benchmark in
that test suite.

See also #16914

Reported-by: Hemanth Malla <hemanth.malla@datadoghq.com>
Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Anything to do with the build, more general then area/CI ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants