github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/e2e/connect/client.go (about) 1 package connect 2 3 import ( 4 "os" 5 6 capi "github.com/hashicorp/consul/api" 7 "github.com/hashicorp/nomad/e2e/e2eutil" 8 "github.com/hashicorp/nomad/e2e/framework" 9 "github.com/hashicorp/nomad/helper/uuid" 10 "github.com/stretchr/testify/require" 11 ) 12 13 type ConnectClientStateE2ETest struct { 14 framework.TC 15 jobIds []string 16 } 17 18 func (tc *ConnectClientStateE2ETest) BeforeAll(f *framework.F) { 19 e2eutil.WaitForLeader(f.T(), tc.Nomad()) 20 e2eutil.WaitForNodesReady(f.T(), tc.Nomad(), 1) 21 } 22 23 func (tc *ConnectClientStateE2ETest) AfterEach(f *framework.F) { 24 if os.Getenv("NOMAD_TEST_SKIPCLEANUP") == "1" { 25 return 26 } 27 28 for _, id := range tc.jobIds { 29 tc.Nomad().Jobs().Deregister(id, true, nil) 30 } 31 tc.jobIds = []string{} 32 tc.Nomad().System().GarbageCollect() 33 } 34 35 func (tc *ConnectClientStateE2ETest) TestClientRestart(f *framework.F) { 36 t := f.T() 37 require := require.New(t) 38 jobID := "connect" + uuid.Generate()[0:8] 39 tc.jobIds = append(tc.jobIds, jobID) 40 client := tc.Nomad() 41 consulClient := tc.Consul() 42 43 allocs := e2eutil.RegisterAndWaitForAllocs(t, client, 44 "connect/input/demo.nomad", jobID, "") 45 require.Equal(2, len(allocs)) 46 47 e2eutil.RequireConsulStatus(require, consulClient, 48 "count-api-sidecar-proxy", capi.HealthPassing) 49 nodeID := allocs[0].NodeID 50 51 restartID, err := e2eutil.AgentRestart(client, nodeID) 52 if restartID != "" { 53 tc.jobIds = append(tc.jobIds, restartID) 54 } 55 if err != nil { 56 t.Skip("node cannot be restarted", err) 57 } 58 59 e2eutil.RequireConsulStatus(require, consulClient, 60 "count-api-sidecar-proxy", capi.HealthPassing) 61 }