forked from SAP/jenkins-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change to default cf create-service implementation (SAP#4224)
* Change to default cf create-service * Adapt test * Adapt tests * Remove comment --------- Co-authored-by: tiloKo <[email protected]>
- Loading branch information
1 parent
cfe21eb
commit 8084ce1
Showing
6 changed files
with
63 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ func TestRunAbapEnvironmentCreateSystem(t *testing.T) { | |
cf := cloudfoundry.CFUtils{Exec: m} | ||
u := &uuidMock{} | ||
|
||
t.Run("Create service with generated manifest", func(t *testing.T) { | ||
t.Run("Create service with cf create-service", func(t *testing.T) { | ||
defer cfMockCleanup(m) | ||
config := abapEnvironmentCreateSystemOptions{ | ||
CfAPIEndpoint: "https://api.endpoint.com", | ||
|
@@ -27,12 +27,11 @@ func TestRunAbapEnvironmentCreateSystem(t *testing.T) { | |
CfServiceInstance: "testName", | ||
CfServicePlan: "testPlan", | ||
} | ||
wd, _ := os.Getwd() | ||
err := runAbapEnvironmentCreateSystem(&config, nil, cf, u) | ||
if assert.NoError(t, err) { | ||
assert.Equal(t, []mock.ExecCall{ | ||
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, | ||
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", wd + "/generated_service_manifest-my-uuid.yml"}}, | ||
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", config.CfService, config.CfServicePlan, config.CfServiceInstance, "-c", "{\"is_development_allowed\":false}", "--wait"}}, | ||
{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, | ||
m.Calls) | ||
} | ||
|
@@ -88,57 +87,7 @@ func TestRunAbapEnvironmentCreateSystem(t *testing.T) { | |
|
||
func TestManifestGeneration(t *testing.T) { | ||
|
||
t.Run("Create service with generated manifest", func(t *testing.T) { | ||
config := abapEnvironmentCreateSystemOptions{ | ||
CfAPIEndpoint: "https://api.endpoint.com", | ||
CfOrg: "testOrg", | ||
CfSpace: "testSpace", | ||
Username: "testUser", | ||
Password: "testPassword", | ||
CfService: "testService", | ||
CfServiceInstance: "testName", | ||
CfServicePlan: "testPlan", | ||
AbapSystemAdminEmail: "[email protected]", | ||
AbapSystemID: "H02", | ||
AbapSystemIsDevelopmentAllowed: true, | ||
AbapSystemSizeOfPersistence: 4, | ||
AbapSystemSizeOfRuntime: 4, | ||
AddonDescriptorFileName: "addon.yml", | ||
} | ||
|
||
dir := t.TempDir() | ||
oldCWD, _ := os.Getwd() | ||
_ = os.Chdir(dir) | ||
// clean up tmp dir | ||
defer func() { | ||
_ = os.Chdir(oldCWD) | ||
}() | ||
|
||
addonYML := `addonProduct: myProduct | ||
addonVersion: 1.2.3 | ||
repositories: | ||
- name: '/DMO/REPO' | ||
` | ||
|
||
addonYMLBytes := []byte(addonYML) | ||
err := ioutil.WriteFile("addon.yml", addonYMLBytes, 0644) | ||
|
||
expectedResult := `create-services: | ||
- broker: testService | ||
name: testName | ||
parameters: '{"admin_email":"[email protected]","is_development_allowed":true,"sapsystemname":"H02","size_of_persistence":4,"size_of_runtime":4}' | ||
plan: testPlan | ||
` | ||
|
||
resultBytes, err := generateManifestYAML(&config) | ||
|
||
if assert.NoError(t, err) { | ||
result := string(resultBytes) | ||
assert.Equal(t, expectedResult, result, "Result not as expected") | ||
} | ||
}) | ||
|
||
t.Run("Create service with generated manifest - with addon", func(t *testing.T) { | ||
t.Run("Create service with addon - development", func(t *testing.T) { | ||
config := abapEnvironmentCreateSystemOptions{ | ||
CfAPIEndpoint: "https://api.endpoint.com", | ||
CfOrg: "testOrg", | ||
|
@@ -174,17 +123,11 @@ repositories: | |
addonYMLBytes := []byte(addonYML) | ||
err := ioutil.WriteFile("addon.yml", addonYMLBytes, 0644) | ||
|
||
expectedResult := `create-services: | ||
- broker: testService | ||
name: testName | ||
parameters: '{"admin_email":"[email protected]","is_development_allowed":true,"sapsystemname":"H02","size_of_persistence":4,"size_of_runtime":4,"addon_product_name":"myProduct","addon_product_version":"1.2.3","parent_saas_appname":"addon_test"}' | ||
plan: testPlan | ||
` | ||
expectedResult := "{\"admin_email\":\"[email protected]\",\"is_development_allowed\":true,\"sapsystemname\":\"H02\",\"size_of_persistence\":4,\"size_of_runtime\":4,\"addon_product_name\":\"myProduct\",\"addon_product_version\":\"1.2.3\",\"parent_saas_appname\":\"addon_test\"}" | ||
|
||
resultBytes, err := generateManifestYAML(&config) | ||
result, err := generateServiceParameterString(&config) | ||
|
||
if assert.NoError(t, err) { | ||
result := string(resultBytes) | ||
assert.Equal(t, expectedResult, result, "Result not as expected") | ||
} | ||
}) | ||
|
@@ -224,22 +167,17 @@ repositories: | |
addonYMLBytes := []byte(addonYML) | ||
err := ioutil.WriteFile("addon.yml", addonYMLBytes, 0644) | ||
|
||
expectedResult := `create-services: | ||
- broker: testService | ||
name: testName | ||
parameters: '{"admin_email":"[email protected]","is_development_allowed":true,"sapsystemname":"H02","size_of_persistence":4,"size_of_runtime":4}' | ||
plan: testPlan | ||
` | ||
expectedResult := "{\"admin_email\":\"[email protected]\",\"is_development_allowed\":true,\"sapsystemname\":\"H02\",\"size_of_persistence\":4,\"size_of_runtime\":4}" | ||
|
||
resultBytes, err := generateManifestYAML(&config) | ||
result, err := generateServiceParameterString(&config) | ||
|
||
if assert.NoError(t, err) { | ||
result := string(resultBytes) | ||
assert.Equal(t, expectedResult, result, "Result not as expected") | ||
} | ||
}) | ||
|
||
t.Run("Create service with generated manifest - with addon", func(t *testing.T) { | ||
t.Run("Create service with addon - no development", func(t *testing.T) { | ||
|
||
config := abapEnvironmentCreateSystemOptions{ | ||
CfAPIEndpoint: "https://api.endpoint.com", | ||
CfOrg: "testOrg", | ||
|
@@ -275,17 +213,11 @@ repositories: | |
addonYMLBytes := []byte(addonYML) | ||
err := ioutil.WriteFile("addon.yml", addonYMLBytes, 0644) | ||
|
||
expectedResult := `create-services: | ||
- broker: testService | ||
name: testName | ||
parameters: '{"admin_email":"[email protected]","is_development_allowed":false,"sapsystemname":"H02","size_of_persistence":4,"size_of_runtime":4,"addon_product_name":"myProduct","addon_product_version":"1.2.3","parent_saas_appname":"addon_test"}' | ||
plan: testPlan | ||
` | ||
expectedResult := "{\"admin_email\":\"[email protected]\",\"is_development_allowed\":false,\"sapsystemname\":\"H02\",\"size_of_persistence\":4,\"size_of_runtime\":4,\"addon_product_name\":\"myProduct\",\"addon_product_version\":\"1.2.3\",\"parent_saas_appname\":\"addon_test\"}" | ||
|
||
resultBytes, err := generateManifestYAML(&config) | ||
result, err := generateServiceParameterString(&config) | ||
|
||
if assert.NoError(t, err) { | ||
result := string(resultBytes) | ||
assert.Equal(t, expectedResult, result, "Result not as expected") | ||
} | ||
}) | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.