mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
consul/connect: use block not optional for opaque map (#15765)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
43
jobspec2/test-fixtures/connect-example.hcl
Normal file
43
jobspec2/test-fixtures/connect-example.hcl
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user