From cc3aab1e7bd4b3dba9c5cf04a725a1d0c48cb147 Mon Sep 17 00:00:00 2001 From: Maxim Merzhanov Date: Mon, 18 Nov 2019 17:20:05 +0300 Subject: [PATCH] add comparing backend declarations --- config_service_integration_test.go | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/config_service_integration_test.go b/config_service_integration_test.go index 679abf5..c926888 100644 --- a/config_service_integration_test.go +++ b/config_service_integration_test.go @@ -31,6 +31,7 @@ const ( maxAwaitingTime = 25 * time.Second deleteCommonConfigsCommand = "config/common_config/delete_config" + getRoutesCommand = "config/routing/get_routes" ) var ( @@ -171,6 +172,13 @@ func getConfigServiceAddress(num int, port string) structure.AddressConfiguratio } func testClusterReady(a *assert.Assertions, except int) bool { + var clients []*backend.InternalGrpcClient + defer func() { + for _, client := range clients { + client.CloseQuietly() + } + }() + for j := 0; j < configsNumber; j++ { if j == except { continue @@ -181,12 +189,22 @@ func testClusterReady(a *assert.Assertions, except int) bool { a.Fail(fmt.Sprintf("unable to connect to %d config", j)) return false } + clients = append(clients, client) ready := testRaftReady(client, a) if !ready { return ready } - client.CloseQuietly() } + + var prevRoutes = getRoutes(clients[0], a) + for i := 1; i < len(clients); i++ { + routes := getRoutes(clients[i], a) + match := a.ElementsMatch(prevRoutes, routes, "different backend declarations") + if !match { + return match + } + } + return true } @@ -231,6 +249,18 @@ func testRaftReady(client *backend.InternalGrpcClient, a *assert.Assertions) boo return a.NoError(err) } +func getRoutes(client *backend.InternalGrpcClient, a *assert.Assertions) []structure.BackendDeclaration { + var response []structure.BackendDeclaration + err := client.Invoke( + getRoutesCommand, + -1, + nil, + &response, + ) + a.NoError(err) + return response +} + func await(dialer func() (interface{}, error), timeout time.Duration) (interface{}, error) { retryer := utils.NewRetryer(dialer, timeout) retryer.AttemptTimeout = 300 * time.Millisecond