libnet: de-flake TestEndpointStore and TestNetworkStore#49764
libnet: de-flake TestEndpointStore and TestNetworkStore#49764vvoland merged 3 commits intomoby:masterfrom
Conversation
libnetwork/endpoint_store_test.go
Outdated
| assert.Check(t, found[0] == ep1, "got: %s; expected: %s", found[0].id, ep1.id) | ||
| assert.Check(t, found[1] == ep2, "got: %s; expected: %s", found[1].id, ep2.id) |
There was a problem hiding this comment.
using is.Equal saves you from writing the message :)
| assert.Check(t, found[0] == ep1, "got: %s; expected: %s", found[0].id, ep1.id) | |
| assert.Check(t, found[1] == ep2, "got: %s; expected: %s", found[1].id, ep2.id) | |
| assert.Check(t, is.Equal(found[0], ep1)) | |
| assert.Check(t, is.Equal(found[1], ep2)) |
There was a problem hiding this comment.
is.Equal is probably more idiomatic but unfortunately it's going to dump the whole struct which isn't particularly readable. So I'll switch to it, but keep the custom message.
I could compare the endpoint ID instead, but one of the goal of this test is to make sure findEndpoints returns the original values (and not copy). I'll add a comment to clarify that.
There was a problem hiding this comment.
one of the goal of this test is to make sure findEndpoints returns the original values (and not copy)
The comment says "and that the returned values are not copies of the original ones" - which seems like the opposite at first glance.
So, is the intention to check the pointers are the same (there's a single Endpoint object), rather than being pointers to different Endpoint objects that have the same values?
I think is.Equal will compare the pointed-to values if the pointers are different. So, it probably needs to go back to the original pointer equality?
(But then, if the pointers are to different objects with the same id value ... the error message will be confusing because the two ids will be the same?)
There was a problem hiding this comment.
I'm talking nonsense, it's not DeepEqual - ignore me!
There was a problem hiding this comment.
(Although, the printed id values are likely to be the same even if the pointers are different?)
libnetwork/endpoint_store_test.go
Outdated
| assert.Check(t, found[0] == ep1, "got: %s; expected: %s", found[0].id, ep1.id) | ||
| assert.Check(t, found[1] == ep2, "got: %s; expected: %s", found[1].id, ep2.id) |
There was a problem hiding this comment.
I think this would work? ...
| assert.Check(t, found[0] == ep1, "got: %s; expected: %s", found[0].id, ep1.id) | |
| assert.Check(t, found[1] == ep2, "got: %s; expected: %s", found[1].id, ep2.id) | |
| assert.Check(t, is.Equal(found[0], ep1)) | |
| assert.Check(t, is.Equal(found[1], ep2)) |
There was a problem hiding this comment.
I think this was done to use the custom message to prevent the whole ep being dumped as "not equal".
Possibly a custom message would work in that case (but not sure if is.Equal would still dump the whole ep);
assert.Check(t, is.Equal(found[0], ep1), "got: %s; expected: %s", found[0].id, ep1.id)|
Ohh! Well, at least we all agree! |
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
87be15d to
7c99f24
Compare
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
7c99f24 to
4eebd2c
Compare
Related to:
- What I did
TestEndpointStore: sort endpoints before comparingTestNetworkStore: fix network sorting- How to verify it
Verified both tests with
-test.count 10000: