@@ -25,10 +25,14 @@ import (
2525 "google.golang.org/protobuf/testing/protocmp"
2626)
2727
28- func TestHandleCombine (t * testing.T ) {
29- undertest := "UnderTest"
28+ func makeWindowingStrategy (trigger * pipepb.Trigger ) * pipepb.WindowingStrategy {
29+ return & pipepb.WindowingStrategy {
30+ Trigger : trigger ,
31+ }
32+ }
3033
31- combineTransform := & pipepb.PTransform {
34+ func makeCombineTransform (inputPCollectionID string ) * pipepb.PTransform {
35+ return & pipepb.PTransform {
3236 UniqueName : "COMBINE" ,
3337 Spec : & pipepb.FunctionSpec {
3438 Urn : urns .TransformCombinePerKey ,
@@ -41,7 +45,7 @@ func TestHandleCombine(t *testing.T) {
4145 }),
4246 },
4347 Inputs : map [string ]string {
44- "input" : "combineIn" ,
48+ "input" : inputPCollectionID ,
4549 },
4650 Outputs : map [string ]string {
4751 "input" : "combineOut" ,
@@ -51,6 +55,15 @@ func TestHandleCombine(t *testing.T) {
5155 "combine_values" ,
5256 },
5357 }
58+ }
59+
60+ func TestHandleCombine (t * testing.T ) {
61+ undertest := "UnderTest"
62+
63+ combineTransform := makeCombineTransform ("combineIn" )
64+ combineTransformWithTriggerElementCount := makeCombineTransform ("combineInWithTriggerElementCount" )
65+ combineTransformWithTriggerAlways := makeCombineTransform ("combineInWithTriggerAlways" )
66+
5467 combineValuesTransform := & pipepb.PTransform {
5568 UniqueName : "combine_values" ,
5669 Subtransforms : []string {
@@ -64,6 +77,14 @@ func TestHandleCombine(t *testing.T) {
6477 "combineOut" : {
6578 CoderId : "outputCoder" ,
6679 },
80+ "combineInWithTriggerElementCount" : {
81+ CoderId : "inputCoder" ,
82+ WindowingStrategyId : "wsElementCount" ,
83+ },
84+ "combineInWithTriggerAlways" : {
85+ CoderId : "inputCoder" ,
86+ WindowingStrategyId : "wsAlways" ,
87+ },
6788 }
6889 baseCoderMap := map [string ]* pipepb.Coder {
6990 "int" : {
@@ -84,7 +105,20 @@ func TestHandleCombine(t *testing.T) {
84105 ComponentCoderIds : []string {"int" , "string" },
85106 },
86107 }
87-
108+ baseWindowingStrategyMap := map [string ]* pipepb.WindowingStrategy {
109+ "wsElementCount" : makeWindowingStrategy (& pipepb.Trigger {
110+ Trigger : & pipepb.Trigger_ElementCount_ {
111+ ElementCount : & pipepb.Trigger_ElementCount {
112+ ElementCount : 10 ,
113+ },
114+ },
115+ }),
116+ "wsAlways" : makeWindowingStrategy (& pipepb.Trigger {
117+ Trigger : & pipepb.Trigger_Always_ {
118+ Always : & pipepb.Trigger_Always {},
119+ },
120+ }),
121+ }
88122 tests := []struct {
89123 name string
90124 lifted bool
@@ -188,6 +222,32 @@ func TestHandleCombine(t *testing.T) {
188222 },
189223 },
190224 },
225+ }, {
226+ name : "noLift_triggerElementCount" ,
227+ lifted : true , // Lifting is enabled, but should be disabled in the present of the trigger
228+ comps : & pipepb.Components {
229+ Transforms : map [string ]* pipepb.PTransform {
230+ undertest : combineTransformWithTriggerElementCount ,
231+ "combine_values" : combineValuesTransform ,
232+ },
233+ Pcollections : basePCollectionMap ,
234+ Coders : baseCoderMap ,
235+ WindowingStrategies : baseWindowingStrategyMap ,
236+ },
237+ want : prepareResult {},
238+ }, {
239+ name : "noLift_triggerAlways" ,
240+ lifted : true , // Lifting is enabled, but should be disabled in the present of the trigger
241+ comps : & pipepb.Components {
242+ Transforms : map [string ]* pipepb.PTransform {
243+ undertest : combineTransformWithTriggerAlways ,
244+ "combine_values" : combineValuesTransform ,
245+ },
246+ Pcollections : basePCollectionMap ,
247+ Coders : baseCoderMap ,
248+ WindowingStrategies : baseWindowingStrategyMap ,
249+ },
250+ want : prepareResult {},
191251 },
192252 }
193253 for _ , test := range tests {
0 commit comments