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

Implementation of Local SDK Server Player Tracking #1496

Merged
merged 1 commit into from Apr 30, 2020

Conversation

markmandel
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking
/kind bug
/kind cleanup
/kind documentation

/kind feature

/kind hotfix

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.

@markmandel markmandel added area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/feature New features for Agones and removed approved size/L labels Apr 25, 2020
@@ -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")
Copy link
Member Author

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?

Copy link
Collaborator

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:

Suggested change
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")

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1496/head:pr_1496 && git checkout pr_1496
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-c32bd85

@@ -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, "")
Copy link
Collaborator

@aLekSer aLekSer Apr 29, 2020

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.

Copy link
Member Author

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.

if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) {
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")
}
logrus.Info("Getting Player Count")
Copy link
Collaborator

@aLekSer aLekSer Apr 29, 2020

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.

Suggested change
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
Copy link
Collaborator

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.

Copy link
Member Author

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?

Copy link
Collaborator

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.


// IsPlayerConnected returns if the playerID is currently connected to the GameServer.
// [Stage:Alpha]
// [FeatureFlag:PlayerTesting]
Copy link
Collaborator

@aLekSer aLekSer Apr 29, 2020

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?

Suggested change
// [FeatureFlag:PlayerTesting]
// [FeatureFlag:PlayerTracking]

Copy link
Member Author

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.

if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) {
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")
}
logrus.WithField("playerID", id.PlayerID).Info("Player Connected")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
logrus.WithField("playerID", id.PlayerID).Info("Player Connected")
l.logger.WithField("playerID", id.PlayerID).Info("Player Connected")

Copy link
Member Author

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 👍

if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) {
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")
}
logrus.WithField("playerID", id.PlayerID).Info("Player Disconnected")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
logrus.WithField("playerID", id.PlayerID).Info("Player Disconnected")
l.logger.WithField("playerID", id.PlayerID).Info("Player Disconnected")

}

result := &alpha.Bool{Bool: false}
logrus.WithField("playerID", id.PlayerID).Info("Is a Player Connected?")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
logrus.WithField("playerID", id.PlayerID).Info("Is a Player Connected?")
l.logger.WithField("playerID", id.PlayerID).Info("Is a Player Connected?")

if !runtime.FeatureEnabled(runtime.FeaturePlayerTracking) {
return nil, errors.New(string(runtime.FeaturePlayerTracking) + " not enabled")
}
logrus.Info("Getting Connected Players")
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// 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

Copy link
Collaborator

@aLekSer aLekSer left a 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.

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1496/head:pr_1496 && git checkout pr_1496
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-8d3ddde

Copy link
Collaborator

@aLekSer aLekSer left a 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.

@google-oss-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Implementation and unit tests for Player Tracking for the local sdk
server.

Conformance tests will come after this.

Work on googleforgames#1033
@google-oss-robot
Copy link

New changes are detected. LGTM label has been removed.

@agones-bot
Copy link
Collaborator

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:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1496/head:pr_1496 && git checkout pr_1496
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-71dd532

@markmandel markmandel merged commit 4d2ac66 into googleforgames:master Apr 30, 2020
@markmandel markmandel added this to the 1.6.0 milestone Apr 30, 2020
@markmandel markmandel deleted the feature/local-tracking branch April 30, 2020 21:15
ilkercelikyilmaz pushed a commit to ilkercelikyilmaz/agones that referenced this pull request Oct 23, 2020
Implementation and unit tests for Player Tracking for the local sdk
server.

Conformance tests will come after this.

Work on googleforgames#1033
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/feature New features for Agones size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants