Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Services to Load test #24499

Merged
merged 1 commit into from
Apr 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 47 additions & 3 deletions test/e2e/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ package e2e
import (
"fmt"
"math/rand"
"os"
"strconv"
"sync"
"time"

"k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/test/e2e/framework"

. "github.com/onsi/ginkgo"
Expand All @@ -36,9 +38,9 @@ const (
smallRCSize = 5
mediumRCSize = 30
bigRCSize = 250
smallRCGroupName = "load-test-small-rc"
mediumRCGroupName = "load-test-medium-rc"
bigRCGroupName = "load-test-big-rc"
smallRCGroupName = "load-small-rc"
mediumRCGroupName = "load-medium-rc"
bigRCGroupName = "load-big-rc"
smallRCBatchSize = 30
mediumRCBatchSize = 5
bigRCBatchSize = 1
Expand Down Expand Up @@ -113,6 +115,19 @@ var _ = framework.KubeDescribe("Load capacity", func() {
It(name, func() {
totalPods := itArg.podsPerNode * nodeCount
configs = generateRCConfigs(totalPods, itArg.image, itArg.command, c, ns)
var services []*api.Service
// Read the environment variable to see if we want to create services
createServices := os.Getenv("CREATE_SERVICES")
if createServices == "true" {
framework.Logf("Creating services")
services := generateServicesForConfigs(configs)
for _, service := range services {
_, err := c.Services(ns).Create(service)
framework.ExpectNoError(err)
}
} else {
framework.Logf("Skipping service creation")
}

// Simulate lifetime of RC:
// * create with initial size
Expand Down Expand Up @@ -149,6 +164,13 @@ var _ = framework.KubeDescribe("Load capacity", func() {
// We may want to revisit it in the future.
deletingTime := time.Duration(totalPods/5) * time.Second
deleteAllRC(configs, deletingTime)
if createServices == "true" {
for _, service := range services {
err := c.Services(ns).Delete(service.Name)
framework.ExpectNoError(err)
}
framework.Logf("%v Services created.", len(services))
}
})
}
})
Expand Down Expand Up @@ -197,6 +219,28 @@ func generateRCConfigsForGroup(c *client.Client, ns, groupName string, size, cou
return configs
}

func generateServicesForConfigs(configs []*framework.RCConfig) []*api.Service {
services := make([]*api.Service, 0, len(configs))
for _, config := range configs {
serviceName := config.Name + "-svc"
labels := map[string]string{"name": config.Name}
service := &api.Service{
ObjectMeta: api.ObjectMeta{
Name: serviceName,
},
Spec: api.ServiceSpec{
Selector: labels,
Ports: []api.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
}},
},
}
services = append(services, service)
}
return services
}

func sleepUpTo(d time.Duration) {
time.Sleep(time.Duration(rand.Int63n(d.Nanoseconds())))
}
Expand Down
1 change: 1 addition & 0 deletions test/kubemark/start-kubemark-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ kubernetes/server/bin/kube-apiserver \
--token-auth-file=/srv/kubernetes/known_tokens.csv \
--secure-port=443 \
--basic-auth-file=/srv/kubernetes/basic_auth.csv \
--service-cluster-ip-range=10.0.0.0/16 \
--delete-collection-workers=16 &> /var/log/kube-apiserver.log &

# kube-contoller-manager now needs running kube-api server to actually start
Expand Down