From d0f3a1e36c8864f692f4b201376cc6e70d5d4873 Mon Sep 17 00:00:00 2001 From: Pavel Valodzka Date: Thu, 20 Apr 2023 15:12:04 +0300 Subject: [PATCH] fix agent endpoint test, add test --- client/taskenv/env_test.go | 15 +++++++++++++++ command/agent/agent_endpoint_test.go | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/client/taskenv/env_test.go b/client/taskenv/env_test.go index 6cbbdc6e126..83ef863b294 100644 --- a/client/taskenv/env_test.go +++ b/client/taskenv/env_test.go @@ -192,6 +192,18 @@ func TestEnvironment_AsList(t *testing.T) { }, }, } + a.AllocatedResources.Tasks["mail"] = &structs.AllocatedTaskResources{ + Networks: []*structs.NetworkResource{ + { + Device: "eth0", + IP: "fd12:3456:789a:1::1", + MBits: 50, + ReservedPorts: []structs.Port{ + {Label: "ipv6", Value: 2222}, + }, + }, + }, + } a.Namespace = "not-default" task := a.Job.TaskGroups[0].Tasks[0] task.Env = map[string]string{ @@ -220,6 +232,9 @@ func TestEnvironment_AsList(t *testing.T) { "NOMAD_IP_ssh_ssh=192.168.0.100", "NOMAD_PORT_ssh_other=1234", "NOMAD_PORT_ssh_ssh=22", + "NOMAD_ADDR_mail_ipv6=[fd12:3456:789a:1::1]:2222", + "NOMAD_IP_mail_ipv6=fd12:3456:789a:1::1", + "NOMAD_PORT_mail_ipv6=2222", "NOMAD_CPU_LIMIT=500", "NOMAD_CPU_CORES=0,5-7", "NOMAD_DC=dc1", diff --git a/command/agent/agent_endpoint_test.go b/command/agent/agent_endpoint_test.go index a22b456df24..f2628a3bf4b 100644 --- a/command/agent/agent_endpoint_test.go +++ b/command/agent/agent_endpoint_test.go @@ -15,6 +15,7 @@ import ( "net/url" "os" "reflect" + "strconv" "strings" "sync" "syscall" @@ -158,7 +159,7 @@ func TestHTTP_AgentJoin(t *testing.T) { httpTest(t, nil, func(s *TestAgent) { // Determine the join address member := s.Agent.Server().LocalMember() - addr := net.JoinHostPort("%s:%d", member.Addr, member.Port) + addr := net.JoinHostPort(string(member.Addr), strconv.Itoa(int(member.Port))) // Make the HTTP request req, err := http.NewRequest("PUT",