Skip to content

Commit c8a5a0a

Browse files
authored
Merge branch 'main' into phorcys420/fix-template-api-docs
2 parents 08c9343 + 3e7c8c9 commit c8a5a0a

File tree

18 files changed

+410
-96
lines changed

18 files changed

+410
-96
lines changed

agent/agent_test.go

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,19 +2668,19 @@ func TestAgent_Dial(t *testing.T) {
26682668

26692669
cases := []struct {
26702670
name string
2671-
setup func(t *testing.T) net.Listener
2671+
setup func(t testing.TB) net.Listener
26722672
}{
26732673
{
26742674
name: "TCP",
2675-
setup: func(t *testing.T) net.Listener {
2675+
setup: func(t testing.TB) net.Listener {
26762676
l, err := net.Listen("tcp", "127.0.0.1:0")
26772677
require.NoError(t, err, "create TCP listener")
26782678
return l
26792679
},
26802680
},
26812681
{
26822682
name: "UDP",
2683-
setup: func(t *testing.T) net.Listener {
2683+
setup: func(t testing.TB) net.Listener {
26842684
addr := net.UDPAddr{
26852685
IP: net.ParseIP("127.0.0.1"),
26862686
Port: 0,
@@ -2698,57 +2698,69 @@ func TestAgent_Dial(t *testing.T) {
26982698

26992699
// The purpose of this test is to ensure that a client can dial a
27002700
// listener in the workspace over tailnet.
2701-
l := c.setup(t)
2702-
done := make(chan struct{})
2703-
defer func() {
2704-
l.Close()
2705-
<-done
2706-
}()
2707-
2708-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
2709-
defer cancel()
2710-
2711-
go func() {
2712-
defer close(done)
2713-
for range 2 {
2714-
c, err := l.Accept()
2715-
if assert.NoError(t, err, "accept connection") {
2716-
testAccept(ctx, t, c)
2717-
_ = c.Close()
2701+
//
2702+
// The OS sometimes drops packets if the system can't keep up with
2703+
// them. For TCP packets, it's typically fine due to
2704+
// retransmissions, but for UDP packets, it can fail this test.
2705+
//
2706+
// The OS gets involved for the Wireguard traffic (either via DERP
2707+
// or direct UDP), and also for the traffic between the agent and
2708+
// the listener in the "workspace".
2709+
//
2710+
// To avoid this, we'll retry this test up to 3 times.
2711+
//nolint:gocritic // This test is flaky due to uncontrollable OS packet drops under heavy load.
2712+
testutil.RunRetry(t, 3, func(t testing.TB) {
2713+
ctx := testutil.Context(t, testutil.WaitLong)
2714+
2715+
l := c.setup(t)
2716+
done := make(chan struct{})
2717+
defer func() {
2718+
l.Close()
2719+
<-done
2720+
}()
2721+
2722+
go func() {
2723+
defer close(done)
2724+
for range 2 {
2725+
c, err := l.Accept()
2726+
if assert.NoError(t, err, "accept connection") {
2727+
testAccept(ctx, t, c)
2728+
_ = c.Close()
2729+
}
27182730
}
2719-
}
2720-
}()
2731+
}()
27212732

2722-
agentID := uuid.UUID{0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}
2723-
//nolint:dogsled
2724-
agentConn, _, _, _, _ := setupAgent(t, agentsdk.Manifest{
2725-
AgentID: agentID,
2726-
}, 0)
2727-
require.True(t, agentConn.AwaitReachable(ctx))
2728-
conn, err := agentConn.DialContext(ctx, l.Addr().Network(), l.Addr().String())
2729-
require.NoError(t, err)
2730-
testDial(ctx, t, conn)
2731-
err = conn.Close()
2732-
require.NoError(t, err)
2733+
agentID := uuid.UUID{0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}
2734+
//nolint:dogsled
2735+
agentConn, _, _, _, _ := setupAgent(t, agentsdk.Manifest{
2736+
AgentID: agentID,
2737+
}, 0)
2738+
require.True(t, agentConn.AwaitReachable(ctx))
2739+
conn, err := agentConn.DialContext(ctx, l.Addr().Network(), l.Addr().String())
2740+
require.NoError(t, err)
2741+
testDial(ctx, t, conn)
2742+
err = conn.Close()
2743+
require.NoError(t, err)
27332744

2734-
// also connect via the CoderServicePrefix, to test that we can reach the agent on this
2735-
// IP. This will be required for CoderVPN.
2736-
_, rawPort, _ := net.SplitHostPort(l.Addr().String())
2737-
port, _ := strconv.ParseUint(rawPort, 10, 16)
2738-
ipp := netip.AddrPortFrom(tailnet.CoderServicePrefix.AddrFromUUID(agentID), uint16(port))
2739-
2740-
switch l.Addr().Network() {
2741-
case "tcp":
2742-
conn, err = agentConn.Conn.DialContextTCP(ctx, ipp)
2743-
case "udp":
2744-
conn, err = agentConn.Conn.DialContextUDP(ctx, ipp)
2745-
default:
2746-
t.Fatalf("unknown network: %s", l.Addr().Network())
2747-
}
2748-
require.NoError(t, err)
2749-
testDial(ctx, t, conn)
2750-
err = conn.Close()
2751-
require.NoError(t, err)
2745+
// also connect via the CoderServicePrefix, to test that we can reach the agent on this
2746+
// IP. This will be required for CoderVPN.
2747+
_, rawPort, _ := net.SplitHostPort(l.Addr().String())
2748+
port, _ := strconv.ParseUint(rawPort, 10, 16)
2749+
ipp := netip.AddrPortFrom(tailnet.CoderServicePrefix.AddrFromUUID(agentID), uint16(port))
2750+
2751+
switch l.Addr().Network() {
2752+
case "tcp":
2753+
conn, err = agentConn.Conn.DialContextTCP(ctx, ipp)
2754+
case "udp":
2755+
conn, err = agentConn.Conn.DialContextUDP(ctx, ipp)
2756+
default:
2757+
t.Fatalf("unknown network: %s", l.Addr().Network())
2758+
}
2759+
require.NoError(t, err)
2760+
testDial(ctx, t, conn)
2761+
err = conn.Close()
2762+
require.NoError(t, err)
2763+
})
27522764
})
27532765
}
27542766
}
@@ -3251,7 +3263,7 @@ func setupSSHSessionOnPort(
32513263
return session
32523264
}
32533265

3254-
func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Duration, opts ...func(*agenttest.Client, *agent.Options)) (
3266+
func setupAgent(t testing.TB, metadata agentsdk.Manifest, ptyTimeout time.Duration, opts ...func(*agenttest.Client, *agent.Options)) (
32553267
*workspacesdk.AgentConn,
32563268
*agenttest.Client,
32573269
<-chan *proto.Stats,
@@ -3349,7 +3361,7 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati
33493361

33503362
var dialTestPayload = []byte("dean-was-here123")
33513363

3352-
func testDial(ctx context.Context, t *testing.T, c net.Conn) {
3364+
func testDial(ctx context.Context, t testing.TB, c net.Conn) {
33533365
t.Helper()
33543366

33553367
if deadline, ok := ctx.Deadline(); ok {
@@ -3365,7 +3377,7 @@ func testDial(ctx context.Context, t *testing.T, c net.Conn) {
33653377
assertReadPayload(t, c, dialTestPayload)
33663378
}
33673379

3368-
func testAccept(ctx context.Context, t *testing.T, c net.Conn) {
3380+
func testAccept(ctx context.Context, t testing.TB, c net.Conn) {
33693381
t.Helper()
33703382
defer c.Close()
33713383

@@ -3382,7 +3394,7 @@ func testAccept(ctx context.Context, t *testing.T, c net.Conn) {
33823394
assertWritePayload(t, c, dialTestPayload)
33833395
}
33843396

3385-
func assertReadPayload(t *testing.T, r io.Reader, payload []byte) {
3397+
func assertReadPayload(t testing.TB, r io.Reader, payload []byte) {
33863398
t.Helper()
33873399
b := make([]byte, len(payload)+16)
33883400
n, err := r.Read(b)
@@ -3391,11 +3403,11 @@ func assertReadPayload(t *testing.T, r io.Reader, payload []byte) {
33913403
assert.Equal(t, payload, b[:n])
33923404
}
33933405

3394-
func assertWritePayload(t *testing.T, w io.Writer, payload []byte) {
3406+
func assertWritePayload(t testing.TB, w io.Writer, payload []byte) {
33953407
t.Helper()
33963408
n, err := w.Write(payload)
33973409
assert.NoError(t, err, "write payload")
3398-
assert.Equal(t, len(payload), n, "payload length does not match")
3410+
assert.Equal(t, len(payload), n, "written payload length does not match")
33993411
}
34003412

34013413
func testSessionOutput(t *testing.T, session *ssh.Session, expected, unexpected []string, expectedRe *regexp.Regexp) {

coderd/apidoc/docs.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apikey.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (api *API) postAPIKey(rw http.ResponseWriter, r *http.Request) {
151151
// @Produce json
152152
// @Tags Users
153153
// @Param user path string true "User ID, name, or me"
154-
// @Param keyid path string true "Key ID" format(uuid)
154+
// @Param keyid path string true "Key ID" format(string)
155155
// @Success 200 {object} codersdk.APIKey
156156
// @Router /users/{user}/keys/{keyid} [get]
157157
func (api *API) apiKeyByID(rw http.ResponseWriter, r *http.Request) {
@@ -292,7 +292,7 @@ func (api *API) tokens(rw http.ResponseWriter, r *http.Request) {
292292
// @Security CoderSessionToken
293293
// @Tags Users
294294
// @Param user path string true "User ID, name, or me"
295-
// @Param keyid path string true "Key ID" format(uuid)
295+
// @Param keyid path string true "Key ID" format(string)
296296
// @Success 204
297297
// @Router /users/{user}/keys/{keyid} [delete]
298298
func (api *API) deleteAPIKey(rw http.ResponseWriter, r *http.Request) {

coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
471471

472472
serverURL, err := url.Parse(srv.URL)
473473
require.NoError(t, err)
474-
serverURL.Host = fmt.Sprintf("localhost:%d", tcpAddr.Port)
474+
serverURL.Host = fmt.Sprintf("127.0.0.1:%d", tcpAddr.Port)
475475

476476
derpPort, err := strconv.Atoi(serverURL.Port())
477477
require.NoError(t, err)

coderd/database/dbpurge/dbpurge_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import (
1515
"github.com/stretchr/testify/assert"
1616
"github.com/stretchr/testify/require"
1717
"go.uber.org/goleak"
18+
"go.uber.org/mock/gomock"
1819

1920
"cdr.dev/slog"
2021
"cdr.dev/slog/sloggers/slogtest"
2122

2223
"github.com/coder/coder/v2/coderd/database"
2324
"github.com/coder/coder/v2/coderd/database/dbgen"
25+
"github.com/coder/coder/v2/coderd/database/dbmock"
2426
"github.com/coder/coder/v2/coderd/database/dbpurge"
2527
"github.com/coder/coder/v2/coderd/database/dbrollup"
2628
"github.com/coder/coder/v2/coderd/database/dbtestutil"
@@ -46,8 +48,9 @@ func TestPurge(t *testing.T) {
4648
// We want to make sure dbpurge is actually started so that this test is meaningful.
4749
clk := quartz.NewMock(t)
4850
done := awaitDoTick(ctx, t, clk)
49-
db, _ := dbtestutil.NewDB(t)
50-
purger := dbpurge.New(context.Background(), testutil.Logger(t), db, clk)
51+
mDB := dbmock.NewMockStore(gomock.NewController(t))
52+
mDB.EXPECT().InTx(gomock.Any(), database.DefaultTXOptions().WithID("db_purge")).Return(nil).Times(2)
53+
purger := dbpurge.New(context.Background(), testutil.Logger(t), mDB, clk)
5154
<-done // wait for doTick() to run.
5255
require.NoError(t, purger.Close())
5356
}

coderd/workspaceagents_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ func TestWatchWorkspaceAgentDevcontainers(t *testing.T) {
15791579
t.Parallel()
15801580

15811581
var (
1582-
ctx = testutil.Context(t, testutil.WaitLong)
1582+
ctx = testutil.Context(t, testutil.WaitSuperLong)
15831583
logger = slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
15841584
mClock = quartz.NewMock(t)
15851585
updaterTickerTrap = mClock.Trap().TickerFunc("updaterLoop")

docs/install/uninstall.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ performing the following step or copying the directory to another location.
7474

7575
<div class="tabs">
7676

77-
## macOS
77+
## Linux
7878

7979
```shell
80-
rm -rf ~/Library/Application\ Support/coderv2
80+
rm -rf ~/.config/coderv2
81+
rm -rf ~/.cache/coder
8182
```
8283

83-
## Linux
84+
## macOS
8485

8586
```shell
86-
rm -rf ~/.config/coderv2
87-
rm -rf ~/.cache/coder
87+
rm -rf ~/Library/Application\ Support/coderv2
8888
```
8989

9090
## Windows

docs/reference/api/users.md

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dogfood/coder/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ module "vscode-web" {
333333
module "jetbrains" {
334334
count = data.coder_workspace.me.start_count
335335
source = "dev.registry.coder.com/coder/jetbrains/coder"
336-
version = "1.0.2"
336+
version = "1.0.3"
337337
agent_id = coder_agent.dev.id
338338
agent_name = "dev"
339339
folder = local.repo_dir
@@ -358,7 +358,7 @@ module "coder-login" {
358358
module "cursor" {
359359
count = data.coder_workspace.me.start_count
360360
source = "dev.registry.coder.com/coder/cursor/coder"
361-
version = "1.2.1"
361+
version = "1.3.0"
362362
agent_id = coder_agent.dev.id
363363
folder = local.repo_dir
364364
}
@@ -374,7 +374,7 @@ module "windsurf" {
374374
module "zed" {
375375
count = data.coder_workspace.me.start_count
376376
source = "dev.registry.coder.com/coder/zed/coder"
377-
version = "1.0.1"
377+
version = "1.1.0"
378378
agent_id = coder_agent.dev.id
379379
agent_name = "dev"
380380
folder = local.repo_dir

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy