mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-10-12 01:58:46 +02:00
Send full host metadata on managed startup
This commit is contained in:
1 parent
b0408e4d1c
commit
be8c068fa9
15 files changed
+456
-56
No files matched your search
@@ -244,6 +244,40 @@ func waitForCondition(t *testing.T, what string, cond func() bool) {
|
||||
t.Fatalf("timed out waiting for %s", what)
|
||||
}
|
||||
|
||||
func TestApiConfigReloadUsesRuntimeMetadata(t *testing.T) {
|
||||
originalFetch, originalUID := fetchResolverConfigFn, cdUID
|
||||
t.Cleanup(func() {
|
||||
fetchResolverConfigFn = originalFetch
|
||||
cdUID = originalUID
|
||||
})
|
||||
cdUID = "test-uid"
|
||||
|
||||
captured := make(chan *controld.ResolverConfigRequest, 1)
|
||||
fetchResolverConfigFn = func(_ context.Context, req *controld.ResolverConfigRequest, _ bool) (*controld.ResolverConfig, error) {
|
||||
captured <- req
|
||||
return &controld.ResolverConfig{}, nil
|
||||
}
|
||||
|
||||
p := progForRefresh()
|
||||
p.cfg = &ctrld.Config{}
|
||||
p.stopCh = make(chan struct{})
|
||||
p.apiForceReloadCh = make(chan struct{})
|
||||
startRefreshLoop(t, p)
|
||||
p.apiForceReloadCh <- struct{}{}
|
||||
|
||||
select {
|
||||
case req := <-captured:
|
||||
if _, ok := req.Metadata["username"]; ok {
|
||||
t.Error("periodic/forced API refresh included username")
|
||||
}
|
||||
if req.IncludeHostnameHints {
|
||||
t.Error("periodic/forced API refresh requested hostname hints")
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("periodic/forced API refresh did not fetch resolver config")
|
||||
}
|
||||
}
|
||||
|
||||
// TestApiConfigReloadAppliesAllowedDestinations drives apiConfigReload itself -
|
||||
// the loop that owns the refresh ticker and the forced-reload channel - rather
|
||||
// than the handler it calls, so the wiring between them is covered too: removing
|
||||
|
||||
Reference in new issue
Block a user