Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/pkg/integration/disk-client.go
2498 views
1
// Copyright (c) 2023 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 integration
6
7
import (
8
"fmt"
9
"strings"
10
11
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
12
)
13
14
type DiskClient struct {
15
rpcClient *RpcClient
16
}
17
18
func Disk(rsa *RpcClient) DiskClient {
19
return DiskClient{rsa}
20
}
21
22
var NoSpaceErrorMsg = "No space left on device"
23
24
func (d DiskClient) Fallocate(testFilePath string, spaceToAllocate string) error {
25
var resp agent.ExecResponse
26
err := d.rpcClient.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
27
Dir: "/workspace",
28
Command: "fallocate",
29
Args: []string{"-l", spaceToAllocate, testFilePath},
30
}, &resp)
31
32
if err != nil {
33
return fmt.Errorf("error: %w", err)
34
}
35
if resp.ExitCode != 0 {
36
return fmt.Errorf("returned returned rc: %d err: %v", resp.ExitCode, resp.Stderr)
37
}
38
if strings.Contains(resp.Stdout, NoSpaceErrorMsg) {
39
return fmt.Errorf(resp.Stdout)
40
}
41
42
return nil
43
}
44
45