@@ -109,6 +109,26 @@ var (
109109 },
110110 Health : & v2.Health {Score : 1 },
111111 }
112+ autonodeInstance = v2.HeartbeatMessage {
113+ Registration : & v2.Registration {
114+ City : "Council Bluffs" ,
115+ CountryCode : "US" ,
116+ ContinentCode : "NA" ,
117+ Experiment : "ndt" ,
118+ Hostname : "ndt-oma396982-2248791f.foo.sandbox.measurement-lab.org" ,
119+ Latitude : 41.3032 ,
120+ Longitude : - 95.8941 ,
121+ Machine : "2248791f" ,
122+ Metro : "oma" ,
123+ Project : "mlab-sandbox" ,
124+ Probability : 1.0 ,
125+ Site : "oma396982" ,
126+ Type : "virtual" ,
127+ Uplink : "10g" ,
128+ Services : validNDT7Services ,
129+ },
130+ Health : & v2.Health {Score : 1 },
131+ }
112132 weheInstance = v2.HeartbeatMessage {
113133 Registration : & v2.Registration {
114134 City : "Portland" ,
@@ -186,6 +206,31 @@ var (
186206 },
187207 },
188208 }
209+ autonodeSite = site {
210+ distance : 1701.749354381346 ,
211+ registration : v2.Registration {
212+ City : "Council Bluffs" ,
213+ CountryCode : "US" ,
214+ ContinentCode : "NA" ,
215+ Experiment : "ndt" ,
216+ Latitude : 41.3032 ,
217+ Longitude : - 95.8941 ,
218+ Metro : "oma" ,
219+ Project : "mlab-sandbox" ,
220+ Probability : 1.0 ,
221+ Site : "oma396982" ,
222+ Type : "virtual" ,
223+ Uplink : "10g" ,
224+ Services : validNDT7Services ,
225+ },
226+ machines : []machine {
227+ {
228+ name : "ndt-oma396982-2248791f.foo.sandbox.measurement-lab.org" ,
229+ host : "ndt-oma396982-2248791f.foo.sandbox.measurement-lab.org" ,
230+ health : v2.Health {Score : 1 },
231+ },
232+ },
233+ }
189234 weheSite = site {
190235 distance : 3710.7679340078703 ,
191236 registration : v2.Registration {
@@ -395,6 +440,7 @@ func TestFilterSites(t *testing.T) {
395440 "virtual1" : virtualInstance1 ,
396441 "virtual2" : virtualInstance2 ,
397442 "physical" : physicalInstance ,
443+ "autonode" : autonodeInstance ,
398444 "wehe" : weheInstance ,
399445 }
400446
@@ -404,6 +450,7 @@ func TestFilterSites(t *testing.T) {
404450 typ string
405451 country string
406452 strict bool
453+ org string
407454 lat float64
408455 lon float64
409456 expected []site
@@ -415,7 +462,7 @@ func TestFilterSites(t *testing.T) {
415462 country : "US" ,
416463 lat : 43.1988 ,
417464 lon : - 75.3242 ,
418- expected : []site {virtualSite , physicalSite },
465+ expected : []site {virtualSite , autonodeSite , physicalSite },
419466 },
420467 {
421468 name : "NDT7-physical" ,
@@ -433,7 +480,7 @@ func TestFilterSites(t *testing.T) {
433480 country : "US" ,
434481 lat : 43.1988 ,
435482 lon : - 75.3242 ,
436- expected : []site {virtualSite },
483+ expected : []site {virtualSite , autonodeSite },
437484 },
438485 {
439486 name : "wehe" ,
@@ -461,7 +508,7 @@ func TestFilterSites(t *testing.T) {
461508 strict : true ,
462509 lat : 43.1988 ,
463510 lon : - 75.3242 ,
464- expected : []site {virtualSite , physicalSite },
511+ expected : []site {virtualSite , autonodeSite , physicalSite },
465512 },
466513 {
467514 name : "country-with-strict-no-results" ,
@@ -473,11 +520,35 @@ func TestFilterSites(t *testing.T) {
473520 lon : - 75.3242 ,
474521 expected : []site {},
475522 },
523+ {
524+ name : "org-skip-v2-names" ,
525+ service : "ndt/ndt7" ,
526+ org : "foo" ,
527+ lat : 43.1988 ,
528+ lon : - 75.3242 ,
529+ expected : []site {autonodeSite },
530+ },
531+ {
532+ name : "org-skip-v3-names-different-org" ,
533+ service : "ndt/ndt7" ,
534+ org : "zoom" ,
535+ lat : 43.1988 ,
536+ lon : - 75.3242 ,
537+ expected : []site {},
538+ },
539+ {
540+ name : "org-allow-v2-names-for-mlab-org" ,
541+ service : "ndt/ndt7" ,
542+ org : "mlab" ,
543+ lat : 43.1988 ,
544+ lon : - 75.3242 ,
545+ expected : []site {virtualSite , physicalSite },
546+ },
476547 }
477548
478549 for _ , tt := range tests {
479550 t .Run (tt .name , func (t * testing.T ) {
480- opts := & NearestOptions {Type : tt .typ , Country : tt .country , Strict : tt .strict }
551+ opts := & NearestOptions {Type : tt .typ , Country : tt .country , Strict : tt .strict , Org : tt . org }
481552 got := filterSites (tt .service , tt .lat , tt .lon , instances , opts )
482553
483554 sortSites (got )
@@ -488,7 +559,7 @@ func TestFilterSites(t *testing.T) {
488559 }
489560
490561 if ! reflect .DeepEqual (got , tt .expected ) {
491- t .Errorf ("filterSites() got: %+v, want : %+v" , got , tt .expected )
562+ t .Errorf ("filterSites()\n got: %+v\n want : %+v" , got , tt .expected )
492563 }
493564 })
494565 }
0 commit comments