consul/connect: use block not optional for opaque map (#15765)

This commit is contained in:
Seth Hoenig
2023-01-12 10:39:10 -06:00
committed by GitHub
parent 4698d8da79
commit 7d2726d887
3 changed files with 60 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/helper/pointer"
"github.com/hashicorp/nomad/jobspec"
"github.com/shoenig/test/must"
"github.com/stretchr/testify/require"
)
@@ -63,6 +64,21 @@ func TestEquivalentToHCL1_ComplexConfig(t *testing.T) {
require.Equal(t, job1, job2)
}
func TestParse_ConnectJob(t *testing.T) {
ci.Parallel(t)
name := "./test-fixtures/connect-example.hcl"
f, err := os.Open(name)
must.NoError(t, err)
t.Cleanup(func() { _ = f.Close() })
job2, err := Parse(name, f)
must.NoError(t, err)
timeout := job2.TaskGroups[0].Services[0].Connect.SidecarService.Proxy.Upstreams[0].Config["connect_timeout_ms"]
must.Eq(t, 9999, timeout)
}
func TestParse_VarsAndFunctions(t *testing.T) {
ci.Parallel(t)

View File

@@ -0,0 +1,43 @@
job "web" {
datacenters = ["dc1"]
group "web" {
network {
mode = "bridge"
port "http" {
static = 80
to = 8080
}
}
service {
name = "website"
port = "8080"
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "database"
local_bind_port = 5432
config {
connect_timeout_ms = 9999
}
}
}
}
}
}
task "httpserver" {
driver = "docker"
env {
COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_database}"
}
config {
image = "hashicorp/website:v1"
auth_soft_fail = true
}
}
}
}