From 43d595b7f3c84b05d1243d02917d5c9f5f497d9b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 17 Jun 2016 00:24:14 +0900 Subject: [PATCH] integration: Add tests for healthmon --- integration-tests/nghttpx_http1_test.go | 19 +++++++++++++++++++ integration-tests/nghttpx_http2_test.go | 19 +++++++++++++++++++ integration-tests/nghttpx_spdy_test.go | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/integration-tests/nghttpx_http1_test.go b/integration-tests/nghttpx_http1_test.go index 5a5e2f8e..d93877a1 100644 --- a/integration-tests/nghttpx_http1_test.go +++ b/integration-tests/nghttpx_http1_test.go @@ -942,3 +942,22 @@ backend=127.0.0.1,3011 t.Errorf("apiResp.Status: %v; want %v", got, want) } } + +// TestH1Healthmon tests health monitor endpoint. +func TestH1Healthmon(t *testing.T) { + st := newServerTesterConnectPort([]string{"-f127.0.0.1,3011;healthmon;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) { + t.Fatalf("request should not be forwarded") + }, 3011) + defer st.Close() + + res, err := st.http1(requestParam{ + name: "TestH1Healthmon", + path: "/alpha/bravo", + }) + if err != nil { + t.Fatalf("Error st.http1() = %v", err) + } + if got, want := res.status, 200; got != want { + t.Errorf("res.status: %v; want %v", got, want) + } +} diff --git a/integration-tests/nghttpx_http2_test.go b/integration-tests/nghttpx_http2_test.go index 307fa61e..86036865 100644 --- a/integration-tests/nghttpx_http2_test.go +++ b/integration-tests/nghttpx_http2_test.go @@ -1992,3 +1992,22 @@ backend=127.0.0.1,3011 t.Errorf("apiResp.Status: %v; want %v", got, want) } } + +// TestH2Healthmon tests health monitor endpoint. +func TestH2Healthmon(t *testing.T) { + st := newServerTesterConnectPort([]string{"-f127.0.0.1,3011;healthmon;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) { + t.Fatalf("request should not be forwarded") + }, 3011) + defer st.Close() + + res, err := st.http2(requestParam{ + name: "TestH2Healthmon", + path: "/alpha/bravo", + }) + if err != nil { + t.Fatalf("Error st.http2() = %v", err) + } + if got, want := res.status, 200; got != want { + t.Errorf("res.status: %v; want %v", got, want) + } +} diff --git a/integration-tests/nghttpx_spdy_test.go b/integration-tests/nghttpx_spdy_test.go index f2073cd4..4bb3b0f1 100644 --- a/integration-tests/nghttpx_spdy_test.go +++ b/integration-tests/nghttpx_spdy_test.go @@ -623,3 +623,22 @@ backend=127.0.0.1,3011 t.Errorf("apiResp.Status: %v; want %v", got, want) } } + +// TestS3Healthmon tests health monitor endpoint. +func TestS3Healthmon(t *testing.T) { + st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3011;healthmon"}, t, func(w http.ResponseWriter, r *http.Request) { + t.Fatalf("request should not be forwarded") + }, 3011) + defer st.Close() + + res, err := st.spdy(requestParam{ + name: "TestS3Healthmon", + path: "/alpha/bravo", + }) + if err != nil { + t.Fatalf("Error st.spdy() = %v", err) + } + if got, want := res.status, 200; got != want { + t.Errorf("res.status: %v; want %v", got, want) + } +}