Skip to content

Commit cb2b1b4

Browse files
Reset Region field for client and server Geo annotations (#1073)
* Add client and server Region reset * Add annotation with empty geo fields for unit tests. * Assert that Client.* and Server.Geo.Region are cleared in test
1 parent 5c8ce23 commit cb2b1b4

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

parser/annotation.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ func (ap *AnnotationParser) ParseAndInsert(meta map[string]bigquery.Value, testN
100100
row.UUID = raw.UUID
101101
row.Server = raw.Server
102102
row.Client = raw.Client
103+
104+
// NOTE: Due to https://github.com/m-lab/etl/issues/1069, we mask the Region
105+
// field found in synthetic uuid annotations prior to 2020-03-12, and no
106+
// longer found in later Geo2 annotations.
107+
if row.Server.Geo != nil {
108+
row.Server.Geo.Region = ""
109+
}
110+
if row.Client.Geo != nil {
111+
row.Client.Geo.Region = ""
112+
}
113+
103114
// NOTE: annotations are joined with other tables using the UUID, so
104115
// finegrain timestamp is not necessary.
105116
//

parser/annotation_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func TestAnnotationParser_ParseAndInsert(t *testing.T) {
2323
name: "success",
2424
file: "ndt-njp6l_1585004303_00000000000170FA.json",
2525
},
26+
{
27+
name: "success-empty-geo",
28+
file: "ndt-empty-geo.json",
29+
},
2630
{
2731
name: "corrupt-input",
2832
file: "ndt-corrupt.json",
@@ -57,15 +61,22 @@ func TestAnnotationParser_ParseAndInsert(t *testing.T) {
5761
expPI := schema.ParseInfo{
5862
Version: "https://github.com/m-lab/etl/tree/foobar",
5963
Time: row.Parser.Time,
60-
ArchiveURL: "gs://mlab-test-bucket/ndt/ndt7/2020/03/18/ndt-njp6l_1585004303_00000000000170FA.json",
61-
Filename: "ndt-njp6l_1585004303_00000000000170FA.json",
64+
ArchiveURL: "gs://mlab-test-bucket/ndt/ndt7/2020/03/18/" + tt.file,
65+
Filename: tt.file,
6266
Priority: 0,
6367
GitCommit: "12345678",
6468
}
6569

6670
if diff := deep.Equal(row.Parser, expPI); diff != nil {
6771
t.Errorf("AnnotationParser.ParseAndInsert() different summary: %s", strings.Join(diff, "\n"))
6872
}
73+
74+
if row.Client.Geo != nil && row.Client.Geo.Region != "" {
75+
t.Errorf("AnnotationParser.ParseAndInsert() did not clear Client.Geo.Region: %q", row.Client.Geo.Region)
76+
}
77+
if row.Server.Geo != nil && row.Server.Geo.Region != "" {
78+
t.Errorf("AnnotationParser.ParseAndInsert() did not clear Server.Geo.Region: %q", row.Server.Geo.Region)
79+
}
6980
}
7081
})
7182
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"UUID": "ndt-njp6l_1585004303_00000000000170FA",
3+
"Timestamp": "2020-04-03T00:00:02.663132563Z",
4+
"Server": {
5+
"Site": "lga1t",
6+
"Machine": "mlab2",
7+
"Network": {
8+
"ASNumber": 3356,
9+
"ASName": "Level 3 Parent, LLC",
10+
"Systems": [
11+
{
12+
"ASNs": [
13+
3356
14+
]
15+
}
16+
]
17+
}
18+
},
19+
"Client": {
20+
"Network": {
21+
"CIDR": "35.184.0.0/13",
22+
"ASNumber": 15169,
23+
"Systems": [
24+
{
25+
"ASNs": [
26+
15169
27+
]
28+
}
29+
]
30+
}
31+
}
32+
}

parser/testdata/Annotation/ndt-njp6l_1585004303_00000000000170FA.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"Geo": {
88
"ContinentCode": "NA",
99
"CountryCode": "US",
10+
"Region": "should-be-cleared",
1011
"City": "New York",
1112
"Latitude": 40.7667,
1213
"Longitude": -73.8667
@@ -28,6 +29,7 @@
2829
"ContinentCode": "NA",
2930
"CountryCode": "US",
3031
"CountryName": "United States",
32+
"Region": "should-be-cleared",
3133
"Subdivision1ISOCode": "VA",
3234
"Subdivision1Name": "Virginia",
3335
"Latitude": 38.6583,
@@ -46,4 +48,4 @@
4648
]
4749
}
4850
}
49-
}
51+
}

0 commit comments

Comments
 (0)