Skip to content

api/types/filters: rewrite / improve some tests#48945

Merged
thaJeztah merged 3 commits intomoby:masterfrom
thaJeztah:filters_clean
Nov 25, 2024
Merged

api/types/filters: rewrite / improve some tests#48945
thaJeztah merged 3 commits intomoby:masterfrom
thaJeztah:filters_clean

Conversation

@thaJeztah
Copy link
Copy Markdown
Member


  • api/types/filters: rewrite tests with gotest.tools
    Use assert.Check() for most cases, instead of failing early.
  • api/types/filters: also test generated JSON
  • api/types/filters: reduce uses of non-exported fields in tests

@thaJeztah thaJeztah added status/2-code-review area/testing kind/refactor PR's that refactor, or clean-up code labels Nov 25, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Nov 25, 2024
@thaJeztah thaJeztah self-assigned this Nov 25, 2024
@thaJeztah
Copy link
Copy Markdown
Member Author

I think this one has become more flaky recently; second time Today that I see it fail;

=== FAIL: libnetwork/cnmallocator TestAllocator (unknown)
time="2024-11-25T13:07:11Z" level=error msg="failed allocating service testID1 during init" error="requested bit is already allocated" existingAddressesOnly=false
--- PASS: TestAllocator/TestAllocateServiceConflictingUserDefinedPorts (0.35s)
time="2024-11-25T13:07:11Z" level=error msg="task allocation failure" error="failed to retrieve network testID3 while allocating task testTaskID3"
time="2024-11-25T13:07:11Z" level=error msg="error reallocating node " error="node  cannot be found" method="(*Allocator).doTaskAlloc"
time="2024-11-25T13:07:12Z" level=error msg="Failed allocation for network testID5" error="failed while allocating driver state for network testID5: could not assign vxlan id 328 to pool 10.0.4.0/24: requested bit is already allocated"
time="2024-11-25T13:07:12Z" level=error msg="task allocation failure" error="network testID5 attached to task testTaskID6 not allocated yet"
time="2024-11-25T13:07:12Z" level=error msg="Failed allocation for service testServiceID4" error="requested bit is already allocated"
time="2024-11-25T13:07:12Z" level=error msg="task allocation failure" error="service testServiceID4 to which task testTaskID7 belongs has pending allocations"

Copy link
Copy Markdown
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread api/types/filters/parse_test.go Outdated
if len(v) != 1 || !v["running"] {
t.Fatalf("Expected to include a running status, got %v", v)
}
assert.Check(t, is.Equal(len(v), 1))
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.

nit:

Suggested change
assert.Check(t, is.Equal(len(v), 1))
assert.Check(t, is.Len(v, 1))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ah, yes, that's cleaner. not sure why I didn't do so; let me fix that.

Use assert.Check() for most cases, instead of failing early.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member Author

Failure is unrelated, and a test that's currently flaky;

=== Failed
=== FAIL: amd64.integration.container TestDiff (0.64s)
    diff_test.go:28: assertion failed: 
        --- expected
        +++ items
          []container.FilesystemChange(
        - 	{{Kind: s"A", Path: "/foo"}, {Kind: s"A", Path: "/foo/bar"}},
        + 	nil,
          )

@thaJeztah thaJeztah merged commit 7a23d69 into moby:master Nov 25, 2024
@thaJeztah thaJeztah deleted the filters_clean branch November 25, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants