Port remaining e2e tests to framework

This commit is contained in:
gmarek 2015-10-27 09:24:32 +01:00
parent 0150d87a73
commit e638a415d4
7 changed files with 39 additions and 100 deletions

View File

@ -17,33 +17,21 @@ limitations under the License.
package e2e package e2e
import ( import (
"time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util" "k8s.io/kubernetes/pkg/util"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
) )
var _ = Describe("Docker Containers", func() { var _ = Describe("Docker Containers", func() {
framework := NewFramework("containers")
var c *client.Client var c *client.Client
var ns string var ns string
BeforeEach(func() { BeforeEach(func() {
var err error c = framework.Client
c, err = loadClient() ns = framework.Namespace.Name
Expect(err).NotTo(HaveOccurred())
ns_, err := createTestingNS("containers", c)
ns = ns_.Name
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete ns %s", err)
}
}) })
It("should use the image defaults if command and args are blank [Conformance]", func() { It("should use the image defaults if command and args are blank [Conformance]", func() {

View File

@ -48,23 +48,12 @@ except:
print 'err'` print 'err'`
var _ = Describe("Examples e2e", func() { var _ = Describe("Examples e2e", func() {
framework := NewFramework("examples")
var c *client.Client var c *client.Client
var ns string var ns string
var testingNs *api.Namespace
BeforeEach(func() { BeforeEach(func() {
var err error c = framework.Client
c, err = loadClient() ns = framework.Namespace.Name
expectNoError(err)
testingNs, err = createTestingNS("examples", c)
ns = testingNs.Name
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
By(fmt.Sprintf("Destroying namespace for this suite %v", ns))
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete ns %s", err)
}
}) })
Describe("[Skipped][Example]Redis", func() { Describe("[Skipped][Example]Redis", func() {
@ -476,10 +465,14 @@ var _ = Describe("Examples e2e", func() {
for i := range namespaces { for i := range namespaces {
var err error var err error
namespaces[i], err = createTestingNS(fmt.Sprintf("dnsexample%d", i), c) namespaces[i], err = createTestingNS(fmt.Sprintf("dnsexample%d", i), c)
if namespaces[i] != nil { if testContext.DeleteNamespace {
defer deleteNS(c, namespaces[i].Name, 5*time.Minute /* namespace deletion timeout */) if namespaces[i] != nil {
defer deleteNS(c, namespaces[i].Name, 5*time.Minute /* namespace deletion timeout */)
}
Expect(err).NotTo(HaveOccurred())
} else {
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
} }
Expect(err).NotTo(HaveOccurred())
} }
for _, ns := range namespaces { for _, ns := range namespaces {

View File

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest" "k8s.io/kubernetes/pkg/api/latest"
@ -28,37 +27,23 @@ import (
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
) )
//TODO : Consolidate this code with the code for emptyDir. //TODO : Consolidate this code with the code for emptyDir.
//This will require some smart. //This will require some smart.
var _ = Describe("hostPath", func() { var _ = Describe("hostPath", func() {
var ( framework := NewFramework("hostpath")
c *client.Client var c *client.Client
namespace *api.Namespace var namespace *api.Namespace
)
BeforeEach(func() { BeforeEach(func() {
var err error c = framework.Client
c, err = loadClient() namespace = framework.Namespace
Expect(err).NotTo(HaveOccurred())
By("Building a namespace api object")
namespace, err = createTestingNS("hostpath", c)
Expect(err).NotTo(HaveOccurred())
//cleanup before running the test. //cleanup before running the test.
_ = os.Remove("/tmp/test-file") _ = os.Remove("/tmp/test-file")
}) })
AfterEach(func() {
By(fmt.Sprintf("Destroying namespace for this suite %v", namespace.Name))
if err := deleteNS(c, namespace.Name, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete ns %s", err)
}
})
It("should give a volume the correct mode [Conformance]", func() { It("should give a volume the correct mode [Conformance]", func() {
volumePath := "/test-volume" volumePath := "/test-volume"
source := &api.HostPathVolumeSource{ source := &api.HostPathVolumeSource{

View File

@ -76,23 +76,12 @@ var proxyRegexp = regexp.MustCompile("Starting to serve on 127.0.0.1:([0-9]+)")
var _ = Describe("Kubectl client", func() { var _ = Describe("Kubectl client", func() {
defer GinkgoRecover() defer GinkgoRecover()
framework := NewFramework("kubectl")
var c *client.Client var c *client.Client
var ns string var ns string
var testingNs *api.Namespace
BeforeEach(func() { BeforeEach(func() {
var err error c = framework.Client
c, err = loadClient() ns = framework.Namespace.Name
expectNoError(err)
testingNs, err = createTestingNS("kubectl", c)
Expect(err).NotTo(HaveOccurred())
ns = testingNs.Name
})
AfterEach(func() {
By(fmt.Sprintf("Destroying namespace for this suite %v", ns))
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete ns %s", err)
}
}) })
Describe("Update Demo", func() { Describe("Update Demo", func() {

View File

@ -17,7 +17,6 @@ limitations under the License.
package e2e package e2e
import ( import (
"fmt"
"time" "time"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -33,23 +32,13 @@ import (
// the test needs privileged containers, which are disabled by default. // the test needs privileged containers, which are disabled by default.
// Run the test with "go run hack/e2e.go ... --ginkgo.focus=PersistentVolume" // Run the test with "go run hack/e2e.go ... --ginkgo.focus=PersistentVolume"
var _ = Describe("[Skipped] persistentVolumes", func() { var _ = Describe("[Skipped] persistentVolumes", func() {
framework := NewFramework("pv")
var c *client.Client var c *client.Client
var ns string var ns string
BeforeEach(func() { BeforeEach(func() {
var err error c = framework.Client
c, err = loadClient() ns = framework.Namespace.Name
Expect(err).NotTo(HaveOccurred())
ns_, err := createTestingNS("pv", c)
ns = ns_.Name
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
By(fmt.Sprintf("Destroying namespace for this suite %v", ns))
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete ns %s", err)
}
}) })
It("PersistentVolume", func() { It("PersistentVolume", func() {

View File

@ -54,13 +54,17 @@ var _ = Describe("Services", func() {
}) })
AfterEach(func() { AfterEach(func() {
for _, ns := range extraNamespaces { if testContext.DeleteNamespace {
By(fmt.Sprintf("Destroying namespace %v", ns)) for _, ns := range extraNamespaces {
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil { By(fmt.Sprintf("Destroying namespace %v", ns))
Failf("Couldn't delete namespace %s: %s", ns, err) if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete namespace %s: %s", ns, err)
}
} }
extraNamespaces = nil
} else {
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
} }
extraNamespaces = nil
}) })
// TODO: We get coverage of TCP/UDP and multi-port services through the DNS test. We should have a simpler test for multi-port TCP here. // TODO: We get coverage of TCP/UDP and multi-port services through the DNS test. We should have a simpler test for multi-port TCP here.

View File

@ -219,27 +219,18 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api
} }
var _ = Describe("Volumes", func() { var _ = Describe("Volumes", func() {
clean := true // If 'false', the test won't clear its namespace (and pods and services) upon completion. Useful for debugging. framework := NewFramework("volume")
// If 'false', the test won't clear its volumes upon completion. Useful for debugging,
// note that namespace deletion is handled by delete-namespace flag
clean := true
// filled in BeforeEach // filled in BeforeEach
var c *client.Client var c *client.Client
var namespace *api.Namespace var namespace *api.Namespace
BeforeEach(func() { BeforeEach(func() {
var err error c = framework.Client
c, err = loadClient() namespace = framework.Namespace
Expect(err).NotTo(HaveOccurred())
By("Building a namespace api object")
namespace, err = createTestingNS("volume", c)
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
if clean {
if err := deleteNS(c, namespace.Name, 5*time.Minute /* namespace deletion timeout */); err != nil {
Failf("Couldn't delete ns %s", err)
}
}
}) })
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////