MCPcopy Create free account
hub / github.com/facebook/time / TestFetchStatsGMNotPresent

Function TestFetchStatsGMNotPresent

fbclock/daemon/datafetcher_http_test.go:119–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

117 fetcher := &HTTPFetcher{}
118 _, err = fetcher.FetchStats(cfg)
119 require.Error(t, err)
120 require.Contains(t, err.Error(), "no selected grandmaster")
121}
122
123func TestFetchStatsNoSelectedGMDescribesEachGM(t *testing.T) {
124 sampleResp := `
125[
126 {"gm_address": "127.0.0.1", "selected": false, "gm_present": 0, "error": "timed out waiting for response"},
127 {"gm_address": "127.0.0.2", "selected": false, "gm_present": 1, "error": "", "cf_rx": -250, "cf_tx": 100,
128 "clock_quality": {"clock_class": 6, "clock_accuracy": 33}},
129 {"gm_address": "127.0.0.3", "selected": false, "gm_present": 1, "error": "",
130 "clock_quality": {"clock_class": 248, "clock_accuracy": 254}},
131 {"gm_address": "127.0.0.4", "selected": false, "gm_present": 1, "error": "",
132 "clock_quality": {"clock_class": 248, "clock_accuracy": 49}}
133]
134`
135 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
136 fmt.Fprintln(w, sampleResp)
137 }))
138 defer ts.Close()
139 surl, err := url.Parse(ts.URL)
140 require.NoError(t, err)
141 cfg := &Config{PTPClientAddress: fmt.Sprintf("%s:%s", surl.Hostname(), surl.Port())}
142 fetcher := &HTTPFetcher{}

Callers

nothing calls this directly

Calls 2

FetchStatsMethod · 0.95
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…