MCPcopy
hub / github.com/NVIDIA/aistore / Test_MsgDryRun

Function Test_MsgDryRun

transport/msg_test.go:60–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func Test_MsgDryRun(t *testing.T) {
61 tutils.CheckSkip(t, tutils.SkipTestArgs{Long: true})
62 t.Setenv("AIS_STREAM_DRY_RUN", "true")
63
64 // fill in common shared read-only bug
65 random := newRand(mono.NanoTime())
66 buf, slab := memsys.PageMM().AllocSize(cos.MiB)
67 defer slab.Free(buf)
68 random.Read(buf)
69
70 wg := &sync.WaitGroup{}
71 num := atomic.NewInt64(0)
72 for i := 0; i < 10; i++ {
73 wg.Add(1)
74 go func(idx int) {
75 defer wg.Done()
76 myrand := newRand(int64(idx * idx))
77 tsize, prevsize, off := int64(0), int64(0), 0
78 total := int64(cos.GiB * 4)
79 if testing.Short() {
80 total = cos.GiB
81 }
82 stream := transport.NewMsgStream(nil, "dry-msg"+strconv.Itoa(idx), cos.GenTie())
83 for tsize < total {
84 msize := myrand.Intn(memsys.PageSize - 64) // <= s.maxheader, zero-length OK
85 if off+msize > len(buf) {
86 off = 0
87 }
88 msg := &transport.Msg{Body: buf[off : off+msize]}
89 off += msize
90 err := stream.Send(msg)
91 tassert.CheckFatal(t, err)
92 num.Inc()
93 tsize += int64(msize)
94 if tsize-prevsize > total/2 {
95 prevsize = tsize
96 tlog.Logf("%s: %s\n", stream, cos.B2S(tsize, 0))
97 }
98 }
99 stream.Fin()
100 }(i)
101 }
102 wg.Wait()
103 tlog.Logf("total messages: %d\n", num.Load())
104}

Callers

nothing calls this directly

Calls 15

SendMethod · 0.95
IncMethod · 0.95
FinMethod · 0.95
LoadMethod · 0.95
CheckSkipFunction · 0.92
NanoTimeFunction · 0.92
PageMMFunction · 0.92
NewInt64Function · 0.92
NewMsgStreamFunction · 0.92
GenTieFunction · 0.92
CheckFatalFunction · 0.92
LogfFunction · 0.92

Tested by

no test coverage detected