-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional Worker Node Pools on Preview
- Loading branch information
1 parent
f28d608
commit 02c7833
Showing
42 changed files
with
368 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1491,6 +1491,165 @@ func TestProvision_Provision(t *testing.T) { | |
// then | ||
require.EqualError(t, err, "while validating input parameters: region: region must be one of the following: \"me-central2\"") | ||
}) | ||
|
||
t.Run("Should pass with additional worker node pools", func(t *testing.T) { | ||
// given | ||
memoryStorage := storage.NewMemoryStorage() | ||
|
||
queue := &automock.Queue{} | ||
queue.On("Add", mock.AnythingOfType("string")) | ||
|
||
factoryBuilder := &automock.PlanValidator{} | ||
factoryBuilder.On("IsPlanSupport", broker.PreviewPlanID).Return(true) | ||
|
||
planDefaults := func(planID string, platformProvider pkg.CloudProvider, provider *pkg.CloudProvider) (*gqlschema.ClusterConfigInput, error) { | ||
return &gqlschema.ClusterConfigInput{}, nil | ||
} | ||
kcBuilder := &kcMock.KcBuilder{} | ||
kcBuilder.On("GetServerURL", "").Return("", fmt.Errorf("error")) | ||
// #create provisioner endpoint | ||
provisionEndpoint := broker.NewProvision( | ||
broker.Config{ | ||
EnablePlans: []string{"preview"}, | ||
URL: brokerURL, | ||
OnlySingleTrialPerGA: true, | ||
EnableKubeconfigURLLabel: true, | ||
}, | ||
gardener.Config{Project: "test", ShootDomain: "example.com", DNSProviders: fixDNSProviders()}, | ||
memoryStorage.Operations(), | ||
memoryStorage.Instances(), | ||
memoryStorage.InstancesArchived(), | ||
queue, | ||
factoryBuilder, | ||
broker.PlansConfig{}, | ||
planDefaults, | ||
log, | ||
dashboardConfig, | ||
kcBuilder, | ||
whitelist.Set{}, | ||
&broker.OneForAllConvergedCloudRegionsProvider{}, | ||
) | ||
|
||
additionalWorkerNodePools := `[{"name": "name-1", "machineType": "m6i.large", "autoScalerMin": 3, "autoScalerMax": 20}, {"name": "name-2", "machineType": "m6i.large", "autoScalerMin": 3, "autoScalerMax": 20}]` | ||
|
||
// when | ||
_, err := provisionEndpoint.Provision(fixRequestContext(t, "cf-sa30"), instanceID, domain.ProvisionDetails{ | ||
ServiceID: serviceID, | ||
PlanID: broker.PreviewPlanID, | ||
RawParameters: json.RawMessage(fmt.Sprintf(`{"name": "%s", "region": "%s","additionalWorkerNodePools": %s }`, clusterName, "eu-central-1", additionalWorkerNodePools)), | ||
RawContext: json.RawMessage(fmt.Sprintf(`{"globalaccount_id": "%s", "subaccount_id": "%s", "user_id": "%s"}`, "any-global-account-id", subAccountID, "[email protected]")), | ||
}, true) | ||
t.Logf("%+v\n", *provisionEndpoint) | ||
|
||
// then | ||
require.NoError(t, err) | ||
}) | ||
|
||
t.Run("Should pass with empty additional worker node pools", func(t *testing.T) { | ||
// given | ||
memoryStorage := storage.NewMemoryStorage() | ||
|
||
queue := &automock.Queue{} | ||
queue.On("Add", mock.AnythingOfType("string")) | ||
|
||
factoryBuilder := &automock.PlanValidator{} | ||
factoryBuilder.On("IsPlanSupport", broker.PreviewPlanID).Return(true) | ||
|
||
planDefaults := func(planID string, platformProvider pkg.CloudProvider, provider *pkg.CloudProvider) (*gqlschema.ClusterConfigInput, error) { | ||
return &gqlschema.ClusterConfigInput{}, nil | ||
} | ||
kcBuilder := &kcMock.KcBuilder{} | ||
kcBuilder.On("GetServerURL", "").Return("", fmt.Errorf("error")) | ||
// #create provisioner endpoint | ||
provisionEndpoint := broker.NewProvision( | ||
broker.Config{ | ||
EnablePlans: []string{"preview"}, | ||
URL: brokerURL, | ||
OnlySingleTrialPerGA: true, | ||
EnableKubeconfigURLLabel: true, | ||
}, | ||
gardener.Config{Project: "test", ShootDomain: "example.com", DNSProviders: fixDNSProviders()}, | ||
memoryStorage.Operations(), | ||
memoryStorage.Instances(), | ||
memoryStorage.InstancesArchived(), | ||
queue, | ||
factoryBuilder, | ||
broker.PlansConfig{}, | ||
planDefaults, | ||
log, | ||
dashboardConfig, | ||
kcBuilder, | ||
whitelist.Set{}, | ||
&broker.OneForAllConvergedCloudRegionsProvider{}, | ||
) | ||
|
||
additionalWorkerNodePools := "[]" | ||
|
||
// when | ||
_, err := provisionEndpoint.Provision(fixRequestContext(t, "cf-sa30"), instanceID, domain.ProvisionDetails{ | ||
ServiceID: serviceID, | ||
PlanID: broker.PreviewPlanID, | ||
RawParameters: json.RawMessage(fmt.Sprintf(`{"name": "%s", "region": "%s","additionalWorkerNodePools": %s }`, clusterName, "eu-central-1", additionalWorkerNodePools)), | ||
RawContext: json.RawMessage(fmt.Sprintf(`{"globalaccount_id": "%s", "subaccount_id": "%s", "user_id": "%s"}`, "any-global-account-id", subAccountID, "[email protected]")), | ||
}, true) | ||
t.Logf("%+v\n", *provisionEndpoint) | ||
|
||
// then | ||
require.NoError(t, err) | ||
}) | ||
|
||
t.Run("Should fail for autoScalerMin bigger than autoScalerMax", func(t *testing.T) { | ||
// given | ||
memoryStorage := storage.NewMemoryStorage() | ||
|
||
queue := &automock.Queue{} | ||
queue.On("Add", mock.AnythingOfType("string")) | ||
|
||
factoryBuilder := &automock.PlanValidator{} | ||
factoryBuilder.On("IsPlanSupport", broker.PreviewPlanID).Return(true) | ||
|
||
planDefaults := func(planID string, platformProvider pkg.CloudProvider, provider *pkg.CloudProvider) (*gqlschema.ClusterConfigInput, error) { | ||
return &gqlschema.ClusterConfigInput{}, nil | ||
} | ||
kcBuilder := &kcMock.KcBuilder{} | ||
kcBuilder.On("GetServerURL", "").Return("", fmt.Errorf("error")) | ||
// #create provisioner endpoint | ||
provisionEndpoint := broker.NewProvision( | ||
broker.Config{ | ||
EnablePlans: []string{"preview"}, | ||
URL: brokerURL, | ||
OnlySingleTrialPerGA: true, | ||
EnableKubeconfigURLLabel: true, | ||
}, | ||
gardener.Config{Project: "test", ShootDomain: "example.com", DNSProviders: fixDNSProviders()}, | ||
memoryStorage.Operations(), | ||
memoryStorage.Instances(), | ||
memoryStorage.InstancesArchived(), | ||
queue, | ||
factoryBuilder, | ||
broker.PlansConfig{}, | ||
planDefaults, | ||
log, | ||
dashboardConfig, | ||
kcBuilder, | ||
whitelist.Set{}, | ||
&broker.OneForAllConvergedCloudRegionsProvider{}, | ||
) | ||
|
||
additionalWorkerNodePools := `[{"name": "name-1", "machineType": "m6i.large", "autoScalerMin": 20, "autoScalerMax": 3}, {"name": "name-2", "machineType": "m6i.large", "autoScalerMin": 3, "autoScalerMax": 20}]` | ||
|
||
// when | ||
_, err := provisionEndpoint.Provision(fixRequestContext(t, "cf-sa30"), instanceID, domain.ProvisionDetails{ | ||
ServiceID: serviceID, | ||
PlanID: broker.PreviewPlanID, | ||
RawParameters: json.RawMessage(fmt.Sprintf(`{"name": "%s", "region": "%s","additionalWorkerNodePools": %s }`, clusterName, "eu-central-1", additionalWorkerNodePools)), | ||
RawContext: json.RawMessage(fmt.Sprintf(`{"globalaccount_id": "%s", "subaccount_id": "%s", "user_id": "%s"}`, "any-global-account-id", subAccountID, "[email protected]")), | ||
}, true) | ||
t.Logf("%+v\n", *provisionEndpoint) | ||
|
||
// then | ||
require.EqualError(t, err, "AutoScalerMax 3 should be larger than AutoScalerMin 20. User provided values min:20, max:3; plan defaults min:0, max:0") | ||
}) | ||
} | ||
|
||
func TestNetworkingValidation(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.