forked from shapeblue/cloudstack-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsanity_test.go
More file actions
59 lines (49 loc) · 1.37 KB
/
sanity_test.go
File metadata and controls
59 lines (49 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//go:build sanity
package sanity
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
"k8s.io/klog/v2"
"github.com/cloudstack/cloudstack-csi-driver/pkg/cloud/fake"
"github.com/cloudstack/cloudstack-csi-driver/pkg/driver"
"github.com/cloudstack/cloudstack-csi-driver/pkg/mount"
"github.com/kubernetes-csi/csi-test/v5/pkg/sanity"
)
func TestSanity(t *testing.T) {
// Setup driver
dir, err := ioutil.TempDir("", "sanity-cloudstack-csi")
if err != nil {
t.Fatalf("error creating directory: %v", err)
}
defer os.RemoveAll(dir)
targetPath := filepath.Join(dir, "target")
stagingPath := filepath.Join(dir, "staging")
endpoint := "unix://" + filepath.Join(dir, "csi.sock")
config := sanity.NewTestConfig()
config.TargetPath = targetPath
config.StagingPath = stagingPath
config.Address = endpoint
config.TestVolumeParameters = map[string]string{
driver.DiskOfferingKey: "9743fd77-0f5d-4ef9-b2f8-f194235c769c",
}
config.IdempotentCount = 5
config.TestNodeVolumeAttachLimit = true
logger := klog.Background()
ctx := klog.NewContext(context.Background(), logger)
options := driver.Options{
Mode: driver.AllMode,
Endpoint: endpoint,
NodeName: "node",
}
csiDriver, err := driver.New(ctx, fake.New(), &options, mount.NewFake())
if err != nil {
t.Fatalf("error creating driver: %v", err)
}
go func() {
csiDriver.Run(ctx)
}()
sanity.Test(t, config)
}