Added more logging to load e2e test

pull/6/head
Piotr Szczesniak 2015-05-13 16:06:32 +02:00
parent 7ba41626e9
commit 2cee828c91
2 changed files with 14 additions and 16 deletions

View File

@ -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)
}
}

View File

@ -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 {