MCPcopy
hub / github.com/grafana/dskit / generateString

Function generateString

middleware/grpc_stats_test.go:464–482  ·  view source on GitHub ↗
(size int)

Source from the content-addressed store, hash-verified

462}
463
464func generateString(size int) string {
465 // Use random bytes, to avoid compression.
466 buf := make([]byte, size)
467 _, err := rand.Read(buf)
468 if err != nil {
469 // Should not happen.
470 panic(err)
471 }
472
473 // To avoid invalid UTF-8 sequences (which protobuf complains about), we cleanup the data a bit.
474 for ix, b := range buf {
475 if b < ' ' {
476 b += ' '
477 }
478 b = b & 0x7f
479 buf[ix] = b
480 }
481 return string(buf)
482}
483
484func TestGrpcStreamTracker(t *testing.T) {
485 tracker := NewStreamTracker(prometheus.NewDesc(

Callers 3

TestGrpcStatsFunction · 0.85
TestGrpcStatsStreamingFunction · 0.85
launchConnWithStreamsFunction · 0.85

Calls 1

ReadMethod · 0.65

Tested by

no test coverage detected