Merge pull request #10658 from ixdy/fix-namespace-e2e-slowness

e2e: update namespace test to create/delete test namespaces in parallel
This commit is contained in:
Zach Loafman 2015-07-01 19:36:13 -07:00
commit 3597344459
2 changed files with 26 additions and 8 deletions

View File

@ -153,7 +153,7 @@ case ${JOB_NAME} in
: ${GINKGO_PARALLEL:="y"} : ${GINKGO_PARALLEL:="y"}
# This list should match the list in kubernetes-e2e-gce-parallel. It # This list should match the list in kubernetes-e2e-gce-parallel. It
# currently also excludes a slow namespace test. # currently also excludes a slow namespace test.
: ${GINKGO_TEST_ARGS:="--ginkgo.skip=${GCE_DEFAULT_SKIP_TEST_REGEX}|${GCE_PARALLEL_SKIP_TEST_REGEX}|${GCE_PARALLEL_FLAKY_TEST_REGEX}|Namespaces\sDelete\s90\spercent\sof\s100\snamespace\sin\s150\sseconds"} : ${GINKGO_TEST_ARGS:="--ginkgo.skip=${GCE_DEFAULT_SKIP_TEST_REGEX}|${GCE_PARALLEL_SKIP_TEST_REGEX}|${GCE_PARALLEL_FLAKY_TEST_REGEX}"}
: ${KUBE_GCE_INSTANCE_PREFIX:="pull-e2e-${EXECUTOR_NUMBER}"} : ${KUBE_GCE_INSTANCE_PREFIX:="pull-e2e-${EXECUTOR_NUMBER}"}
: ${KUBE_GCS_STAGING_PATH_SUFFIX:="-${EXECUTOR_NUMBER}"} : ${KUBE_GCS_STAGING_PATH_SUFFIX:="-${EXECUTOR_NUMBER}"}
: ${PROJECT:="kubernetes-jenkins-pull"} : ${PROJECT:="kubernetes-jenkins-pull"}

View File

@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
"strings" "strings"
"sync"
"time" "time"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -42,27 +43,44 @@ func countRemaining(c *client.Client, withName string) (int, error) {
} }
func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSeconds int) { func extinguish(c *client.Client, totalNS int, maxAllowedAfterDel int, maxSeconds int) {
var err error var err error
By("Creating testing namespaces")
wg := &sync.WaitGroup{}
for n := 0; n < totalNS; n += 1 { for n := 0; n < totalNS; n += 1 {
_, err = createTestingNS(fmt.Sprintf("nslifetest-%v", n), c) wg.Add(1)
Expect(err).NotTo(HaveOccurred()) go func(n int) {
defer wg.Done()
defer GinkgoRecover()
_, err = createTestingNS(fmt.Sprintf("nslifetest-%v", n), c)
Expect(err).NotTo(HaveOccurred())
}(n)
} }
wg.Wait()
By("Waiting 10 seconds")
//Wait 10 seconds, then SEND delete requests for all the namespaces. //Wait 10 seconds, then SEND delete requests for all the namespaces.
time.Sleep(time.Duration(10 * time.Second)) time.Sleep(time.Duration(10 * time.Second))
By("Deleting namespaces")
nsList, err := c.Namespaces().List(labels.Everything(), fields.Everything()) nsList, err := c.Namespaces().List(labels.Everything(), fields.Everything())
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
var nsCount = 0
for _, item := range nsList.Items { for _, item := range nsList.Items {
if strings.Contains(item.Name, "nslifetest") { if strings.Contains(item.Name, "nslifetest") {
if err := c.Namespaces().Delete(item.Name); err != nil { wg.Add(1)
Failf("Failed deleting error ::: --- %v ", err) nsCount++
} go func(nsName string) {
defer wg.Done()
defer GinkgoRecover()
Expect(c.Namespaces().Delete(nsName)).To(Succeed())
Logf("namespace : %v api call to delete is complete ", nsName)
}(item.Name)
} }
Logf("namespace : %v api call to delete is complete ", item)
} }
Expect(nsCount).To(Equal(totalNS))
wg.Wait()
By("Waiting for namespaces to vanish")
//Now POLL until all namespaces have been eradicated. //Now POLL until all namespaces have been eradicated.
expectNoError(wait.Poll(2*time.Second, time.Duration(maxSeconds)*time.Second, expectNoError(wait.Poll(2*time.Second, time.Duration(maxSeconds)*time.Second,
func() (bool, error) { func() (bool, error) {