From 8c67f92bd721db4f4000a75f7b865e8c28d55a16 Mon Sep 17 00:00:00 2001 From: gmarek Date: Tue, 21 Feb 2017 16:18:43 +0100 Subject: [PATCH] Add randomized load test --- test/e2e/load.go | 18 ++++++++++++++++++ test/utils/runners.go | 13 ++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/test/e2e/load.go b/test/e2e/load.go index 109bffba7e3..6c9dd67411e 100644 --- a/test/e2e/load.go +++ b/test/e2e/load.go @@ -63,6 +63,16 @@ const ( nodeCountPerNamespace = 100 ) +var randomKind = schema.GroupKind{Kind: "Random"} + +var knownKinds = []schema.GroupKind{ + api.Kind("ReplicationController"), + extensions.Kind("Deployment"), + // TODO: uncomment when Jobs are fixed: #38497 + //batch.Kind("Job"), + extensions.Kind("ReplicaSet"), +} + // This test suite can take a long time to run, so by default it is added to // the ginkgo.skip list (see driver.go). // To run this suite you must explicitly ask for it by setting the @@ -141,6 +151,8 @@ var _ = framework.KubeDescribe("Load capacity", func() { {podsPerNode: 30, image: "gcr.io/google_containers/serve_hostname:v1.4", kind: api.Kind("ReplicationController"), daemonsPerNode: 2}, // Test with secrets {podsPerNode: 30, image: "gcr.io/google_containers/serve_hostname:v1.4", kind: extensions.Kind("Deployment"), secretsPerPod: 2}, + // Special test case which randomizes created resources + {podsPerNode: 30, image: "gcr.io/google_containers/serve_hostname:v1.4", kind: randomKind}, } for _, testArg := range loadTests { @@ -370,7 +382,9 @@ func generateConfigsForGroup( ) ([]testutils.RunObjectConfig, []*testutils.SecretConfig) { configs := make([]testutils.RunObjectConfig, 0, count) secretConfigs := make([]*testutils.SecretConfig, 0, count*secretsPerPod) + savedKind := kind for i := 1; i <= count; i++ { + kind = savedKind namespace := nss[i%len(nss)].Name secretNames := make([]string, 0, secretsPerPod) @@ -400,6 +414,10 @@ func generateConfigsForGroup( SecretNames: secretNames, } + if kind == randomKind { + kind = knownKinds[rand.Int()%len(knownKinds)] + } + var config testutils.RunObjectConfig switch kind { case api.Kind("ReplicationController"): diff --git a/test/utils/runners.go b/test/utils/runners.go index 8eb8616416b..e96c76c0a84 100644 --- a/test/utils/runners.go +++ b/test/utils/runners.go @@ -52,6 +52,13 @@ const ( nonExist = "NonExist" ) +func removePtr(replicas *int32) int32 { + if replicas == nil { + return 0 + } + return *replicas +} + func WaitUntilPodIsScheduled(c clientset.Interface, name, namespace string, timeout time.Duration) (*v1.Pod, error) { // Wait until it's scheduled p, err := c.Core().Pods(namespace).Get(name, metav1.GetOptions{ResourceVersion: "0"}) @@ -306,7 +313,7 @@ func (config *DeploymentConfig) create() error { if err != nil { return fmt.Errorf("Error creating deployment: %v", err) } - config.RCConfigLog("Created deployment with name: %v, namespace: %v, replica count: %v", deployment.Name, config.Namespace, deployment.Spec.Replicas) + config.RCConfigLog("Created deployment with name: %v, namespace: %v, replica count: %v", deployment.Name, config.Namespace, removePtr(deployment.Spec.Replicas)) return nil } @@ -370,7 +377,7 @@ func (config *ReplicaSetConfig) create() error { if err != nil { return fmt.Errorf("Error creating replica set: %v", err) } - config.RCConfigLog("Created replica set with name: %v, namespace: %v, replica count: %v", rs.Name, config.Namespace, rs.Spec.Replicas) + config.RCConfigLog("Created replica set with name: %v, namespace: %v, replica count: %v", rs.Name, config.Namespace, removePtr(rs.Spec.Replicas)) return nil } @@ -527,7 +534,7 @@ func (config *RCConfig) create() error { if err != nil { return fmt.Errorf("Error creating replication controller: %v", err) } - config.RCConfigLog("Created replication controller with name: %v, namespace: %v, replica count: %v", rc.Name, config.Namespace, rc.Spec.Replicas) + config.RCConfigLog("Created replication controller with name: %v, namespace: %v, replica count: %v", rc.Name, config.Namespace, removePtr(rc.Spec.Replicas)) return nil }