From 2d4977a8c9ef7443c2868f6d99bc8941c8854a3d Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 24 Nov 2021 15:37:26 -0500 Subject: [PATCH] config: fix test-only failures in UI handler setup The `TestHTTPServer_Limits_Error` test never starts the agent so it had an incomplete configuration, which caused panics in the test. Fix the configuration. The PR #11555 had a branch name like `f-ui-*` which caused CI to skip the unit tests over the HTTP handler setup, so this wasn't caught in PR review. --- command/agent/http.go | 1 + command/agent/http_test.go | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/command/agent/http.go b/command/agent/http.go index 6371873d0e60..c94e5706034e 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -119,6 +119,7 @@ func NewHTTPServer(agent *Agent, config *Config) (*HTTPServer, error) { Addr: ln.Addr().String(), wsUpgrader: wsUpgrader, } + srv.registerHandlers(config.EnableDebug) // Handle requests with gzip compression diff --git a/command/agent/http_test.go b/command/agent/http_test.go index 3871ac1a9867..6083779d2a41 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -944,11 +944,6 @@ func TestHTTPServer_Limits_Error(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() - // Use a fake agent since the HTTP server should never start - agent := &Agent{ - logger: testlog.HCLogger(t), - } - conf := &Config{ normalizedAddrs: &Addresses{ HTTP: "localhost:0", // port is never used @@ -962,6 +957,13 @@ func TestHTTPServer_Limits_Error(t *testing.T) { }, } + // Use a fake agent since the HTTP server should never start + agent := &Agent{ + logger: testlog.HCLogger(t), + httpLogger: testlog.HCLogger(t), + config: conf, + } + srv, err := NewHTTPServer(agent, conf) require.Error(t, err) require.Nil(t, srv)