From aa197cf824bbe5a670317f3b2826aa2c29494a77 Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Thu, 4 Jan 2024 08:52:39 +0100 Subject: [PATCH] e2e: pass Nomad address to Consul WI test (#19603) --- e2e/consul/consul_test.go | 4 +++- e2e/consul/consul_wi_test.go | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/e2e/consul/consul_test.go b/e2e/consul/consul_test.go index 2f8675efe..dbdafe3ed 100644 --- a/e2e/consul/consul_test.go +++ b/e2e/consul/consul_test.go @@ -19,5 +19,7 @@ func TestConsul(t *testing.T) { t.Run("testServiceReversion", testServiceReversion) t.Run("testAllocRestart", testAllocRestart) - t.Run("testConsulWI", testConsulWI_Service_and_Task) + + consulWITest := ConsulWITest{nomad.Address()} + t.Run("testConsulWI", consulWITest.testConsulWIServiceAndTask) } diff --git a/e2e/consul/consul_wi_test.go b/e2e/consul/consul_wi_test.go index 0502a9b19..9a549c2ad 100644 --- a/e2e/consul/consul_wi_test.go +++ b/e2e/consul/consul_wi_test.go @@ -5,6 +5,7 @@ package consul import ( "context" + "fmt" "testing" "github.com/hashicorp/nomad/e2e/e2eutil" @@ -13,12 +14,16 @@ import ( "github.com/shoenig/test/must" ) +type ConsulWITest struct { + nomadAddress string +} + // testConsulWI_Service_and_Task asserts we can -// - consigure Consul correctly with setup consul -y command +// - configure Consul correctly with setup consul -y command // - run a job with a service and a task // - make sure the expected service is registered in Consul // - get Consul token written to a task secret directory -func testConsulWI_Service_and_Task(t *testing.T) { +func (tc *ConsulWITest) testConsulWIServiceAndTask(t *testing.T) { const jobFile = "./input/consul_wi_example.nomad" jobID := "consul-wi-" + uuid.Short() jobIDs := []string{jobID} @@ -31,7 +36,8 @@ func testConsulWI_Service_and_Task(t *testing.T) { // Run the setup helper that should configure Consul ACL with default // policies, roles, auth method and binding rules. - _, err := e2eutil.Command("nomad", "setup", "consul", "-y") + jwksURL := fmt.Sprintf("%s/.well-known/jwks.json", tc.nomadAddress) + _, err := e2eutil.Command("nomad", "setup", "consul", "-y", "-jwks-url", jwksURL) must.NoError(t, err) // register a job