-
Notifications
You must be signed in to change notification settings - Fork 817
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
Implementation of Local SDK Server Player Tracking #1496
Implementation of Local SDK Server Player Tracking #1496
Conversation
pkg/sdkserver/localsdk.go
Outdated
@@ -498,7 +605,7 @@ func (l *LocalSDKServer) EqualSets(expected, received []string) bool { | |||
func (l *LocalSDKServer) compare() { | |||
if l.testMode { | |||
if !l.EqualSets(l.expectedSequence, l.requestSequence) { | |||
l.logger.Errorf("Testing Failed %v %v", l.expectedSequence, l.requestSequence) | |||
logrus.WithField("expected", l.expectedSequence).WithField("received", l.requestSequence).Info("Testing Failed") |
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.
@aLekSer I snuck a small tweak to your conformance test reporting in here. WDYT?
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, now it is much more readable. But same as above:
logrus.WithField("expected", l.expectedSequence).WithField("received", l.requestSequence).Info("Testing Failed") | |
l.logger.WithField("expected", l.expectedSequence).WithField("received", l.requestSequence).Info("Testing Failed") |
Build Succeeded 👏 Build Id: c7ad5aa3-3746-4c3d-a35e-a1502bfd4c74 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:
|
pkg/sdkserver/localsdk.go
Outdated
@@ -197,6 +198,8 @@ func (l *LocalSDKServer) recordRequestWithValue(request string, value string, ob | |||
fieldVal = l.gs.ObjectMeta.Uid | |||
case "PlayerCapacity": | |||
fieldVal = strconv.FormatInt(l.gs.Status.Players.Capacity, 10) | |||
case "PlayerIDs": | |||
fieldVal = strings.Join(l.gs.Status.Players.IDs, "") |
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 use separator here? This seems to be for test, but might be more readable.
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.
Just tried it, and it didn't break any tests! So yep, adding this in, in case people want to test against multiple values in the future.
pkg/sdkserver/localsdk.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | ||
} | ||
logrus.Info("Getting Player Count") |
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 have added logger
field recently, so we can set log level to all this logs.
logrus.Info("Getting Player Count") | |
l.logger.Info("Getting Player Count") |
@@ -374,7 +502,7 @@ func TestSDKConformanceFunctionality(t *testing.T) { | |||
setAnnotation := "setannotation" | |||
l.gs.ObjectMeta.Uid = exampleUID | |||
|
|||
expected := []string{} | |||
var expected []string |
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.
Curious why this is better than before.
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.
Oh, my IDE gave me a hint, and I clicked it. It's nicer because it doesn't allocate space to an array that is empty when nil will work just the same -- but for a test it's relatively inconsequential.
I can remove it if you would prefer?
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 need to change, I think it would be better this way.
pkg/sdkserver/localsdk.go
Outdated
|
||
// IsPlayerConnected returns if the playerID is currently connected to the GameServer. | ||
// [Stage:Alpha] | ||
// [FeatureFlag:PlayerTesting] |
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 it be PlayerTracking
as in FeatureFlag Parse below?
// [FeatureFlag:PlayerTesting] | |
// [FeatureFlag:PlayerTracking] |
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.
Thank you - I missed that.
pkg/sdkserver/localsdk.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | ||
} | ||
logrus.WithField("playerID", id.PlayerID).Info("Player Connected") |
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.
logrus.WithField("playerID", id.PlayerID).Info("Player Connected") | |
l.logger.WithField("playerID", id.PlayerID).Info("Player Connected") |
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.
Ah very nice, I missed that. Making these changes 👍
pkg/sdkserver/localsdk.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | ||
} | ||
logrus.WithField("playerID", id.PlayerID).Info("Player Disconnected") |
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.
logrus.WithField("playerID", id.PlayerID).Info("Player Disconnected") | |
l.logger.WithField("playerID", id.PlayerID).Info("Player Disconnected") |
pkg/sdkserver/localsdk.go
Outdated
} | ||
|
||
result := &alpha.Bool{Bool: false} | ||
logrus.WithField("playerID", id.PlayerID).Info("Is a Player Connected?") |
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.
logrus.WithField("playerID", id.PlayerID).Info("Is a Player Connected?") | |
l.logger.WithField("playerID", id.PlayerID).Info("Is a Player Connected?") |
pkg/sdkserver/localsdk.go
Outdated
if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) { | ||
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled") | ||
} | ||
logrus.Info("Getting Connected Players") |
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.
same as above
pkg/sdkserver/localsdk_test.go
Outdated
assert.NoError(t, err) | ||
assert.Equal(t, []string{id.PlayerID}, list.List) | ||
|
||
// should return an error if we try and add another, since we're at capacity |
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 return an error if we try and add another, since we're at capacity | |
// should return an error if we try to add another, since we're at capacity |
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.
There are few nits which are pending.
c32bd85
to
8d3ddde
Compare
Build Succeeded 👏 Build Id: 29c06855-0f17-4f40-b42a-d61aa31e9a7f 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:
|
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, all nits are fixed.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aLekSer, 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 |
Implementation and unit tests for Player Tracking for the local sdk server. Conformance tests will come after this. Work on googleforgames#1033
8d3ddde
to
71dd532
Compare
New changes are detected. LGTM label has been removed. |
Build Succeeded 👏 Build Id: 79c3ed1b-70a4-4d18-ae15-da950640011f 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:
|
Implementation and unit tests for Player Tracking for the local sdk server. Conformance tests will come after this. Work on googleforgames#1033
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Implementation and unit tests for Player Tracking for the local sdk
server.
Which issue(s) this PR fixes:
Work on #1033
Special notes for your reviewer:
Conformance tests will come after this.