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

E2E flaky test fix #462

Merged
merged 7 commits into from
Jul 31, 2024
Merged

E2E flaky test fix #462

merged 7 commits into from
Jul 31, 2024

Conversation

geoff-vball
Copy link
Contributor

@geoff-vball geoff-vball commented Jul 30, 2024

Why this should be merged

Fixes test flakiness introduced with the switchover to tmpnet.

Also contains some formatting

How this works

Sorts the slice created by GetSubnetsInfo() before returning it. We were adding items to a slice by ranging over a map, which gives a random order. Therefore calling GetTwoSubnets() could return the two subnets in the opposite order if called twice in one test.

How this was tested

Existing E2E tests.

How is this documented

N/A

@geoff-vball geoff-vball changed the title TEST: e2e flaky test fix #2 E2E flaky test fix Jul 31, 2024
@geoff-vball geoff-vball marked this pull request as ready for review July 31, 2024 17:38
@geoff-vball geoff-vball requested a review from a team as a code owner July 31, 2024 17:38
iansuvak
iansuvak previously approved these changes Jul 31, 2024
Copy link
Contributor

@iansuvak iansuvak left a comment

Choose a reason for hiding this comment

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

Lots of formatting only changes but the core of the fix makes sense to me.

Copy link
Contributor

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

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

Nice find! One comment to revert an unrelated change.

@@ -464,7 +471,7 @@ func (n *LocalNetwork) AddSubnetValidators(ctx context.Context, subnetID ids.ID,

// consume some of the extraNodes
newValidatorNodes := n.extraNodes[0:count]
defer slices.Delete(n.extraNodes, 0, int(count))
copy(n.extraNodes, n.extraNodes[count:])
Copy link
Contributor

Choose a reason for hiding this comment

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

This will still preserve the nodes to be deleted in n.extraNodes, since n.extraNodes[count:] is a subset. See example here: https://go.dev/play/p/z8RhPp136sr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by copying the newValidatorNodes from extraNodes and then just assigning extraNodes to the subset.

@@ -470,8 +470,9 @@ func (n *LocalNetwork) AddSubnetValidators(ctx context.Context, subnetID ids.ID,
)]

// consume some of the extraNodes
newValidatorNodes := n.extraNodes[0:count]
copy(n.extraNodes, n.extraNodes[count:])
var newValidatorNodes []*tmpnet.Node
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
var newValidatorNodes []*tmpnet.Node
newValidatorNodes := make([]*tmpnet.Node, len(n.extraNodes[0:count]))

We need to preallocate the destination, otherwise nothing will be copied. Example

Copy link
Contributor

Choose a reason for hiding this comment

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

The append approach you adopted also works.

@geoff-vball geoff-vball merged commit c032a58 into main Jul 31, 2024
14 checks passed
@geoff-vball geoff-vball deleted the gstuart/test-fix-2 branch July 31, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants