-
Notifications
You must be signed in to change notification settings - Fork 825
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
Graduate StateAllocationFilter to Stable #3308
Conversation
Build Failed 😱 Build Id: e1b5fa03-59a6-43d3-bd51-e4ca4186eda4 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: db01691e-0ab3-48ff-a0bc-5fc031a97540 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
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.
Great start! Gave some comments on some general cleanup, and also on why those unit tests are failing.
@@ -45,7 +45,6 @@ The current set of `alpha` and `beta` feature gates: | |||
| [GameServer Stable Network ID]({{% ref "/docs/Reference/gameserver.md#stable-network-id" %}}) | `PodHostname` | Enabled | `Beta` | 1.32.0 | | |||
| [Reset Metric Export on Fleet / Autoscaler deletion]({{% relref "./metrics.md#dropping-metric-labels" %}}) | `ResetMetricsOnDelete` | Enabled | `Beta` | 1.32.0 | | |||
| [Split `agones-controller` ](https://github.com/googleforgames/agones/issues/2797) | `SplitControllerAndExtensions` | Enabled | `Beta` | 1.32.0 | | |||
| [GameServer state filtering on GameServerAllocations](https://github.com/googleforgames/agones/issues/1239) | `StateAllocationFilter` | Enabled | `Beta` | 1.26.0 | |
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.
We'll need to use a feature
shortcode for the documentation please.
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.
This line has been added in the expiryVersion shortcode and removed it from the publishVersion shortcode.
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.
Should we also delete line 34 | [GameServer state filtering on GameServerAllocations](https://github.com/googleforgames/agones/issues/1239) |
StateAllocationFilter | Enabled |
Beta | 1.26.0 |
?
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.
This line is in expiryVersion of feature shortcode and lines in expiryVersion shortcode will be removed during the release. Could you please correct me if I am wrong?
@@ -500,13 +480,10 @@ func TestAllocationCacheCompareGameServers(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestAllocatorRunCacheSyncFeatureStateAllocationFilter(t *testing.T) { | |||
func TestAllocatorRunCacheSync(t *testing.T) { | |||
t.Parallel() | |||
|
|||
// TODO(markmandel): When this feature gets promoted to stable, replace test TestAllocatorRunCacheSync below with this test. |
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.
We can drop the TODO as well here please, since we did the replacement 😄
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.
done!
- matchLabels: | ||
game: my-game | ||
matchExpressions: | ||
- {key: tier, operator: In, values: [cache]} |
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.
I might be not seeing something, but shouldn't gameServerState
be in here somewhere?
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.
Added it along with description
@@ -216,7 +216,7 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) { | |||
}, | |||
{ | |||
name: "all fields are set", | |||
features: fmt.Sprintf("%s=false&%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter, runtime.FeatureCountsAndLists), |
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.
This test will need to be changed, since it had TestConvertAllocationRequestToGameServerAllocation
set to false, so it's expecting a nil
GameServer.
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.
Do I need to include something like the below code snippet?
{
name: "nil object",
in: nil,
want: nil,
},
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.
Here is the test implementation:
agones/pkg/allocation/converters/converter_test.go
Lines 565 to 575 in e7d01dc
for _, tc := range tests { | |
tc := tc | |
t.Run(tc.name, func(t *testing.T) { | |
t.Parallel() | |
runtime.FeatureTestMutex.Lock() | |
defer runtime.FeatureTestMutex.Unlock() | |
require.NoError(t, runtime.ParseFeatures(tc.features)) | |
out := ConvertAllocationRequestToGSA(tc.in) | |
assert.Equal(t, tc.want, out, "mismatch with want after conversion: \"%s\"", tc.name) |
This is a really good example of Go table driven tests: https://dave.cheney.net/2019/05/07/prefer-table-driven-tests
Have a look, lemme know if you have questions, and we can go from there 👍🏻
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.
The tests were failing with GameServerState: nil
, but they succeeded after updating it to GameServerState: &ready
@@ -366,7 +366,7 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) { | |||
}, | |||
{ | |||
name: "empty fields to GSA with selectors fields", | |||
features: fmt.Sprintf("%s=false&%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter, runtime.FeatureCountsAndLists), |
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.
This test will need to be changed, since it had TestConvertAllocationRequestToGameServerAllocation
set to false, so it's expecting a nil
GameServer.
Build Failed 😱 Build Id: 8cb07a2a-df82-44cf-9edc-4fae8d21ad5e To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: cb36d2cd-cae1-4cf6-a9eb-ab9d0d51ad41 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
@@ -127,7 +127,7 @@ func TestFindGameServerForAllocationPacked(t *testing.T) { | |||
assert.Equal(t, ErrNoGameServer, err) | |||
assert.Nil(t, gs) | |||
}, | |||
features: fmt.Sprintf("%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter), |
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.
You can delete this entire "one label" test, as it is only passing when FeatureStateAllocationFilter=False.
(The test below "one label with player state (StateAllocationFilter)" is for when StateAllocationFilter=True.)
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.
Deleted the "one label" test.
@@ -127,7 +127,7 @@ func TestFindGameServerForAllocationPacked(t *testing.T) { | |||
assert.Equal(t, ErrNoGameServer, err) | |||
assert.Nil(t, gs) | |||
}, | |||
features: fmt.Sprintf("%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter), | |||
features: fmt.Sprintf("%s=false", runtime.FeaturePlayerAllocationFilter), | |||
}, | |||
"one label with player state (StateAllocationFilter)": { | |||
// nolint: dupl |
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.
You can also delete this line // nolint: dupl
once the "one label" test is deleted.
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.
Deleted // nolint: dupl
line
@@ -278,7 +278,7 @@ func TestFindGameServerForAllocationPacked(t *testing.T) { | |||
assert.Equal(t, gs, list[index]) | |||
assert.Equal(t, agonesv1.GameServerStateReady, gs.Status.State) | |||
}, | |||
features: fmt.Sprintf("%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter), |
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.
Change line 273 from require.Len(t, list, 4)
to require.Len(t, list, 8)
.
The previous StateAllocationFilter=false used a cache with matcher gameserverallocations.readyGameServerMatcher which only returns the ready gameservers. The current StateAllocationFilter=true uses a cache with matcher gameserverallocations.readyOrAllocatedGameServerMatcher which returns ready or allocated game servers.
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.
Done!
I have made changes to a few more lines that were indicated in the error log.
You'll also need to navigate to agones/build and then run I usually do this (and any other generated files) as unique commit within the PR just in case they need to be dropped and regenerated later. |
Build Failed 😱 Build Id: 078051e6-f288-43a4-b986-aa1b1c016edf To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
This command updated |
Build Failed 😱 Build Id: 551cca44-b99f-44b1-b1dd-60ad1da105b7 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Failed 😱 Build Id: 4c4bd9b8-69cd-4508-947d-893827fd7b61 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
File agones/pkg/gameserverallocations/allocator_test.go has a remaining reference to the FeatureStateAllocationFilter. |
Excluded the |
Build Succeeded 👏 Build Id: 659baa80-6d75-4414-8b42-84d96e54cfc2 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Please find the error log here. There are 4 test cases failing, but the build has succeeded. |
Honestly, I don't usually run the full suite of e2e tests locally - it takes too long, and there are usually some setup that make differ slightly than the prod testing setup (might as well make other computers do all the work while doing other things!). I usually just focus on https://github.com/googleforgames/agones/blob/main/build/README.md#running-individual-end-to-end-tests if there are specific tests I think are very relevant to what I'm working on or are failing in Cloud Build. So if you are passing in Cloud Build - you are passing! |
test/e2e/allocator_test.go
Outdated
@@ -201,7 +201,7 @@ func TestAllocatorWithSelectors(t *testing.T) { | |||
helper.ValidateAllocatorResponse(t, response) | |||
|
|||
// let's do a re-allocation | |||
if runtime.FeatureEnabled(runtime.FeatureStateAllocationFilter) && runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) { | |||
if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) { | |||
logrus.Info("testing state allocation filter") |
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.
We should probably pull the state allocation filter tests out of this if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter)
block.
test/e2e/allocator_test.go
Outdated
@@ -106,7 +106,7 @@ func TestAllocatorWithDeprecatedRequired(t *testing.T) { | |||
helper.ValidateAllocatorResponse(t, response) | |||
|
|||
// let's do a re-allocation | |||
if runtime.FeatureEnabled(runtime.FeatureStateAllocationFilter) && runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) { | |||
if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) { | |||
logrus.Info("testing state allocation filter") |
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.
We should probably pull the state allocation filter tests out of this if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter)
block.
Build Succeeded 👏 Build Id: 56a46d89-1850-43cb-b874-5b723796c97a The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
Build Succeeded 👏 Build Id: ceb462f7-2200-4503-8d4b-d8ecdd40a0dc The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version:
|
In this case, I will move the PR to "Ready for Review" |
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.
This LGTM! @igooch did you want to take another pass?
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: igooch, Kalaiselvi84, markmandel 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 |
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Which issue(s) this PR fixes:
Closes #
Special notes for your reviewer: