Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.

TestEnqueueRequestForSelector: only run test if -online flag is set - #776

Merged
rfratto merged 2 commits into
grafana-cold-storage:mainfrom
flokli:network-access-tests
Jul 23, 2021
Merged

TestEnqueueRequestForSelector: only run test if -online flag is set#776
rfratto merged 2 commits into
grafana-cold-storage:mainfrom
flokli:network-access-tests

Conversation

@flokli

@flokli flokli commented Jul 23, 2021

Copy link
Copy Markdown
Contributor

This test does download and invoke kubebuilder-tools, to make sure there
is no extra steps needed just to run this one test.
(#731 (comment)).

However, distros usually build and run tests in a sandbox with network
access disabled, causing this test to fail.

Introduce a online flag, defaulting to false, and skip this test as
long as -online is not passed.

CI, which invokes make test deliberately sets this to true, to have
coverage for that test provided by CI.

Fixes #731.

PR Description

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG updated
  • Documentation added
  • Tests updated

@CLAassistant

CLAassistant commented Jul 23, 2021

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rfratto rfratto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool, thanks! I've been on the fence about build tags and flags, but after playing around with tags for #773 I think this approach is better.

We'll likely move that flag into its own util package soon so other packages can make use of it but this is fine for now.

Comment thread CHANGELOG.md Outdated
@flokli
flokli force-pushed the network-access-tests branch from 6ae1454 to 9b40355 Compare July 23, 2021 07:27
Comment thread Makefile Outdated
This test does download and invoke kubebuilder-tools, to make sure there
is no extra steps needed just to run this one test.
(grafana-cold-storage#731 (comment)).

However, distros usually build and run tests in a sandbox with network
access disabled, causing this test to fail.

Introduce a `online` flag, defaulting to false, and skip this test as
long as `-online` is not passed.

CI, which invokes `make test` deliberately sets this to true, to have
coverage for that test provided by CI.

Fixes grafana-cold-storage#731.
@flokli
flokli force-pushed the network-access-tests branch from 9b40355 to 17e51a0 Compare July 23, 2021 15:44

@rfratto rfratto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@rfratto
rfratto merged commit 977c1ca into grafana-cold-storage:main Jul 23, 2021
@flokli
flokli deleted the network-access-tests branch August 19, 2021 15:36
@flokli

flokli commented Aug 19, 2021

Copy link
Copy Markdown
Contributor Author

@rfratto this seems to have changed / reverted during the merge of #773.

I found https://github.com/grafana/agent/pull/773/files#r687958362 mentioning build flags, but I don't set that flag, and in a networkless build of 0.18.2, the test still seems to get executed, and fail:

ok      github.com/grafana/agent/pkg/loki       10.160s
=== RUN   TestEnqueueRequestForSelector
    selector_eventhandler_test.go:48:
                Error Trace:    selector_eventhandler_test.go:170
                                                        selector_eventhandler_test.go:48
                Error:          Received unexpected error:
                                Get "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-1.19.2-linux-amd64.tar.gz": dial tcp: lookup storage.googleapis.com on [::1]:53: read udp [::1]:47651->[::1]:53: read: connection refused
                Test:           TestEnqueueRequestForSelector
                Messages:       failed to download dependencies for envtest
--- FAIL: TestEnqueueRequestForSelector (0.00s)
FAIL
FAIL    github.com/grafana/agent/pkg/operator   0.025s

@mattdurham mattdurham mentioned this pull request Sep 7, 2021
3 tasks
mattdurham pushed a commit that referenced this pull request Nov 11, 2021
…776)

* TestEnqueueRequestForSelector: only run test if -online flag is set

This test does download and invoke kubebuilder-tools, to make sure there
is no extra steps needed just to run this one test.
(#731 (comment)).

However, distros usually build and run tests in a sandbox with network
access disabled, causing this test to fail.

Introduce a `online` flag, defaulting to false, and skip this test as
long as `-online` is not passed.

CI, which invokes `make test` deliberately sets this to true, to have
coverage for that test provided by CI.

Fixes #731.

* fix flag passing

Co-authored-by: Robert Fratto <robertfratto@gmail.com>
@github-actions github-actions Bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Apr 9, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

don't require network access for running tests

3 participants