-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
only async trigger changes #8778
Changes from 7 commits
ef66dd0
704ddee
84560ab
0a1f586
ac177c6
a970ebd
eb6b8cc
b7e3d4c
770139f
f6d637f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,16 @@ func TestAPI_HealthChecks(t *testing.T) { | |
t.Fatalf("err: %v", err) | ||
} | ||
|
||
retry.Run(t, func(r *retry.R) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait for service to sync to catalog. |
||
services, _, err := c.Catalog().Services(nil) | ||
if err != nil { | ||
r.Fatal(err) | ||
} | ||
if _, ok := services["foo"]; !ok { | ||
r.Fatal("service foo not synced") | ||
} | ||
}) | ||
|
||
retry.Run(t, func(r *retry.R) { | ||
checks := HealthChecks{ | ||
&HealthCheck{ | ||
|
@@ -234,6 +244,7 @@ func TestAPI_HealthChecks(t *testing.T) { | |
if meta.LastIndex == 0 { | ||
r.Fatalf("bad: %v", meta) | ||
} | ||
require.NotEmpty(r, out) | ||
checks[0].CreateIndex = out[0].CreateIndex | ||
checks[0].ModifyIndex = out[0].ModifyIndex | ||
require.Equal(r, checks, out) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,7 +250,6 @@ func NewTestServerConfigT(t TestingTB, cb ServerConfigCallback) (*TestServer, er | |
return nil, errors.Wrap(err, "failed marshaling json") | ||
} | ||
|
||
t.Logf("CONFIG JSON: %s", string(b)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove debug. |
||
configFile := filepath.Join(tmpdir, "config.json") | ||
if err := ioutil.WriteFile(configFile, b, 0644); err != nil { | ||
cfg.ReturnPorts() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ func WaitUntilNoLeader(t *testing.T, rpc rpcFn, dc string, options ...waitOption | |
type waitOption struct { | ||
Token string | ||
WaitForAntiEntropySync bool | ||
WaitForService string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add ability to wait for a service because services are no longer synced immediately. |
||
} | ||
|
||
func WithToken(token string) waitOption { | ||
|
@@ -74,6 +75,10 @@ func WaitForAntiEntropySync() waitOption { | |
return waitOption{WaitForAntiEntropySync: true} | ||
} | ||
|
||
func WaitForService(service string) waitOption { | ||
return waitOption{WaitForService: service} | ||
} | ||
|
||
func flattenOptions(options []waitOption) waitOption { | ||
var flat waitOption | ||
for _, opt := range options { | ||
|
@@ -83,10 +88,17 @@ func flattenOptions(options []waitOption) waitOption { | |
if opt.WaitForAntiEntropySync { | ||
flat.WaitForAntiEntropySync = true | ||
} | ||
if opt.WaitForService != "" { | ||
flat.WaitForService = opt.WaitForService | ||
} | ||
} | ||
return flat | ||
} | ||
|
||
func WaitForSyncedTestAgent(t *testing.T, rpc rpcFn, dc string, options ...waitOption) { | ||
t.Helper() | ||
} | ||
|
||
// WaitForTestAgent ensures we have a node with serfHealth check registered | ||
func WaitForTestAgent(t *testing.T, rpc rpcFn, dc string, options ...waitOption) { | ||
t.Helper() | ||
|
@@ -95,6 +107,7 @@ func WaitForTestAgent(t *testing.T, rpc rpcFn, dc string, options ...waitOption) | |
|
||
var nodes structs.IndexedNodes | ||
var checks structs.IndexedHealthChecks | ||
var services structs.IndexedServices | ||
|
||
retry.Run(t, func(r *retry.R) { | ||
dcReq := &structs.DCSpecificRequest{ | ||
|
@@ -134,6 +147,23 @@ func WaitForTestAgent(t *testing.T, rpc rpcFn, dc string, options ...waitOption) | |
if !found { | ||
r.Fatalf("serfHealth check not found") | ||
} | ||
|
||
if flat.WaitForService != "" { | ||
servicesReq := &structs.DCSpecificRequest{ | ||
Datacenter: dc, | ||
QueryOptions: structs.QueryOptions{Token: flat.Token}, | ||
} | ||
if err := rpc("Catalog.ListServices", servicesReq, &services); err != nil { | ||
r.Fatalf("Catalog.ListServices failed: %v", err) | ||
} | ||
if len(services.Services) == 0 { | ||
r.Fatalf("No registered services") | ||
} | ||
if _, ok := services.Services[flat.WaitForService]; !ok { | ||
r.Fatalf("service not found") | ||
} | ||
} | ||
|
||
}) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the consequences of this function no longer returning an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your comment I revisited this part and reverted to returning and handling any errors from
syncNodeInfo
. I also added a longer explanation for these changes to the PR description.