Skip to content

Commit

Permalink
Fix tests running master in CI with specific dapr version (#1461)
Browse files Browse the repository at this point in the history
* Fix tests running master in CI with specific dapr version

Signed-off-by: Anton Troshin <anton@diagrid.io>

* move env version load into common

Signed-off-by: Anton Troshin <anton@diagrid.io>

* fix k8s test files

Signed-off-by: Anton Troshin <anton@diagrid.io>

* Revert "fix k8s test files"

This reverts commit 344867d.

Signed-off-by: Anton Troshin <anton@diagrid.io>

* Revert "move env version load into common"

This reverts commit 39e8c8c.

Signed-off-by: Anton Troshin <anton@diagrid.io>

* Revert "Fix tests running master in CI with specific dapr version"

This reverts commit a02c81f.

Signed-off-by: Anton Troshin <anton@diagrid.io>

* Add GetRuntimeVersion to be able to compare semver dapr versions for conditional tests
Use GetRuntimeVersion in test

Signed-off-by: Anton Troshin <anton@diagrid.io>

---------

Signed-off-by: Anton Troshin <anton@diagrid.io>
  • Loading branch information
antontroshin authored Nov 8, 2024
1 parent 8cd81b0 commit 6d5e64d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
9 changes: 8 additions & 1 deletion tests/e2e/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
17 changes: 13 additions & 4 deletions tests/e2e/standalone/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"runtime"
"testing"

"github.com/dapr/cli/tests/e2e/common"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -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.
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 6d5e64d

Please sign in to comment.