-
Notifications
You must be signed in to change notification settings - Fork 287
/
util.go
32 lines (29 loc) · 916 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cluster
import (
"testing"
"time"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/hashicorp/boundary/internal/servers/worker"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func expectWorkers(t *testing.T, c *controller.TestController, workers ...*worker.TestWorker) {
updateTimes := c.Controller().WorkerStatusUpdateTimes()
workerMap := map[string]*worker.TestWorker{}
for _, w := range workers {
workerMap[w.Name()] = w
}
updateTimes.Range(func(k, v interface{}) bool {
require.NotNil(t, k)
require.NotNil(t, v)
if workerMap[k.(string)] == nil {
// We don't remove from updateTimes currently so if we're not
// expecting it we'll see an out-of-date entry
return true
}
assert.WithinDuration(t, time.Now(), v.(time.Time), 30*time.Second)
delete(workerMap, k.(string))
return true
})
assert.Empty(t, workerMap)
}