From 15f190a09996b8683b92933ccb8bcc24e3a1a948 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Tue, 16 Mar 2021 09:47:21 -0500 Subject: [PATCH] taskenv: update environment test expectation Also remove old version of same test, marked for removal after 0.11 --- client/taskenv/env_test.go | 118 +------------------------------------ 1 file changed, 1 insertion(+), 117 deletions(-) diff --git a/client/taskenv/env_test.go b/client/taskenv/env_test.go index da9edc18e7c5..7bc43fdc0d64 100644 --- a/client/taskenv/env_test.go +++ b/client/taskenv/env_test.go @@ -211,123 +211,7 @@ func TestEnvironment_AsList(t *testing.T) { fmt.Sprintf("NOMAD_JOB_PARENT_ID=%s", a.Job.ParentID), fmt.Sprintf("NOMAD_ALLOC_ID=%s", a.ID), "NOMAD_ALLOC_INDEX=0", - } - sort.Strings(act) - sort.Strings(exp) - require.Equal(t, exp, act) -} - -// COMPAT(0.11): Remove in 0.11 -func TestEnvironment_AsList_Old(t *testing.T) { - n := mock.Node() - n.Meta = map[string]string{ - "metaKey": "metaVal", - } - a := mock.Alloc() - a.AllocatedResources = nil - a.Resources = &structs.Resources{ - CPU: 500, - MemoryMB: 256, - DiskMB: 150, - Networks: []*structs.NetworkResource{ - { - Device: "eth0", - IP: "192.168.0.100", - ReservedPorts: []structs.Port{ - {Label: "ssh", Value: 22}, - {Label: "other", Value: 1234}, - }, - MBits: 50, - DynamicPorts: []structs.Port{{Label: "http", Value: 2000}}, - }, - }, - } - a.TaskResources = map[string]*structs.Resources{ - "web": { - CPU: 500, - MemoryMB: 256, - Networks: []*structs.NetworkResource{ - { - Device: "eth0", - IP: "127.0.0.1", - ReservedPorts: []structs.Port{{Label: "https", Value: 8080}}, - MBits: 50, - DynamicPorts: []structs.Port{{Label: "http", Value: 80}}, - }, - }, - }, - } - a.TaskResources["ssh"] = &structs.Resources{ - Networks: []*structs.NetworkResource{ - { - Device: "eth0", - IP: "192.168.0.100", - MBits: 50, - ReservedPorts: []structs.Port{ - {Label: "ssh", Value: 22}, - {Label: "other", Value: 1234}, - }, - }, - }, - } - - // simulate canonicalization on restore or fetch - a.Canonicalize() - - task := a.Job.TaskGroups[0].Tasks[0] - task.Env = map[string]string{ - "taskEnvKey": "taskEnvVal", - } - task.Resources.Networks = []*structs.NetworkResource{ - // Nomad 0.8 didn't fully populate the fields in task Resource Networks - { - IP: "", - ReservedPorts: []structs.Port{{Label: "https"}}, - DynamicPorts: []structs.Port{{Label: "http"}}, - }, - } - env := NewBuilder(n, a, task, "global").SetDriverNetwork( - &drivers.DriverNetwork{PortMap: map[string]int{"https": 443}}, - ) - - act := env.Build().List() - exp := []string{ - "taskEnvKey=taskEnvVal", - "NOMAD_ADDR_http=127.0.0.1:80", - "NOMAD_PORT_http=80", - "NOMAD_IP_http=127.0.0.1", - "NOMAD_ADDR_https=127.0.0.1:8080", - "NOMAD_PORT_https=443", - "NOMAD_IP_https=127.0.0.1", - "NOMAD_HOST_PORT_http=80", - "NOMAD_HOST_PORT_https=8080", - "NOMAD_TASK_NAME=web", - "NOMAD_GROUP_NAME=web", - "NOMAD_ADDR_ssh_other=192.168.0.100:1234", - "NOMAD_ADDR_ssh_ssh=192.168.0.100:22", - "NOMAD_IP_ssh_other=192.168.0.100", - "NOMAD_IP_ssh_ssh=192.168.0.100", - "NOMAD_PORT_ssh_other=1234", - "NOMAD_PORT_ssh_ssh=22", - "NOMAD_CPU_LIMIT=500", - "NOMAD_DC=dc1", - "NOMAD_NAMESPACE=default", - "NOMAD_REGION=global", - "NOMAD_MEMORY_LIMIT=256", - "NOMAD_META_ELB_CHECK_INTERVAL=30s", - "NOMAD_META_ELB_CHECK_MIN=3", - "NOMAD_META_ELB_CHECK_TYPE=http", - "NOMAD_META_FOO=bar", - "NOMAD_META_OWNER=armon", - "NOMAD_META_elb_check_interval=30s", - "NOMAD_META_elb_check_min=3", - "NOMAD_META_elb_check_type=http", - "NOMAD_META_foo=bar", - "NOMAD_META_owner=armon", - fmt.Sprintf("NOMAD_JOB_ID=%s", a.Job.ID), - "NOMAD_JOB_NAME=my-job", - fmt.Sprintf("NOMAD_ALLOC_ID=%s", a.ID), - "NOMAD_ALLOC_INDEX=0", + "NOMAD_ALLOC_NAME=my-job.web[0]", } sort.Strings(act) sort.Strings(exp)