From 2cee828c917b0f9cfdb442359340c8fe8b67db40 Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Wed, 13 May 2015 16:06:32 +0200 Subject: [PATCH] Added more logging to load e2e test --- test/e2e/load.go | 26 ++++++++++++-------------- test/e2e/util.go | 4 ++-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/test/e2e/load.go b/test/e2e/load.go index 031dc3e716..6470eb3f00 100644 --- a/test/e2e/load.go +++ b/test/e2e/load.go @@ -19,13 +19,13 @@ package e2e import ( "fmt" "math/rand" + "strconv" "sync" "time" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" - "github.com/GoogleCloudPlatform/kubernetes/pkg/util" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -89,9 +89,9 @@ var _ = Describe("Load", func() { wg.Add(threads) // Run RC load for all kinds of RC. - runRCLoad(c, &wg, ns, smallRCSize, smallRCCount) - runRCLoad(c, &wg, ns, mediumRCSize, mediumRCCount) - runRCLoad(c, &wg, ns, bigRCSize, bigRCCount) + runRCLoad(c, &wg, ns, "load-test-small-rc", smallRCSize, smallRCCount) + runRCLoad(c, &wg, ns, "load-test-medium-rc", mediumRCSize, mediumRCCount) + runRCLoad(c, &wg, ns, "load-test-big-rc", bigRCSize, bigRCCount) // Wait for all the pods from all the RC's to return. wg.Wait() @@ -113,35 +113,33 @@ func computeRCCounts(total int) (int, int, int) { } // The function creates a RC and then every few second resize it and with 0.1 probability deletes it. -func playWithRC(c *client.Client, wg *sync.WaitGroup, ns string, size int) { +func playWithRC(c *client.Client, wg *sync.WaitGroup, ns, name string, size int) { defer GinkgoRecover() defer wg.Done() rcExist := false - var name string // Once every 1-2 minutes perform resize of RC. for start := time.Now(); time.Since(start) < simulationTime; time.Sleep(time.Duration(60+rand.Intn(60)) * time.Second) { if !rcExist { - name = "load-test-" + string(util.NewUUID()) - expectNoError(RunRC(c, name, ns, image, size)) + expectNoError(RunRC(c, name, ns, image, size), fmt.Sprintf("creating rc %s in namespace %s", name, ns)) rcExist = true } // Resize RC to a random size between 0.5x and 1.5x of the original size. newSize := uint(rand.Intn(size+1) + size/2) - expectNoError(ResizeRC(c, ns, name, newSize)) + expectNoError(ResizeRC(c, ns, name, newSize), fmt.Sprintf("resizing rc %s in namespace %s", name, ns)) // With probability 0.1 remove this RC. if rand.Intn(10) == 0 { - expectNoError(DeleteRC(c, ns, name)) + expectNoError(DeleteRC(c, ns, name), fmt.Sprintf("deleting rc %s in namespace %s", name, ns)) rcExist = false } } if rcExist { - expectNoError(DeleteRC(c, ns, name)) + expectNoError(DeleteRC(c, ns, name), fmt.Sprintf("deleting rc %s in namespace %s after test completion", name, ns)) } } -func runRCLoad(c *client.Client, wg *sync.WaitGroup, ns string, size, count int) { +func runRCLoad(c *client.Client, wg *sync.WaitGroup, ns, groupName string, size, count int) { By(fmt.Sprintf("Running %v Replication Controllers with size %v and playing with them", count, size)) - for i := 0; i < count; i++ { - go playWithRC(c, wg, ns, size) + for i := 1; i <= count; i++ { + go playWithRC(c, wg, ns, groupName+"-"+strconv.Itoa(i), size) } } diff --git a/test/e2e/util.go b/test/e2e/util.go index 29b08e8e72..d74490da93 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -420,7 +420,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) error current := 0 same := 0 - By(fmt.Sprintf("Creating replication controller %s", name)) + By(fmt.Sprintf("Creating replication controller %s in namespace %s", name, ns)) _, err := c.ReplicationControllers(ns).Create(&api.ReplicationController{ ObjectMeta: api.ObjectMeta{ Name: name, @@ -450,7 +450,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) error return fmt.Errorf("Error creating replication controller: %v", err) } - By(fmt.Sprintf("Making sure all %d replicas exist", replicas)) + By(fmt.Sprintf("Making sure all %d replicas of rc %s in namespace %s exist", replicas, name, ns)) label := labels.SelectorFromSet(labels.Set(map[string]string{"name": name})) pods, err := listPods(c, ns, label, fields.Everything()) if err != nil {