From 9545525e46c08e2478936d8dbb46028280add08c Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Tue, 2 May 2023 20:53:49 +0200 Subject: [PATCH] Extend process reconnect test --- process/process_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/process/process_test.go b/process/process_test.go index 449c9693..13db51a3 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -51,7 +51,7 @@ func TestReconnectProcess(t *testing.T) { "2", }, Reconnect: true, - ReconnectDelay: 10 * time.Second, + ReconnectDelay: 3 * time.Second, StaleTimeout: 0, OnExit: func(string) { wg.Done() @@ -72,6 +72,22 @@ func TestReconnectProcess(t *testing.T) { require.Greater(t, p.Status().Reconnect, time.Duration(0)) + wg.Add(1) + + p.Start() + + require.Eventually(t, func() bool { + return p.Status().State == "running" + }, 10*time.Second, 500*time.Millisecond) + + require.Eventually(t, func() bool { + return p.Status().State == "finished" + }, 10*time.Second, 500*time.Millisecond) + + wg.Wait() + + require.Greater(t, p.Status().Reconnect, time.Duration(0)) + p.Stop(false) require.Equal(t, "finished", p.Status().State)