-
Notifications
You must be signed in to change notification settings - Fork 885
Flaky Test: TestGameServerAllocationReturnLabels #4435
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
Open
Sivasankaran25
wants to merge
12
commits into
googleforgames:main
Choose a base branch
from
Sivasankaran25:flaky/gameserver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9bd03d6
Flaky Test: TestGameServerAllocationReturnLabels
Sivasankaran25 93beb15
Update TestGameServerAllocationReturnLabels
Sivasankaran25 a3b1dd7
Merge branch 'main' into flaky/gameserver
Sivasankaran25 d3cf825
fix lint
Sivasankaran25 cf50a09
Update suggest changes
Sivasankaran25 687f5d7
Merge branch 'main' into flaky/gameserver
Sivasankaran25 38c230c
Merge branch 'main' into flaky/gameserver
Sivasankaran25 4c0398a
Update Suggest changes
Sivasankaran25 e0ff458
Merge branch 'main' into flaky/gameserver
Sivasankaran25 20ecbb9
fix suggest changes
Sivasankaran25 1da7ea3
Merge branch 'main' into flaky/gameserver
Sivasankaran25 3bd2be5
fix lint error
Sivasankaran25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1348,29 +1348,49 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { | |
| flt.Spec.Replicas = 1 | ||
| flt.Spec.Template.ObjectMeta.Labels = label | ||
| flt.Spec.Template.ObjectMeta.Annotations = annotations | ||
|
|
||
| flt, err := fleets.Create(ctx, flt, metav1.CreateOptions{}) | ||
| defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint:errcheck | ||
| require.NoError(t, err) | ||
| defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint | ||
|
|
||
| framework.AssertFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) | ||
|
|
||
| gsa := &allocationv1.GameServerAllocation{ObjectMeta: metav1.ObjectMeta{GenerateName: "allocation-"}, | ||
| gsa := &allocationv1.GameServerAllocation{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| GenerateName: "allocation-", | ||
| }, | ||
| Spec: allocationv1.GameServerAllocationSpec{ | ||
| Selectors: []allocationv1.GameServerSelector{ | ||
| {LabelSelector: metav1.LabelSelector{MatchLabels: label}}, | ||
| { | ||
| LabelSelector: metav1.LabelSelector{ | ||
| MatchLabels: label, | ||
| }, | ||
| }, | ||
| }, | ||
| }} | ||
| }, | ||
| } | ||
|
|
||
| gsa, err = framework.AgonesClient.AllocationV1().GameServerAllocations(framework.Namespace).Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) | ||
| require.NoError(t, err) | ||
| require.EventuallyWithT(t, func(c *assert.CollectT) { | ||
| currGsa, err := framework.AgonesClient.AllocationV1().GameServerAllocations(framework.Namespace).Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) | ||
| if !assert.NoError(c, err, "API call to allocate should not fail") { | ||
| return | ||
| } | ||
| if !assert.Equal(c, allocationv1.GameServerAllocationAllocated, currGsa.Status.State, "Allocation should be 'Allocated' state") { | ||
| return | ||
| } | ||
| if !assert.NotEmpty(c, currGsa.Status.GameServerName, "Allocated GS name should not be empty") { | ||
| return | ||
| } | ||
| gs, err := gameServers.Get(ctx, currGsa.Status.GameServerName, metav1.GetOptions{}) | ||
| if !assert.NoError(c, err, "Should be able to get the allocated GameServer") { | ||
| return | ||
| } | ||
|
|
||
| assert.Equal(t, allocationv1.GameServerAllocationAllocated, gsa.Status.State) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we lost all these assertions on the GameServerAllocation -- which is the point of the test, to make sure that labels and annotations are passed back to the allocation. These should still be in there. |
||
| assert.Equal(t, t.Name(), gsa.Status.Metadata.Labels[role]) | ||
| assert.Equal(t, flt.ObjectMeta.Name, gsa.Status.Metadata.Labels[agonesv1.FleetNameLabel]) | ||
| assert.Equal(t, annotationValue, gsa.Status.Metadata.Annotations[annotationKey]) | ||
| gs, err := gameServers.Get(ctx, gsa.Status.GameServerName, metav1.GetOptions{}) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel]) | ||
| assert.Equal(c, t.Name(), gs.ObjectMeta.Labels[role], "Role label should match test name") | ||
| assert.Equal(c, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") | ||
| assert.Equal(c, annotationValue, gs.ObjectMeta.Annotations[annotationKey], "Annotation value should match") | ||
|
|
||
| }, 30*time.Second, 1*time.Second) | ||
| } | ||
|
|
||
| func TestGameServerAllocationDeletionOnUnAllocate(t *testing.T) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason for the
ifconditional if you want to fail fast - that's whatrequiresis for.Same for all the others below.