Skip to content

Commit 57e3382

Browse files
Merge pull request #172 from m-lab/soltesz-fix-hostname
Add missing NDT client values & Add tls & websocket columns
2 parents b102586 + 579221d commit 57e3382

File tree

6 files changed

+59
-3
lines changed

6 files changed

+59
-3
lines changed

parser/ndt_meta.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ var fieldPairs = map[string]string{
4242
"client OS name": "client_os",
4343
"client_browser name": "client_browser",
4444
"client_application name": "client_application",
45+
46+
// Some client fields are "Additional" meta data optionally provided by the client.
47+
// The NDT client names these fields differently than the server.
48+
// Other clients may provide different key names.
49+
"client.kernel.version": "client_kernel_version",
50+
"client.version": "client_version",
51+
52+
// NDT SSL added two additional meta fields to signify whether the test was
53+
// a websocket and/or tls test.
54+
"tls": "tls",
55+
"websockets": "websockets",
4556
}
4657

4758
func handleIP(connSpec schema.Web100ValueMap, prefix string, ipString string) {
@@ -72,6 +83,17 @@ func (mfd *MetaFileData) PopulateConnSpec(connSpec schema.Web100ValueMap) {
7283
log.Printf("Missing field: %s %v\n", k, v)
7384
}
7485
}
86+
// Only set the value for tls & websocket if the field is present.
87+
if s, ok := mfd.Fields["tls"]; ok {
88+
if s != "" {
89+
connSpec.SetBool("tls", mfd.Tls)
90+
}
91+
}
92+
if s, ok := mfd.Fields["websockets"]; ok {
93+
if s != "" {
94+
connSpec.SetBool("websockets", mfd.Websockets)
95+
}
96+
}
7597
s, ok := connSpec["server_ip"]
7698
// TODO - extract function for this stanza
7799
if ok {
@@ -80,7 +102,7 @@ func (mfd *MetaFileData) PopulateConnSpec(connSpec schema.Web100ValueMap) {
80102
}
81103
} else {
82104
metrics.WarningCount.WithLabelValues(
83-
"table", "unknown", "missing server_ip").Inc()
105+
"ndt", "unknown", "missing server_ip").Inc()
84106
}
85107
s, ok = connSpec["client_ip"]
86108
if ok {
@@ -90,7 +112,7 @@ func (mfd *MetaFileData) PopulateConnSpec(connSpec schema.Web100ValueMap) {
90112
} else {
91113
log.Println("client_ip missing from .meta")
92114
metrics.WarningCount.WithLabelValues(
93-
"table", "unknown", "missing client_ip").Inc()
115+
"ndt", "unknown", "missing client_ip").Inc()
94116
}
95117
}
96118

@@ -110,8 +132,10 @@ func createMetaFileData(testName string, fields map[string]string) (*MetaFileDat
110132
"20060102T15:04:05.999999999Z", v)
111133
case "tls":
112134
data.Tls, err = strconv.ParseBool(v)
135+
data.Fields[k] = v
113136
case "websockets":
114137
data.Websockets, err = strconv.ParseBool(v)
138+
data.Fields[k] = v
115139
case "Summary data":
116140
err = json.Unmarshal(
117141
[]byte(`{"SummaryData":[`+v+`]}`),

parser/ndt_meta_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestMetaParser(t *testing.T) {
3737
t.Error("Incorrect hostname: ", meta.Fields["hostname"])
3838
}
3939

40+
// Check for the presenece of select connSpec fields.
4041
connSpec := schema.EmptyConnectionSpec()
4142
meta.PopulateConnSpec(connSpec)
4243

@@ -63,5 +64,25 @@ func TestMetaParser(t *testing.T) {
6364
if v.(int64) != syscall.AF_INET {
6465
t.Logf("Wrong client_af value: ", v.(int64))
6566
}
67+
68+
}
69+
70+
if s, ok := connSpec["tls"]; ok {
71+
t.Errorf("Found field tls: got %q; want not found", s)
72+
}
73+
if connSpec["websockets"] != true {
74+
t.Errorf("Incorrect websockets: got %q; want true", connSpec["websockets"])
75+
}
76+
if connSpec["client_kernel_version"] != "3.14.0" {
77+
t.Errorf("Incorrect client_kernel_version: got %s; want 3.14.0",
78+
connSpec["client_kernel_version"])
79+
}
80+
if connSpec["client_version"] != "3.7.0" {
81+
t.Errorf("Incorrect client_version: got %s; want 3.7.0",
82+
connSpec["client_version"])
83+
}
84+
if connSpec["client_os"] != "CLIWebsockets" {
85+
t.Errorf("Incorrect client_os: got %s; want CLIWebsockets",
86+
connSpec["client_os"])
6687
}
6788
}

parser/testdata/20170509T13:45:13.590210000Z_eb.measurementlab.net:53000.meta

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ client_application name:
1616
Summary data: 0,36,1346,14,2983,24,32,2,74,0,1448,16,39,136448,23184,8688,0,10521978,347602,105334,0,4,4,2896,364,136448,100,0,0,0,1,6,3,2,10,2,74,97,7,22,6,0,156,0,-1,-1,0,1,0,-1,1448,8688,7
1717
* Additional data:
1818
client.os.name: CLIWebsockets
19-
tls: false
19+
client.version: 3.7.0
20+
client.kernel.version: 3.14.0
2021
websockets: true

schema/ndt.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
{ "name": "server_hostname", "type": "STRING"},
2727
{ "name": "server_ip", "type": "STRING"},
2828
{ "name": "server_kernel_version", "type": "STRING"},
29+
{ "name": "tls", "type": "BOOLEAN"},
30+
{ "name": "websockets", "type": "BOOLEAN"},
2931
{
3032
"fields": [
3133
{ "name": "area_code", "type": "INTEGER"},

schema/web100.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func (s Web100ValueMap) SetString(name string, value string) {
8585
s[name] = value
8686
}
8787

88+
// SetBool saves a boolean in a field with the given name.
89+
func (s Web100ValueMap) SetBool(name string, value bool) {
90+
s[name] = value
91+
}
92+
8893
// if overwrite is false, will only add missing values.
8994
// if overwrite is true, will overwrite existing values.
9095
func (r Web100ValueMap) SubstituteString(overwrite bool, target []string, source []string) {
@@ -179,6 +184,8 @@ func FullConnectionSpec() Web100ValueMap {
179184
"client_browser": "",
180185
"client_application": "",
181186
"data_direction": 0,
187+
"tls": false,
188+
"websockets": false,
182189
"client_geolocation": FullGeolocation(),
183190
"server_geolocation": FullGeolocation(),
184191
}

web100/web100.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import (
8181
type Saver interface {
8282
SetInt64(name string, value int64)
8383
SetString(name string, value string)
84+
SetBool(name string, value bool)
8485
}
8586

8687
//=================================================================================

0 commit comments

Comments
 (0)