package discovery import ( "slices" "testing" ) // The client's output of perftest 24.x, with a duration. const writeBWClient = `--------------------------------------------------------------------------------------- RDMA_Write BW Test Dual-port : OFF Device : mlx5_0 Number of qps : 1 Transport type : IB Connection type : RC Using SRQ : OFF TX depth : 128 CQ Moderation : 100 Mtu : 4096[B] Link type : IB Max inline data : 0[B] rdma_cm QPs : OFF Data ex. method : Ethernet --------------------------------------------------------------------------------------- local address: LID 0x05 QPN 0x0112 PSN 0x7b1f02 RKey 0x1fffbd VAddr 0x007f1d2a5f0000 remote address: LID 0x09 QPN 0x0113 PSN 0x2c1e44 RKey 0x1ffeaf VAddr 0x007fa4e1a60000 --------------------------------------------------------------------------------------- #bytes #iterations BW peak[Gb/sec] BW average[Gb/sec] MsgRate[Mpps] 65536 1851214 0.00 388.21 0.740422 --------------------------------------------------------------------------------------- ` func TestTheAverageBandwidthIsReadFromPerftest(t *testing.T) { got, err := ParseWriteBW(writeBWClient) if err != nil || got != 388.21 { t.Errorf("got %v, %v", got, err) } if _, err := ParseWriteBW(" Couldn't connect to 10.0.0.2:18515\n"); err == nil { t.Error("output with no result table gave a number") } } func TestWriteBWArguments(t *testing.T) { ib := WriteBW{HCA: "mlx5_0", Port: 1, GIDIndex: -1, TCPPort: 18515, Seconds: 3}.Args() if slices.Contains(ib, "-x") { t.Errorf("InfiniBand was given a GID index: %v", ib) } roce := WriteBW{HCA: "mlx5_0", Port: 1, GIDIndex: 3, Peer: "10.0.0.2", TCPPort: 18515, Seconds: 3}.Args() if !slices.Contains(roce, "-x") || roce[len(roce)-1] != "10.0.0.2" { t.Errorf("RoCE client: %v", roce) } }