Move and export ExpectWorkers (#4207)
This is a useful test function and keeping it in the cluster package means it can't be used by api/cli tests.
This commit is contained in:
1 parent
9b56db8858
commit
fe4c43305c
9 files changed
+62
-71
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller"
|
||||
"github.com/hashicorp/boundary/internal/daemon/worker"
|
||||
"github.com/hashicorp/boundary/internal/tests/helper"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -37,8 +38,8 @@ func TestMultiControllerMultiWorkerConnections(t *testing.T) {
|
||||
})
|
||||
defer c2.Shutdown()
|
||||
|
||||
expectWorkers(t, c1)
|
||||
expectWorkers(t, c2)
|
||||
helper.ExpectWorkers(t, c1)
|
||||
helper.ExpectWorkers(t, c2)
|
||||
|
||||
w1 := worker.NewTestWorker(t, &worker.TestWorkerOpts{
|
||||
WorkerAuthKms: c1.Config().WorkerAuthKms,
|
||||
@@ -48,8 +49,8 @@ func TestMultiControllerMultiWorkerConnections(t *testing.T) {
|
||||
defer w1.Shutdown()
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c1, w1)
|
||||
expectWorkers(t, c2, w1)
|
||||
helper.ExpectWorkers(t, c1, w1)
|
||||
helper.ExpectWorkers(t, c2, w1)
|
||||
|
||||
w2 := w1.AddClusterWorkerMember(t, &worker.TestWorkerOpts{
|
||||
Logger: logger.Named("w2"),
|
||||
@@ -57,13 +58,13 @@ func TestMultiControllerMultiWorkerConnections(t *testing.T) {
|
||||
defer w2.Shutdown()
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c1, w1, w2)
|
||||
expectWorkers(t, c2, w1, w2)
|
||||
helper.ExpectWorkers(t, c1, w1, w2)
|
||||
helper.ExpectWorkers(t, c2, w1, w2)
|
||||
|
||||
require.NoError(w1.Worker().Shutdown())
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c1, w2)
|
||||
expectWorkers(t, c2, w2)
|
||||
helper.ExpectWorkers(t, c1, w2)
|
||||
helper.ExpectWorkers(t, c2, w2)
|
||||
|
||||
w1 = worker.NewTestWorker(t, &worker.TestWorkerOpts{
|
||||
WorkerAuthKms: c1.Config().WorkerAuthKms,
|
||||
@@ -73,12 +74,12 @@ func TestMultiControllerMultiWorkerConnections(t *testing.T) {
|
||||
defer w1.Shutdown()
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c1, w1, w2)
|
||||
expectWorkers(t, c2, w1, w2)
|
||||
helper.ExpectWorkers(t, c1, w1, w2)
|
||||
helper.ExpectWorkers(t, c2, w1, w2)
|
||||
|
||||
require.NoError(c2.Controller().Shutdown())
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c1, w1, w2)
|
||||
helper.ExpectWorkers(t, c1, w1, w2)
|
||||
|
||||
c2 = c1.AddClusterControllerMember(t, &controller.TestControllerOpts{
|
||||
Logger: c1.Config().Logger.ResetNamed("c2"),
|
||||
@@ -86,8 +87,8 @@ func TestMultiControllerMultiWorkerConnections(t *testing.T) {
|
||||
defer c2.Shutdown()
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
expectWorkers(t, c1, w1, w2)
|
||||
expectWorkers(t, c2, w1, w2)
|
||||
helper.ExpectWorkers(t, c1, w1, w2)
|
||||
helper.ExpectWorkers(t, c2, w1, w2)
|
||||
}
|
||||
|
||||
func TestWorkerAppendInitialUpstreams(t *testing.T) {
|
||||
@@ -106,7 +107,7 @@ func TestWorkerAppendInitialUpstreams(t *testing.T) {
|
||||
})
|
||||
defer c1.Shutdown()
|
||||
|
||||
expectWorkers(t, c1)
|
||||
helper.ExpectWorkers(t, c1)
|
||||
|
||||
initialUpstreams := append(c1.ClusterAddrs(), "127.0.0.9")
|
||||
w1 := worker.NewTestWorker(t, &worker.TestWorkerOpts{
|
||||
@@ -131,7 +132,7 @@ func TestWorkerAppendInitialUpstreams(t *testing.T) {
|
||||
break
|
||||
}
|
||||
}
|
||||
expectWorkers(t, c1, w1)
|
||||
helper.ExpectWorkers(t, c1, w1)
|
||||
|
||||
// Upstreams should be equivalent to the controller cluster addr after status updates
|
||||
assert.Equal(c1.ClusterAddrs(), w1.Worker().LastStatusSuccess().LastCalculatedUpstreams)
|
||||
|
||||
Reference in new issue
Block a user