Skip to content

Commit

Permalink
e2e: allow to run regualar vertical scale tests in OpenStack
Browse files Browse the repository at this point in the history
If `OPENSTACK_CONTROLPLANE_FLAVOR_ALTERNATE` is found in the environment
variables, we'll use that flavor when running the control plane
verticale scale tests. Otherwise, roll back on the tags.
  • Loading branch information
EmilienM committed Jun 29, 2023
1 parent e9c1526 commit db07333
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
23 changes: 23 additions & 0 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"regexp"
"strconv"

Expand Down Expand Up @@ -56,6 +57,9 @@ var (
// This means that even though the format is correct, we haven't implemented the logic to increase
// this instance size.
errInstanceTypeNotSupported = errors.New("instance type is not supported")

// errMissingInstanceSize is returned when the instance size is missing.
errMissingInstanceSize = errors.New("instance size is missing")
)

// Framework is an interface for getting clients and information
Expand Down Expand Up @@ -236,6 +240,8 @@ func (f *framework) IncreaseProviderSpecInstanceSize(rawProviderSpec *runtime.Ra
return increaseGCPInstanceSize(rawProviderSpec, providerConfig)
case configv1.NutanixPlatformType:
return increaseNutanixInstanceSize(rawProviderSpec, providerConfig)
case configv1.OpenStackPlatformType:
return increaseOpenStackInstanceSize(rawProviderSpec, providerConfig)
default:
return fmt.Errorf("%w: %s", errUnsupportedPlatform, f.platform)
}
Expand Down Expand Up @@ -683,6 +689,23 @@ func increaseNutanixInstanceSize(rawProviderSpec *runtime.RawExtension, provider
return nil
}

// increase OpenStackInstanceSize increases the instance size of the instance on the providerSpec for an OpenStack providerSpec.
func increaseOpenStackInstanceSize(rawProviderSpec *runtime.RawExtension, providerConfig providerconfig.ProviderConfig) error {
cfg := providerConfig.OpenStack().Config()

if os.Getenv("OPENSTACK_CONTROLPLANE_FLAVOR_ALTERNATE") == "" {
return fmt.Errorf("OPENSTACK_CONTROLPLANE_FLAVOR_ALTERNATE environment variable not set: %w", errMissingInstanceSize)
} else {
cfg.Flavor = os.Getenv("OPENSTACK_CONTROLPLANE_FLAVOR_ALTERNATE")
}

if err := setProviderSpecValue(rawProviderSpec, cfg); err != nil {
return fmt.Errorf("failed to set provider spec value: %w", err)
}

return nil
}

// nextGCPVMSize returns the next GCP machine size in the series.
// The Machine sizes being used are in format <e2|n2|n1>-standard-<number>.
func nextGCPMachineSize(current string) (string, error) {
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/helpers/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"os"
"regexp"
"sort"
"strconv"
Expand Down Expand Up @@ -409,8 +410,13 @@ func IncreaseControlPlaneMachineInstanceSize(testFramework framework.Framework,

switch platformType {
case configv1.OpenStackPlatformType:
// OpenStack flavors are not predictable, so we just tag the instance with a new tag, which will trigger the redeployment.
Expect(testFramework.TagInstanceInProviderSpec(updatedProviderSpec.Value)).To(Succeed(), "provider spec should be updated with a new tag")
// OpenStack flavors are not predictable. So if OPENSTACK_CONTROLPLANE_FLAVOR_ALTERNATE is set in the environment, we'll use it
// to increase the instance size, otherwise we just tag the instance with a new tag, which will trigger the redeployment.
if os.Getenv("OPENSTACK_CONTROLPLANE_FLAVOR_ALTERNATE") == "" {
Expect(testFramework.TagInstanceInProviderSpec(updatedProviderSpec.Value)).To(Succeed(), "provider spec should be updated with a new tag")
} else {
Expect(testFramework.IncreaseProviderSpecInstanceSize(updatedProviderSpec.Value)).To(Succeed(), "provider spec should be updated with bigger instance size")
}
default:
Expect(testFramework.IncreaseProviderSpecInstanceSize(updatedProviderSpec.Value)).To(Succeed(), "provider spec should be updated with bigger instance size")
}
Expand Down

0 comments on commit db07333

Please sign in to comment.