From a81fbbf00f825071afb773ef80ab1784b92e8f97 Mon Sep 17 00:00:00 2001 From: Vault Automation Date: Fri, 8 May 2026 06:08:26 -0600 Subject: [PATCH] Backport tests: fix failing dev server command test into release/2.x.x+ent into ce/release/2.x.x (#14279) * tests: fix failing dev server command test (#14255) (#14267) Test was failing because the global prometheus registry doesn't allow duplicate registrations. We don't need prometheus in server command tests, so we disable it. Co-authored-by: John-Michael Faircloth * fix test build --------- Co-authored-by: John-Michael Faircloth Co-authored-by: JM Faircloth --- command/server_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/command/server_test.go b/command/server_test.go index 9c2f1eb42c..da91b78c98 100644 --- a/command/server_test.go +++ b/command/server_test.go @@ -17,6 +17,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "regexp" "strings" "sync" @@ -328,7 +329,31 @@ func TestServer(t *testing.T) { // TestServer_DevTLS verifies that a vault server starts up correctly with the -dev-tls flag func TestServer_DevTLS(t *testing.T) { ui, cmd := testServerCommand(t) - args := []string{"-dev-tls", "-dev-listen-address=127.0.0.1:0", "-test-server-config"} + + // testConfig is used to disable prometheus to avoid issues with the + // global prometheus registry in tests + testConfig := ` + storage "inmem" {} + listener "tcp" { + address = "127.0.0.1:0" + tls_disable = true + } + disable_mlock = true + telemetry { + prometheus_retention_time = "0s" + disable_hostname = true + } +` + configPath := filepath.Join(t.TempDir(), "config.hcl") + err := os.WriteFile(configPath, []byte(testConfig), 0o644) + require.NoError(t, err) + + args := []string{ + "-dev-tls", + "-dev-listen-address=127.0.0.1:0", + "-test-server-config", + "-config=" + configPath, + } retCode := cmd.Run(args) output := ui.ErrorWriter.String() + ui.OutputWriter.String() require.Equal(t, 0, retCode, output)