Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Feb 10, 2018
1 parent bf32a43 commit 4f18205
Show file tree
Hide file tree
Showing 79 changed files with 8,399 additions and 292 deletions.
25 changes: 21 additions & 4 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/e2e/certificate_gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var _ = Describe("CertificateWithDNSProvider", func() {
f = root.Invoke()

skipTestIfSecretNotProvided()
if !f.Config.TestCertificate {
if !options.TestCertificate {
Skip("Certificate Test is not enabled")
}

Expand Down Expand Up @@ -89,7 +89,7 @@ var _ = Describe("CertificateWithDNSProvider", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.KubeClient.CoreV1().Secrets(userSecret.Namespace).Delete(userSecret.Name, &metav1.DeleteOptions{})
f.KubeClient.CoreV1().Secrets(credentialSecret.Namespace).Delete(credentialSecret.Name, &metav1.DeleteOptions{})
}
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/certificate_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io/ioutil"
"net/http"

"github.com/appscode/kutil/meta"
api "github.com/appscode/voyager/apis/voyager/v1beta1"
"github.com/appscode/voyager/pkg/certificate"
"github.com/appscode/voyager/test/framework"
Expand All @@ -25,7 +26,7 @@ var _ = Describe("CertificateWithHTTPProvider", func() {
BeforeEach(func() {
f = root.Invoke()

if !f.Config.TestCertificate {
if !options.TestCertificate {
Skip("Certificate Test is not enabled")
}

Expand Down Expand Up @@ -83,7 +84,7 @@ var _ = Describe("CertificateWithHTTPProvider", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
f.KubeClient.CoreV1().Secrets(userSecret.Namespace).Delete(userSecret.Name, &metav1.DeleteOptions{})
}
Expand All @@ -106,7 +107,7 @@ var _ = Describe("CertificateWithHTTPProvider", func() {
return false
}, "20m", "10s").Should(BeTrue())

if f.Config.InCluster {
if meta.PossiblyInCluster() {
eps, err := f.Ingress.GetHTTPEndpoints(ing)
Expect(err).NotTo(HaveOccurred())
Expect(len(eps)).Should(BeNumerically(">=", 1))
Expand Down
74 changes: 30 additions & 44 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ import (
"testing"
"time"

"testing"
"time"

"github.com/appscode/go/runtime"
"github.com/appscode/kutil/meta"
"github.com/appscode/kutil/tools/clientcmd"
"github.com/appscode/voyager/client/scheme"
"github.com/appscode/voyager/pkg/config"
hpdata "github.com/appscode/voyager/pkg/haproxy/template"
"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"
"github.com/appscode/voyager/test/framework"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"
"github.com/appscode/voyager/pkg/config"
"github.com/appscode/go/runtime"
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
)

const (
Expand All @@ -35,54 +30,45 @@ var (
func RunE2ETestSuit(t *testing.T) {
RegisterFailHandler(Fail)
SetDefaultEventuallyTimeout(TestTimeout)

root = framework.New()
invocation = root.Invoke()

junitReporter := reporters.NewJUnitReporter("report.xml")
RunSpecsWithDefaultAndCustomReporters(t, "Voyager E2E Suite", []Reporter{junitReporter})
}

var _ = BeforeSuite(func() {
op := operator.New(
root.KubeClient,
root.CRDClient,
root.VoyagerClient,
nil,
config.OperatorOptions{
CloudProvider: root.Config.CloudProviderName,
DockerRegistry: root.Config.DockerRegistry,
HAProxyImageTag: root.Config.HAProxyImageTag,
IngressClass: root.Config.IngressClass,
NumThreads: 1,
},
)

By("Ensuring Test Namespace " + root.Config.TestNamespace)
err := root.EnsureNamespace()
Expect(err).NotTo(HaveOccurred())
scheme.AddToScheme(clientsetscheme.Scheme)
config.LoggerOptions.Verbosity = "5"

options.validate()

clientConfig, err := clientcmd.BuildConfigFromContext(options.KubeConfig, options.KubeContext)
Expect(err).NotTo(HaveOccurred())

config.LoggerOptions.Verbosity = "5"
operatorConfig := operator.NewOperatorConfig(clientConfig)
err = options.ApplyTo(operatorConfig)
Expect(err).NotTo(HaveOccurred())

if !root.Config.InCluster {
By("Running Controller in Local mode")
err := op.Setup()
Expect(err).NotTo(HaveOccurred())
root = framework.New(operatorConfig, options.TestNamespace, options.Cleanup)

err = hpdata.LoadTemplates(runtime.GOPath()+"/src/github.com/appscode/voyager/hack/docker/voyager/templates/*.cfg", "")
Expect(err).NotTo(HaveOccurred())
By("Ensuring Test Namespace " + options.TestNamespace)
err = root.EnsureNamespace()
Expect(err).NotTo(HaveOccurred())

//stop := make(chan struct{})
//defer close(stop)
go op.Run(nil)
}
root.EventuallyCRD().Should(Succeed())
invocation = root.Invoke()

if !meta.PossiblyInCluster() {
err = hpdata.LoadTemplates(runtime.GOPath()+"/src/github.com/appscode/voyager/hack/docker/voyager/templates/*.cfg", "")
Expect(err).NotTo(HaveOccurred())

//stop := make(chan struct{})
//defer close(stop)
go root.Operator.RunInformers(nil)
}

Eventually(invocation.Ingress.Setup).Should(BeNil())
Eventually(invocation.Ingress.Setup).Should(BeNil())
})

var _ = AfterSuite(func() {
if root.Config.Cleanup {
if options.Cleanup {
root.DeleteNamespace()
invocation.Ingress.Teardown()
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ingress_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var _ = Describe("Frontend rule using specified backend", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
}
})
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/ingress_basicauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var _ = Describe("IngressWithBasicAuth", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
f.KubeClient.CoreV1().Secrets(secret.Namespace).Delete(secret.Name, &metav1.DeleteOptions{})
}
Expand Down Expand Up @@ -269,7 +269,7 @@ var _ = Describe("IngressWithBasicAuth", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.KubeClient.CoreV1().Secrets(sec.Namespace).Delete(sec.Name, &metav1.DeleteOptions{})
}
})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ingress_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("IngressCoreOperations", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.KubeClient.ExtensionsV1beta1().Ingresses(ext.Namespace).Delete(ext.Name, &metav1.DeleteOptions{})
}
})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ingress_dnsresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var _ = Describe("IngressWithDNSResolvers", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
f.KubeClient.CoreV1().Services(svcResolveDNSWithNS.Namespace).Delete(svcResolveDNSWithNS.Name, &metav1.DeleteOptions{})
f.KubeClient.CoreV1().Services(svcResolveDNSWithNS.Namespace).Delete(svcResolveDNSWithNS.Name, &metav1.DeleteOptions{})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ingress_errorfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Content-Type: text/html
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
f.KubeClient.CoreV1().ConfigMaps(configMap.Namespace).Delete(configMap.Name, &metav1.DeleteOptions{})
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/ingress_hostnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("IngressWithHostName", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.DeleteResourceWithHostNames(meta)
f.Ingress.Delete(ing)
}
Expand Down Expand Up @@ -74,8 +74,8 @@ var _ = Describe("IngressWithHostName", func() {
})

It("Should create Ingress with hostname", func() {
By("Checking StatusIP for provider" + f.Config.CloudProviderName)
if f.Config.CloudProviderName == "minikube" {
By("Checking StatusIP for provider" + options.CloudProvider)
if options.CloudProvider == "minikube" {
Skip("Minikube do not support this")
}
// Check Status for ingress
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/ingress_hostport.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"time"

"github.com/appscode/kutil/meta"
api "github.com/appscode/voyager/apis/voyager/v1beta1"
"github.com/appscode/voyager/test/framework"
"github.com/appscode/voyager/test/test-server/client"
Expand All @@ -25,7 +26,7 @@ var _ = Describe("IngressHostPort", func() {
ing = f.Ingress.GetSkeleton()
f.Ingress.SetDaemonSkeletonRule(ing)

if !f.Config.InCluster && f.Config.CloudProviderName != "minikube" {
if !meta.PossiblyInCluster() && options.CloudProvider != "minikube" {
Skip("Test is Running from outside of cluster skipping test")
}
})
Expand All @@ -42,7 +43,7 @@ var _ = Describe("IngressHostPort", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
}
})
Expand Down Expand Up @@ -162,7 +163,7 @@ var _ = Describe("IngressHostPort", func() {
return errors.New("TCP port not found")
}, "5m", "20s").Should(BeNil())

if f.Config.CloudProviderName != "minikube" {
if options.CloudProvider != "minikube" {
eps, err := f.Ingress.GetHTTPEndpoints(ing)
Expect(err).NotTo(HaveOccurred())
Expect(len(eps)).Should(BeNumerically(">=", 1))
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/ingress_l7_withport.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = Describe("IngressWithCustomPorts", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
}
})
Expand Down Expand Up @@ -153,7 +153,7 @@ var _ = Describe("IngressWithCustomPorts", func() {
})

It("Should check update", func() {
if root.Config.CloudProviderName != "minikube" {
if options.CloudProvider != "minikube" {
Skip("CloudProvider Needs to be configured for NodePort")
}

Expand Down Expand Up @@ -215,7 +215,7 @@ var _ = Describe("IngressWithCustomPorts", func() {
})

It("Should check update", func() {
if root.Config.CloudProviderName != "minikube" {
if options.CloudProvider != "minikube" {
Skip("CloudProvider needs to be configured for NodePort")
}

Expand Down Expand Up @@ -258,7 +258,7 @@ var _ = Describe("IngressWithCustomPorts", func() {
})

It("Should check update", func() {
if root.Config.CloudProviderName != "minikube" {
if options.CloudProvider != "minikube" {
Skip("CloudProvider needs to be configured for NodePort")
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ingress_nodeport.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = Describe("IngressNodePort", func() {
})

AfterEach(func() {
if root.Config.Cleanup {
if options.Cleanup {
f.Ingress.Delete(ing)
}
})
Expand Down
Loading

0 comments on commit 4f18205

Please sign in to comment.