From 53c95e1775fe246a8144bebfe73a4570da01e331 Mon Sep 17 00:00:00 2001 From: Todd Date: Wed, 28 Feb 2024 08:52:11 -0800 Subject: [PATCH] Extract out the setup of workers and targets to handle ent specific configurations (#4461) --- internal/tests/api/proxy/proxy_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/tests/api/proxy/proxy_test.go b/internal/tests/api/proxy/proxy_test.go index 461bf248b8..cdd15d05e9 100644 --- a/internal/tests/api/proxy/proxy_test.go +++ b/internal/tests/api/proxy/proxy_test.go @@ -23,6 +23,17 @@ import ( _ "github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets/tcp" ) +var updateTargetForProxy = func(t *testing.T, ctx context.Context, c *targets.Client, tgt *targets.TargetReadResult, port uint32, connLimit int32, workerName string) *targets.TargetReadResult { + t.Helper() + ret, err := c.Update(ctx, tgt.Item.Id, tgt.Item.Version, + targets.WithTcpTargetDefaultPort(port), + targets.WithSessionConnectionLimit(connLimit), + ) + require.NoError(t, err) + require.NotNil(t, ret) + return ret +} + // TestConnectionsLeft tests general proxy functionality, as well as the // mechanism to notify the caller of the number of connections left on the // caller's channel and in the ConnectionsLeft function. @@ -50,6 +61,7 @@ func TestConnectionsLeft(t *testing.T) { InitialUpstreams: c1.ClusterAddrs(), Logger: logger.Named("w1"), SuccessfulStatusGracePeriodDuration: helper.DefaultWorkerStatusGracePeriod, + Name: "w1", }) defer w1.Shutdown() err = w1.Worker().WaitForNextSuccessfulStatusUpdate() @@ -71,9 +83,8 @@ func TestConnectionsLeft(t *testing.T) { require.NotNil(t, ts) defer ts.Close() var sessionConnsLimit int32 = 4 - tgt, err = tcl.Update(c1.Context(), tgt.Item.Id, tgt.Item.Version, targets.WithTcpTargetDefaultPort(ts.Port()), targets.WithSessionConnectionLimit(sessionConnsLimit)) - require.NoError(err) - require.NotNil(tgt) + + tgt = updateTargetForProxy(t, c1.Context(), tcl, tgt, ts.Port(), sessionConnsLimit, w1.Name()) // Authorize session to get authorization data sess, err := tcl.AuthorizeSession(c1.Context(), tgt.Item.Id)