Make use of prism in periodic tests not cross compile. (#27054)
Co-authored-by: lostluck <13907733+lostluck@users.noreply.github.com>
diff --git a/sdks/go/pkg/beam/transforms/periodic/periodic.go b/sdks/go/pkg/beam/transforms/periodic/periodic.go
index f8752dc..5a7b4d0 100644
--- a/sdks/go/pkg/beam/transforms/periodic/periodic.go
+++ b/sdks/go/pkg/beam/transforms/periodic/periodic.go
@@ -100,7 +100,7 @@
for currentOutputTimestamp.Before(currentTime) {
if rt.TryClaim(currentOutputIndex) {
emit(mtime.FromTime(currentOutputTimestamp), currentOutputIndex)
- currentOutputIndex += 1
+ currentOutputIndex++
currentOutputTimestamp = mtime.Time(sd.Start).ToTime().Add(sd.Interval * time.Duration(currentOutputIndex))
currentTime = time.Now()
we.UpdateWatermark(currentOutputTimestamp)
diff --git a/sdks/go/pkg/beam/transforms/periodic/periodic_test.go b/sdks/go/pkg/beam/transforms/periodic/periodic_test.go
index 7553e1f..a34edf8 100644
--- a/sdks/go/pkg/beam/transforms/periodic/periodic_test.go
+++ b/sdks/go/pkg/beam/transforms/periodic/periodic_test.go
@@ -21,12 +21,16 @@
"time"
"github.com/apache/beam/sdks/v2/go/pkg/beam"
+ "github.com/apache/beam/sdks/v2/go/pkg/beam/options/jobopts"
_ "github.com/apache/beam/sdks/v2/go/pkg/beam/runners/prism"
"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/passert"
"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest"
)
func TestMain(m *testing.M) {
+ // Since we force loopback with prism, avoid cross-compilation.
+ f, _ := os.CreateTemp("", "dummy")
+ *jobopts.WorkerBinary = f.Name()
os.Exit(ptest.MainRetWithDefault(m, "prism"))
}