refact(controller): Decouple listeners/servers shutdown from Worker
In general, these changes were introduced in the same vein of the changes to controller `startListeners`. Specifically, these changes also decouple the Controller and the Worker shutdown processes. Currently, a call to `stopListeners` on an instance that is running as both a Controller and a Worker would stop the listeners for both. Lastly, we also add unit/integration tests to the shutdown code.
This commit is contained in:
1 parent
d438a6d2dd
commit
eebdfb88dc
9 files changed
+572
-72
No files matched your search
@@ -77,16 +77,18 @@ func TestIPv6Listener(t *testing.T) {
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(c1, w1)
|
||||
|
||||
c2 := c1.AddClusterControllerMember(t, &controller.TestControllerOpts{
|
||||
Logger: c1.Config().Logger.ResetNamed("c2"),
|
||||
})
|
||||
defer c2.Shutdown()
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(c2, w1)
|
||||
|
||||
require.NoError(w1.Worker().Shutdown(true))
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(c1)
|
||||
|
||||
require.NoError(c1.Controller().Shutdown(true))
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
require.NoError(c1.Controller().Start())
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(c1, w1)
|
||||
expectWorkers(c2)
|
||||
|
||||
client, err := api.NewClient(nil)
|
||||
require.NoError(err)
|
||||
|
||||
@@ -64,7 +64,7 @@ func TestMultiControllerMultiWorkerConnections(t *testing.T) {
|
||||
expectWorkers(t, c1, w1, w2)
|
||||
expectWorkers(t, c2, w1, w2)
|
||||
|
||||
require.NoError(c1.Controller().Shutdown(true))
|
||||
require.NoError(c2.Controller().Shutdown())
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c2, w1, w2)
|
||||
|
||||
|
||||
@@ -94,12 +94,16 @@ func TestUnixListener(t *testing.T) {
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(c1)
|
||||
|
||||
require.NoError(c1.Controller().Shutdown(true))
|
||||
time.Sleep(10 * time.Second)
|
||||
require.NoError(c1.Controller().Shutdown())
|
||||
c1 = controller.NewTestController(t, &controller.TestControllerOpts{
|
||||
Config: conf,
|
||||
Logger: logger.Named("c1"),
|
||||
DisableOidcAuthMethodCreation: true,
|
||||
})
|
||||
defer c1.Shutdown()
|
||||
|
||||
require.NoError(c1.Controller().Start())
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(c1, w1)
|
||||
expectWorkers(c1)
|
||||
|
||||
client, err := api.NewClient(nil)
|
||||
require.NoError(err)
|
||||
|
||||
Reference in new issue
Block a user