mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
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:
commit
a19a18aecf
@ -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"):
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user