Merge pull request #41808 from gmarek/random-tests

Automatic merge from submit-queue (batch tested with PRs 41540, 41808, 41710, 41838, 41840)

Add randomized load test
This commit is contained in:
Kubernetes Submit Queue 2017-02-23 03:29:32 -08:00 committed by GitHub
commit a19a18aecf
2 changed files with 28 additions and 3 deletions

View File

@ -63,6 +63,16 @@ const (
nodeCountPerNamespace = 100 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 // This test suite can take a long time to run, so by default it is added to
// the ginkgo.skip list (see driver.go). // the ginkgo.skip list (see driver.go).
// To run this suite you must explicitly ask for it by setting the // 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}, {podsPerNode: 30, image: "gcr.io/google_containers/serve_hostname:v1.4", kind: api.Kind("ReplicationController"), daemonsPerNode: 2},
// Test with secrets // Test with secrets
{podsPerNode: 30, image: "gcr.io/google_containers/serve_hostname:v1.4", kind: extensions.Kind("Deployment"), secretsPerPod: 2}, {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 { for _, testArg := range loadTests {
@ -370,7 +382,9 @@ func generateConfigsForGroup(
) ([]testutils.RunObjectConfig, []*testutils.SecretConfig) { ) ([]testutils.RunObjectConfig, []*testutils.SecretConfig) {
configs := make([]testutils.RunObjectConfig, 0, count) configs := make([]testutils.RunObjectConfig, 0, count)
secretConfigs := make([]*testutils.SecretConfig, 0, count*secretsPerPod) secretConfigs := make([]*testutils.SecretConfig, 0, count*secretsPerPod)
savedKind := kind
for i := 1; i <= count; i++ { for i := 1; i <= count; i++ {
kind = savedKind
namespace := nss[i%len(nss)].Name namespace := nss[i%len(nss)].Name
secretNames := make([]string, 0, secretsPerPod) secretNames := make([]string, 0, secretsPerPod)
@ -400,6 +414,10 @@ func generateConfigsForGroup(
SecretNames: secretNames, SecretNames: secretNames,
} }
if kind == randomKind {
kind = knownKinds[rand.Int()%len(knownKinds)]
}
var config testutils.RunObjectConfig var config testutils.RunObjectConfig
switch kind { switch kind {
case api.Kind("ReplicationController"): case api.Kind("ReplicationController"):

View File

@ -52,6 +52,13 @@ const (
nonExist = "NonExist" 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) { func WaitUntilPodIsScheduled(c clientset.Interface, name, namespace string, timeout time.Duration) (*v1.Pod, error) {
// Wait until it's scheduled // Wait until it's scheduled
p, err := c.Core().Pods(namespace).Get(name, metav1.GetOptions{ResourceVersion: "0"}) p, err := c.Core().Pods(namespace).Get(name, metav1.GetOptions{ResourceVersion: "0"})
@ -306,7 +313,7 @@ func (config *DeploymentConfig) create() error {
if err != nil { if err != nil {
return fmt.Errorf("Error creating deployment: %v", err) 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 return nil
} }
@ -370,7 +377,7 @@ func (config *ReplicaSetConfig) create() error {
if err != nil { if err != nil {
return fmt.Errorf("Error creating replica set: %v", err) 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 return nil
} }
@ -527,7 +534,7 @@ func (config *RCConfig) create() error {
if err != nil { if err != nil {
return fmt.Errorf("Error creating replication controller: %v", err) 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 return nil
} }