grpc: add shutdown call for external management (#957)

* grpc: add shutdown call for external management

* go mod: tidy

* glorious: suggestion

* Update engine/engine.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update engine/rpcserver.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update main.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update engine/rpcserver.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2022-05-20 11:20:39 +10:00
committed by GitHub
parent c492e6600e
commit ee9c35d5ee
13 changed files with 1194 additions and 853 deletions

View File

@@ -2304,3 +2304,24 @@ func TestGetCollateral(t *testing.T) {
t.Errorf("received '%v', expected '%v'", err, nil)
}
}
func TestShutdown(t *testing.T) {
t.Parallel()
s := RPCServer{Engine: &Engine{}}
_, err := s.Shutdown(context.Background(), &gctrpc.ShutdownRequest{})
if !errors.Is(err, errShutdownNotAllowed) {
t.Fatalf("received: '%v' but expected: '%v'", err, errShutdownNotAllowed)
}
s.Engine.Settings.EnableGRPCShutdown = true
_, err = s.Shutdown(context.Background(), &gctrpc.ShutdownRequest{})
if !errors.Is(err, errGRPCShutdownSignalIsNil) {
t.Fatalf("received: '%v' but expected: '%v'", err, errGRPCShutdownSignalIsNil)
}
s.Engine.GRPCShutdownSignal = make(chan struct{}, 1)
_, err = s.Shutdown(context.Background(), &gctrpc.ShutdownRequest{})
if !errors.Is(err, nil) {
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
}
}