mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #16269 from gmarek/delete-namespace
Auto commit by PR queue bot
This commit is contained in:
commit
f2208a9855
@ -59,6 +59,7 @@ cpu-percent
|
|||||||
default-container-cpu-limit
|
default-container-cpu-limit
|
||||||
default-container-mem-limit
|
default-container-mem-limit
|
||||||
delay-shutdown
|
delay-shutdown
|
||||||
|
delete-namespace
|
||||||
deleting-pods-burst
|
deleting-pods-burst
|
||||||
deleting-pods-qps
|
deleting-pods-qps
|
||||||
deployment-label-key
|
deployment-label-key
|
||||||
|
@ -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() {
|
||||||
|
@ -82,6 +82,7 @@ func init() {
|
|||||||
flag.StringVar(&testContext.UpgradeTarget, "upgrade-target", "ci/latest", "Version to upgrade to (e.g. 'release/stable', 'release/latest', 'ci/latest', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
|
flag.StringVar(&testContext.UpgradeTarget, "upgrade-target", "ci/latest", "Version to upgrade to (e.g. 'release/stable', 'release/latest', 'ci/latest', '0.19.1', '0.19.1-669-gabac8c8') if doing an upgrade test.")
|
||||||
flag.StringVar(&testContext.PrometheusPushGateway, "prom-push-gateway", "", "The URL to prometheus gateway, so that metrics can be pushed during e2es and scraped by prometheus. Typically something like 127.0.0.1:9091.")
|
flag.StringVar(&testContext.PrometheusPushGateway, "prom-push-gateway", "", "The URL to prometheus gateway, so that metrics can be pushed during e2es and scraped by prometheus. Typically something like 127.0.0.1:9091.")
|
||||||
flag.BoolVar(&testContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
|
flag.BoolVar(&testContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
|
||||||
|
flag.BoolVar(&testContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestE2E(t *testing.T) {
|
func TestE2E(t *testing.T) {
|
||||||
|
@ -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 testContext.DeleteNamespace {
|
||||||
if namespaces[i] != nil {
|
if namespaces[i] != nil {
|
||||||
defer deleteNS(c, namespaces[i].Name, 5*time.Minute /* namespace deletion timeout */)
|
defer deleteNS(c, namespaces[i].Name, 5*time.Minute /* namespace deletion timeout */)
|
||||||
}
|
}
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
} else {
|
||||||
|
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ns := range namespaces {
|
for _, ns := range namespaces {
|
||||||
|
@ -100,6 +100,7 @@ func (f *Framework) afterEach() {
|
|||||||
Failf("All nodes should be ready after test, %v", err)
|
Failf("All nodes should be ready after test, %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if testContext.DeleteNamespace {
|
||||||
By(fmt.Sprintf("Destroying namespace %q for this suite.", f.Namespace.Name))
|
By(fmt.Sprintf("Destroying namespace %q for this suite.", f.Namespace.Name))
|
||||||
|
|
||||||
timeout := 5 * time.Minute
|
timeout := 5 * time.Minute
|
||||||
@ -109,6 +110,9 @@ func (f *Framework) afterEach() {
|
|||||||
if err := deleteNS(f.Client, f.Namespace.Name, timeout); err != nil {
|
if err := deleteNS(f.Client, f.Namespace.Name, timeout); err != nil {
|
||||||
Failf("Couldn't delete ns %q: %s", f.Namespace.Name, err)
|
Failf("Couldn't delete ns %q: %s", f.Namespace.Name, err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
|
||||||
|
}
|
||||||
// Paranoia-- prevent reuse!
|
// Paranoia-- prevent reuse!
|
||||||
f.Namespace = nil
|
f.Namespace = nil
|
||||||
f.Client = nil
|
f.Client = nil
|
||||||
|
@ -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{
|
||||||
|
@ -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() {
|
||||||
|
@ -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() {
|
||||||
|
@ -54,6 +54,7 @@ var _ = Describe("Services", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
if testContext.DeleteNamespace {
|
||||||
for _, ns := range extraNamespaces {
|
for _, ns := range extraNamespaces {
|
||||||
By(fmt.Sprintf("Destroying namespace %v", ns))
|
By(fmt.Sprintf("Destroying namespace %v", ns))
|
||||||
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
|
if err := deleteNS(c, ns, 5*time.Minute /* namespace deletion timeout */); err != nil {
|
||||||
@ -61,6 +62,9 @@ var _ = Describe("Services", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
extraNamespaces = nil
|
extraNamespaces = nil
|
||||||
|
} else {
|
||||||
|
Logf("Found DeleteNamespace=false, skipping namespace deletion!")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -120,6 +120,7 @@ type TestContextType struct {
|
|||||||
UpgradeTarget string
|
UpgradeTarget string
|
||||||
PrometheusPushGateway string
|
PrometheusPushGateway string
|
||||||
VerifyServiceAccount bool
|
VerifyServiceAccount bool
|
||||||
|
DeleteNamespace bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var testContext TestContextType
|
var testContext TestContextType
|
||||||
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user