MCPcopy
hub / github.com/grpc/grpc-go / TestDetermineTargetCSM

Method TestDetermineTargetCSM

stats/opentelemetry/csm/pluginoption_test.go:265–303  ·  view source on GitHub ↗

TestDetermineTargetCSM tests the helper function that determines whether a target is relevant to CSM or not, based off the rules outlined in design.

(t *testing.T)

Source from the content-addressed store, hash-verified

263// TestDetermineTargetCSM tests the helper function that determines whether a
264// target is relevant to CSM or not, based off the rules outlined in design.
265func (s) TestDetermineTargetCSM(t *testing.T) {
266 tests := []struct {
267 name string
268 target string
269 targetCSM bool
270 }{
271 {
272 name: "dns:///localhost",
273 target: "normal-target-here",
274 targetCSM: false,
275 },
276 {
277 name: "xds-no-authority",
278 target: "xds:///localhost",
279 targetCSM: true,
280 },
281 {
282 name: "xds-traffic-director-authority",
283 target: "xds://traffic-director-global.xds.googleapis.com/localhost",
284 targetCSM: true,
285 },
286 {
287 name: "xds-not-traffic-director-authority",
288 target: "xds://not-traffic-director-authority/localhost",
289 targetCSM: false,
290 },
291 }
292 for _, test := range tests {
293 t.Run(test.name, func(t *testing.T) {
294 parsedTarget, err := url.Parse(test.target)
295 if err != nil {
296 t.Fatalf("test target %v failed to parse: %v", test.target, err)
297 }
298 if got := determineTargetCSM(parsedTarget); got != test.targetCSM {
299 t.Fatalf("cpo.determineTargetCSM(%v): got %v, want %v", test.target, got, test.targetCSM)
300 }
301 })
302 }
303}
304
305// TestSetLabels tests the setting of labels, which snapshots the resource and
306// environment. It mocks the resource and environment, and then calls into

Callers

nothing calls this directly

Calls 3

determineTargetCSMFunction · 0.85
ParseMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected