Skip to content

Work with go1.13 by simply deleting explicit flag parsing#5398

Merged
knative-prow-robot merged 2 commits into
knative:masterfrom
chaodaiG:go113_simple
Sep 6, 2019
Merged

Work with go1.13 by simply deleting explicit flag parsing#5398
knative-prow-robot merged 2 commits into
knative:masterfrom
chaodaiG:go113_simple

Conversation

@chaodaiG
Copy link
Copy Markdown
Contributor

@chaodaiG chaodaiG commented Sep 4, 2019

go test with any flag failed to work with go.1.13, as reported in knative/test-infra#1329. The root cause is testing level flags (i.e. -v) are registered in testing.Init() according to release note as part of generated main() function, which is executed later than global variable initialization, such as initializeServingFlags call, which failed to parse flags as they are not registered yet.

Deleting flag.Parse() from initializeServingFlags seems not affecting flags parsing in both go1.12 and go1.13, in the latter it's done via testing.Init(). And in go1.12 it also works as the execution order is:
initializeServingFlags -> testing.M.Run (where flag.Parse is invoked implicitly) -> Running each individual test

Fixes knative/test-infra#1329

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 4, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 4, 2019
@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 4, 2019
@chaodaiG
Copy link
Copy Markdown
Contributor Author

chaodaiG commented Sep 4, 2019

/uncc @markusthoemmes
/uncc @srinivashegde86

@knative-prow-robot knative-prow-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 5, 2019
@chaodaiG chaodaiG changed the title Work with go1.13 by simply deleting duplicate flag parsing Work with go1.13 by simply deleting explicit flag parsing Sep 5, 2019
@chaodaiG chaodaiG marked this pull request as ready for review September 5, 2019 19:50
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 5, 2019
@chaodaiG
Copy link
Copy Markdown
Contributor Author

chaodaiG commented Sep 5, 2019

/cc @vagababov
/cc @mattmoor
/cc @adrcunha

Comment thread test/e2e_flags.go
@chaodaiG
Copy link
Copy Markdown
Contributor Author

chaodaiG commented Sep 5, 2019 via email

Copy link
Copy Markdown
Contributor

@adrcunha adrcunha left a comment

Choose a reason for hiding this comment

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

/approve

@knative-test-reporter-robot
Copy link
Copy Markdown

The following jobs failed due to test flakiness:

Test name Triggers Retries
pull-knative-serving-integration-tests 0/3

Failed non-flaky tests preventing automatic retry of pull-knative-serving-integration-tests:

test/conformance/api/v1alpha1.TestSingleConcurrency
test/conformance/api/v1beta1.TestContainerExitingMsg
test/conformance/api/v1beta1.TestRouteCreation
test/conformance/api/v1beta1.TestProjectedComplex
test/conformance/api/v1beta1.TestContainerExitingMsg/http
test/conformance/runtime.TestConfigsViaEnv
test/conformance/runtime.TestMustEnvVars
test/conformance/runtime.TestWorkingDirService

and 3 more.

@chaodaiG
Copy link
Copy Markdown
Contributor Author

chaodaiG commented Sep 5, 2019

/retest

Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 6, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrcunha, chaodaiG, mattmoor

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit 219d07c into knative:master Sep 6, 2019
@chaodaiG chaodaiG deleted the go113_simple branch September 18, 2019 21:00
@coryrc coryrc mentioned this pull request Nov 9, 2019
knative-prow-robot pushed a commit that referenced this pull request Nov 25, 2019
In #5398 we missed that flags cannot be set until after they are parsed.
As golang/testing is now doing the parsing just before calling our test function,
to change values they must now be called during the test (or before if we
were to use TestMain -- a future improvement planned). So split the flag setup
into definition and value setting, then call it in the tests that use ServingFlags.

The actual flag reading/parsing has been put into pkg:
knative/pkg#870
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2E tests fail with go 1.13

6 participants