Skip to content

Commit 163dadf

Browse files
Strip "unsafe" from ndt5 and ndt7 UUIDs (#1107)
* Strip _unsafe from ndt5 UUIDs * Strip _unsafe from ndt7 UUIDs * Add new unsafe test data
1 parent 1700f84 commit 163dadf

File tree

6 files changed

+67
-18
lines changed

6 files changed

+67
-18
lines changed

parser/ndt5_result.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func (dp *NDT5ResultParser) newResult(test []byte, parser schema.ParseInfo, date
162162
func (dp *NDT5ResultParser) prepareS2CRow(row *schema.NDT5ResultRowV2) {
163163
// Record S2C result.
164164
s2c := row.Raw.S2C
165+
s2c.UUID = strings.ReplaceAll(s2c.UUID, "_unsafe", "")
165166
row.ID = s2c.UUID
166167
row.A = &schema.NDT5Summary{
167168
UUID: s2c.UUID,
@@ -191,6 +192,7 @@ func (dp *NDT5ResultParser) prepareS2CRow(row *schema.NDT5ResultRowV2) {
191192
func (dp *NDT5ResultParser) prepareC2SRow(row *schema.NDT5ResultRowV2) {
192193
// Record C2S result.
193194
c2s := row.Raw.C2S
195+
c2s.UUID = strings.ReplaceAll(c2s.UUID, "_unsafe", "")
194196
row.ID = c2s.UUID
195197
row.A = &schema.NDT5Summary{
196198
UUID: c2s.UUID,

parser/ndt5_result_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func TestNDT5ResultParser_ParseAndInsert(t *testing.T) {
4242
testName: `ndt-m9pcq_1652405655_000000000014FD22.json`,
4343
expectTCPInfo: true,
4444
},
45+
{
46+
name: "success-remove-download-unsafe-uuid",
47+
testName: `ndt-rczlq_1666977535_unsafe_0000000000169592.json`,
48+
},
4549
}
4650
for _, tt := range tests {
4751
t.Run(tt.name, func(t *testing.T) {
@@ -91,6 +95,9 @@ func TestNDT5ResultParser_ParseAndInsert(t *testing.T) {
9195
download.Raw.Control.ClientMetadata[0].Name,
9296
download.Raw.Control.ClientMetadata[0].Value)
9397
}
98+
if strings.Contains(download.ID, "_unsafe") || strings.Contains(download.A.UUID, "_unsafe") {
99+
t.Fatalf("ID or A.UUID contain the string '_unsafe'")
100+
}
94101
if download.Raw.S2C == nil {
95102
t.Fatalf("Raw.S2C is nil")
96103
}
@@ -123,6 +130,9 @@ func TestNDT5ResultParser_ParseAndInsert(t *testing.T) {
123130
upload.Raw.Control.ClientMetadata[0].Name,
124131
upload.Raw.Control.ClientMetadata[0].Value)
125132
}
133+
if strings.Contains(upload.ID, "_unsafe") || strings.Contains(upload.A.UUID, "_unsafe") {
134+
t.Fatalf("ID or A.UUID contain the string '_unsafe'")
135+
}
126136
if upload.Raw.C2S == nil {
127137
t.Fatalf("Raw.C2S is nil")
128138
}

parser/ndt7_result.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func (dp *NDT7ResultParser) ParseAndInsert(meta map[string]bigquery.Value, testN
132132
}
133133

134134
func downSummary(down *model.ArchivalData) schema.NDT7Summary {
135+
down.UUID = strings.ReplaceAll(down.UUID, "_unsafe", "")
135136
return schema.NDT7Summary{
136137
UUID: down.UUID,
137138
TestTime: down.StartTime,
@@ -142,6 +143,7 @@ func downSummary(down *model.ArchivalData) schema.NDT7Summary {
142143
}
143144
}
144145
func upSummary(up *model.ArchivalData) schema.NDT7Summary {
146+
up.UUID = strings.ReplaceAll(up.UUID, "_unsafe", "")
145147
return schema.NDT7Summary{
146148
UUID: up.UUID,
147149
TestTime: up.StartTime,

parser/ndt7_result_test.go

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package parser_test
22

33
import (
44
"io/ioutil"
5+
"path"
56
"strings"
67
"testing"
78

@@ -14,6 +15,30 @@ import (
1415
"github.com/m-lab/go/pretty"
1516
)
1617

18+
func setupNDT7InMemoryParser(t *testing.T, testName string) (*schema.NDT7ResultRow, error) {
19+
ins := newInMemorySink()
20+
n := parser.NewNDT7ResultParser(ins, "test", "_suffix")
21+
22+
resultData, err := ioutil.ReadFile(path.Join("testdata/NDT7Result/", testName))
23+
if err != nil {
24+
t.Fatalf(err.Error())
25+
}
26+
meta := map[string]bigquery.Value{
27+
"filename": "gs://mlab-test-bucket/ndt/ndt7/2020/03/18/ndt_ndt7_2020_03_18_20200318T003853.425987Z-ndt7-mlab3-syd03-ndt.tgz",
28+
"date": civil.Date{Year: 2020, Month: 3, Day: 18},
29+
}
30+
err = n.ParseAndInsert(meta, testName, resultData)
31+
if err != nil {
32+
return nil, err
33+
}
34+
if n.Accepted() != 1 {
35+
t.Fatal("Failed to insert snaplog data.", ins)
36+
}
37+
n.Flush()
38+
row := ins.data[0].(*schema.NDT7ResultRow)
39+
return row, err
40+
}
41+
1742
func TestNDT7ResultParser_ParseAndInsert(t *testing.T) {
1843
tests := []struct {
1944
name string
@@ -31,26 +56,10 @@ func TestNDT7ResultParser_ParseAndInsert(t *testing.T) {
3156
}
3257
for _, tt := range tests {
3358
t.Run(tt.name, func(t *testing.T) {
34-
ins := newInMemorySink()
35-
n := parser.NewNDT7ResultParser(ins, "test", "_suffix")
36-
37-
resultData, err := ioutil.ReadFile(`testdata/NDT7Result/` + tt.testName)
38-
if err != nil {
39-
t.Fatalf(err.Error())
40-
}
41-
meta := map[string]bigquery.Value{
42-
"filename": "gs://mlab-test-bucket/ndt/ndt7/2020/03/18/ndt_ndt7_2020_03_18_20200318T003853.425987Z-ndt7-mlab3-syd03-ndt.tgz",
43-
"date": civil.Date{Year: 2020, Month: 3, Day: 18},
44-
}
45-
46-
if err := n.ParseAndInsert(meta, tt.testName, resultData); (err != nil) != tt.wantErr {
59+
row, err := setupNDT7InMemoryParser(t, tt.testName)
60+
if (err != nil) != tt.wantErr {
4761
t.Errorf("NDT7ResultParser.ParseAndInsert() error = %v, wantErr %v", err, tt.wantErr)
4862
}
49-
if n.Accepted() != 1 {
50-
t.Fatal("Failed to insert snaplog data.", ins)
51-
}
52-
n.Flush()
53-
row := ins.data[0].(*schema.NDT7ResultRow)
5463
if row.Raw.Download != nil {
5564
exp := schema.NDT7Summary{
5665
UUID: "ndt-knwp4_1583603744_000000000000590E",
@@ -136,6 +145,30 @@ func TestNDT7ResultParser_ParseAndInsert(t *testing.T) {
136145
}
137146
}
138147

148+
func TestNDT7ResultParser_ParseAndInsertUnsafe(t *testing.T) {
149+
tests := []struct {
150+
name string
151+
testName string
152+
wantErr bool
153+
}{
154+
{
155+
name: "success-remove-unsafe-uuid",
156+
testName: `ndt7-download-20221130T230746.606388371Z.ndt-rczlq_1666977535_unsafe_000000000016912D.json`,
157+
},
158+
}
159+
for _, tt := range tests {
160+
t.Run(tt.name, func(t *testing.T) {
161+
row, err := setupNDT7InMemoryParser(t, tt.testName)
162+
if (err != nil) != tt.wantErr {
163+
t.Errorf("NDT7ResultParser.ParseAndInsert() error = %v, wantErr %v", err, tt.wantErr)
164+
}
165+
if strings.Contains(row.ID, "_unsafe") || strings.Contains(row.A.UUID, "_unsafe") || strings.Contains(row.Raw.Download.UUID, "_unsafe") {
166+
t.Fatalf("ID or A.UUID contain the string '_unsafe'")
167+
}
168+
})
169+
}
170+
}
171+
139172
func TestNDT7ResultParser_IsParsable(t *testing.T) {
140173
tests := []struct {
141174
name string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"GitShortCommit":"65ed3f0","Version":"v0.20.17","ServerIP":"212.73.231.203","ServerPort":3001,"ClientIP":"93.26.109.189","ClientPort":35105,"StartTime":"2022-11-30T23:46:06.03304386Z","EndTime":"2022-11-30T23:46:16.207358103Z","Control":{"UUID":"ndt-rczlq_1666977535_unsafe_0000000000169592","Protocol":"PLAIN","MessageProtocol":"JSON","ServerMetadata":[{"Name":"deployment","Value":"stable"},{"Name":"type","Value":"physical"}]},"C2S":{"ServerIP":"212.73.231.203","ServerPort":36081,"ClientIP":"193.248.160.8","ClientPort":60684,"UUID":"ndt-rczlq_1666977535_unsafe_0000000000168F69","StartTime":"2022-11-30T22:52:46.910235486Z","EndTime":"2022-11-30T22:52:56.910490315Z","MeanThroughputMbps":14.133278312335156},"S2C":{"UUID":"ndt-rczlq_1666977535_unsafe_0000000000169594","ServerIP":"212.73.231.203","ServerPort":36245,"ClientIP":"93.26.109.189","ClientPort":35137,"StartTime":"2022-11-30T23:46:06.080155486Z","EndTime":"2022-11-30T23:46:16.10196625Z","MeanThroughputMbps":218.32357147346343,"MinRTT":12000000,"MaxRTT":41000000,"SumRTT":2596000000,"CountRTT":101,"ClientReportedMbps":219.151,"TCPInfo":{"State":1,"CAState":0,"Retransmits":0,"Probes":0,"Backoff":0,"Options":7,"WScale":119,"AppLimited":0,"RTO":232000,"ATO":0,"SndMSS":1448,"RcvMSS":536,"Unacked":578,"Sacked":0,"Lost":0,"Retrans":0,"Fackets":0,"LastDataSent":0,"LastAckSent":0,"LastDataRecv":10000,"LastAckRecv":0,"PMTU":1500,"RcvSsThresh":64076,"RTT":30444,"RTTVar":455,"SndSsThresh":426,"SndCwnd":591,"AdvMSS":1448,"Reordering":3,"RcvRTT":0,"RcvSpace":14600,"TotalRetrans":224,"PacingRate":33730939,"MaxPacingRate":-1,"BytesAcked":273499688,"BytesReceived":0,"SegsOut":189770,"SegsIn":79124,"NotsentBytes":3160984,"MinRTT":11817,"DataSegsIn":0,"DataSegsOut":189770,"DeliveryRate":26132932,"BusyTime":10000000,"RWndLimited":424000,"SndBufLimited":0,"Delivered":188969,"DeliveredCE":0,"BytesSent":274660984,"BytesRetrans":324352,"DSackDups":0,"ReordSeen":0,"RcvOooPack":0,"SndWnd":3009280}}}

parser/testdata/NDT7Result/ndt7-download-20221130T230746.606388371Z.ndt-rczlq_1666977535_unsafe_000000000016912D.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)