failing test for #6310

This commit is contained in:
Tim Gross 2019-09-12 12:00:21 -04:00
parent 53d3ea8ebd
commit e86a476bbb
3 changed files with 119 additions and 53 deletions

61
e2e/connect/client.go Normal file
View File

@ -0,0 +1,61 @@
package connect
import (
"os"
capi "github.com/hashicorp/consul/api"
"github.com/hashicorp/nomad/e2e/e2eutil"
"github.com/hashicorp/nomad/e2e/framework"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/stretchr/testify/require"
)
type ConnectClientStateE2ETest struct {
framework.TC
jobIds []string
}
func (tc *ConnectClientStateE2ETest) BeforeAll(f *framework.F) {
e2eutil.WaitForLeader(f.T(), tc.Nomad())
e2eutil.WaitForNodesReady(f.T(), tc.Nomad(), 1)
}
func (tc *ConnectClientStateE2ETest) AfterEach(f *framework.F) {
if os.Getenv("NOMAD_TEST_SKIPCLEANUP") == "1" {
return
}
for _, id := range tc.jobIds {
tc.Nomad().Jobs().Deregister(id, true, nil)
}
tc.jobIds = []string{}
tc.Nomad().System().GarbageCollect()
}
func (tc *ConnectClientStateE2ETest) TestClientRestart(f *framework.F) {
t := f.T()
require := require.New(t)
jobID := "connect" + uuid.Generate()[0:8]
tc.jobIds = append(tc.jobIds, jobID)
client := tc.Nomad()
consulClient := tc.Consul()
allocs := e2eutil.RegisterAndWaitForAllocs(t, client,
"connect/input/demo.nomad", jobID)
require.Equal(2, len(allocs))
e2eutil.RequireConsulStatus(require, consulClient,
"count-api-sidecar-proxy", capi.HealthPassing)
nodeID := allocs[0].NodeID
restartID, err := e2eutil.AgentRestart(client, nodeID)
if restartID != "" {
tc.jobIds = append(tc.jobIds, restartID)
}
if err != nil {
t.Skip("node cannot be restarted: %v", err)
}
e2eutil.RequireConsulStatus(require, consulClient,
"count-api-sidecar-proxy", capi.HealthPassing)
}

View File

@ -27,6 +27,7 @@ func init() {
Consul: true,
Cases: []framework.TestCase{
new(ConnectE2ETest),
new(ConnectClientStateE2ETest),
},
})
}

View File

@ -1,61 +1,65 @@
job "countdash" {
datacenters = ["dc1"]
job "countdash" {
datacenters = ["dc1"]
group "api" {
network {
mode = "bridge"
}
group "api" {
network {
mode = "bridge"
}
service {
name = "count-api"
port = "9001"
service {
name = "count-api"
port = "9001"
connect {
sidecar_service {}
}
}
connect {
sidecar_service {}
}
}
task "web" {
driver = "docker"
config {
image = "hashicorpnomad/counter-api:v1"
}
}
}
task "web" {
driver = "docker"
group "dashboard" {
network {
mode ="bridge"
port "http" {
static = 9002
to = 9002
}
}
config {
image = "hashicorpnomad/counter-api:v1"
}
}
}
service {
name = "count-dashboard"
port = "9002"
group "dashboard" {
network {
mode = "bridge"
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "count-api"
local_bind_port = 8080
}
}
}
}
}
port "http" {
static = 9002
to = 9002
}
}
task "dashboard" {
driver = "docker"
env {
COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
}
config {
image = "hashicorpnomad/counter-dashboard:v1"
}
}
}
}
service {
name = "count-dashboard"
port = "9002"
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "count-api"
local_bind_port = 8080
}
}
}
}
}
task "dashboard" {
driver = "docker"
env {
COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
}
config {
image = "hashicorpnomad/counter-dashboard:v1"
}
}
}
}