Skip to content

Commit ccd4217

Browse files
committed
disable wireguard on agent tests
1 parent 2361e15 commit ccd4217

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

cli/agent.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@ import (
1414
"cloud.google.com/go/compute/metadata"
1515
"github.com/spf13/cobra"
1616
"golang.org/x/xerrors"
17+
"gopkg.in/natefinch/lumberjack.v2"
1718

1819
"cdr.dev/slog"
1920
"cdr.dev/slog/sloggers/sloghuman"
20-
2121
"github.com/coder/coder/agent"
2222
"github.com/coder/coder/agent/reaper"
2323
"github.com/coder/coder/cli/cliflag"
2424
"github.com/coder/coder/codersdk"
2525
"github.com/coder/retry"
26-
27-
"gopkg.in/natefinch/lumberjack.v2"
2826
)
2927

3028
func workspaceAgent() *cobra.Command {
3129
var (
32-
auth string
33-
pprofEnabled bool
34-
pprofAddress string
35-
noReap bool
30+
auth string
31+
pprofEnabled bool
32+
pprofAddress string
33+
noReap bool
34+
disableWireguard bool
3635
)
3736
cmd := &cobra.Command{
3837
Use: "agent",
@@ -178,7 +177,7 @@ func workspaceAgent() *cobra.Command {
178177
// shells so "gitssh" works!
179178
"CODER_AGENT_TOKEN": client.SessionToken,
180179
},
181-
EnableWireguard: true,
180+
EnableWireguard: !disableWireguard,
182181
PostPublicKeys: client.PostWorkspaceAgentKeys,
183182
ListenWireguardPeers: client.WireguardPeerListener,
184183
})
@@ -191,5 +190,6 @@ func workspaceAgent() *cobra.Command {
191190
cliflag.BoolVarP(cmd.Flags(), &pprofEnabled, "pprof-enable", "", "CODER_AGENT_PPROF_ENABLE", false, "Enable serving pprof metrics on the address defined by --pprof-address.")
192191
cliflag.BoolVarP(cmd.Flags(), &noReap, "no-reap", "", "", false, "Do not start a process reaper.")
193192
cliflag.StringVarP(cmd.Flags(), &pprofAddress, "pprof-address", "", "CODER_AGENT_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
193+
cliflag.BoolVarP(cmd.Flags(), &disableWireguard, "disable-wireguard", "", "", false, "Disable creating a wireguard interface.")
194194
return cmd
195195
}

cli/agent_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestWorkspaceAgent(t *testing.T) {
4646
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
4747
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
4848

49-
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
49+
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String(), "--disable-wireguard")
5050
ctx, cancelFunc := context.WithCancel(context.Background())
5151
defer cancelFunc()
5252
errC := make(chan error)
@@ -101,7 +101,7 @@ func TestWorkspaceAgent(t *testing.T) {
101101
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
102102
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
103103

104-
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
104+
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String(), "--disable-wireguard")
105105
ctx, cancelFunc := context.WithCancel(context.Background())
106106
defer cancelFunc()
107107
errC := make(chan error)
@@ -156,7 +156,7 @@ func TestWorkspaceAgent(t *testing.T) {
156156
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
157157
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
158158

159-
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
159+
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String(), "--disable-wireguard")
160160
ctx, cancelFunc := context.WithCancel(context.Background())
161161
defer cancelFunc()
162162
errC := make(chan error)

coderd/coderdtest/coderdtest.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@ import (
2525
"testing"
2626
"time"
2727

28-
"github.com/spf13/afero"
29-
30-
"github.com/coder/coder/coderd/rbac"
31-
"github.com/coder/coder/coderd/telemetry"
32-
"github.com/coder/coder/coderd/util/ptr"
33-
3428
"cloud.google.com/go/compute/metadata"
3529
"github.com/fullsailor/pkcs7"
3630
"github.com/golang-jwt/jwt"
3731
"github.com/google/uuid"
3832
"github.com/moby/moby/pkg/namesgenerator"
33+
"github.com/spf13/afero"
3934
"github.com/stretchr/testify/assert"
4035
"github.com/stretchr/testify/require"
4136
"google.golang.org/api/idtoken"
@@ -50,7 +45,10 @@ import (
5045
"github.com/coder/coder/coderd/database/databasefake"
5146
"github.com/coder/coder/coderd/database/postgres"
5247
"github.com/coder/coder/coderd/gitsshkey"
48+
"github.com/coder/coder/coderd/rbac"
49+
"github.com/coder/coder/coderd/telemetry"
5350
"github.com/coder/coder/coderd/turnconn"
51+
"github.com/coder/coder/coderd/util/ptr"
5452
"github.com/coder/coder/codersdk"
5553
"github.com/coder/coder/cryptorand"
5654
"github.com/coder/coder/provisioner/echo"

0 commit comments

Comments
 (0)