Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/tests/components/ws-daemon/fuse_device_test.go
2501 views
1
// Copyright (c) 2022 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 wsdaemon
6
7
import (
8
"context"
9
"testing"
10
"time"
11
12
"github.com/gitpod-io/gitpod/test/pkg/integration"
13
"sigs.k8s.io/e2e-framework/pkg/envconf"
14
"sigs.k8s.io/e2e-framework/pkg/features"
15
)
16
17
func TestFuseDevice(t *testing.T) {
18
f := features.New("fuse devive").
19
WithLabel("component", "ws-daemon").
20
Assess("verify fuse device", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
21
t.Parallel()
22
23
ctx, cancel := context.WithTimeout(testCtx, 5*time.Minute)
24
defer cancel()
25
26
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
27
t.Cleanup(func() {
28
api.Done(t)
29
})
30
31
ws, stopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api)
32
if err != nil {
33
t.Fatal(err)
34
}
35
t.Cleanup(func() {
36
sctx, scancel := context.WithTimeout(context.Background(), 5*time.Minute)
37
defer scancel()
38
39
sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
40
defer sapi.Done(t)
41
42
_, err = stopWs(true, sapi)
43
if err != nil {
44
t.Fatal(err)
45
}
46
})
47
48
rsa, closer, err := integration.Instrument(integration.ComponentWorkspace, "workspace", cfg.Namespace(), kubeconfig, cfg.Client(), integration.WithInstanceID(ws.Req.Id))
49
if err != nil {
50
t.Fatalf("unexpected error instrumenting workspace: %v", err)
51
}
52
defer rsa.Close()
53
integration.DeferCloser(t, closer)
54
55
t.Logf("checking fuse device")
56
hasFuse, err := integration.HasFuseDevice(rsa)
57
if err != nil {
58
t.Fatalf("unexpected error checking fuse device: %v", err)
59
}
60
if !hasFuse {
61
t.Fatalf("fuse device is not available: %v", err)
62
}
63
64
return testCtx
65
}).Feature()
66
67
testEnv.Test(t, f)
68
}
69
70