Skip to content

Commit

Permalink
Assimilate TestGenericQuitOnly
Browse files Browse the repository at this point in the history
Update the test to be consistent with other tests.
  • Loading branch information
kvij committed Oct 1, 2023
1 parent 0034c0a commit 41e6e17
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ func initTestingEnv() {

// Reset all the environment variables
func clearTestingEnv() {
os.Setenv("START_WITHOUT_ENVOY", "")
os.Setenv("ENVOY_ADMIN_API", "")
os.Setenv("QUIT_WITHOUT_ENVOY_TIMEOUT", "")
os.Setenv("WAIT_FOR_ENVOY_TIMEOUT", "")
os.Setenv("GENERIC_QUIT_ENDPOINTS", "")
os.Setenv("QUIT_REQUEST_TIMEOUT", "")
os.Unsetenv("START_WITHOUT_ENVOY")
os.Unsetenv("ENVOY_ADMIN_API")
os.Unsetenv("QUIT_WITHOUT_ENVOY_TIMEOUT")
os.Unsetenv("WAIT_FOR_ENVOY_TIMEOUT")
os.Unsetenv("GENERIC_QUIT_ONLY")
os.Unsetenv("GENERIC_QUIT_ENDPOINTS")
os.Unsetenv("QUIT_REQUEST_TIMEOUT")
callCount = 0
}

Expand Down Expand Up @@ -167,19 +168,17 @@ func TestGenericQuitEndpoints(t *testing.T) {

// Tests GenericQuitOnly triggers GenericQuitEndpoints
func TestGenericQuitOnly(t *testing.T) {
var quitEndpointCalled bool
fmt.Println("Starting TestGenericQuitOnly")
checkCallServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
quitEndpointCalled = true
}))
os.Setenv("ENVOY_ADMIN_API", goodServer.URL)
os.Setenv("ISTIO_QUIT_API", genericQuitServer.URL)
os.Setenv("GENERIC_QUIT_ONLY", "true")
os.Setenv("GENERIC_QUIT_ENDPOINTS", fmt.Sprintf("http://%s", checkCallServer.Listener.Addr().String()))
os.Setenv("GENERIC_QUIT_ENDPOINTS", genericQuitServer.URL)
initTestingEnv()
defer clearTestingEnv()
kill(0)
if quitEndpointCalled == false {
if callCount != 1 {
t.Error("Expected GENERIC_QUIT_ONLY to trigger GENERIC_QUIT_ENDPOINTS")
}
checkCallServer.Close()
}

// Tests scuttle does not fail when the /quitquitquit endpoint does not return a response
Expand Down

0 comments on commit 41e6e17

Please sign in to comment.