Skip to content

Commit

Permalink
KIM Integration - AWS trial unit tests (#970)
Browse files Browse the repository at this point in the history
initial version

quite modest coverage

platform mapping provided
  • Loading branch information
jaroslaw-pieszka authored Aug 1, 2024
1 parent 872fc3c commit fd63ca9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/provider/aws_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type (
MultiZone bool
ControlPlaneFailureTolerance string
}

AWSTrialInput struct {
PlatformRegionMapping map[string]string
UseSmallerMachineTypes bool
Expand Down
62 changes: 62 additions & 0 deletions internal/provider/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/stretchr/testify/assert"
)

var AWSTrialPlafomRegionMapping = map[string]string{"cf-eu10": "europe", "cf-us10": "us", "cf-ap21": "asia"}

func TestAWSDefaults(t *testing.T) {

// given
Expand Down Expand Up @@ -69,6 +71,66 @@ func TestAWSSpecific(t *testing.T) {
}, values)
}

func TestAWSTrialDefaults(t *testing.T) {

// given
aws := AWSTrialInputProvider{
PlatformRegionMapping: AWSTrialPlafomRegionMapping,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eu-central-1")},
PlatformRegion: "cf-eu11",
},
}

// when
values := aws.Provide()

// then

assertValues(t, Values{
DefaultAutoScalerMax: 1,
DefaultAutoScalerMin: 1,
ZonesCount: 1,
Zones: []string{"eu-central-1a", "eu-central-1b", "eu-central-1c"},
ProviderType: "aws",
DefaultMachineType: "m5.xlarge",
Region: "eu-central-1",
Purpose: "evaluation",
}, values)
}

func TestAWSTrialSpecific(t *testing.T) {

// given
aws := AWSTrialInputProvider{
PlatformRegionMapping: AWSTrialPlafomRegionMapping,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
MachineType: ptr.String("m6i.xlarge"),
Region: ptr.String("eu-central-1"),
},
PlatformRegion: "cf-ap21",
},
}

// when
values := aws.Provide()

// then

assertValues(t, Values{
// default values do not depend on provisioning parameters
DefaultAutoScalerMax: 1,
DefaultAutoScalerMin: 1,
ZonesCount: 1,
Zones: []string{"ap-southeast-1a", "ap-southeast-1b", "ap-southeast-1c"},
ProviderType: "aws",
DefaultMachineType: "m5.xlarge",
Region: "ap-southeast-1",
Purpose: "evaluation",
}, values)
}

func assertValues(t *testing.T, expected Values, got Values) {
assert.Equal(t, expected.ZonesCount, len(got.Zones))
assert.Subset(t, expected.Zones, got.Zones)
Expand Down

0 comments on commit fd63ca9

Please sign in to comment.