youngoli commented on a change in pull request #13013:
URL: https://github.com/apache/beam/pull/13013#discussion_r500674070



##########
File path: sdks/go/pkg/beam/core/runtime/exec/sdf_test.go
##########
@@ -400,6 +400,90 @@ func TestAsSplittableUnit(t *testing.T) {
        if err != nil {
                t.Fatalf("invalid function: %v", err)
        }
+       //wdfn, err := graph.NewDoFn(&VetWindowSdf{}, 
graph.NumMainInputs(graph.MainSingle))
+       //if err != nil {
+       //      t.Fatalf("invalid function: %v", err)
+       //}
+       multiWindows := []typex.Window{
+               window.IntervalWindow{Start: 10, End: 20},
+               window.IntervalWindow{Start: 11, End: 21},
+               window.IntervalWindow{Start: 12, End: 22},
+               window.IntervalWindow{Start: 13, End: 23},
+       }
+
+       // Test that progress returns expected results and respects windows.
+       t.Run("Progress", func(t *testing.T) {
+               tests := []struct {
+                       name          string
+                       fn            *graph.DoFn
+                       in            FullValue
+                       doneWork      float64 // Will be output by RTracker's 
GetProgress.
+                       remainingWork float64 // Will be output by RTracker's 
GetProgress.
+                       currWindow    int
+                       wantProgress  float64
+               }{
+                       {
+                               name: "SingleWindow",
+                               fn:   dfn,
+                               in: FullValue{
+                                       Elm: &FullValue{
+                                               Elm:  1,
+                                               Elm2: &VetRestriction{ID: 
"Sdf"},
+                                       },
+                                       Elm2:      1.0,
+                                       Timestamp: testTimestamp,
+                                       Windows:   testWindows,
+                               },
+                               doneWork:      1.0,
+                               remainingWork: 1.0,
+                               currWindow:    0,
+                               wantProgress:  0.5,
+                       },
+                       {
+                               name: "MultipleWindows",
+                               fn:   dfn,

Review comment:
       This test doesn't actually check the code in ProcessElement because it 
never actually calls ProcessElement, so it doesn't actually matter what the 
DoFn being used is (in fact, I can probably erase that field from the tests). 
It's unit testing the SplittableUnit behavior specifically.
   
   I think I can add a unit test to make sure ProcessElement handles windows 
correctly (or a component test technically, since it's testing multiple 
methods), but it's a little more involved since I need to figure out how to 
block processing to check progress and perform splits. I'll add it in the 
upcoming PR enabling multi-window splitting.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to