Skip to content

Commit dd2366b

Browse files
committed
Adding synchronization and other features to extended test's cluster loader.
Fixes: - number of templates no longer ignored - tuningsets no longer ignored for templates - maxRetries reflected the number of all tries, not retries New features: - label-based pod post deployment synchronization at pod, template or global level - creation of config maps and secrets from files - support for getting parameter values from the environment
1 parent 607caee commit dd2366b

File tree

3 files changed

+265
-80
lines changed

3 files changed

+265
-80
lines changed

test/extended/cluster/cl.go

+43-33
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
oapi "github.com/openshift/origin/pkg/api"
1818
projectapi "github.com/openshift/origin/pkg/project/apis/project"
1919
exutil "github.com/openshift/origin/test/extended/util"
20-
testutil "github.com/openshift/origin/test/util"
2120
)
2221

2322
const deploymentRunTimeout = 5 * time.Minute
@@ -59,6 +58,7 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
5958
g.It("should load the cluster", func() {
6059
project := ConfigContext.ClusterLoader.Projects
6160
tuningSets := ConfigContext.ClusterLoader.TuningSets
61+
sync := ConfigContext.ClusterLoader.Sync
6262
if project == nil {
6363
e2e.Failf("Invalid config file.\nFile: %v", project)
6464
}
@@ -81,30 +81,26 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
8181
e2e.Logf("%d/%d : Created new namespace: %v", j+1, p.Number, nsName)
8282
namespaces = append(namespaces, nsName)
8383

84-
// Create templates as defined
85-
for _, template := range p.Templates {
86-
var allArgs []string
87-
templateFile := mkPath(template.File)
88-
e2e.Logf("We're loading file %v: ", templateFile)
89-
templateObj, err := testutil.GetTemplateFixture(templateFile)
90-
if err != nil {
91-
e2e.Failf("Cant read template config file. Error: %v", err)
92-
}
93-
allArgs = append(allArgs, templateObj.Name)
94-
95-
if template.Parameters == nil {
96-
e2e.Logf("Template environment variables will not be modified.")
97-
} else {
98-
params := convertVariablesToString(template.Parameters)
99-
allArgs = append(allArgs, params...)
100-
}
84+
// Create config maps
85+
if p.Configmaps != nil {
86+
// Configmaps defined, create them
87+
err := CreateConfigmaps(oc, c, nsName, p.Configmaps)
88+
o.Expect(err).NotTo(o.HaveOccurred())
89+
}
10190

102-
config, err := oc.AdminTemplateClient().Template().Templates(nsName).Create(templateObj)
103-
e2e.Logf("Template %v created, arguments: %v, config: %+v", templateObj.Name, allArgs, config)
91+
// Create secrets
92+
if p.Secrets != nil {
93+
// Secrets defined, create them
94+
err := CreateSecrets(oc, c, nsName, p.Secrets)
95+
o.Expect(err).NotTo(o.HaveOccurred())
96+
}
10497

105-
err = oc.SetNamespace(nsName).Run("new-app").Args(allArgs...).Execute()
98+
// Create templates as defined
99+
for _, template := range p.Templates {
100+
err := CreateTemplates(oc, c, nsName, template, template.Number, tuning)
106101
o.Expect(err).NotTo(o.HaveOccurred())
107102
}
103+
108104
// This is too familiar, create pods
109105
for _, pod := range p.Pods {
110106
// Parse Pod file into struct
@@ -122,11 +118,36 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
122118
}
123119
// TODO sjug: pass label via config
124120
labels := map[string]string{"purpose": "test"}
125-
CreatePods(c, pod.Basename, nsName, labels, config.Spec, pod.Number, tuning)
121+
err := CreatePods(c, pod.Basename, nsName, labels, config.Spec, pod.Number, tuning, &pod.Sync)
122+
o.Expect(err).NotTo(o.HaveOccurred())
126123
}
127124
}
128125
}
129126

127+
if sync.Running {
128+
timeout, err := time.ParseDuration(sync.Timeout)
129+
o.Expect(err).NotTo(o.HaveOccurred())
130+
for _, ns := range namespaces {
131+
err := SyncRunningPods(c, ns, sync.Selectors, timeout)
132+
o.Expect(err).NotTo(o.HaveOccurred())
133+
}
134+
}
135+
136+
if sync.Server.Enabled {
137+
var podCount PodCount
138+
err := Server(&podCount, sync.Server.Port, false)
139+
o.Expect(err).NotTo(o.HaveOccurred())
140+
}
141+
142+
if sync.Succeeded {
143+
timeout, err := time.ParseDuration(sync.Timeout)
144+
o.Expect(err).NotTo(o.HaveOccurred())
145+
for _, ns := range namespaces {
146+
err := SyncSucceededPods(c, ns, sync.Selectors, timeout)
147+
o.Expect(err).NotTo(o.HaveOccurred())
148+
}
149+
}
150+
130151
// Wait for builds and deployments to complete
131152
for _, ns := range namespaces {
132153
buildList, err := oc.BuildClient().Build().Builds(ns).List(metav1.ListOptions{})
@@ -158,17 +179,6 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
158179
err := writeJSONToDisk(TestResult{testDuration}, testResultFile)
159180
o.Expect(err).NotTo(o.HaveOccurred())
160181

161-
// Wait for pods to be running
162-
//for _, ns := range namespaces {
163-
// label := labels.SelectorFromSet(labels.Set(map[string]string{"purpose": "test"}))
164-
// err := testutils.WaitForPodsWithLabelRunning(c, ns, label)
165-
// if err != nil {
166-
// e2e.Failf("Got %v when trying to wait for the pods to start", err)
167-
// }
168-
// o.Expect(err).NotTo(o.HaveOccurred())
169-
// e2e.Logf("All pods running in namespace %s.", ns)
170-
//}
171-
172182
// If config context set to cleanup on completion
173183
if ConfigContext.ClusterLoader.Cleanup == true {
174184
for _, ns := range namespaces {

test/extended/cluster/context.go

+21-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ type ContextType struct {
1313
ClusterLoader struct {
1414
Cleanup bool
1515
Projects []ClusterLoaderType
16+
Sync SyncObjectType
1617
TuningSets []TuningSetType
1718
}
1819
}
1920

2021
// ClusterLoaderType struct only used for Cluster Loader test config
2122
type ClusterLoaderType struct {
22-
Number int `mapstructure:"num"`
23-
Basename string
24-
Tuning string
25-
Pods []ClusterLoaderObjectType
26-
Templates []ClusterLoaderObjectType
23+
Number int `mapstructure:"num"`
24+
Basename string
25+
Tuning string
26+
Configmaps map[string]interface{}
27+
Secrets map[string]interface{}
28+
Pods []ClusterLoaderObjectType
29+
Templates []ClusterLoaderObjectType
2730
}
2831

2932
// ClusterLoaderObjectType is nested object type for cluster loader struct
@@ -33,9 +36,22 @@ type ClusterLoaderObjectType struct {
3336
Image string
3437
Basename string
3538
File string
39+
Sync SyncObjectType
3640
Parameters map[string]interface{}
3741
}
3842

43+
// SyncObjectType is nested object type for cluster loader synchronisation functionality
44+
type SyncObjectType struct {
45+
Server struct {
46+
Enabled bool
47+
Port int
48+
}
49+
Running bool
50+
Succeeded bool
51+
Selectors map[string]string
52+
Timeout string
53+
}
54+
3955
// TuningSetType is nested type for controlling Cluster Loader deployment pattern
4056
type TuningSetType struct {
4157
Name string

0 commit comments

Comments
 (0)