From 6a377a3df390d317478aced1699588ab8d495224 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Wed, 25 Nov 2020 08:27:45 -0500 Subject: [PATCH] Add helper used in ent. (#10445) --- helper/testhelpers/testhelpers.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/helper/testhelpers/testhelpers.go b/helper/testhelpers/testhelpers.go index 7cf8766d5..cefaa8af9 100644 --- a/helper/testhelpers/testhelpers.go +++ b/helper/testhelpers/testhelpers.go @@ -280,6 +280,25 @@ func WaitForNCoresUnsealed(t testing.T, cluster *vault.TestCluster, n int) { t.Fatalf("%d cores were not unsealed", n) } +func SealCores(t testing.T, cluster *vault.TestCluster) { + t.Helper() + for _, core := range cluster.Cores { + if err := core.Shutdown(); err != nil { + t.Fatal(err) + } + timeout := time.Now().Add(3 * time.Second) + for { + if time.Now().After(timeout) { + t.Fatal("timeout waiting for core to seal") + } + if core.Sealed() { + break + } + time.Sleep(100 * time.Millisecond) + } + } +} + func WaitForNCoresSealed(t testing.T, cluster *vault.TestCluster, n int) { t.Helper() for i := 0; i < 60; i++ {