New external site management. New external prober heartbeat feature.
This commit is contained in:
1 parent
42f584dd3c
commit
ef24cc9858
38 files changed
+1058
-158
No files matched your search
@@ -26,6 +26,8 @@ type fakeControlAPI struct {
|
||||
ips []ipQueueItem
|
||||
validators []validatorDTO
|
||||
sites map[int]string
|
||||
siteState map[int]string
|
||||
siteHostname map[int]string
|
||||
groups map[string][]string
|
||||
checkTypes map[string]checkTypeDTO
|
||||
fipSettleSeconds int
|
||||
@@ -36,9 +38,11 @@ type fakeControlAPI struct {
|
||||
func newFakeControlAPI(t *testing.T) (*fakeControlAPI, string) {
|
||||
t.Helper()
|
||||
f := &fakeControlAPI{
|
||||
sites: map[int]string{},
|
||||
groups: map[string][]string{},
|
||||
checkTypes: map[string]checkTypeDTO{},
|
||||
sites: map[int]string{},
|
||||
siteState: map[int]string{},
|
||||
siteHostname: map[int]string{},
|
||||
groups: map[string][]string{},
|
||||
checkTypes: map[string]checkTypeDTO{},
|
||||
}
|
||||
ts := httptest.NewServer(f.handler())
|
||||
t.Cleanup(ts.Close)
|
||||
@@ -285,7 +289,7 @@ func (f *fakeControlAPI) handler() http.Handler {
|
||||
defer f.mu.Unlock()
|
||||
var out []siteDTO
|
||||
for idx, id := range f.sites {
|
||||
out = append(out, siteDTO{Index: idx, SiteID: id})
|
||||
out = append(out, siteDTO{Index: idx, SiteID: id, Hostname: f.siteHostname[idx], State: f.siteState[idx]})
|
||||
}
|
||||
writeJSON(w, http.StatusOK, out)
|
||||
})
|
||||
@@ -305,7 +309,11 @@ func (f *fakeControlAPI) handler() http.Handler {
|
||||
}
|
||||
}
|
||||
f.sites[idx] = req.SiteID
|
||||
writeJSON(w, http.StatusOK, siteDTO{Index: idx, SiteID: req.SiteID})
|
||||
// UpsertSite always resets connection status on write (see its
|
||||
// control-api doc comment) — mirror that here.
|
||||
f.siteState[idx] = "unregistered"
|
||||
f.siteHostname[idx] = ""
|
||||
writeJSON(w, http.StatusOK, siteDTO{Index: idx, SiteID: req.SiteID, State: "unregistered"})
|
||||
})
|
||||
mux.HandleFunc("DELETE /api/v1/admin/config/sites/{index}", func(w http.ResponseWriter, r *http.Request) {
|
||||
f.mu.Lock()
|
||||
@@ -313,6 +321,8 @@ func (f *fakeControlAPI) handler() http.Handler {
|
||||
var idx int
|
||||
fmt.Sscanf(r.PathValue("index"), "%d", &idx)
|
||||
delete(f.sites, idx)
|
||||
delete(f.siteState, idx)
|
||||
delete(f.siteHostname, idx)
|
||||
writeJSON(w, http.StatusOK, map[string]bool{"ok": true})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user