From 47a57f1f236b5b484c2dc17c2f6a55a8891cbeba Mon Sep 17 00:00:00 2001 From: Michael Li Date: Fri, 1 May 2026 15:59:51 -0400 Subject: [PATCH] test(e2e): Add worker version check (#6677) --- testing/internal/e2e/boundary/version.go | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 testing/internal/e2e/boundary/version.go diff --git a/testing/internal/e2e/boundary/version.go b/testing/internal/e2e/boundary/version.go new file mode 100644 index 0000000000..b5f914c1f0 --- /dev/null +++ b/testing/internal/e2e/boundary/version.go @@ -0,0 +1,49 @@ +// Copyright IBM Corp. 2020, 2026 +// SPDX-License-Identifier: BUSL-1.1 + +package boundary + +import ( + "context" + "encoding/json" + "testing" + + gvers "github.com/hashicorp/go-version" + "github.com/stretchr/testify/require" + + "github.com/hashicorp/boundary/testing/internal/e2e" + "github.com/hashicorp/boundary/version" +) + +// IsVersionAtLeast checks if the Boundary version running in the specified container is at least the given minimum version. +func IsVersionAtLeast(t testing.TB, ctx context.Context, containerName string, minVersion string) { + output := e2e.RunCommand( + ctx, + "docker", + e2e.WithArgs( + "exec", containerName, + "boundary", "version", + "-format", "json", + ), + ) + require.NoError(t, output.Err, "failed to get version from container %q: %s", containerName, string(output.Stderr)) + + var versionResult version.Info + err := json.Unmarshal(output.Stdout, &versionResult) + require.NoError(t, err) + + minSemVersion, err := gvers.NewSemver(minVersion) + require.NoError(t, err) + + containerVersion := versionResult.Semver() + require.NotNil(t, containerVersion, "failed to parse version %q from container %q", versionResult.VersionNumber(), containerName) + + if !containerVersion.GreaterThanOrEqual(minSemVersion) { + t.Skipf( + "Skipping test because container %q is running %q, but this test requires >= %q", + containerName, + versionResult.VersionNumber(), + minVersion, + ) + } +}