From 6ec6187b1105e4caa2c327c4e464bacda2bf2459 Mon Sep 17 00:00:00 2001 From: Fionera Date: Sat, 23 Sep 2023 00:19:09 +0200 Subject: [PATCH] add e2e test for panic handler --- spop/e2e_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spop/e2e_test.go b/spop/e2e_test.go index 1372783..9e7e4d1 100644 --- a/spop/e2e_test.go +++ b/spop/e2e_test.go @@ -69,6 +69,22 @@ func TestE2E(t *testing.T) { }, backendCfg: "http-request return status 401 if { var(txn.e2e.error) -m found }", }, + { + name: "recover from panic", + hf: func(ctx context.Context, w *encoding.ActionWriter, m *encoding.Message) { + panic("example panic") + }, + tf: func(t *testing.T, config testutil.HAProxyConfig) { + resp, err := http.Get("http://127.0.0.1:" + config.FrontendPort) + if err != nil { + t.Fatal(err) + } + + if resp.StatusCode != http.StatusOK { + t.Fatalf("expected %d; got %d", http.StatusOK, resp.StatusCode) + } + }, + }, } t.Parallel()