Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3aa7857

Browse files
committed
fix: allow startup scripts larger than 32k
1 parent 4d63a47 commit 3aa7857

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

coderd/workspaceagentsrpc_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package coderd_test
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
agentproto "github.com/coder/coder/v2/agent/proto"
8+
"github.com/coder/coder/v2/coderd/coderdtest"
9+
"github.com/coder/coder/v2/coderd/database"
10+
"github.com/coder/coder/v2/coderd/database/dbfake"
11+
"github.com/coder/coder/v2/codersdk/agentsdk"
12+
"github.com/coder/coder/v2/provisionersdk/proto"
13+
"github.com/stretchr/testify/require"
14+
)
15+
16+
func TestAgentAPI_LargeManifest(t *testing.T) {
17+
t.Parallel()
18+
ctx := context.Background()
19+
client, store := coderdtest.NewWithDatabase(t, nil)
20+
adminUser := coderdtest.CreateFirstUser(t, client)
21+
n := 512000
22+
longScript := make([]byte, n)
23+
for i := range longScript {
24+
longScript[i] = 'q'
25+
}
26+
r := dbfake.WorkspaceBuild(t, store, database.Workspace{
27+
OrganizationID: adminUser.OrganizationID,
28+
OwnerID: adminUser.UserID,
29+
}).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
30+
agents[0].Scripts = []*proto.Script{
31+
{
32+
Script: string(longScript),
33+
},
34+
}
35+
return agents
36+
}).Do()
37+
ac := agentsdk.New(client.URL)
38+
ac.SetSessionToken(r.AgentToken)
39+
conn, err := ac.ConnectRPC(ctx)
40+
defer conn.Close()
41+
require.NoError(t, err)
42+
agentAPI := agentproto.NewDRPCAgentClient(conn)
43+
manifest, err := agentAPI.GetManifest(ctx, &agentproto.GetManifestRequest{})
44+
require.NoError(t, err)
45+
require.Len(t, manifest.Scripts, 1)
46+
require.Len(t, manifest.Scripts[0].Script, n)
47+
}

0 commit comments

Comments
 (0)