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

jrmccluskey 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 f7e8cfb3599 Programmatically choose target Beam version for Automated 
Expansion Service tests (#27274)
f7e8cfb3599 is described below

commit f7e8cfb3599a2caceb4fba541284b6633a481a9d
Author: Jack McCluskey <[email protected]>
AuthorDate: Wed Jun 28 10:59:48 2023 -0400

    Programmatically choose target Beam version for Automated Expansion Service 
tests (#27274)
    
    * Increase target Beam version for Automated Expansion Service testing
    
    * Automate selection of target JAR version
---
 sdks/go/test/integration/xlang/expansion_test.go | 41 ++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/sdks/go/test/integration/xlang/expansion_test.go 
b/sdks/go/test/integration/xlang/expansion_test.go
index 2cd032384f5..6b87f493d9c 100644
--- a/sdks/go/test/integration/xlang/expansion_test.go
+++ b/sdks/go/test/integration/xlang/expansion_test.go
@@ -17,21 +17,56 @@ package xlang
 
 import (
        "os"
+       "strconv"
+       "strings"
        "testing"
 
+       "github.com/apache/beam/sdks/v2/go/pkg/beam/core"
        
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/runtime/xlangx/expansionx"
        "github.com/apache/beam/sdks/v2/go/test/integration"
 )
 
 const (
-       // TODO(https://github.com/apache/beam/issues/21279): Select the most 
recent Beam release instead of a hard-coded
-       // string.
-       beamVersion  = "2.34.0"
        gradleTarget = ":sdks:java:io:expansion-service:runExpansionService"
 )
 
+func getTargetVersion(currentVersion string) string {
+       curVersion := strings.Split(currentVersion, ".")
+       minorVersion, _ := strconv.Atoi(curVersion[1])
+       targetMinor := minorVersion - 2
+       curVersion[1] = strconv.Itoa(targetMinor)
+       return strings.Join(curVersion[0:3], ".")
+}
+
+func TestGetTargetVersion(t *testing.T) {
+       var tests = []struct {
+               name      string
+               input     string
+               expOutput string
+       }{
+               {
+                       "normal version",
+                       "2.50.0",
+                       "2.48.0",
+               },
+               {
+                       "dev version",
+                       "2.10.0.dev",
+                       "2.8.0",
+               },
+       }
+       for _, test := range tests {
+               t.Run(test.name, func(t *testing.T) {
+                       if got, want := getTargetVersion(test.input), 
test.expOutput; got != want {
+                               t.Errorf("got %v, want %v", got, want)
+                       }
+               })
+       }
+}
+
 func TestAutomatedExpansionService(t *testing.T) {
        integration.CheckFilters(t)
+       beamVersion := getTargetVersion(core.SdkVersion)
        jarPath, err := expansionx.GetBeamJar(gradleTarget, beamVersion)
        if err != nil {
                t.Fatalf("failed to get JAR path, got %v", err)

Reply via email to