From 5e809acd875152a47c36639da2ad227c5a5bc49c Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 29 Oct 2020 15:09:38 +0100 Subject: [PATCH 1/3] Use OS-dependant pathListSeparator, when appending to PATH Signed-off-by: Guillaume Tardif --- cli/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/main.go b/cli/main.go index 6a717ed5..3f685e7f 100644 --- a/cli/main.go +++ b/cli/main.go @@ -73,7 +73,7 @@ func init() { if err != nil { fatal(errors.Wrap(err, "unable to get absolute bin path")) } - if err := os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), path)); err != nil { + if err := os.Setenv("PATH", fmt.Sprintf("%s%s%s", os.Getenv("PATH"), os.PathListSeparator, path)); err != nil { panic(err) } // Seed random From b604ba624699e4fbccf5382b270bccad3a678f32 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 29 Oct 2020 15:22:44 +0100 Subject: [PATCH 2/3] Fix 2 corner cases with PATH settings * windows PATH should use windows separator (;) * do not add separator if initial PATH is empty (was creating PATH=:/path) Signed-off-by: Guillaume Tardif --- cli/main.go | 11 ++++++++++- cli/main_test.go | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cli/main.go b/cli/main.go index 3f685e7f..13ea7911 100644 --- a/cli/main.go +++ b/cli/main.go @@ -24,6 +24,7 @@ import ( "os/signal" "path/filepath" "regexp" + "strings" "syscall" "time" @@ -73,13 +74,21 @@ func init() { if err != nil { fatal(errors.Wrap(err, "unable to get absolute bin path")) } - if err := os.Setenv("PATH", fmt.Sprintf("%s%s%s", os.Getenv("PATH"), os.PathListSeparator, path)); err != nil { + + if err := os.Setenv("PATH", appendPaths(os.Getenv("PATH"), path)); err != nil { panic(err) } // Seed random rand.Seed(time.Now().UnixNano()) } +func appendPaths(envPath string, path string) string { + if envPath == "" { + return path + } + return strings.Join([]string{envPath, path}, string(os.PathListSeparator)) +} + func isContextAgnosticCommand(cmd *cobra.Command) bool { if cmd == nil { return false diff --git a/cli/main_test.go b/cli/main_test.go index c151ce0d..20426de3 100644 --- a/cli/main_test.go +++ b/cli/main_test.go @@ -69,3 +69,8 @@ func TestCheckOwnCommand(t *testing.T) { assert.Assert(t, !isContextAgnosticCommand(cmd.LogsCommand())) assert.Assert(t, !isContextAgnosticCommand(cmd.PsCommand())) } + +func TestAppendPaths(t *testing.T) { + assert.Equal(t, appendPaths("", "/bin/path"), "/bin/path") + assert.Equal(t, appendPaths("path1", "binaryPath"), "path1"+string(os.PathListSeparator)+"binaryPath") +} From a78cc47b1c0b1dda677c9e059ec063c1c874a126 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 29 Oct 2020 17:23:10 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Use=20HttpgetWithRetry()=20that=E2=80=99ll?= =?UTF-8?q?=20set=20timeout=20for=20each=20retry=20and=20not=20freeze=20on?= =?UTF-8?q?=20he=20first=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guillaume Tardif --- tests/aci-e2e/e2e-aci_test.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index 9e77e257..759afb19 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -434,14 +434,7 @@ func TestContainerRunAttached(t *testing.T) { endpoint = fmt.Sprintf("http://%s:%d", fqdn, port.HostPort) assert.Assert(t, !strings.Contains(followLogsProcess.Stdout(), "/test")) - checkRequest := func(t poll.LogT) poll.Result { - r, _ := http.Get(endpoint + "/test") - if r != nil && r.StatusCode == http.StatusNotFound { - return poll.Success() - } - return poll.Continue("waiting for container to serve request") - } - poll.WaitOn(t, checkRequest, poll.WithDelay(1*time.Second), poll.WithTimeout(60*time.Second)) + HTTPGetWithRetry(t, endpoint+"/test", http.StatusNotFound, 2*time.Second, 60*time.Second) checkLog := func(t poll.LogT) poll.Result { if strings.Contains(followLogsProcess.Stdout(), "/test") {