add a label to namespaces created by e2e framework

This commit is contained in:
Mike Danese 2015-12-10 14:20:48 -08:00
parent aaa1fe67f6
commit a3b6674fbf
6 changed files with 17 additions and 5 deletions

View File

@ -180,5 +180,6 @@ func TestE2E(t *testing.T) {
if *reportDir != "" { if *reportDir != "" {
r = append(r, reporters.NewJUnitReporter(path.Join(*reportDir, fmt.Sprintf("junit_%02d.xml", config.GinkgoConfig.ParallelNode)))) r = append(r, reporters.NewJUnitReporter(path.Join(*reportDir, fmt.Sprintf("junit_%02d.xml", config.GinkgoConfig.ParallelNode))))
} }
glog.Infof("Starting e2e run; %q", runId)
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r) ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r)
} }

View File

@ -76,7 +76,7 @@ var _ = Describe("[Example] ClusterDns", func() {
namespaces := []*api.Namespace{nil, nil} namespaces := []*api.Namespace{nil, nil}
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, nil)
if testContext.DeleteNamespace { 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 */)

View File

@ -75,7 +75,9 @@ func (f *Framework) beforeEach() {
f.Client = c f.Client = c
By("Building a namespace api object") By("Building a namespace api object")
namespace, err := createTestingNS(f.BaseName, f.Client) namespace, err := createTestingNS(f.BaseName, f.Client, map[string]string{
"e2e-framework": f.BaseName,
})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
f.Namespace = namespace f.Namespace = namespace

View File

@ -40,7 +40,7 @@ func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSecond
go func(n int) { go func(n int) {
defer wg.Done() defer wg.Done()
defer GinkgoRecover() defer GinkgoRecover()
_, err = createTestingNS(fmt.Sprintf("nslifetest-%v", n), c) _, err = createTestingNS(fmt.Sprintf("nslifetest-%v", n), c, nil)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}(n) }(n)
} }

View File

@ -778,7 +778,7 @@ var _ = Describe("Services", func() {
ns1 := f.Namespace.Name ns1 := f.Namespace.Name
By("Building a second namespace api object") By("Building a second namespace api object")
namespacePtr, err := createTestingNS("services", c) namespacePtr, err := createTestingNS("services", c, nil)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
ns2 := namespacePtr.Name ns2 := namespacePtr.Name
extraNamespaces = append(extraNamespaces, ns2) extraNamespaces = append(extraNamespaces, ns2)

View File

@ -119,6 +119,9 @@ type CloudConfig struct {
Provider cloudprovider.Interface Provider cloudprovider.Interface
} }
// unique identifier of the e2e run
var runId = util.NewUUID()
type TestContextType struct { type TestContextType struct {
KubeConfig string KubeConfig string
KubeContext string KubeContext string
@ -554,11 +557,17 @@ func waitForPersistentVolumePhase(phase api.PersistentVolumePhase, c *client.Cli
// createTestingNS should be used by every test, note that we append a common prefix to the provided test name. // createTestingNS should be used by every test, note that we append a common prefix to the provided test name.
// Please see NewFramework instead of using this directly. // Please see NewFramework instead of using this directly.
func createTestingNS(baseName string, c *client.Client) (*api.Namespace, error) { func createTestingNS(baseName string, c *client.Client, labels map[string]string) (*api.Namespace, error) {
if labels == nil {
labels = map[string]string{}
}
labels["e2e-run"] = string(runId)
namespaceObj := &api.Namespace{ namespaceObj := &api.Namespace{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
GenerateName: fmt.Sprintf("e2e-tests-%v-", baseName), GenerateName: fmt.Sprintf("e2e-tests-%v-", baseName),
Namespace: "", Namespace: "",
Labels: labels,
}, },
Status: api.NamespaceStatus{}, Status: api.NamespaceStatus{},
} }