Skip to content
Open
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
10 changes: 10 additions & 0 deletions actions/scaling/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package scaling

const (
AutoScalingConfigurationKey = "autoScalingConfig"
)

type AutoscalingConfig struct {
ChartRepository string `json:"chartRepository,omitempty" yaml:"chartRepository,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
}
67 changes: 67 additions & 0 deletions validation/prime/autoscaling/auto_scaling_main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package autoscaling

import (
"os"
"testing"

"github.com/rancher/shepherd/clients/rancher"
"github.com/rancher/shepherd/pkg/config"
"github.com/rancher/shepherd/pkg/config/operations"
"github.com/rancher/shepherd/pkg/session"
"github.com/rancher/tests/actions/features"
"github.com/rancher/tests/actions/scaling"
"github.com/sirupsen/logrus"
)

func TestMain(m *testing.M) {
testSession := session.NewSession()
client, err := rancher.NewClient("", testSession)
if err != nil {
logrus.Errorf("Failed, during client setup: %s", err)
os.Exit(1)
}

cattleConfig := config.LoadConfigFromFile(os.Getenv(config.ConfigEnvironmentKey))

autoScalingConfig := new(scaling.AutoscalingConfig)
operations.LoadObjectFromMap(scaling.AutoScalingConfigurationKey, cattleConfig, autoScalingConfig)

configureAutoscaler, err := features.IsEnabled(client, features.ClusterAutoscaling)
if err != nil {
logrus.Errorf("Failed, to get %s state", features.ClusterAutoscaling)
os.Exit(1)
}

if !configureAutoscaler {
if autoScalingConfig.ChartRepository == "" || autoScalingConfig.Image == "" {
logrus.Errorf("Autoscaling is not configured and no autoscaling config was provided")
os.Exit(1)
}

logrus.Infof("Setting autoscaler environment variables")
err = features.ConfigureAutoscaler(client, autoScalingConfig.ChartRepository, autoScalingConfig.Image)
if err != nil {
logrus.Errorf("Failed, to set autoscaler environment variables: %s", err)
os.Exit(1)
}

logrus.Infof("Enabling, %s", features.ClusterAutoscaling)
err = features.UpdateFeatureFlag(client, features.ClusterAutoscaling, true)
if err != nil {
logrus.Errorf("Failed, to enable %s: %s", features.ClusterAutoscaling, err)
os.Exit(1)
}
}

exitCode := m.Run()

if !configureAutoscaler {
err = features.UpdateFeatureFlag(client, features.ClusterAutoscaling, false)
if err != nil {
logrus.Errorf("Failed, to disable %s: %s", features.ClusterAutoscaling, err)
os.Exit(1)
}
}

os.Exit(exitCode)
}
1 change: 0 additions & 1 deletion validation/prime/autoscaling/auto_scaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,5 +359,4 @@ func TestAutoScalingPause(t *testing.T) {
logrus.Warningf("Failed to upload schema parameters %s", err)
}
}

}
5 changes: 5 additions & 0 deletions validation/prime/autoscaling/defaults/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ awsMachineConfigs:
vpcId: "<required>"
retries: "5"
zone: "a"

#Required for non prime environments
autoScalingConfig:
autoscalerChartRepository: "<required>"
autoScalerImage: "<required>"

logging:
level: "info"
Loading