lostluck commented on code in PR #30072:
URL: https://github.com/apache/beam/pull/30072#discussion_r1492852786
##########
sdks/go/pkg/beam/runners/prism/internal/engine/engine_test.go:
##########
@@ -169,3 +169,50 @@ func TestElementManagerCoverage(t *testing.T) {
})
}
}
+
+func TestTestStream(t *testing.T) {
+ initRunner(t)
+
+ tests := []struct {
+ pipeline func(s beam.Scope)
+ }{
+ {pipeline: primitives.TestStreamBoolSequence},
+ {pipeline: primitives.TestStreamByteSliceSequence},
+ {pipeline: primitives.TestStreamFloat64Sequence},
+ {pipeline: primitives.TestStreamInt64Sequence},
+ {pipeline: primitives.TestStreamInt16Sequence},
+ {pipeline: primitives.TestStreamStrings},
+ {pipeline: primitives.TestStreamTwoBoolSequences},
+ {pipeline: primitives.TestStreamTwoFloat64Sequences},
+ {pipeline: primitives.TestStreamTwoInt64Sequences},
+ {pipeline: primitives.TestStreamTwoUserTypeSequences},
+ }
+
+ configs := []struct {
+ name string
+ OneElementPerKey, OneKeyPerBundle bool
+ }{
+ {"Greedy", false, false},
+ {"AllElementsPerKey", false, true},
+ {"OneElementPerKey", true, false},
+ {"OneElementPerBundle", true, true},
+ }
+ for _, config := range configs {
+ for _, test := range tests {
+ t.Run(initTestName(test.pipeline)+"_"+config.name,
func(t *testing.T) {
+ t.Cleanup(func() {
+ engine.OneElementPerKey = false
+ engine.OneKeyPerBundle = false
+ })
+ engine.OneElementPerKey =
config.OneElementPerKey
+ engine.OneKeyPerBundle = config.OneKeyPerBundle
+ p, s := beam.NewPipelineWithRoot()
+ test.pipeline(s)
+ _, err := executeWithT(context.Background(), t,
p)
+ if err != nil {
+ t.Fatalf("pipeline failed, but feature
should be implemented in Prism: %v", err)
+ }
+ })
+ }
+ }
+}
Review Comment:
Not without making teststream_test.go be in `package engine_test`, which
puts it outside of the engine package, so that we avoid a circular import loop
by depending on test cases (from primitives), that depend on packages that
depend on prism, enabling proper black box testing of the entire engine. (See
the docs at the top of https://pkg.go.dev/testing for some details, and
https://pkg.go.dev/cmd/go@master#hdr-Test_packages for others)
I expect I'll want to actually add real unit tests once the processing time
handling is in (never trust time), and those would need to be in
`engine/teststream_test.go`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]