-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #41: Cleanup metrics for deleted routes
- Loading branch information
1 parent
62e3b29
commit bc38aea
Showing
6 changed files
with
103 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package route | ||
|
||
import ( | ||
"reflect" | ||
"sort" | ||
"testing" | ||
|
||
"github.com/eBay/fabio/metrics" | ||
) | ||
|
||
func TestSyncRegistry(t *testing.T) { | ||
names := func() []string { | ||
var n []string | ||
metrics.ServiceRegistry.Each(func(name string, x interface{}) { | ||
n = append(n, name) | ||
}) | ||
sort.Strings(n) | ||
return n | ||
} | ||
|
||
metrics.ServiceRegistry.UnregisterAll() | ||
|
||
tbl := make(Table) | ||
tbl.AddRoute("svc-a", "/aaa", "http://localhost:1234", 1, nil) | ||
tbl.AddRoute("svc-b", "/bbb", "http://localhost:5678", 1, nil) | ||
if got, want := names(), []string{"svc-a._./aaa.localhost_1234", "svc-b._./bbb.localhost_5678"}; !reflect.DeepEqual(got, want) { | ||
t.Fatalf("got %v want %v", got, want) | ||
} | ||
|
||
tbl.DelRoute("svc-b", "/bbb", "http://localhost:5678") | ||
syncRegistry(tbl) | ||
if got, want := names(), []string{"svc-a._./aaa.localhost_1234"}; !reflect.DeepEqual(got, want) { | ||
t.Fatalf("got %v want %v", got, want) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters