test(daemon): remove tests with multihop (#5397)
This commit is contained in:
1 parent
2342e4b644
commit
868d7b8a2d
5 files changed
-420
No files matched your search
@@ -16,7 +16,6 @@ import (
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/common"
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/event"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
@@ -423,146 +422,6 @@ func (tw *TestWorker) AddClusterWorkerMember(t testing.TB, opts *TestWorkerOpts)
|
||||
return NewTestWorker(t, nextOpts)
|
||||
}
|
||||
|
||||
// NewTestMultihopWorkers creates a PKI-KMS and PKI worker with the controller
|
||||
// as an upstream, and two child workers (one PKI, one KMS) as downstreams of
|
||||
// the initial workers (child PKI -> upstream PKI-KMS, child PKI-KMS -> upstream
|
||||
// PKI). Tags for the PKI and child PKI/KMS workers can be passed in, if
|
||||
// desired.
|
||||
func NewTestMultihopWorkers(t testing.TB,
|
||||
logger hclog.Logger,
|
||||
controllerContext context.Context,
|
||||
clusterAddrs []string,
|
||||
workerAuthKms wrapping.Wrapper,
|
||||
serversRepoFn common.ServersRepoFactory,
|
||||
pkiTags, childPkiTags, childKmsTags map[string][]string,
|
||||
enableAuthDebugging *atomic.Bool,
|
||||
) (kmsWorker, pkiWorker, childPkiWorker, childKmsWorker *TestWorker) {
|
||||
require := require.New(t)
|
||||
|
||||
// Create a few test wrappers for the child KMS worker to use
|
||||
childDownstreamWrapper1 := db.TestWrapper(t)
|
||||
childDownstreamWrapper2 := db.TestWrapper(t)
|
||||
childDownstreamWrapper, err := multi.NewPooledWrapper(context.Background(), childDownstreamWrapper1)
|
||||
require.NoError(err)
|
||||
added, err := childDownstreamWrapper.AddWrapper(context.Background(), childDownstreamWrapper2)
|
||||
require.NoError(err)
|
||||
require.True(added)
|
||||
|
||||
kmsWorker = NewTestWorker(t, &TestWorkerOpts{
|
||||
WorkerAuthKms: workerAuthKms,
|
||||
InitialUpstreams: clusterAddrs,
|
||||
Logger: logger.Named("kmsWorker"),
|
||||
WorkerAuthDebuggingEnabled: enableAuthDebugging,
|
||||
DownstreamWorkerAuthKms: childDownstreamWrapper,
|
||||
})
|
||||
t.Cleanup(kmsWorker.Shutdown)
|
||||
|
||||
// Give time for it to be inserted into the database
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// names should not be set when using pki workers
|
||||
pkiWorkerConf, err := config.DevWorker()
|
||||
require.NoError(err)
|
||||
pkiWorkerConf.Worker.Name = ""
|
||||
if pkiTags != nil {
|
||||
pkiWorkerConf.Worker.Tags = pkiTags
|
||||
}
|
||||
pkiWorkerConf.Worker.InitialUpstreams = clusterAddrs
|
||||
pkiWorker = NewTestWorker(t, &TestWorkerOpts{
|
||||
InitialUpstreams: clusterAddrs,
|
||||
Logger: logger.Named("pkiWorker"),
|
||||
Config: pkiWorkerConf,
|
||||
DownstreamWorkerAuthKms: childDownstreamWrapper,
|
||||
WorkerAuthDebuggingEnabled: enableAuthDebugging,
|
||||
})
|
||||
t.Cleanup(pkiWorker.Shutdown)
|
||||
|
||||
// Give time for it to be inserted into the database
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// Get a server repo and worker auth repo
|
||||
serversRepo, err := serversRepoFn()
|
||||
require.NoError(err)
|
||||
// Perform initial authentication of worker to controller
|
||||
reqBytes, err := base58.FastBase58Decoding(pkiWorker.Worker().WorkerAuthRegistrationRequest)
|
||||
require.NoError(err)
|
||||
|
||||
// Decode the proto into the request and create the worker
|
||||
pkiWorkerReq := new(types.FetchNodeCredentialsRequest)
|
||||
require.NoError(proto.Unmarshal(reqBytes, pkiWorkerReq))
|
||||
_, err = serversRepo.CreateWorker(controllerContext, &server.Worker{
|
||||
Worker: &store.Worker{
|
||||
ScopeId: scope.Global.String(),
|
||||
},
|
||||
}, server.WithFetchNodeCredentialsRequest(pkiWorkerReq))
|
||||
require.NoError(err)
|
||||
|
||||
childPkiWorkerConf, err := config.DevWorker()
|
||||
require.NoError(err)
|
||||
childPkiWorkerConf.Worker.Name = ""
|
||||
if childPkiTags != nil {
|
||||
childPkiWorkerConf.Worker.Tags = childPkiTags
|
||||
}
|
||||
childPkiWorkerConf.Worker.InitialUpstreams = kmsWorker.ProxyAddrs()
|
||||
|
||||
childPkiWorker = NewTestWorker(t, &TestWorkerOpts{
|
||||
InitialUpstreams: kmsWorker.ProxyAddrs(),
|
||||
Logger: logger.Named("childPkiWorker"),
|
||||
Config: childPkiWorkerConf,
|
||||
WorkerRecordingStoragePath: t.TempDir(),
|
||||
WorkerAuthDebuggingEnabled: enableAuthDebugging,
|
||||
})
|
||||
t.Cleanup(childPkiWorker.Shutdown)
|
||||
|
||||
// Give time for it to be inserted into the database
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// Perform initial authentication of worker to controller
|
||||
reqBytes, err = base58.FastBase58Decoding(childPkiWorker.Worker().WorkerAuthRegistrationRequest)
|
||||
require.NoError(err)
|
||||
|
||||
// Decode the proto into the request and create the worker
|
||||
childPkiWorkerReq := new(types.FetchNodeCredentialsRequest)
|
||||
require.NoError(proto.Unmarshal(reqBytes, childPkiWorkerReq))
|
||||
_, err = serversRepo.CreateWorker(controllerContext, &server.Worker{
|
||||
Worker: &store.Worker{
|
||||
ScopeId: scope.Global.String(),
|
||||
},
|
||||
}, server.WithFetchNodeCredentialsRequest(childPkiWorkerReq))
|
||||
require.NoError(err)
|
||||
|
||||
childKmsWorkerConf, err := config.DevWorker()
|
||||
require.NoError(err)
|
||||
childKmsWorkerConf.Worker.Name = "child-kms-worker"
|
||||
childKmsWorkerConf.Worker.Description = "child-kms-worker description"
|
||||
// Set tags the same
|
||||
if childKmsTags != nil {
|
||||
childKmsWorkerConf.Worker.Tags = childKmsTags
|
||||
}
|
||||
childKmsWorkerConf.Worker.InitialUpstreams = kmsWorker.ProxyAddrs()
|
||||
|
||||
childKmsWorker = NewTestWorker(t, &TestWorkerOpts{
|
||||
InitialUpstreams: pkiWorker.ProxyAddrs(),
|
||||
Logger: logger.Named("childKmsWorker"),
|
||||
Config: childKmsWorkerConf,
|
||||
WorkerAuthKms: childDownstreamWrapper2,
|
||||
WorkerAuthDebuggingEnabled: enableAuthDebugging,
|
||||
DisableAutoStart: true,
|
||||
})
|
||||
childKmsWorker.w.conf.WorkerAuthStorageKms = nil
|
||||
|
||||
err = childKmsWorker.w.Start()
|
||||
t.Cleanup(childKmsWorker.Shutdown)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Sleep so that workers can startup and connect.
|
||||
time.Sleep(12 * time.Second)
|
||||
|
||||
return kmsWorker, pkiWorker, childPkiWorker, childKmsWorker
|
||||
}
|
||||
|
||||
// NewAuthorizedPkiTestWorker creates a new test worker with the provided upstreams
|
||||
// and creates it in the provided repo as an authorized worker. It returns
|
||||
// The TestWorker and it's boundary id.
|
||||
|
||||
Reference in new issue
Block a user