From 1bcce0d039be02102c93486284dd98878f49dafd Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Tue, 5 Nov 2024 20:39:41 -0600 Subject: [PATCH 1/7] Fix tests running master in CI with specific dapr version Signed-off-by: Anton Troshin --- tests/e2e/common/common.go | 1 + tests/e2e/kubernetes/clean_env.go | 12 ++++++++++-- tests/e2e/standalone/run_test.go | 15 +++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/e2e/common/common.go b/tests/e2e/common/common.go index e79b5a50c..4b40a57ad 100644 --- a/tests/e2e/common/common.go +++ b/tests/e2e/common/common.go @@ -67,6 +67,7 @@ type VersionDetails struct { ClusterRoles []string ClusterRoleBindings []string UseDaprLatestVersion bool + HasScheduler bool } type TestOptions struct { diff --git a/tests/e2e/kubernetes/clean_env.go b/tests/e2e/kubernetes/clean_env.go index 32109918a..62ad16798 100644 --- a/tests/e2e/kubernetes/clean_env.go +++ b/tests/e2e/kubernetes/clean_env.go @@ -36,6 +36,12 @@ var ( // ensureCleanEnv function needs to be called in every Test function. // sets necessary variable values and uninstalls any previously installed `dapr`. func ensureCleanEnv(t *testing.T, useDaprLatestVersion bool) { + ensureEnvVersionSet(t, useDaprLatestVersion) + // Ensure a clean environment + common.EnsureUninstall(true, true) // does not wait for pod deletion +} + +func ensureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) { currentRuntimeVersion, currentDashboardVersion = common.GetVersionsFromEnv(t, useDaprLatestVersion) currentVersionDetails = common.VersionDetails{ @@ -52,6 +58,8 @@ func ensureCleanEnv(t *testing.T, useDaprLatestVersion bool) { currentVersionDetails.ClusterRoles = clusterRoles1_10_X currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X } - // Ensure a clean environment - common.EnsureUninstall(true, true) // does not wait for pod deletion + + if strings.HasPrefix(currentRuntimeVersion, "1.14.") { + currentVersionDetails.HasScheduler = true + } } diff --git a/tests/e2e/standalone/run_test.go b/tests/e2e/standalone/run_test.go index c98d71f0e..45bcfcb14 100644 --- a/tests/e2e/standalone/run_test.go +++ b/tests/e2e/standalone/run_test.go @@ -27,6 +27,7 @@ import ( func TestStandaloneRun(t *testing.T) { ensureDaprInstallation(t) + ensureEnvVersionSet(t, false) ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() @@ -35,9 +36,11 @@ 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 currentVersionDetails.HasScheduler { + 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 +71,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 currentVersionDetails.HasScheduler { + 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") From 450e51b86483de9a436e24f82c1e66d3d35eecb3 Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Wed, 6 Nov 2024 12:02:19 -0600 Subject: [PATCH 2/7] move env version load into common Signed-off-by: Anton Troshin --- tests/e2e/common/common.go | 24 +++++++++++++++++++++- tests/e2e/kubernetes/clean_env.go | 34 ++++++++----------------------- tests/e2e/standalone/run_test.go | 8 +++++--- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/tests/e2e/common/common.go b/tests/e2e/common/common.go index 4b40a57ad..1a0c7d506 100644 --- a/tests/e2e/common/common.go +++ b/tests/e2e/common/common.go @@ -57,7 +57,10 @@ const ( devZipkinReleaseName = "dapr-dev-zipkin" ) -var VersionWithScheduler = semver.MustParse("1.14.0") +var ( + VersionWithScheduler = semver.MustParse("1.14.0-rc.1") + CurrentVersionDetails VersionDetails +) type VersionDetails struct { RuntimeVersion string @@ -1269,3 +1272,22 @@ func exportCurrentCertificate(daprPath string) error { } return nil } + +func EnsureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) VersionDetails { + currentRuntimeVersion, currentDashboardVersion := GetVersionsFromEnv(t, useDaprLatestVersion) + + vd := VersionDetails{ + RuntimeVersion: currentRuntimeVersion, + DashboardVersion: currentDashboardVersion, + CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io", "httpendpoints.dapr.io"}, + ImageVariant: "", + UseDaprLatestVersion: useDaprLatestVersion, + } + + version := semver.MustParse(currentRuntimeVersion) + if version.GreaterThan(VersionWithScheduler) { + CurrentVersionDetails.HasScheduler = true + } + + return vd +} diff --git a/tests/e2e/kubernetes/clean_env.go b/tests/e2e/kubernetes/clean_env.go index 62ad16798..c7efb96e3 100644 --- a/tests/e2e/kubernetes/clean_env.go +++ b/tests/e2e/kubernetes/clean_env.go @@ -24,9 +24,6 @@ import ( ) var ( - currentRuntimeVersion string - currentDashboardVersion string - currentVersionDetails common.VersionDetails clusterRoles1_9_X = []string{"dapr-operator-admin", "dashboard-reader"} clusterRoleBindings1_9_X = []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"} clusterRoles1_10_X = []string{"dapr-dashboard", "dapr-injector", "dapr-operator-admin", "dapr-placement", "dapr-sentry"} @@ -36,30 +33,15 @@ var ( // ensureCleanEnv function needs to be called in every Test function. // sets necessary variable values and uninstalls any previously installed `dapr`. func ensureCleanEnv(t *testing.T, useDaprLatestVersion bool) { - ensureEnvVersionSet(t, useDaprLatestVersion) - // Ensure a clean environment - common.EnsureUninstall(true, true) // does not wait for pod deletion -} + common.EnsureEnvVersionSet(t, useDaprLatestVersion) -func ensureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) { - currentRuntimeVersion, currentDashboardVersion = common.GetVersionsFromEnv(t, useDaprLatestVersion) - - currentVersionDetails = common.VersionDetails{ - RuntimeVersion: currentRuntimeVersion, - DashboardVersion: currentDashboardVersion, - CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io", "httpendpoints.dapr.io"}, - ImageVariant: "", - UseDaprLatestVersion: useDaprLatestVersion, - } - if strings.HasPrefix(currentRuntimeVersion, "1.9.") { - currentVersionDetails.ClusterRoles = clusterRoles1_9_X - currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_9_X + if strings.HasPrefix(common.CurrentVersionDetails.RuntimeVersion, "1.9.") { + common.CurrentVersionDetails.ClusterRoles = clusterRoles1_9_X + common.CurrentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_9_X } else { - currentVersionDetails.ClusterRoles = clusterRoles1_10_X - currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X - } - - if strings.HasPrefix(currentRuntimeVersion, "1.14.") { - currentVersionDetails.HasScheduler = true + common.CurrentVersionDetails.ClusterRoles = clusterRoles1_10_X + common.CurrentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X } + // Ensure a clean environment + common.EnsureUninstall(true, true) // does not wait for pod deletion } diff --git a/tests/e2e/standalone/run_test.go b/tests/e2e/standalone/run_test.go index 45bcfcb14..509859639 100644 --- a/tests/e2e/standalone/run_test.go +++ b/tests/e2e/standalone/run_test.go @@ -21,13 +21,15 @@ import ( "runtime" "testing" + "github.com/dapr/cli/tests/e2e/common" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestStandaloneRun(t *testing.T) { ensureDaprInstallation(t) - ensureEnvVersionSet(t, false) + common.EnsureEnvVersionSet(t, false) ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() @@ -36,7 +38,7 @@ 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) - if currentVersionDetails.HasScheduler { + if common.CurrentVersionDetails.HasScheduler { output, err = cmdProcess(ctx, "scheduler", t.Log, "--metrics-port", "9092", "--healthz-port", "8082") require.NoError(t, err) t.Log(output) @@ -71,7 +73,7 @@ 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") - if currentVersionDetails.HasScheduler { + if common.CurrentVersionDetails.HasScheduler { assert.Contains(t, output, "Internal gRPC server is running on :9999") } else { assert.Contains(t, output, "Internal gRPC server is running on port 9999") From c87d2e077d363c323428e092d160eb8bc17fad53 Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Wed, 6 Nov 2024 16:30:12 -0600 Subject: [PATCH 3/7] fix k8s test files Signed-off-by: Anton Troshin --- tests/e2e/kubernetes/kubernetes_test.go | 72 +++++++++++------------ tests/e2e/kubernetes/run_template_test.go | 4 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/e2e/kubernetes/kubernetes_test.go b/tests/e2e/kubernetes/kubernetes_test.go index d080eba4c..828704e14 100644 --- a/tests/e2e/kubernetes/kubernetes_test.go +++ b/tests/e2e/kubernetes/kubernetes_test.go @@ -28,7 +28,7 @@ func TestKubernetesNonHAModeMTLSDisabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ HAEnabled: false, MTLSEnabled: false, ApplyComponentChanges: true, @@ -39,7 +39,7 @@ func TestKubernetesNonHAModeMTLSDisabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -59,7 +59,7 @@ func TestKubernetesHAModeMTLSDisabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ HAEnabled: true, MTLSEnabled: false, ApplyComponentChanges: true, @@ -70,7 +70,7 @@ func TestKubernetesHAModeMTLSDisabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -90,7 +90,7 @@ func TestKubernetesDev(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ DevEnabled: true, HAEnabled: false, MTLSEnabled: true, @@ -102,7 +102,7 @@ func TestKubernetesDev(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ DevEnabled: true, UninstallAll: true, CheckResourceExists: map[common.Resource]bool{ @@ -124,7 +124,7 @@ func TestKubernetesNonHAModeMTLSEnabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ HAEnabled: false, MTLSEnabled: true, ApplyComponentChanges: true, @@ -135,7 +135,7 @@ func TestKubernetesNonHAModeMTLSEnabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -155,7 +155,7 @@ func TestKubernetesHAModeMTLSEnabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ HAEnabled: true, MTLSEnabled: true, ApplyComponentChanges: true, @@ -166,7 +166,7 @@ func TestKubernetesHAModeMTLSEnabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ UninstallAll: true, CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: false, @@ -187,7 +187,7 @@ func TestKubernetesInitWithCustomCert(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ HAEnabled: false, MTLSEnabled: true, InitWithCustomCert: true, @@ -199,7 +199,7 @@ func TestKubernetesInitWithCustomCert(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -231,13 +231,13 @@ func TestRenewCertificateMTLSEnabled(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // tests for certifcate renewal. - tests = append(tests, common.GetTestForCertRenewal(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestForCertRenewal(common.CurrentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -266,13 +266,13 @@ func TestRenewCertificateMTLSDisabled(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // tests for certifcate renewal. - tests = append(tests, common.GetTestForCertRenewal(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestForCertRenewal(common.CurrentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -301,20 +301,20 @@ func TestRenewCertWithPrivateKey(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // tests for certifcate renewal with newly generated certificates when pem encoded private root.key file is provided tests = append(tests, []common.TestCase{ - {"Renew certificate which expires in less than 30 days", common.UseProvidedPrivateKeyAndRenewCerts(currentVersionDetails, installOpts)}, + {"Renew certificate which expires in less than 30 days", common.UseProvidedPrivateKeyAndRenewCerts(common.CurrentVersionDetails, installOpts)}, }...) - tests = append(tests, common.GetTestsPostCertificateRenewal(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsPostCertificateRenewal(common.CurrentVersionDetails, installOpts)...) tests = append(tests, []common.TestCase{ - {"Cert Expiry warning message check " + currentVersionDetails.RuntimeVersion, common.CheckMTLSStatus(currentVersionDetails, installOpts, true)}, + {"Cert Expiry warning message check " + common.CurrentVersionDetails.RuntimeVersion, common.CheckMTLSStatus(common.CurrentVersionDetails, installOpts, true)}, }...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -343,9 +343,9 @@ func TestKubernetesUninstall(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // setup tests - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -373,7 +373,7 @@ func TestRenewCertWithIncorrectFlags(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // tests for certifcate renewal with incorrect set of flags provided. tests = append(tests, []common.TestCase{ @@ -381,7 +381,7 @@ func TestRenewCertWithIncorrectFlags(t *testing.T) { }...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -401,7 +401,7 @@ func TestK8sInstallwithMarinerImagesAndRenewCertificate(t *testing.T) { ensureCleanEnv(t, false) // install with mariner images - currentVersionDetails.ImageVariant = "mariner" + common.CurrentVersionDetails.ImageVariant = "mariner" tests := []common.TestCase{} installOpts := common.TestOptions{ @@ -415,13 +415,13 @@ func TestK8sInstallwithMarinerImagesAndRenewCertificate(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // tests for certifcate renewal. - tests = append(tests, common.GetTestForCertRenewal(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestForCertRenewal(common.CurrentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -450,10 +450,10 @@ func TestKubernetesInstallwithoutRuntimeVersionFlag(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -471,7 +471,7 @@ func TestK8sInstallwithoutRuntimeVersionwithMarinerImagesFlag(t *testing.T) { ensureCleanEnv(t, true) // install with mariner images - currentVersionDetails.ImageVariant = "mariner" + common.CurrentVersionDetails.ImageVariant = "mariner" tests := []common.TestCase{} installOpts := common.TestOptions{ @@ -485,10 +485,10 @@ func TestK8sInstallwithoutRuntimeVersionwithMarinerImagesFlag(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, diff --git a/tests/e2e/kubernetes/run_template_test.go b/tests/e2e/kubernetes/run_template_test.go index 5d050f4cc..32f9c0842 100644 --- a/tests/e2e/kubernetes/run_template_test.go +++ b/tests/e2e/kubernetes/run_template_test.go @@ -56,7 +56,7 @@ func TestKubernetesRunFile(t *testing.T) { HAEnabled: false, MTLSEnabled: true, } - tests = append(tests, common.GetInstallOnlyTest(currentVersionDetails, opts)) + tests = append(tests, common.GetInstallOnlyTest(common.CurrentVersionDetails, opts)) tests = append(tests, common.TestCase{ Name: "run file k8s", @@ -68,7 +68,7 @@ func TestKubernetesRunFile(t *testing.T) { UninstallAll: true, } - tests = append(tests, common.GetUninstallOnlyTest(currentVersionDetails, opts)) + tests = append(tests, common.GetUninstallOnlyTest(common.CurrentVersionDetails, opts)) // execute tests for _, tc := range tests { From 8be17a5c5e5458be8eb7f8719220857e737c63df Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Wed, 6 Nov 2024 18:27:08 -0600 Subject: [PATCH 4/7] Revert "fix k8s test files" This reverts commit 344867d19ca4b38e5a83a82a2a00bb04c1775bab. Signed-off-by: Anton Troshin --- tests/e2e/kubernetes/kubernetes_test.go | 72 +++++++++++------------ tests/e2e/kubernetes/run_template_test.go | 4 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/e2e/kubernetes/kubernetes_test.go b/tests/e2e/kubernetes/kubernetes_test.go index 828704e14..d080eba4c 100644 --- a/tests/e2e/kubernetes/kubernetes_test.go +++ b/tests/e2e/kubernetes/kubernetes_test.go @@ -28,7 +28,7 @@ func TestKubernetesNonHAModeMTLSDisabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ HAEnabled: false, MTLSEnabled: false, ApplyComponentChanges: true, @@ -39,7 +39,7 @@ func TestKubernetesNonHAModeMTLSDisabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -59,7 +59,7 @@ func TestKubernetesHAModeMTLSDisabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ HAEnabled: true, MTLSEnabled: false, ApplyComponentChanges: true, @@ -70,7 +70,7 @@ func TestKubernetesHAModeMTLSDisabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -90,7 +90,7 @@ func TestKubernetesDev(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ DevEnabled: true, HAEnabled: false, MTLSEnabled: true, @@ -102,7 +102,7 @@ func TestKubernetesDev(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ DevEnabled: true, UninstallAll: true, CheckResourceExists: map[common.Resource]bool{ @@ -124,7 +124,7 @@ func TestKubernetesNonHAModeMTLSEnabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ HAEnabled: false, MTLSEnabled: true, ApplyComponentChanges: true, @@ -135,7 +135,7 @@ func TestKubernetesNonHAModeMTLSEnabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -155,7 +155,7 @@ func TestKubernetesHAModeMTLSEnabled(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ HAEnabled: true, MTLSEnabled: true, ApplyComponentChanges: true, @@ -166,7 +166,7 @@ func TestKubernetesHAModeMTLSEnabled(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ UninstallAll: true, CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: false, @@ -187,7 +187,7 @@ func TestKubernetesInitWithCustomCert(t *testing.T) { // setup tests tests := []common.TestCase{} - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, common.TestOptions{ HAEnabled: false, MTLSEnabled: true, InitWithCustomCert: true, @@ -199,7 +199,7 @@ func TestKubernetesInitWithCustomCert(t *testing.T) { }, })...) - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -231,13 +231,13 @@ func TestRenewCertificateMTLSEnabled(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // tests for certifcate renewal. - tests = append(tests, common.GetTestForCertRenewal(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestForCertRenewal(currentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -266,13 +266,13 @@ func TestRenewCertificateMTLSDisabled(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // tests for certifcate renewal. - tests = append(tests, common.GetTestForCertRenewal(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestForCertRenewal(currentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -301,20 +301,20 @@ func TestRenewCertWithPrivateKey(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // tests for certifcate renewal with newly generated certificates when pem encoded private root.key file is provided tests = append(tests, []common.TestCase{ - {"Renew certificate which expires in less than 30 days", common.UseProvidedPrivateKeyAndRenewCerts(common.CurrentVersionDetails, installOpts)}, + {"Renew certificate which expires in less than 30 days", common.UseProvidedPrivateKeyAndRenewCerts(currentVersionDetails, installOpts)}, }...) - tests = append(tests, common.GetTestsPostCertificateRenewal(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsPostCertificateRenewal(currentVersionDetails, installOpts)...) tests = append(tests, []common.TestCase{ - {"Cert Expiry warning message check " + common.CurrentVersionDetails.RuntimeVersion, common.CheckMTLSStatus(common.CurrentVersionDetails, installOpts, true)}, + {"Cert Expiry warning message check " + currentVersionDetails.RuntimeVersion, common.CheckMTLSStatus(currentVersionDetails, installOpts, true)}, }...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -343,9 +343,9 @@ func TestKubernetesUninstall(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // setup tests - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -373,7 +373,7 @@ func TestRenewCertWithIncorrectFlags(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // tests for certifcate renewal with incorrect set of flags provided. tests = append(tests, []common.TestCase{ @@ -381,7 +381,7 @@ func TestRenewCertWithIncorrectFlags(t *testing.T) { }...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -401,7 +401,7 @@ func TestK8sInstallwithMarinerImagesAndRenewCertificate(t *testing.T) { ensureCleanEnv(t, false) // install with mariner images - common.CurrentVersionDetails.ImageVariant = "mariner" + currentVersionDetails.ImageVariant = "mariner" tests := []common.TestCase{} installOpts := common.TestOptions{ @@ -415,13 +415,13 @@ func TestK8sInstallwithMarinerImagesAndRenewCertificate(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // tests for certifcate renewal. - tests = append(tests, common.GetTestForCertRenewal(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestForCertRenewal(currentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -450,10 +450,10 @@ func TestKubernetesInstallwithoutRuntimeVersionFlag(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, @@ -471,7 +471,7 @@ func TestK8sInstallwithoutRuntimeVersionwithMarinerImagesFlag(t *testing.T) { ensureCleanEnv(t, true) // install with mariner images - common.CurrentVersionDetails.ImageVariant = "mariner" + currentVersionDetails.ImageVariant = "mariner" tests := []common.TestCase{} installOpts := common.TestOptions{ @@ -485,10 +485,10 @@ func TestK8sInstallwithoutRuntimeVersionwithMarinerImagesFlag(t *testing.T) { }, } - tests = append(tests, common.GetTestsOnInstall(common.CurrentVersionDetails, installOpts)...) + tests = append(tests, common.GetTestsOnInstall(currentVersionDetails, installOpts)...) // teardown everything - tests = append(tests, common.GetTestsOnUninstall(common.CurrentVersionDetails, common.TestOptions{ + tests = append(tests, common.GetTestsOnUninstall(currentVersionDetails, common.TestOptions{ CheckResourceExists: map[common.Resource]bool{ common.CustomResourceDefs: true, common.ClusterRoles: false, diff --git a/tests/e2e/kubernetes/run_template_test.go b/tests/e2e/kubernetes/run_template_test.go index 32f9c0842..5d050f4cc 100644 --- a/tests/e2e/kubernetes/run_template_test.go +++ b/tests/e2e/kubernetes/run_template_test.go @@ -56,7 +56,7 @@ func TestKubernetesRunFile(t *testing.T) { HAEnabled: false, MTLSEnabled: true, } - tests = append(tests, common.GetInstallOnlyTest(common.CurrentVersionDetails, opts)) + tests = append(tests, common.GetInstallOnlyTest(currentVersionDetails, opts)) tests = append(tests, common.TestCase{ Name: "run file k8s", @@ -68,7 +68,7 @@ func TestKubernetesRunFile(t *testing.T) { UninstallAll: true, } - tests = append(tests, common.GetUninstallOnlyTest(common.CurrentVersionDetails, opts)) + tests = append(tests, common.GetUninstallOnlyTest(currentVersionDetails, opts)) // execute tests for _, tc := range tests { From e8881c4ae2bfc5e0d5fb0678d2fea1edb52e5a7b Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Wed, 6 Nov 2024 18:27:09 -0600 Subject: [PATCH 5/7] Revert "move env version load into common" This reverts commit 39e8c8caf54a157464bb44dffe448fc75727487f. Signed-off-by: Anton Troshin --- tests/e2e/common/common.go | 24 +--------------------- tests/e2e/kubernetes/clean_env.go | 34 +++++++++++++++++++++++-------- tests/e2e/standalone/run_test.go | 8 +++----- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/tests/e2e/common/common.go b/tests/e2e/common/common.go index 1a0c7d506..4b40a57ad 100644 --- a/tests/e2e/common/common.go +++ b/tests/e2e/common/common.go @@ -57,10 +57,7 @@ const ( devZipkinReleaseName = "dapr-dev-zipkin" ) -var ( - VersionWithScheduler = semver.MustParse("1.14.0-rc.1") - CurrentVersionDetails VersionDetails -) +var VersionWithScheduler = semver.MustParse("1.14.0") type VersionDetails struct { RuntimeVersion string @@ -1272,22 +1269,3 @@ func exportCurrentCertificate(daprPath string) error { } return nil } - -func EnsureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) VersionDetails { - currentRuntimeVersion, currentDashboardVersion := GetVersionsFromEnv(t, useDaprLatestVersion) - - vd := VersionDetails{ - RuntimeVersion: currentRuntimeVersion, - DashboardVersion: currentDashboardVersion, - CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io", "httpendpoints.dapr.io"}, - ImageVariant: "", - UseDaprLatestVersion: useDaprLatestVersion, - } - - version := semver.MustParse(currentRuntimeVersion) - if version.GreaterThan(VersionWithScheduler) { - CurrentVersionDetails.HasScheduler = true - } - - return vd -} diff --git a/tests/e2e/kubernetes/clean_env.go b/tests/e2e/kubernetes/clean_env.go index c7efb96e3..62ad16798 100644 --- a/tests/e2e/kubernetes/clean_env.go +++ b/tests/e2e/kubernetes/clean_env.go @@ -24,6 +24,9 @@ import ( ) var ( + currentRuntimeVersion string + currentDashboardVersion string + currentVersionDetails common.VersionDetails clusterRoles1_9_X = []string{"dapr-operator-admin", "dashboard-reader"} clusterRoleBindings1_9_X = []string{"dapr-operator", "dapr-role-tokenreview-binding", "dashboard-reader-global"} clusterRoles1_10_X = []string{"dapr-dashboard", "dapr-injector", "dapr-operator-admin", "dapr-placement", "dapr-sentry"} @@ -33,15 +36,30 @@ var ( // ensureCleanEnv function needs to be called in every Test function. // sets necessary variable values and uninstalls any previously installed `dapr`. func ensureCleanEnv(t *testing.T, useDaprLatestVersion bool) { - common.EnsureEnvVersionSet(t, useDaprLatestVersion) + ensureEnvVersionSet(t, useDaprLatestVersion) + // Ensure a clean environment + common.EnsureUninstall(true, true) // does not wait for pod deletion +} - if strings.HasPrefix(common.CurrentVersionDetails.RuntimeVersion, "1.9.") { - common.CurrentVersionDetails.ClusterRoles = clusterRoles1_9_X - common.CurrentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_9_X +func ensureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) { + currentRuntimeVersion, currentDashboardVersion = common.GetVersionsFromEnv(t, useDaprLatestVersion) + + currentVersionDetails = common.VersionDetails{ + RuntimeVersion: currentRuntimeVersion, + DashboardVersion: currentDashboardVersion, + CustomResourceDefs: []string{"components.dapr.io", "configurations.dapr.io", "subscriptions.dapr.io", "resiliencies.dapr.io", "httpendpoints.dapr.io"}, + ImageVariant: "", + UseDaprLatestVersion: useDaprLatestVersion, + } + if strings.HasPrefix(currentRuntimeVersion, "1.9.") { + currentVersionDetails.ClusterRoles = clusterRoles1_9_X + currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_9_X } else { - common.CurrentVersionDetails.ClusterRoles = clusterRoles1_10_X - common.CurrentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X + currentVersionDetails.ClusterRoles = clusterRoles1_10_X + currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X + } + + if strings.HasPrefix(currentRuntimeVersion, "1.14.") { + currentVersionDetails.HasScheduler = true } - // Ensure a clean environment - common.EnsureUninstall(true, true) // does not wait for pod deletion } diff --git a/tests/e2e/standalone/run_test.go b/tests/e2e/standalone/run_test.go index 509859639..45bcfcb14 100644 --- a/tests/e2e/standalone/run_test.go +++ b/tests/e2e/standalone/run_test.go @@ -21,15 +21,13 @@ import ( "runtime" "testing" - "github.com/dapr/cli/tests/e2e/common" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestStandaloneRun(t *testing.T) { ensureDaprInstallation(t) - common.EnsureEnvVersionSet(t, false) + ensureEnvVersionSet(t, false) ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() @@ -38,7 +36,7 @@ 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) - if common.CurrentVersionDetails.HasScheduler { + if currentVersionDetails.HasScheduler { output, err = cmdProcess(ctx, "scheduler", t.Log, "--metrics-port", "9092", "--healthz-port", "8082") require.NoError(t, err) t.Log(output) @@ -73,7 +71,7 @@ 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") - if common.CurrentVersionDetails.HasScheduler { + if currentVersionDetails.HasScheduler { assert.Contains(t, output, "Internal gRPC server is running on :9999") } else { assert.Contains(t, output, "Internal gRPC server is running on port 9999") From a6368a160c7b16a8afbcf30346cd31d028e86dcb Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Wed, 6 Nov 2024 18:27:09 -0600 Subject: [PATCH 6/7] Revert "Fix tests running master in CI with specific dapr version" This reverts commit a02c81f7e25a6bbdb8e3b172a8e215dae60d321f. Signed-off-by: Anton Troshin --- tests/e2e/common/common.go | 1 - tests/e2e/kubernetes/clean_env.go | 12 ++---------- tests/e2e/standalone/run_test.go | 15 ++++----------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/tests/e2e/common/common.go b/tests/e2e/common/common.go index 4b40a57ad..e79b5a50c 100644 --- a/tests/e2e/common/common.go +++ b/tests/e2e/common/common.go @@ -67,7 +67,6 @@ type VersionDetails struct { ClusterRoles []string ClusterRoleBindings []string UseDaprLatestVersion bool - HasScheduler bool } type TestOptions struct { diff --git a/tests/e2e/kubernetes/clean_env.go b/tests/e2e/kubernetes/clean_env.go index 62ad16798..32109918a 100644 --- a/tests/e2e/kubernetes/clean_env.go +++ b/tests/e2e/kubernetes/clean_env.go @@ -36,12 +36,6 @@ var ( // ensureCleanEnv function needs to be called in every Test function. // sets necessary variable values and uninstalls any previously installed `dapr`. func ensureCleanEnv(t *testing.T, useDaprLatestVersion bool) { - ensureEnvVersionSet(t, useDaprLatestVersion) - // Ensure a clean environment - common.EnsureUninstall(true, true) // does not wait for pod deletion -} - -func ensureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) { currentRuntimeVersion, currentDashboardVersion = common.GetVersionsFromEnv(t, useDaprLatestVersion) currentVersionDetails = common.VersionDetails{ @@ -58,8 +52,6 @@ func ensureEnvVersionSet(t *testing.T, useDaprLatestVersion bool) { currentVersionDetails.ClusterRoles = clusterRoles1_10_X currentVersionDetails.ClusterRoleBindings = clusterRoleBindings1_10_X } - - if strings.HasPrefix(currentRuntimeVersion, "1.14.") { - currentVersionDetails.HasScheduler = true - } + // Ensure a clean environment + common.EnsureUninstall(true, true) // does not wait for pod deletion } diff --git a/tests/e2e/standalone/run_test.go b/tests/e2e/standalone/run_test.go index 45bcfcb14..c98d71f0e 100644 --- a/tests/e2e/standalone/run_test.go +++ b/tests/e2e/standalone/run_test.go @@ -27,7 +27,6 @@ import ( func TestStandaloneRun(t *testing.T) { ensureDaprInstallation(t) - ensureEnvVersionSet(t, false) ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() @@ -36,11 +35,9 @@ 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) - if currentVersionDetails.HasScheduler { - output, err = cmdProcess(ctx, "scheduler", t.Log, "--metrics-port", "9092", "--healthz-port", "8082") - 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) } t.Cleanup(func() { // remove dapr installation after all tests in this function. @@ -71,11 +68,7 @@ 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") - if currentVersionDetails.HasScheduler { - 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, "Internal gRPC server is running on :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") From 22a8a7ac093598a4c0c88fa791755316e6fe2288 Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Wed, 6 Nov 2024 18:36:21 -0600 Subject: [PATCH 7/7] Add GetRuntimeVersion to be able to compare semver dapr versions for conditional tests Use GetRuntimeVersion in test 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")