From 871c2e67040011fe49e443dcf9354aa40d3c792c Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Sun, 19 May 2019 14:07:02 -0700 Subject: [PATCH] Better clean up after tesdt proxy setup --- test/integration/addons_test.go | 2 +- test/integration/proxy_test.go | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/test/integration/addons_test.go b/test/integration/addons_test.go index 8243d4a39..748894f2e 100644 --- a/test/integration/addons_test.go +++ b/test/integration/addons_test.go @@ -73,7 +73,7 @@ func readLineWithTimeout(b *bufio.Reader, timeout time.Duration) (string, error) } func testDashboard(t *testing.T) { - // t.Parallel() + t.Parallel() minikubeRunner := NewMinikubeRunner(t) cmd, out := minikubeRunner.RunDaemon("dashboard --url") defer func() { diff --git a/test/integration/proxy_test.go b/test/integration/proxy_test.go index 2d001548f..d6bad5dcb 100644 --- a/test/integration/proxy_test.go +++ b/test/integration/proxy_test.go @@ -61,26 +61,29 @@ func setUpProxy(t *testing.T) (*http.Server, error) { } func TestProxy(t *testing.T) { + origHP := os.Getenv("HTTP_PROXY") + origNP := os.Getenv("NO_PROXY") srv, err := setUpProxy(t) - defer func(t *testing.T) { - err := srv.Shutdown(context.TODO()) // shutting down the http proxy after tests + if err != nil { + t.Fatalf("Failed to set up the test proxy: %s", err) + } + + defer func(t *testing.T) { // Clean up after setting up proxy + err = os.Setenv("HTTP_PROXY", origHP) if err != nil { - t.Errorf("Error shutting down the http proxy") + t.Errorf("Error reverting the HTTP_PROXY env") } - err = os.Setenv("HTTP_PROXY", "") + err = os.Setenv("NO_PROCY", origNP) if err != nil { t.Errorf("Error reverting the HTTP_PROXY env") } - err = os.Setenv("HTTPS_PROXY", "") + + err := srv.Shutdown(context.TODO()) // shutting down the http proxy after tests if err != nil { - t.Errorf("Error reverting the HTTPS_PROXY env") + t.Errorf("Error shutting down the http proxy") } - }(t) - if err != nil { - t.Fatalf("Failed to set up the test proxy: %s", err) - } t.Run("ConsoleWarnning", testProxyWarning) t.Run("DashboardProxy", testDashboard) -- GitLab