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

Adding synchronization and other features to extended test cluster loader. #17894

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 43 additions & 33 deletions test/extended/cluster/cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
oapi "github.com/openshift/origin/pkg/api"
projectapi "github.com/openshift/origin/pkg/project/apis/project"
exutil "github.com/openshift/origin/test/extended/util"
testutil "github.com/openshift/origin/test/util"
)

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

// Create templates as defined
for _, template := range p.Templates {
var allArgs []string
templateFile := mkPath(template.File)
e2e.Logf("We're loading file %v: ", templateFile)
templateObj, err := testutil.GetTemplateFixture(templateFile)
if err != nil {
e2e.Failf("Cant read template config file. Error: %v", err)
}
allArgs = append(allArgs, templateObj.Name)

if template.Parameters == nil {
e2e.Logf("Template environment variables will not be modified.")
} else {
params := convertVariablesToString(template.Parameters)
allArgs = append(allArgs, params...)
}
// Create config maps
if p.Configmaps != nil {
// Configmaps defined, create them
err := CreateConfigmaps(oc, c, nsName, p.Configmaps)
o.Expect(err).NotTo(o.HaveOccurred())
}

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

err = oc.SetNamespace(nsName).Run("new-app").Args(allArgs...).Execute()
// Create templates as defined
for _, template := range p.Templates {
err := CreateTemplates(oc, c, nsName, template, template.Number, tuning)
o.Expect(err).NotTo(o.HaveOccurred())
}

// This is too familiar, create pods
for _, pod := range p.Pods {
// Parse Pod file into struct
Expand All @@ -122,11 +118,36 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
}
// TODO sjug: pass label via config
labels := map[string]string{"purpose": "test"}
CreatePods(c, pod.Basename, nsName, labels, config.Spec, pod.Number, tuning)
err := CreatePods(c, pod.Basename, nsName, labels, config.Spec, pod.Number, tuning, &pod.Sync)
o.Expect(err).NotTo(o.HaveOccurred())
}
}
}

if sync.Running {
timeout, err := time.ParseDuration(sync.Timeout)
o.Expect(err).NotTo(o.HaveOccurred())
for _, ns := range namespaces {
err := SyncRunningPods(c, ns, sync.Selectors, timeout)
o.Expect(err).NotTo(o.HaveOccurred())
}
}

if sync.Server.Enabled {
var podCount PodCount
err := Server(&podCount, sync.Server.Port, false)
o.Expect(err).NotTo(o.HaveOccurred())
}

if sync.Succeeded {
timeout, err := time.ParseDuration(sync.Timeout)
o.Expect(err).NotTo(o.HaveOccurred())
for _, ns := range namespaces {
err := SyncSucceededPods(c, ns, sync.Selectors, timeout)
o.Expect(err).NotTo(o.HaveOccurred())
}
}

// Wait for builds and deployments to complete
for _, ns := range namespaces {
buildList, err := oc.BuildClient().Build().Builds(ns).List(metav1.ListOptions{})
Expand Down Expand Up @@ -158,17 +179,6 @@ var _ = g.Describe("[Feature:Performance][Serial][Slow] Load cluster", func() {
err := writeJSONToDisk(TestResult{testDuration}, testResultFile)
o.Expect(err).NotTo(o.HaveOccurred())

// Wait for pods to be running
//for _, ns := range namespaces {
// label := labels.SelectorFromSet(labels.Set(map[string]string{"purpose": "test"}))
// err := testutils.WaitForPodsWithLabelRunning(c, ns, label)
// if err != nil {
// e2e.Failf("Got %v when trying to wait for the pods to start", err)
// }
// o.Expect(err).NotTo(o.HaveOccurred())
// e2e.Logf("All pods running in namespace %s.", ns)
//}

// If config context set to cleanup on completion
if ConfigContext.ClusterLoader.Cleanup == true {
for _, ns := range namespaces {
Expand Down
26 changes: 21 additions & 5 deletions test/extended/cluster/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ type ContextType struct {
ClusterLoader struct {
Cleanup bool
Projects []ClusterLoaderType
Sync SyncObjectType
TuningSets []TuningSetType
}
}

// ClusterLoaderType struct only used for Cluster Loader test config
type ClusterLoaderType struct {
Number int `mapstructure:"num"`
Basename string
Tuning string
Pods []ClusterLoaderObjectType
Templates []ClusterLoaderObjectType
Number int `mapstructure:"num"`
Basename string
Tuning string
Configmaps map[string]interface{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, missing a space?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where, formatted by gofmt, also used go tool vet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The columns should align, not sure why you're not getting proper output.

Copy link
Contributor Author

@jmencak jmencak Jan 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which columns do not align? I do not see any mis-alignment. Again, the code is formatted with "gofmt -s -d context.go" produces no diff. Please be specific.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one I've tagged, line 26?
Configmaps is aligned, but map[string]interface{} is not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just on github... ffs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, was getting desperate...

Secrets map[string]interface{}
Pods []ClusterLoaderObjectType
Templates []ClusterLoaderObjectType
}

// ClusterLoaderObjectType is nested object type for cluster loader struct
Expand All @@ -33,9 +36,22 @@ type ClusterLoaderObjectType struct {
Image string
Basename string
File string
Sync SyncObjectType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is SyncObjectType nested in two structs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to perform synchronization both on template/pod and cluster-loader wide level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss this further.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not currently used but may be helpful in the future.

Parameters map[string]interface{}
}

// SyncObjectType is nested object type for cluster loader synchronisation functionality
type SyncObjectType struct {
Server struct {
Enabled bool
Port int
}
Running bool
Succeeded bool
Selectors map[string]string
Timeout string
}

// TuningSetType is nested type for controlling Cluster Loader deployment pattern
type TuningSetType struct {
Name string
Expand Down
Loading