tests: use constructor instead init (#8024)

This commit is contained in:
Hans Hasselberg 2020-06-04 22:59:06 +02:00 committed by GitHub
parent 9fa605f077
commit dfcf45c6cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -651,9 +651,8 @@ func test_createAlias(t *testing.T, agent *TestAgent, chk *structs.CheckType, ex
if c.Check.CheckID == chk.CheckID { if c.Check.CheckID == chk.CheckID {
found = true found = true
assert.Equal(t, expectedResult, c.Check.Status, "Check state should be %s, was %s in %#v", expectedResult, c.Check.Status, c.Check) assert.Equal(t, expectedResult, c.Check.Status, "Check state should be %s, was %s in %#v", expectedResult, c.Check.Status, c.Check)
var srvID structs.ServiceID srvID := structs.NewServiceID(srv.ID, structs.WildcardEnterpriseMeta())
srvID.Init(srv.ID, structs.WildcardEnterpriseMeta()) if err := agent.Agent.State.RemoveService(srvID); err != nil {
if err := agent.Agent.State.RemoveService(structs.ServiceID(srvID)); err != nil {
fmt.Println("[DEBUG] Fail to remove service", srvID, ", err:=", err) fmt.Println("[DEBUG] Fail to remove service", srvID, ", err:=", err)
} }
fmt.Println("[DEBUG] Service Removed", srvID, ", err:=", err) fmt.Println("[DEBUG] Service Removed", srvID, ", err:=", err)
@ -714,8 +713,7 @@ func TestAgent_CheckAliasRPC(t *testing.T) {
err := a.RPC("Catalog.NodeServices", &args, &out) err := a.RPC("Catalog.NodeServices", &args, &out)
assert.NoError(r, err) assert.NoError(r, err)
foundService := false foundService := false
var lookup structs.ServiceID lookup := structs.NewServiceID("svcid1", structs.WildcardEnterpriseMeta())
lookup.Init("svcid1", structs.WildcardEnterpriseMeta())
for _, srv := range out.NodeServices.Services { for _, srv := range out.NodeServices.Services {
sid := srv.CompoundServiceID() sid := srv.CompoundServiceID()
if lookup.Matches(&sid) { if lookup.Matches(&sid) {

View File

@ -144,7 +144,7 @@ func (c *CheckAlias) checkServiceExistsOnRemoteServer(serviceID *structs.Service
args.AllowStale = true args.AllowStale = true
args.EnterpriseMeta = c.EnterpriseMeta args.EnterpriseMeta = c.EnterpriseMeta
// We are late at maximum of 15s compared to leader // We are late at maximum of 15s compared to leader
args.MaxStaleDuration = time.Duration(15 * time.Second) args.MaxStaleDuration = 15 * time.Second
attempts := 0 attempts := 0
RETRY_CALL: RETRY_CALL:
var out structs.IndexedNodeServices var out structs.IndexedNodeServices
@ -172,7 +172,7 @@ func (c *CheckAlias) runQuery(stopCh chan struct{}) {
args.MaxQueryTime = 1 * time.Minute args.MaxQueryTime = 1 * time.Minute
args.EnterpriseMeta = c.EnterpriseMeta args.EnterpriseMeta = c.EnterpriseMeta
// We are late at maximum of 15s compared to leader // We are late at maximum of 15s compared to leader
args.MaxStaleDuration = time.Duration(15 * time.Second) args.MaxStaleDuration = 15 * time.Second
var attempt uint var attempt uint
for { for {