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

Frontend Create Backfill #1279

Merged
merged 8 commits into from
Nov 26, 2020
Merged

Conversation

aLekSer
Copy link
Collaborator

@aLekSer aLekSer commented Nov 9, 2020

Initial version of CreateBackfill. It stores an empty regular TicketIds list.

What this PR does / Why we need it:

Which issue(s) this PR fixes:

Special notes for your reviewer:
Wait on StateStare changes.

@google-cla
Copy link

google-cla bot commented Nov 9, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Nov 9, 2020
@aLekSer aLekSer changed the title Frontend create bf Frontend create Backfill Nov 9, 2020
err := store.CreateBackfill(ctx, backfill, []string{})
if err != nil {
return nil, err

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a missing closing curly brace here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's true, I cannot run the test without state store changes.

@google-cla
Copy link

google-cla bot commented Nov 10, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Nov 12, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla
Copy link

google-cla bot commented Nov 13, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@@ -0,0 +1,29 @@
// Copyright 2020 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think statestore.proto might be a more appropriate name for this file. It matches the style of using the module name in the proto file name that synchronizer.proto has started.

Choose a reason for hiding this comment

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

messages.proto would also be appropriate, as we put all message definitions that aren't request/response types in a similarly named file in the public api.

Choose a reason for hiding this comment

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

Oh that file is actually being added by #1273

Copy link
Collaborator

Choose a reason for hiding this comment

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

My initial take on how this file should be named was not right. Laramere educated me on how these files are named. The naming pattern is not based on the module name. Instead, services and their req/resp usually go into their own proto file, and objects that aren't coupled to a service's API usually go in a messages.proto file.
+1 for messages.proto

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will copy a following thread back to the author @akremsa

@syntxerror syntxerror added this to the v1.2.0 milestone Nov 18, 2020
@google-cla google-cla bot added cla: yes and removed cla: no labels Nov 23, 2020
@aLekSer aLekSer marked this pull request as ready for review November 23, 2020 08:12
require.Nil(t, err)

// Different Ids should be generated
assert.NotEqual(t, b1.Id, b2.Id)
Copy link

Choose a reason for hiding this comment

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

why do you mix assert and require?
please use require

// Other than CreateTune abd Id fields, they should be equal
assert.Equal(t, b1, b2)
require.Nil(t, err)
get, err := om.Frontend().GetBackfill(ctx, &pb.GetBackfillRequest{BackfillId: b1.Id})
Copy link

Choose a reason for hiding this comment

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

please use common naming like result or actual, it will be easier to read this code.

assert.NotEqual(t, b1.Id, b2.Id)
b1.Id = b2.Id
b1.CreateTime = b2.CreateTime
// Other than CreateTune abd Id fields, they should be equal
Copy link

Choose a reason for hiding this comment

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

What does it mean? Could you rephrase it, please?

Copy link
Collaborator Author

@aLekSer aLekSer Nov 23, 2020

Choose a reason for hiding this comment

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

I have updated this comment, but in a separate branch, sorry. I meant that all fields other than CreateTime and Ids are the same if we CreateBackfill with the same input args.

ctx, cancel := context.WithCancel(utilTesting.NewContext(t))
test.preAction(cancel)

res, err := doCreateBackfill(ctx, &pb.CreateBackfillRequest{Backfill: test.backfill}, store)
Copy link

Choose a reason for hiding this comment

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

require.NotNil(t, res)

Copy link

Choose a reason for hiding this comment

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

Why do you test doCreateBackfill instead of CreateBackfill?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am testing real handlers as part of E2E test.

Copy link

@akremsa akremsa Nov 23, 2020

Choose a reason for hiding this comment

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

This is a unit test, it has nothing to do with e2e one. doCreateBackfill is not an entry point to the current package. Please, test exported methods only, as you do in TestDoGetBackfill. Otherwise, you just skip all code which comes before doCreateBackfill.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

First of all we follow the same pattern for TestDoCreateTicket(), second Scott asked me to use E2E to cover those handlers:
https://github.com/googleforgames/open-match/pull/1279/files#r528961563

Copy link

@akremsa akremsa Nov 24, 2020

Choose a reason for hiding this comment

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

You should not rely on any other tests (e2e, etc) while working on unit tests. Here you ignore everything which comes before doCreateBackfill.

Copy link

Choose a reason for hiding this comment

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

@Laremere do you mean that we should test public API in e2e tests, rather than unit ones?
Because at this moment I don't see a clear boundary between tickets e2e and tickets unit tests, for instance.
If so - there is no point to add and support tests in frontend package right now.

Copy link

@akremsa akremsa Nov 24, 2020

Choose a reason for hiding this comment

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

With TestDoCreateTickets half of the method is tested in frontend package, another part (validations) in e2e, which is a bit confusing.

Copy link

@akremsa akremsa left a comment

Choose a reason for hiding this comment

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

Some minor changes requested

@@ -88,6 +88,62 @@ func TestDoCreateTickets(t *testing.T) {
}
}

func TestDoCreateBackfill(t *testing.T) {

Choose a reason for hiding this comment

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

While I think this follows the patterns of the testing for the other calls, I'm unsure about the value these tests are adding:

  • I don't think calling with canceled context actually finds problems, at most if checks that one use of context is done correctly, but not that all uses are correct.
  • It took a bit to get there, but I'm pretty confident that "preAction" is an anti-pattern at this point. It's adding too much logic to tests.
  • See also, the if err != nil check in the test code is definitely logic. This should be removed, and is evidence of the tests being over-generalized.

My recommendation:
Get the test coverage using the e2e tests for:

  • creating
  • getting backfill created
  • getting backfill which isn't present, and getting not found
    (first two are already done, as far as I can tell)

At most, keep only the canceled context tests here, but I'm fine not having those.
The other tests that follow these patterns for existing features should probably be cleaned up, but that's out of scope for this project.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your feedback, will address all comments

Generate ID, store into Redis, add telemetry.
Add lock/unlock to Frontend Create method.
Create and GetBackfill E2E test.
for E2E tests.
Add CreateBackfill validation check. Extend E2E test.
We need to create a new statestore, so cancel() would always succeed.
@aLekSer aLekSer changed the title Frontend create Backfill Frontend Create Backfill Nov 26, 2020
@aLekSer
Copy link
Collaborator Author

aLekSer commented Nov 26, 2020

Hello @Laremere I have applied all comments, if I did something wrong please leave feedback.

Copy link

@Laremere Laremere left a comment

Choose a reason for hiding this comment

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

Adding a few comments, don't want to block this on nit for testing, so merging with comments. Cleanup to match my desired state doesn't involve only the new tests here, so it's fine.

tc := tc
t.Run(tc.description, func(t *testing.T) {
res, err := fs.CreateBackfill(ctx, tc.request)
if tc.expectedCode == codes.OK {

Choose a reason for hiding this comment

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

Avoid clauses like this in tests: instead this should be two separate test cases.

})
}

// expect error with canceled context

Choose a reason for hiding this comment

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

Should be in a separate test case.

require.Equal(t, b1, actual)

// Get Backfill which is not present - NotFound
actual, err = om.Frontend().GetBackfill(ctx, &pb.GetBackfillRequest{BackfillId: b1.Id + "new"})

Choose a reason for hiding this comment

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

I think this should be a separate test case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I will make it as a separate PR.

@Laremere Laremere merged commit 248494c into googleforgames:master Nov 26, 2020
@syntxerror syntxerror added area/feature breaking api change Breaking API change that may require migration for existing customers to update to new version. labels Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature breaking api change Breaking API change that may require migration for existing customers to update to new version. cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants