Skip to content

Conversation

@youngoli
Copy link
Contributor

This is meant to be part of a larger change adding unit tests for the various pipeline transformations in graphx/xlang.go.

After how long it took to figure out how to implement this, and the realization that each other transformation is going to be similarly difficult and they're already somewhat tested by the xlang examples (and soon-to-be integration tests), I think I'd rather not implement the rest anymore. But I already implemented most of this test so I just finished it up and am sending it out in a PR.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

Post-Commit Tests Status (on master branch)

Lang SDK Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status --- Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang Build Status Build Status Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status --- --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

This is meant to be part of a larger change adding unit tests for the various pipeline transformations in graphx/xlang.go.
@youngoli
Copy link
Contributor Author

R: @lostluck

Copy link
Contributor

@lostluck lostluck left a comment

Choose a reason for hiding this comment

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

Fair enough. Dealing with protos is a Pain in the Butt to synthesize.

The only other way I can think of testing this is writing a Go side expansion service that can handle a single test transform, and simply plug it all together in process. However that seems much more implementation heavy until a Go side expansion service handler exists. Using the integration tests are reasonable for coverage. Thanks for trying!

wantTransform := exp.Transform.(*pipepb.PTransform)
var found bool
for _, gotTransform := range gotComps.GetTransforms() {
if d := cmp.Diff(wantTransform, gotTransform, protocmp.Transform()); d == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, you probably just want cmp.Equal instead of cmp.Diff, since we never use the diff result.

https://pkg.go.dev/github.com/google/go-cmp/cmp#Equal

Copy link
Contributor Author

@youngoli youngoli Nov 19, 2020

Choose a reason for hiding this comment

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

Whoops, kinda embarrassed I missed that. Done.

}
}

func validateComponents(t *testing.T, wantComps, gotComps *pipepb.Components) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused why this is broken out rather than simply using a single cmp.Diff(wantComps, gotComps, protocmp.Transform()) ?

I'm assuming that you wanted additional granularity on the parts that were missing/extra for each component, and the full diff was less clear than this output?

Consider adding a comment documenting that reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the main reason was because the pipeline object can contain the components from multiple external transforms, so just diffing the components wouldn't work. What I needed to validate is that the components of the external transform are a subset of the pipeline components, not that they're exactly equal.

I'll add a comment explaining that, because I agree it's not immediately obvious.

@youngoli youngoli merged commit 70ddf84 into apache:master Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants