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

Fix test case in TestCreateExpectedEventPatterns #8022

Conversation

creydr
Copy link
Member

@creydr creydr commented Jun 21, 2024

TestCreateExpectedEventPatterns will start to fail with go 1.22 (see #8019 (comment)):

$ go test ./test/rekt/features/broker/... -run TestCreateExpectedEventPatterns
ok      knative.dev/eventing/test/rekt/features/broker  0.015s

$ GOEXPERIMENT=loopvar go test ./test/rekt/features/broker/... -run TestCreateExpectedEventPatterns
--- FAIL: TestCreateExpectedEventPatterns (0.00s)
    --- FAIL: TestCreateExpectedEventPatterns/t1,_one_retry,_one_failure,_both_t0_/_t1_get_it,_t1dlq_gets_it_too (0.00s)
        topology_test.go:227: t1, one retry, one failure, both t0 / t1 get it, t1dlq gets it too: Maps unequal: want:
            map[brokerdlq:{Success:[] Interval:[]} t0:{Success:[true] Interval:[0]} t0dlq:{Success:[] Interval:[]} t1:{Success:[false true] Interval:[0 0]} t1dlq:{Success:[true] Interval:[0]}]
            got:
            map[brokerdlq:{Success:[] Interval:[]} t0:{Success:[true] Interval:[0]} t0dlq:{Success:[] Interval:[]} t1:{Success:[false true] Interval:[0 0]} t1dlq:{Success:[] Interval:[]}]
FAIL
FAIL    knative.dev/eventing/test/rekt/features/broker  0.016s
FAIL

The test was actually never totally correct and only the last test case was tested. See https://go.dev/blog/loopvar-preview:

In Go 1.21, ... passes because t.Parallel blocks each subtest until the entire loop has finished and then runs all the subtests in parallel.

This PR addresses it and fixes the test. Actually the tests is the same as the one for t0 which was setup correctly:

name: "t0, one retry, one failure, both t0 / t1 get it, t0dlq gets it too",
brokerDS: nil,
t0DS: &v1.DeliverySpec{
Retry: ptr.Int32(1),
DeadLetterSink: new(pkgduckv1.Destination),
},
t1DS: nil,
t0FailCount: 2,
t1FailCount: 0,
want: map[string]knconf.EventPattern{
"t0": {
Success: []bool{false, false},
Interval: []uint{0, 0},
},
"t1": {
Success: []bool{true},
Interval: []uint{0},
},
"t0dlq": oneSuccessfulEvent,
"t1dlq": noEvents,
"brokerdlq": noEvents,
},

@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 21, 2024
@knative-prow knative-prow bot added the area/test-and-release Test infrastructure, tests or release label Jun 21, 2024
@creydr
Copy link
Member Author

creydr commented Jun 21, 2024

/cc @pierDipi

@knative-prow knative-prow bot requested a review from pierDipi June 21, 2024 15:30
@dprotaso
Copy link
Member

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 21, 2024
Copy link

knative-prow bot commented Jun 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: creydr, dprotaso

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

The pull request process is described here

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 knative-prow bot merged commit 825202f into knative:main Jun 21, 2024
29 of 35 checks passed
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 Test infrastructure, tests or release 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.

None yet

2 participants