Skip to content

Commit 678eccf

Browse files
committed
oversight: deflake test mean to prove the clockwork will not panic
1 parent 703e807 commit 678eccf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tree_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222
"log"
23+
"math/rand"
2324
"reflect"
2425
"strings"
2526
"sync"
@@ -880,7 +881,7 @@ func Test_dynamicNesting(t *testing.T) {
880881
for i := 0; i < 10; i++ {
881882
wg.Add(1)
882883
tree.Add(oversight.ChildProcessSpecification{
883-
Name: "child",
884+
Name: fmt.Sprintf("child %d", rand.Int63()),
884885
Restart: oversight.Transient(),
885886
Start: func(ctx context.Context) error {
886887
defer wg.Done()
@@ -890,13 +891,13 @@ func Test_dynamicNesting(t *testing.T) {
890891
select {
891892
case <-ctx.Done():
892893
return ctx.Err()
893-
case <-time.After(1 * time.Second):
894+
case <-time.After(100 * time.Millisecond):
894895
t.Log("deleting", realChildName)
895896
_ = tree.Delete(realChildName)
896897
return nil
897898
}
898899
},
899-
Shutdown: oversight.Timeout(1 * time.Second),
900+
Shutdown: oversight.Timeout(500 * time.Millisecond),
900901
})
901902
}
902903
return nil
@@ -907,6 +908,9 @@ func Test_dynamicNesting(t *testing.T) {
907908
if err != nil && err != oversight.ErrNoChildProcessLeft {
908909
t.Fatal("unexpected error:", err)
909910
}
911+
if err := tree.Start(context.Background()); !errors.Is(err, oversight.ErrNoChildProcessLeft) {
912+
t.Fatal("expected error missing: %$v", err)
913+
}
910914
}
911915

912916
func TestTree_shutdownOrder(t *testing.T) {

0 commit comments

Comments
 (0)