From 261bcecf0be3e250f63026524252c5507cbd834b Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Wed, 17 Jul 2024 18:35:32 -0300 Subject: [PATCH] Add E2E to validate scheduler after init. Signed-off-by: Artur Souza --- tests/e2e/standalone/init_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/e2e/standalone/init_test.go b/tests/e2e/standalone/init_test.go index 14a688bc2..a73715472 100644 --- a/tests/e2e/standalone/init_test.go +++ b/tests/e2e/standalone/init_test.go @@ -18,9 +18,11 @@ package standalone_test import ( "context" + "net" "os" "path/filepath" "runtime" + "strconv" "strings" "testing" @@ -157,6 +159,16 @@ func TestStandaloneInit(t *testing.T) { verifyContainers(t, latestDaprRuntimeVersion) verifyBinaries(t, daprPath, latestDaprRuntimeVersion, latestDaprDashboardVersion) verifyConfigs(t, daprPath) + + placementPort := 50005 + schedulerPort := 50006 + if runtime.GOOS == "windows" { + placementPort = 6050 + schedulerPort = 6060 + } + + verifyTCPLocalhost(t, placementPort) + verifyTCPLocalhost(t, schedulerPort) }) t.Run("init without runtime-version flag with mariner images", func(t *testing.T) { @@ -353,3 +365,14 @@ func verifyConfigs(t *testing.T, daprPath string) { }) } } + +// verifyTCPLocalhost verifies a given localhost TCP port is being listened to. +func verifyTCPLocalhost(t *testing.T, port int) { + // Check that the server is up and can accept connections. + endpoint := "127.0.0.1:" + strconv.Itoa(port) + conn, err := net.Dial("tcp", endpoint) + if err != nil { + t.Error("could not connect to "+endpoint, err) + } + defer conn.Close() +}