From 6d5e64d96499fc3747e5e9ed375aaabd3b1ef7ad Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Fri, 8 Nov 2024 12:33:08 -0600 Subject: [PATCH] Fix tests running master in CI with specific dapr version (#1461) * Fix tests running master in CI with specific dapr version Signed-off-by: Anton Troshin * move env version load into common Signed-off-by: Anton Troshin * fix k8s test files Signed-off-by: Anton Troshin * Revert "fix k8s test files" This reverts commit 344867d19ca4b38e5a83a82a2a00bb04c1775bab. Signed-off-by: Anton Troshin * Revert "move env version load into common" This reverts commit 39e8c8caf54a157464bb44dffe448fc75727487f. Signed-off-by: Anton Troshin * Revert "Fix tests running master in CI with specific dapr version" This reverts commit a02c81f7e25a6bbdb8e3b172a8e215dae60d321f. Signed-off-by: Anton Troshin * Add GetRuntimeVersion to be able to compare semver dapr versions for conditional tests Use GetRuntimeVersion in test Signed-off-by: Anton Troshin --------- Signed-off-by: Anton Troshin --- tests/e2e/common/common.go | 9 ++++++++- tests/e2e/standalone/run_test.go | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/e2e/common/common.go b/tests/e2e/common/common.go index e79b5a50c..a10fba8c0 100644 --- a/tests/e2e/common/common.go +++ b/tests/e2e/common/common.go @@ -57,7 +57,7 @@ const ( devZipkinReleaseName = "dapr-dev-zipkin" ) -var VersionWithScheduler = semver.MustParse("1.14.0") +var VersionWithScheduler = semver.MustParse("1.14.0-rc.1") type VersionDetails struct { RuntimeVersion string @@ -109,6 +109,13 @@ func GetVersionsFromEnv(t *testing.T, latest bool) (string, string) { return daprRuntimeVersion, daprDashboardVersion } +func GetRuntimeVersion(t *testing.T, latest bool) *semver.Version { + daprRuntimeVersion, _ := GetVersionsFromEnv(t, latest) + runtimeVersion, err := semver.NewVersion(daprRuntimeVersion) + require.NoError(t, err) + return runtimeVersion +} + func UpgradeTest(details VersionDetails, opts TestOptions) func(t *testing.T) { return func(t *testing.T) { daprPath := GetDaprPath() diff --git a/tests/e2e/standalone/run_test.go b/tests/e2e/standalone/run_test.go index c98d71f0e..d4260aa9e 100644 --- a/tests/e2e/standalone/run_test.go +++ b/tests/e2e/standalone/run_test.go @@ -21,6 +21,8 @@ import ( "runtime" "testing" + "github.com/dapr/cli/tests/e2e/common" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -35,9 +37,12 @@ func TestStandaloneRun(t *testing.T) { output, err := cmdProcess(ctx, "placement", t.Log, "--metrics-port", "9091", "--healthz-port", "8081") require.NoError(t, err) t.Log(output) - output, err = cmdProcess(ctx, "scheduler", t.Log, "--metrics-port", "9092", "--healthz-port", "8082") - require.NoError(t, err) - t.Log(output) + + if common.GetRuntimeVersion(t, false).GreaterThan(common.VersionWithScheduler) { + output, err = cmdProcess(ctx, "scheduler", t.Log, "--metrics-port", "9092", "--healthz-port", "8082") + require.NoError(t, err) + t.Log(output) + } } t.Cleanup(func() { // remove dapr installation after all tests in this function. @@ -68,7 +73,11 @@ func TestStandaloneRun(t *testing.T) { output, err := cmdRun(path, "--dapr-internal-grpc-port", "9999", "--", "bash", "-c", "echo test") t.Log(output) require.NoError(t, err, "run failed") - assert.Contains(t, output, "Internal gRPC server is running on :9999") + if common.GetRuntimeVersion(t, false).GreaterThan(common.VersionWithScheduler) { + assert.Contains(t, output, "Internal gRPC server is running on :9999") + } else { + assert.Contains(t, output, "Internal gRPC server is running on port 9999") + } assert.Contains(t, output, "Exited App successfully") assert.Contains(t, output, "Exited Dapr successfully") assert.NotContains(t, output, "Could not update sidecar metadata for cliPID")