This is an automated email from the ASF dual-hosted git repository.

lostluck pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 0c977e9  [BEAM-13399] Add extra time buffer to reduce likelihood of 
flake in expansion service test (#16331)
0c977e9 is described below

commit 0c977e9065ea2bf6adfabec7b7d131522b189115
Author: Jack McCluskey <[email protected]>
AuthorDate: Wed Dec 22 17:36:48 2021 -0500

    [BEAM-13399] Add extra time buffer to reduce likelihood of flake in 
expansion service test (#16331)
---
 sdks/go/test/integration/xlang/expansion_test.go | 26 +++++++++++++++---------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/sdks/go/test/integration/xlang/expansion_test.go 
b/sdks/go/test/integration/xlang/expansion_test.go
index 070fccf..3adc446 100644
--- a/sdks/go/test/integration/xlang/expansion_test.go
+++ b/sdks/go/test/integration/xlang/expansion_test.go
@@ -20,6 +20,7 @@ import (
        "os/exec"
        "strings"
        "testing"
+       "time"
 
        
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/runtime/xlangx/expansionx"
        "github.com/apache/beam/sdks/v2/go/test/integration"
@@ -33,16 +34,21 @@ const (
        expansionPort = "8097"
 )
 
-func checkPort(t *testing.T, port string) {
-       ping := exec.Command("nc", "-vz", "localhost", port)
-       output, err := ping.CombinedOutput()
-       if err != nil {
-               t.Errorf("failed to run ping to localhost:%v", port)
-       }
-       outputStr := string(output)
-       if strings.Contains(outputStr, "failed") {
-               t.Errorf("failed to connect to localhost:%v, got err %v", port, 
outputStr)
+func checkPort(t *testing.T, port string, duration time.Duration) {
+       var outputStr string
+       for i := 0.0; i < duration.Seconds(); i += 0.5 {
+               ping := exec.Command("nc", "-vz", "localhost", port)
+               output, err := ping.CombinedOutput()
+               if err != nil {
+                       t.Fatalf("failed to run ping to port, got %v", err)
+               }
+               outputStr = string(output)
+               if !strings.Contains(outputStr, "failed") {
+                       return
+               }
+               time.Sleep(500 * time.Millisecond)
        }
+       t.Errorf("Failed to connect to expansion service after %f seconds", 
duration.Seconds())
 }
 
 func TestAutomatedExpansionService(t *testing.T) {
@@ -59,7 +65,7 @@ func TestAutomatedExpansionService(t *testing.T) {
                t.Errorf("failed to start expansion service JAR, got %v", err)
        }
 
-       checkPort(t, expansionPort)
+       checkPort(t, expansionPort, 15*time.Second)
 
        err = serviceRunner.StopService()
        if err != nil {

Reply via email to