HH-833: fence gateway generations across replicas (#22)
This commit is contained in:
@@ -168,3 +168,25 @@ func TestMemoryProxyRemoveRequiresMatchingGeneration(t *testing.T) {
|
||||
t.Fatal("stale generation removed the current proxy")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMemoryProxyReplacesStaleGenerationWithoutOldCleanup(t *testing.T) {
|
||||
registry := newMemoryProxyRegistry()
|
||||
exit := gatewayProxyExit{Protocol: "http", Host: "127.0.0.1", Port: 1}
|
||||
oldURL, oldCleanup, err := registry.configure("account-a", 1, "127.0.0.1", 0, exit, "network-n1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldPort := registry.proxies["account-a"].listener.Addr().(*net.TCPAddr).Port
|
||||
newURL, newCleanup, err := registry.configure("account-a", 2, "127.0.0.1", oldPort, exit, "network-n2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer newCleanup()
|
||||
if newURL != oldURL || registry.proxies["account-a"].bindingVersion != 2 {
|
||||
t.Fatalf("stale proxy was not replaced: old=%q new=%q proxy=%#v", oldURL, newURL, registry.proxies["account-a"])
|
||||
}
|
||||
oldCleanup()
|
||||
if registry.proxies["account-a"].bindingVersion != 2 {
|
||||
t.Fatal("old cleanup removed the replacement proxy")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user