-
Notifications
You must be signed in to change notification settings - Fork 775
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
Nodejs counters and lists #3726
Conversation
Build Failed 😱 Build Id: cd4e2795-51eb-4952-82ad-43e4d70abc71 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
It is a bit difficult to work with the CounterUpdateRequest in JavaScript due to the type google.protobuf.Int64Value instead of int64 From alpha.protoc
I got it working with the following but this seems like an internal type. It's a bit hacky to require/import at a nested path because it is not a supported export of the library, so will break if the library gets refactored#
I'm wondering why we don't use int64 instead as we use this in other places in the SDK (edited) |
@igooch Would you be able to shed any light on this? |
The google.protobuf.Int64Value is there so that it will be a nullable object rather than a primitive type that has a default value (0 in the case of Golang). In the case of updating the Count or Capacity 0 is a meaningful value, so we don't want 0 to be the default. 0 for the "diff" isn't meaningful, since that's just adding the diff to the Count. |
Thank you. Reading around, it also seems that For my curiosity I was wondering if we could use a wrapper type e.g. the
Also did we consider using -1 as a special value for count and capacity in the update to mean unspecified, as these would be invalid values? I don't know if these could be set by default to -1, so not setting them would leave them at -1. |
So we use these standard wrappers all over the place - I asked the gRPC team what the canonical way to import the standard wrappers is and will get back to you. |
Feedback I got was basically "if So I think we should move forward with this approach 👍🏻 |
Thank you and so it seems the library is missing some code as we should be able to do the following so a library user does not need to know the internal path
Or in the more modern format
But yes, can go ahead with the current solution |
That's a new one
You can ignore that. Restarting test. |
Build Failed 😱 Build Id: 14d2f577-ac55-42ea-a735-4d181de07309 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Oooh, you will need to rebase against |
@steven-supersolid we're updating the SDK, so that most of the methods that return (bool, error) are now simply returning (error). I updated the issue #3645. (Discussion: #3581#discussion_r1505135182). Also tracked in #3737. |
Great, I think that is closer to the rest of the API. Will update |
@steven-supersolid we moved Counts and Lists from Alpha to Beta #3806. This is the last major expected change (until it goes into stable, but I imagine that will be several more releases away). |
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
Build Failed 😱 Build Id: 2e4fb29a-2a11-4ea5-885b-8479cb907465 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
Build Succeeded 👏 Build Id: 505e54a6-c93d-48d0-9f55-b4ec3f4acf36 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:
|
@igooch this should now be ready |
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.
A caveat that I'm not familiar with nodejs, so if you know of someone with more language specific knowledge that might have more insight, feel free to tag them in the comments.
Overall looks good, just a few clarifying comments.
Some of the language SDKs have unit tests. Do you think this would be beneficial to add, or would it not add anything beyond what's already being tested in test/sdk/nodejs/testSDKClient.js?
// LocalSDKServer starting "rooms": {Count: 1, Capacity: 10} | ||
const counter = "rooms"; | ||
|
||
try { |
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.
Genuine question here as I'm not familiar with nodejs, is there an advantage to using a try catch block over an assert statement like https://nodejs.org/api/assert.html#assertdoesnotrejectasyncfn-error-message?
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've not used the Assert class much because it is usual to rely on a test runner framework such as jasmine or mocha instead.
In runtime code it is standard to rely on try/catch when dealing with async functions. In test code it is convenient to do the same.
I think in this case as we want to also check the return value it is easier to write the code with try/catch. We end up nesting in a try/catch block vs. nesting in a function call, which is preferable.
It may be worth investigating in another PR and also investigate if we could swap out jasmine for the new node.js built in test runner, which relies on assert.
@@ -165,7 +165,8 @@ run-sdk-conformance-test-cpp: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=cpp GRPC_PORT=9003 HTTP_PORT=9103 | |||
|
|||
run-sdk-conformance-test-node: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 | |||
# run with on-by-default (Beta) feature flags enabled | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(COUNTS_AND_LISTS_TESTS) |
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.
By itself, this fails with error:
~/agones/build$ make run-sdk-conformance-test-node
...
> node ./testSDKClient.js
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module '@grpc/grpc-js'
Require stack:
- /go/src/agones.dev/agones/sdks/nodejs/src/agonesSDK.js
- /go/src/agones.dev/agones/sdks/nodejs/src/index.js
- /go/src/agones.dev/agones/test/sdk/nodejs/testSDKClient.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/go/src/agones.dev/agones/sdks/nodejs/src/agonesSDK.js:15:14)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/go/src/agones.dev/agones/sdks/nodejs/src/agonesSDK.js',
'/go/src/agones.dev/agones/sdks/nodejs/src/index.js',
'/go/src/agones.dev/agones/test/sdk/nodejs/testSDKClient.js'
]
}
Once I run ~/agones/build$ SDK_FOLDER=node make test-sdk
it installs the dependencies successfully, and then the command ~/agones/build$ make run-sdk-conformance-test-node
runs successfully. If there's not a quick way to check that the build script was run as part of the run-sdk-conformance-test-node
we should probably add a comment noting that SDK_FOLDER=node make test-sdk
needs to be run first.
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 would need to execute npm install
in the sdk folder, e.g. in build-sdk-test.sh the minimum required is
cd /go/src/agones.dev/agones/test/sdk/nodejs
npm install --quiet
Could we add something like that here? I don't know enough about these makefiles
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.
Probably not worth modifying the make command, since the test gets build properly during CI / CD, so this only applies to local testing. I added in a suggested comment change above.
- name: default | ||
portPolicy: Dynamic | ||
containerPort: 7654 | ||
counters: |
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.
Did you want the example to have the same counter and list as the local SDK Server? The sample local SDK server counters is "rooms" and lists is "players"
agones/pkg/sdkserver/localsdk.go
Lines 76 to 83 in 4b2910b
if runtime.FeatureEnabled(runtime.FeatureCountsAndLists) { | |
gs.Status.Counters = map[string]*sdk.GameServer_Status_CounterStatus{ | |
"rooms": {Count: 1, Capacity: 10}, | |
} | |
gs.Status.Lists = map[string]*sdk.GameServer_Status_ListStatus{ | |
"players": {Values: []string{"test0", "test1", "test2"}, Capacity: 100}, | |
} | |
} |
The unit tests for the SDK can be found in sdks/nodejs/spec/ and all the new functions were covered with unit tests in this file sdks/nodejs/spec/betaAgonesSDK.spec.js in the PR. These are the must have tests and can be run by using
There is an uncovered inner function in an error handler on line 103 of agonesSDK.js which may not be possible to test. It's unrelated to counts and lists. |
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
Build Succeeded 👏 Build Id: 0675c440-0b25-4c0b-a6c9-6102e035527f 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.
LGTM. Thanks for all your work on this!
@@ -165,7 +165,8 @@ run-sdk-conformance-test-cpp: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=cpp GRPC_PORT=9003 HTTP_PORT=9103 | |||
|
|||
run-sdk-conformance-test-node: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 | |||
# run with on-by-default (Beta) feature flags enabled | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(COUNTS_AND_LISTS_TESTS) |
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.
Probably not worth modifying the make command, since the test gets build properly during CI / CD, so this only applies to local testing. I added in a suggested comment change above.
Co-authored-by: igooch <igooch@google.com>
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
Build Failed 😱 Build Id: a5ee1237-fa39-429b-b8a1-5f01066c1e56 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
HTML tests failing after merging in main
|
Oh yep. Fix in #3847. This PR should be good to merge once the fix goes through. |
Build Failed 😱 Build Id: 8a22074e-7196-438f-95db-59623fdf143f To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
@steven-supersolid we can never auto-update your PRs 😃 we're heading into the weekend, so please rebase against |
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
Build Succeeded 👏 Build Id: e92653c2-feda-4dc6-9564-04fe6bccff2e 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:
|
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Which issue(s) this PR fixes:
Closes #3645
Special notes for your reviewer: