Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ping router before adding to qdb #277

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions coordinator/provider/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,18 @@ func (qc *qdbCoordinator) RegisterRouter(ctx context.Context, r *topology.Router
Str("address", r.Address).
Str("router", r.ID).
Msg("register router")

// ping router
conn, err := DialRouter(r)
if err != nil {
return fmt.Errorf("failed to ping router: %s", err)
}
cl := routerproto.NewTopologyServiceClient(conn)
_, err = cl.GetRouterStatus(ctx, &routerproto.GetRouterStatusRequest{})
if err != nil {
return fmt.Errorf("failed to ping router: %s", err)
}

return qc.db.AddRouter(ctx, qdb.NewRouter(r.Address, r.ID, qdb.OPENED))
}

Expand Down
14 changes: 13 additions & 1 deletion test/feature/features/coordinator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,19 @@ Feature: Coordinator test
"""
Then SQL error on host "coordinator" should match regexp
"""
Error while dialing
failed to ping router
"""

When I run SQL on host "coordinator"
"""
SHOW routers
"""
Then SQL result should match json_exactly
"""
[{
"show routers":"router r1-regress_router:7000",
"status":"OPENED"
}]
"""

Scenario: Unregister router with invalid id fails
Expand Down
Loading