Skip to content

Commit

Permalink
Merge pull request #40 from frobware/e2e-test-enhancements
Browse files Browse the repository at this point in the history
UPSTREAM: <carry>: test/openshift/e2e: don't modify replica count
  • Loading branch information
openshift-merge-robot authored Feb 15, 2019
2 parents 1e69f2e + ef50f59 commit 1e8e192
Show file tree
Hide file tree
Showing 72 changed files with 6,443 additions and 1,251 deletions.
33 changes: 16 additions & 17 deletions test/openshift/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/openshift/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[[constraint]]
name = "github.com/openshift/cluster-autoscaler-operator"
version = "0.0.0"
revision = "4bcabb30b24b7289ea2b935f5a9cf0b89784835d"

[[constraint]]
name = "github.com/openshift/cluster-api"
Expand Down
42 changes: 28 additions & 14 deletions test/openshift/e2e/operator_expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
waitShort = 1 * time.Minute
waitMedium = 3 * time.Minute
waitLong = 10 * time.Minute
waitLong = 15 * time.Minute
)

func newWorkLoad() *batchv1.Job {
Expand Down Expand Up @@ -60,6 +60,9 @@ func newWorkLoad() *batchv1.Job {
},
},
RestartPolicy: corev1.RestartPolicy("Never"),
NodeSelector: map[string]string{
"node-role.kubernetes.io/worker": "",
},
},
},
ActiveDeadlineSeconds: &activeDeadlineSeconds,
Expand Down Expand Up @@ -122,7 +125,7 @@ func (tc *testConfig) ExpectAutoscalerScalesOut(ctx context.Context) error {
// we need to test against deployments instead so we skip this test.
targetMachineSet := machineSetList.Items[0]
if ownerReferences := targetMachineSet.GetOwnerReferences(); len(ownerReferences) > 0 {
glog.Infof("MachineSet %s is owned by a machineDeployment. Please run tests agains machineDeployment instead", targetMachineSet.Name)
glog.Infof("MachineSet %s is owned by a machineDeployment. Please run tests against machineDeployment instead", targetMachineSet.Name)
return nil
}

Expand All @@ -137,6 +140,15 @@ func (tc *testConfig) ExpectAutoscalerScalesOut(ctx context.Context) error {
Kind: "ClusterAutoscaler",
APIVersion: "autoscaling.openshift.io/v1alpha1",
},
Spec: caov1alpha1.ClusterAutoscalerSpec{
ScaleDown: &caov1alpha1.ScaleDownConfig{
Enabled: true,
DelayAfterAdd: "10s",
DelayAfterDelete: "10s",
DelayAfterFailure: "10s",
UnneededTime: "10s",
},
},
}
machineAutoscaler := caov1alpha1.MachineAutoscaler{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -181,8 +193,11 @@ func (tc *testConfig) ExpectAutoscalerScalesOut(ctx context.Context) error {

defer func() {
if workLoad != nil {
cascadeDelete := metav1.DeletePropagationForeground
wait.PollImmediate(1*time.Second, waitShort, func() (bool, error) {
if err := tc.client.Delete(context.TODO(), workLoad); err != nil {
if err := tc.client.Delete(context.TODO(), workLoad, func(opt *client.DeleteOptions) {
opt.PropagationPolicy = &cascadeDelete
}); err != nil {
glog.Errorf("error querying api for workLoad object: %v, retrying...", err)
return false, nil
}
Expand Down Expand Up @@ -229,7 +244,7 @@ func (tc *testConfig) ExpectAutoscalerScalesOut(ctx context.Context) error {

if err := wait.PollImmediate(1*time.Second, waitMedium, func() (bool, error) {
if err := tc.client.Create(ctx, workLoad); err != nil {
glog.Errorf("error querying api for workLoad object: %T, retrying...", err)
glog.Errorf("error querying api for workLoad object: %v, retrying...", err)
return false, ctx.Err()
}
return true, nil
Expand Down Expand Up @@ -270,7 +285,10 @@ func (tc *testConfig) ExpectAutoscalerScalesOut(ctx context.Context) error {

glog.Info("Delete workload")
if err := wait.PollImmediate(1*time.Second, waitMedium, func() (bool, error) {
if err := tc.client.Delete(ctx, workLoad); err != nil {
cascadeDelete := metav1.DeletePropagationForeground
if err := tc.client.Delete(ctx, workLoad, func(opt *client.DeleteOptions) {
opt.PropagationPolicy = &cascadeDelete
}); err != nil {
glog.Errorf("error querying api for workLoad object: %v, retrying...", err)
return false, ctx.Err()
}
Expand All @@ -285,23 +303,19 @@ func (tc *testConfig) ExpectAutoscalerScalesOut(ctx context.Context) error {
// condition; if successful we assert that (a smoke test of)
// scale down is functional.

glog.Infof("Ensure initial number of replicas: %d", initialNumberOfReplicas)
if err := wait.PollImmediate(1*time.Second, waitShort, func() (bool, error) {
glog.Info("Wait for cluster to match initial number of replicas")
if err := wait.PollImmediate(1*time.Second, waitLong, func() (bool, error) {
msKey := types.NamespacedName{
Namespace: namespace,
Name: targetMachineSet.Name,
}
ms := &mapiv1beta1.MachineSet{}
if err := tc.client.Get(ctx, msKey, ms); err != nil {
glog.Errorf("error querying api for machineSet object: %v, retrying...", err)
return false, ctx.Err()
}
ms.Spec.Replicas = initialNumberOfReplicas
if err := tc.client.Update(ctx, ms); err != nil {
glog.Errorf("error querying api for machineSet object: %v, retrying...", err)
return false, ctx.Err()
return false, nil
}
return true, nil
glog.Infof("Initial number of replicas: %d. Current number of replicas: %d", *initialNumberOfReplicas, *ms.Spec.Replicas)
return *ms.Spec.Replicas == *initialNumberOfReplicas, nil
}); err != nil {
return err
}
Expand Down
13 changes: 6 additions & 7 deletions test/openshift/vendor/github.com/gregjones/httpcache/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion test/openshift/vendor/github.com/imdario/mergo/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/openshift/vendor/github.com/imdario/mergo/map.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions test/openshift/vendor/github.com/imdario/mergo/merge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1e8e192

Please sign in to comment.