MCPcopy
hub / github.com/uber/aresdb / fileTransfer

Function fileTransfer

datanode/bootstrap/bootstrap_server_bm_test.go:59–91  ·  view source on GitHub ↗
(testName string, addr string, fileName string, chunkSize, bufferSize int32, expectedSize int)

Source from the content-addressed store, hash-verified

57}
58
59func fileTransfer(testName string, addr string, fileName string, chunkSize, bufferSize int32, expectedSize int) error {
60 conn, err := grpc.Dial(addr, grpc.WithInsecure())
61 if err != nil {
62 return err
63 }
64 defer conn.Close()
65
66 timeStart := utils.Now()
67 client := pb.NewPeerDataNodeClient(conn)
68 req := &pb.BenchmarkRequest{
69 File: fileName,
70 ChunkSize: chunkSize,
71 BufferSize: bufferSize,
72 }
73 txClient, err := client.BenchmarkFileTransfer(context.Background(), req)
74 if err != nil {
75 return err
76 }
77 var size int
78 for {
79 d, err := txClient.Recv()
80 if err != nil {
81 break
82 }
83 size += len(d.Chunk)
84 }
85 timeUsed := utils.Now().Sub(timeStart)
86 fmt.Printf("%s, time used: %d ns\n", testName, timeUsed)
87 if size != expectedSize {
88 return fmt.Errorf("file transfer failed, size not match, size=%d, expected:%d", size, expectedSize)
89 }
90 return nil
91}
92
93func BenchmarkFileTransfer(b *testing.B) {
94 testFile := "/tmp/file2m"

Callers 2

TestFileTransferFunction · 0.85
BenchmarkFileTransferFunction · 0.85

Calls 5

BenchmarkFileTransferMethod · 0.95
NowFunction · 0.92
CloseMethod · 0.65
RecvMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected