From 4d60560bdbf913ba01bc5d65a579da4ab85bd514 Mon Sep 17 00:00:00 2001 From: Jaana Dogan Date: Thu, 10 Dec 2020 18:26:43 -0800 Subject: [PATCH] Rename SignalTestComplete to Shutdown (#2277) SignalTestComplete shouldn't be in the public API and Application should provide a Shutdown method instead. This change is fixing the public API, behavior of Shutdown will be fixed in the future. Fixes #2260. --- service/service.go | 4 +++- service/service_test.go | 4 ++-- testbed/testbed/otelcol_runner.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/service/service.go b/service/service.go index 99b3a305741..d0ff423a199 100644 --- a/service/service.go +++ b/service/service.go @@ -231,7 +231,9 @@ func (app *Application) RegisterZPages(mux *http.ServeMux, pathPrefix string) { mux.HandleFunc(path.Join(pathPrefix, extensionzPath), app.handleExtensionzRequest) } -func (app *Application) SignalTestComplete() { +func (app *Application) Shutdown() { + // TODO: Implement a proper shutdown with graceful draining of the pipeline. + // See https://github.com/open-telemetry/opentelemetry-collector/issues/483. defer func() { if r := recover(); r != nil { app.logger.Info("stopTestChan already closed") diff --git a/service/service_test.go b/service/service_test.go index d3d1b181e59..2d1125d005c 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -167,8 +167,8 @@ func TestApplication_StartAsGoRoutine(t *testing.T) { assert.Equal(t, Starting, <-app.GetStateChannel()) assert.Equal(t, Running, <-app.GetStateChannel()) - app.SignalTestComplete() - app.SignalTestComplete() + app.Shutdown() + app.Shutdown() <-appDone assert.Equal(t, Closing, <-app.GetStateChannel()) assert.Equal(t, Closed, <-app.GetStateChannel()) diff --git a/testbed/testbed/otelcol_runner.go b/testbed/testbed/otelcol_runner.go index 56fafff5211..489fff4bc4e 100644 --- a/testbed/testbed/otelcol_runner.go +++ b/testbed/testbed/otelcol_runner.go @@ -142,7 +142,7 @@ func (ipp *InProcessCollector) Start(args StartParams) error { func (ipp *InProcessCollector) Stop() (stopped bool, err error) { if !ipp.stopped { ipp.stopped = true - ipp.svc.SignalTestComplete() + ipp.svc.Shutdown() } <-ipp.appDone stopped = ipp.stopped