1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00

Abap environment build tag support (#4479)

* Hand over Tag to bf

---------

Co-authored-by: rosemarieB <45030247+rosemarieB@users.noreply.github.com>
This commit is contained in:
tiloKo 2023-07-20 15:57:57 +02:00 committed by GitHub
parent e117067a66
commit f9f1b59894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 14 deletions

View File

@ -15,15 +15,47 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestReserveNextPackagesStep(t *testing.T) { func arrangeConfig(addonDescriptor abaputils.AddonDescriptor) abapAddonAssemblyKitReserveNextPackagesOptions {
var config abapAddonAssemblyKitReserveNextPackagesOptions var config abapAddonAssemblyKitReserveNextPackagesOptions
config.Username = "dummy" config.Username = "dummy"
config.Password = "dummy" config.Password = "dummy"
adoDesc, _ := json.Marshal(addonDescriptor)
config.AddonDescriptor = string(adoDesc)
return config
}
func TestReserveNextPackagesStep(t *testing.T) {
var cpe abapAddonAssemblyKitReserveNextPackagesCommonPipelineEnvironment var cpe abapAddonAssemblyKitReserveNextPackagesCommonPipelineEnvironment
bundle := aakaas.NewAakBundleMock() bundle := aakaas.NewAakBundleMock()
utils := bundle.GetUtils() utils := bundle.GetUtils()
t.Run("step success tag", func(t *testing.T) {
config := arrangeConfig(abaputils.AddonDescriptor{
Repositories: []abaputils.Repository{
{
Name: "/DRNMSPC/COMP01",
VersionYAML: "1.0.0.",
Tag: "myTestTagv1.0",
},
{
Name: "/DRNMSPC/COMP02",
VersionYAML: "1.0.0.",
Tag: "myTestTagv1.0",
},
},
})
bodyList := []string{responseReserveNextPackageReleased, responseReserveNextPackagePlanned, responseReserveNextPackagePostReleased, "myToken", responseReserveNextPackagePostPlanned, "myToken"}
bundle.SetBodyList(bodyList)
err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe)
assert.NoError(t, err, "Did not expect error")
var addonDescriptorFinal abaputils.AddonDescriptor
err = json.Unmarshal([]byte(cpe.abap.addonDescriptor), &addonDescriptorFinal)
assert.NoError(t, err)
assert.Equal(t, "P", addonDescriptorFinal.Repositories[0].Status)
assert.Equal(t, "R", addonDescriptorFinal.Repositories[1].Status)
})
t.Run("step success", func(t *testing.T) { t.Run("step success", func(t *testing.T) {
addonDescriptor := abaputils.AddonDescriptor{ config := arrangeConfig(abaputils.AddonDescriptor{
Repositories: []abaputils.Repository{ Repositories: []abaputils.Repository{
{ {
Name: "/DRNMSPC/COMP01", Name: "/DRNMSPC/COMP01",
@ -36,9 +68,7 @@ func TestReserveNextPackagesStep(t *testing.T) {
CommitID: "something40charslongxxxxxxxxxxxxxxxxxxxx", CommitID: "something40charslongxxxxxxxxxxxxxxxxxxxx",
}, },
}, },
} })
adoDesc, _ := json.Marshal(addonDescriptor)
config.AddonDescriptor = string(adoDesc)
bodyList := []string{responseReserveNextPackageReleased, responseReserveNextPackagePlanned, responseReserveNextPackagePostReleased, "myToken", responseReserveNextPackagePostPlanned, "myToken"} bodyList := []string{responseReserveNextPackageReleased, responseReserveNextPackagePlanned, responseReserveNextPackagePostReleased, "myToken", responseReserveNextPackagePostPlanned, "myToken"}
bundle.SetBodyList(bodyList) bundle.SetBodyList(bodyList)
err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe) err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe)
@ -50,29 +80,25 @@ func TestReserveNextPackagesStep(t *testing.T) {
assert.Equal(t, "R", addonDescriptorFinal.Repositories[1].Status) assert.Equal(t, "R", addonDescriptorFinal.Repositories[1].Status)
}) })
t.Run("step error - invalid input", func(t *testing.T) { t.Run("step error - invalid input", func(t *testing.T) {
addonDescriptor := abaputils.AddonDescriptor{ config := arrangeConfig(abaputils.AddonDescriptor{
Repositories: []abaputils.Repository{ Repositories: []abaputils.Repository{
{ {
Name: "/DRNMSPC/COMP01", Name: "/DRNMSPC/COMP01",
}, },
}, },
} })
adoDesc, _ := json.Marshal(addonDescriptor)
config.AddonDescriptor = string(adoDesc)
err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe) err := runAbapAddonAssemblyKitReserveNextPackages(&config, nil, &utils, &cpe)
assert.Error(t, err, "Did expect error") assert.Error(t, err, "Did expect error")
}) })
t.Run("step error - timeout", func(t *testing.T) { t.Run("step error - timeout", func(t *testing.T) {
addonDescriptor := abaputils.AddonDescriptor{ config := arrangeConfig(abaputils.AddonDescriptor{
Repositories: []abaputils.Repository{ Repositories: []abaputils.Repository{
{ {
Name: "/DRNMSPC/COMP01", Name: "/DRNMSPC/COMP01",
VersionYAML: "1.0.0.", VersionYAML: "1.0.0.",
}, },
}, },
} })
adoDesc, _ := json.Marshal(addonDescriptor)
config.AddonDescriptor = string(adoDesc)
bodyList := []string{responseReserveNextPackageCreationTriggered, responseReserveNextPackagePostPlanned, "myToken"} bodyList := []string{responseReserveNextPackageCreationTriggered, responseReserveNextPackagePostPlanned, "myToken"}
bundle.SetBodyList(bodyList) bundle.SetBodyList(bodyList)
bundle.SetMaxRuntime(time.Duration(1 * time.Microsecond)) bundle.SetMaxRuntime(time.Duration(1 * time.Microsecond))

View File

@ -180,7 +180,7 @@ func (br *buildWithRepository) start() error {
Value: br.repo.PredecessorCommitID}) Value: br.repo.PredecessorCommitID})
} }
if br.repo.CommitID != "" { if br.repo.CommitID != "" {
// old value to be used until 2302 [can be deleted latest with 2308] // old value to be used until 2302 [can be deleted earliest with 2311]
valuesInput.Values = append(valuesInput.Values, valuesInput.Values = append(valuesInput.Values,
abapbuild.Value{ValueID: "ACTUAL_DELIVERY_COMMIT", abapbuild.Value{ValueID: "ACTUAL_DELIVERY_COMMIT",
Value: br.repo.CommitID}) Value: br.repo.CommitID})
@ -189,6 +189,9 @@ func (br *buildWithRepository) start() error {
abapbuild.Value{ValueID: "CURRENT_DELIVERY_COMMIT", abapbuild.Value{ValueID: "CURRENT_DELIVERY_COMMIT",
Value: br.repo.CommitID}) Value: br.repo.CommitID})
} }
if br.repo.Tag != "" {
valuesInput.Values = append(valuesInput.Values, abapbuild.Value{ValueID: "CURRENT_DELIVERY_TAG", Value: br.repo.Tag})
}
if len(br.repo.Languages) > 0 { if len(br.repo.Languages) > 0 {
valuesInput.Values = append(valuesInput.Values, valuesInput.Values = append(valuesInput.Values,
abapbuild.Value{ValueID: "SSDC_EXPORT_LANGUAGE_VECTOR", abapbuild.Value{ValueID: "SSDC_EXPORT_LANGUAGE_VECTOR",