Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/tests/workspace/mount_proc_test.go
2496 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package workspace
6
7
import (
8
"context"
9
"fmt"
10
"sync"
11
"testing"
12
"time"
13
14
"sigs.k8s.io/e2e-framework/pkg/envconf"
15
"sigs.k8s.io/e2e-framework/pkg/features"
16
17
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
18
"github.com/gitpod-io/gitpod/test/pkg/integration"
19
)
20
21
const (
22
numberOfMount = 500
23
parallel = 5
24
)
25
26
func loadMountProc(t *testing.T, rsa *integration.RpcClient) {
27
var resp agent.ExecResponse
28
err := rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
29
Dir: "/",
30
Command: "bash",
31
Args: []string{
32
"-c",
33
fmt.Sprintf("for i in {1..%d}; do echo $i; sudo unshare -m --propagation unchanged mount -t proc proc $(mktemp -d) || exit 1; done", numberOfMount),
34
},
35
}, &resp)
36
if err != nil {
37
t.Fatalf("proc mount run failed: %v\n%s\n%s", err, resp.Stdout, resp.Stderr)
38
}
39
40
if resp.ExitCode != 0 {
41
t.Fatalf("proc mount run failed: %s\n%s", resp.Stdout, resp.Stderr)
42
}
43
44
}
45
46
func TestMountProc(t *testing.T) {
47
f := features.New("proc mount").
48
WithLabel("component", "workspace").
49
Assess("load test proc mount", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
50
ctx, cancel := context.WithTimeout(testCtx, 5*time.Minute)
51
defer cancel()
52
53
t.Parallel()
54
55
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
56
t.Cleanup(func() {
57
api.Done(t)
58
})
59
60
ws, stopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api)
61
if err != nil {
62
t.Fatal(err)
63
}
64
65
t.Cleanup(func() {
66
sctx, scancel := context.WithTimeout(context.Background(), 5*time.Minute)
67
defer scancel()
68
69
sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
70
defer sapi.Done(t)
71
72
_, err = stopWs(true, sapi)
73
if err != nil {
74
t.Errorf("cannot stop workspace: %q", err)
75
}
76
})
77
78
rsa, closer, err := integration.Instrument(integration.ComponentWorkspace, "workspace", cfg.Namespace(), kubeconfig, cfg.Client(), integration.WithInstanceID(ws.Req.Id), integration.WithWorkspacekitLift(true))
79
if err != nil {
80
t.Fatalf("unexpected error instrumenting workspace: %v", err)
81
}
82
defer rsa.Close()
83
integration.DeferCloser(t, closer)
84
85
var wg sync.WaitGroup
86
wg.Add(parallel)
87
for i := 0; i < parallel; i++ {
88
go func() {
89
defer wg.Done()
90
loadMountProc(t, rsa)
91
}()
92
}
93
wg.Wait()
94
95
return testCtx
96
}).
97
Feature()
98
99
testEnv.Test(t, f)
100
}
101
102