Skip to content

Commit

Permalink
Fix standalone e2e tests
Browse files Browse the repository at this point in the history
Fix podman e2e install
Fix scheduler start failure on standalone mariner image variant

Signed-off-by: Anton Troshin <[email protected]>
  • Loading branch information
antontroshin committed Sep 12, 2024
1 parent e08443b commit dbfa27a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/kind_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ jobs:
name: E2E tests for K8s (KinD)
runs-on: ubuntu-latest
env:
DAPR_RUNTIME_PINNED_VERSION: 1.13.0-rc.2
DAPR_RUNTIME_PINNED_VERSION: 1.13.5
DAPR_DASHBOARD_PINNED_VERSION: 0.14.0
DAPR_RUNTIME_LATEST_STABLE_VERSION:
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
DAPR_TGZ: dapr-1.13.0-rc.2.tgz
strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/self_hosted_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
DAPR_RUNTIME_LATEST_STABLE_VERSION: ""
DAPR_DASHBOARD_LATEST_STABLE_VERSION: ""
GOLANG_PROTOBUF_REGISTRATION_CONFLICT: warn
PODMAN_VERSION: 4.4.4
PODMAN_VERSION: 4.9.3
strategy:
# TODO: Remove this when our E2E tests are stable for podman on MacOS.
fail-fast: false # Keep running if one leg fails.
Expand Down
6 changes: 5 additions & 1 deletion pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,11 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn
)
}

args = append(args, image, "--etcd-data-dir=/var/lock/dapr/scheduler")
if strings.EqualFold(info.imageVariant, "mariner") {
args = append(args, image, "--etcd-data-dir=/var/tmp/dapr/scheduler")
} else {
args = append(args, image, "--etcd-data-dir=/var/lock/dapr/scheduler")
}

_, err = utils.RunCmdAndWait(runtimeCmd, args...)
if err != nil {
Expand Down
15 changes: 8 additions & 7 deletions tests/e2e/standalone/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,17 @@ func TestStandaloneInit(t *testing.T) {
placementPort = 6050
}

verifyTCPLocalhost(t, placementPort)
verifyTCPLocalhost(t, placementPort)
})

t.Run("init version with scheduler", func(t *testing.T) {
// Ensure a clean environment
must(t, cmdUninstall, "failed to uninstall Dapr")

latestDaprRuntimeVersion, latestDaprDashboardVersion := common.GetVersionsFromEnv(t, true)

args := []string{
"--runtime-version", "1.14.0-rc.3",
"--runtime-version", latestDaprRuntimeVersion,
"--dev",
}
output, err := cmdInit(args...)
Expand All @@ -189,9 +191,8 @@ func TestStandaloneInit(t *testing.T) {
daprPath := filepath.Join(homeDir, ".dapr")
require.DirExists(t, daprPath, "Directory %s does not exist", daprPath)

_, latestDaprDashboardVersion := common.GetVersionsFromEnv(t, true)
verifyContainers(t, "1.14.0-rc.3")
verifyBinaries(t, daprPath, "1.14.0-rc.3", latestDaprDashboardVersion)
verifyContainers(t, latestDaprRuntimeVersion)
verifyBinaries(t, daprPath, latestDaprRuntimeVersion, latestDaprDashboardVersion)
verifyConfigs(t, daprPath)

placementPort := 50005
Expand All @@ -201,8 +202,8 @@ func TestStandaloneInit(t *testing.T) {
schedulerPort = 6060
}

verifyTCPLocalhost(t, placementPort)
verifyTCPLocalhost(t, schedulerPort)
verifyTCPLocalhost(t, placementPort)
verifyTCPLocalhost(t, schedulerPort)
})

t.Run("init without runtime-version flag with mariner images", func(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/standalone/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ func TestStandaloneList(t *testing.T) {
t.Log(output)
require.NoError(t, err, "expected no error status on list")
require.Equal(t, "No Dapr instances found.\n", output)

// This test is skipped on Windows, but just in case, try to terminate dashboard process only on non-Windows OSs
// stopProcess uses kill command, won't work on windows
if runtime.GOOS != "windows" {
err = stopProcess("dashboard", "--port", "5555")
require.NoError(t, err, "failed to stop dashboard process")
}
})
}

Expand Down
32 changes: 32 additions & 0 deletions tests/e2e/standalone/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,35 @@ func containerRuntime() string {
}
return ""
}

func getRunningProcesses() []string {
cmd := exec.Command("ps", "-o", "pid,command")
output, err := cmd.Output()
if err != nil {
return nil
}

processes := strings.Split(string(output), "\n")

// clean the process output whitespace
for i, process := range processes {
processes[i] = strings.TrimSpace(process)
}
return processes
}

func stopProcess(args ...string) error {
processCommand := strings.Join(args, " ")
processes := getRunningProcesses()
for _, process := range processes {
if strings.Contains(process, processCommand) {
processSplit := strings.SplitN(process, " ", 2)
cmd := exec.Command("kill", "-9", processSplit[0])
err := cmd.Run()
if err != nil {
return err
}
}
}
return nil
}

0 comments on commit dbfa27a

Please sign in to comment.