-
Notifications
You must be signed in to change notification settings - Fork 26
/
e2e.go
105 lines (82 loc) · 2.21 KB
/
e2e.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package main
import (
"log"
"os"
"sync"
"testing"
"github.com/golang/glog"
kubernikusClient "github.com/sapcc/kubernikus/pkg/api/client"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
)
type E2ETestSuite struct {
E2ETestSuiteOptions
testing *testing.T
clientSet *kubernetes.Clientset
ClusterName string
kubernikusClient *kubernikusClient.Kubernikus
timeout int
readyNodes []v1.Node
readyPods []v1.Pod
readyServices []v1.Service
kubeConfig string
stopCh *chan bool
}
func NewE2ETestSuite(t *testing.T, options E2ETestSuiteOptions) *E2ETestSuite {
if err := options.OptionsFromConfigFile(); err != nil {
glog.Fatal(err)
}
if err := options.Verify(); err != nil {
log.Printf("Couldn't obtain openstack token using parameters given in config. Trying parameters from ENV. ")
options.OpenStackCredentials = getOpenStackCredentialsFromENV()
if err := options.Verify(); err != nil {
glog.Errorf("Checked config and env. Insufficient parameters for authentication : %v", err)
os.Exit(1)
}
}
token, err := getToken(options.OpenStackCredentials)
if err != nil {
glog.Fatalf("Authentication failed. Verify config file or environment")
}
options.OpenStackCredentials.Token = token
kubernikusCli := kubernikusClient.NewHTTPClientWithConfig(
nil,
&kubernikusClient.TransportConfig{
Host: options.APIURL,
Schemes: []string{"https"},
},
)
return &E2ETestSuite{
E2ETestSuiteOptions: options,
testing: t,
ClusterName: "e2e",
timeout: 5,
kubernikusClient: kubernikusCli,
}
}
func (s *E2ETestSuite) Run(wg *sync.WaitGroup, sigs chan os.Signal, stopCh chan bool) {
defer wg.Done()
wg.Add(1)
s.stopCh = &stopCh
log.Println("Running tests")
// API tests
if s.IsTestCreate || s.IsTestAPI || s.IsTestAll {
s.TestCreateCluster()
}
if s.IsTestAPI || s.IsTestAll {
s.TestListClusters()
s.TestShowCluster()
s.TestUpdateCluster()
s.TestGetClusterInfo()
}
// Smoke tests
if s.IsTestSmoke || s.IsTestNetwork || s.IsTestVolume || s.IsTestAll {
s.SetupSmokeTest()
s.RunSmokeTest()
}
if s.IsTestDelete || s.IsTestAPI || s.IsTestAll {
s.TestTerminateCluster()
}
//stopCh <- true
s.exitGraceful(sigs)
}