/
e2e.go
78 lines (61 loc) 路 1.84 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
package e2e
import (
"testing"
"time"
"github.com/appscode/kutil/meta"
"github.com/appscode/kutil/tools/clientcmd"
"github.com/appscode/voyager/client/clientset/versioned/scheme"
"github.com/appscode/voyager/pkg/config"
"github.com/appscode/voyager/pkg/operator"
"github.com/appscode/voyager/test/framework"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
)
const (
TestTimeout = 2 * time.Hour
)
var (
root *framework.Framework
invocation *framework.Invocation
)
func RunE2ETestSuit(t *testing.T) {
RegisterFailHandler(Fail)
SetDefaultEventuallyTimeout(TestTimeout)
junitReporter := reporters.NewJUnitReporter("report.xml")
RunSpecsWithDefaultAndCustomReporters(t, "Voyager E2E Suite", []Reporter{junitReporter})
}
var _ = BeforeSuite(func() {
scheme.AddToScheme(clientsetscheme.Scheme)
config.LoggerOptions.Verbosity = "5"
options.validate()
clientConfig, err := clientcmd.BuildConfigFromContext(options.KubeConfig, options.KubeContext)
Expect(err).NotTo(HaveOccurred())
operatorConfig := operator.NewOperatorConfig(clientConfig)
err = options.ApplyTo(operatorConfig)
Expect(err).NotTo(HaveOccurred())
root = framework.New(operatorConfig, options.TestNamespace, options.Cleanup)
if options.OperatorOnly { // run operator locally without running tests
root.Operator.RunInformers(nil)
}
By("Ensuring Test Namespace " + options.TestNamespace)
err = root.EnsureNamespace()
Expect(err).NotTo(HaveOccurred())
invocation = root.Invoke()
if !meta.PossiblyInCluster() {
go root.Operator.RunInformers(nil)
}
Eventually(invocation.Ingress.Setup).Should(BeNil())
})
var _ = AfterSuite(func() {
if !options.Cleanup {
return
}
if invocation != nil {
invocation.Ingress.Teardown()
}
if root != nil {
root.DeleteNamespace()
}
})