-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_test.go
57 lines (46 loc) · 1.39 KB
/
main_test.go
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
package main
import (
"context"
"os"
"testing"
"github.com/civo/civo-csi/pkg/driver"
"github.com/civo/civogo"
"github.com/kubernetes-csi/csi-test/v4/pkg/sanity"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/sync/errgroup"
)
// TestCivoCSI runs the Sanity test suite
func TestCivoCSI(t *testing.T) {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
fc, _ := civogo.NewFakeClient()
d, _ := driver.NewTestDriver(fc)
ctx, cancel := context.WithCancel(context.Background())
os.Setenv("REGION", "TESTING1")
os.Setenv("NAMESPACE", "default")
cluster, _ := d.CivoClient.NewKubernetesClusters(&civogo.KubernetesClusterConfig{
Name: "test",
NumTargetNodes: 1,
})
os.Setenv("NODE_ID", cluster.Pools[0].Instances[0].ID)
d.ClusterID = cluster.ID
os.Setenv("CLUSTER_ID", cluster.ID)
var eg errgroup.Group
eg.Go(func() error {
return d.Run(ctx)
})
config := sanity.NewTestConfig()
if err := os.RemoveAll(config.TargetPath); err != nil {
t.Fatalf("failed to delete target path %s: %s", config.TargetPath, err)
}
if err := os.RemoveAll(config.StagingPath); err != nil {
t.Fatalf("failed to delete staging path %s: %s", config.StagingPath, err)
}
config.Address = d.SocketFilename
sanity.Test(t, config)
cancel()
if err := eg.Wait(); err != nil {
t.Errorf("driver run failed: %s", err)
}
}