Skip to content

Commit

Permalink
SAP_COM_0948 (#4715)
Browse files Browse the repository at this point in the history
* SAP_COM_0948 clone, pull & checkout

* Fix log output

* Enable compatibility for old tests

* Fix tests

* Add tests for SAP_COM_0948

* Change message

* Add tags for test

* add retry for error code 501

---------

Co-authored-by: tiloKo <[email protected]>
  • Loading branch information
DanielMieg and tiloKo authored Dec 19, 2023
1 parent 13a97c8 commit dbc3d41
Show file tree
Hide file tree
Showing 11 changed files with 1,018 additions and 128 deletions.
12 changes: 6 additions & 6 deletions cmd/abapEnvironmentCheckoutBranch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestCheckoutBranchStep(t *testing.T) {
StatusCode: 200,
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCheckoutBranch(&config, &autils, apiManager)
assert.NoError(t, err, "Did not expect error")
})
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestCheckoutBranchStep(t *testing.T) {
StatusCode: 200,
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCheckoutBranch(&config, &autils, apiManager)
assert.EqualError(t, err, expectedErrorMessage)
})
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestCheckoutBranchStep(t *testing.T) {
StatusCode: 200,
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCheckoutBranch(&config, &autils, apiManager)
assert.EqualError(t, err, expectedErrorMessage)
})
Expand Down Expand Up @@ -184,7 +184,7 @@ repositories:
Password: "testPassword",
Repositories: "repositoriesTest.yml",
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCheckoutBranch(&config, &autils, apiManager)
assert.NoError(t, err)
})
Expand Down Expand Up @@ -228,7 +228,7 @@ repositories:
Password: "testPassword",
Repositories: "repositoriesTest.yml",
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCheckoutBranch(&config, &autils, apiManager)
assert.EqualError(t, err, expectedErrorMessage)
})
Expand Down Expand Up @@ -277,7 +277,7 @@ repositories:
Password: "testPassword",
Repositories: "repositoriesTest.yml",
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCheckoutBranch(&config, &autils, apiManager)
assert.EqualError(t, err, expectedErrorMessage)
})
Expand Down
20 changes: 10 additions & 10 deletions cmd/abapEnvironmentCloneGitRepo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ repositories:
Token: "myToken",
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
assert.NoError(t, err, "Did not expect error")
assert.Equal(t, 0, len(client.BodyList), "Not all requests were done")
Expand Down Expand Up @@ -140,7 +140,7 @@ repositories:
StatusCode: 200,
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
assert.NoError(t, err, "Did not expect error")
assert.Equal(t, 0, len(client.BodyList), "Not all requests were done")
Expand Down Expand Up @@ -177,7 +177,7 @@ repositories:
StatusCode: 200,
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
if assert.Error(t, err, "Expected error") {
assert.Equal(t, "Clone of repository / software component 'testRepo1', branch 'testBranch1' failed on the ABAP system: Request to ABAP System not successful", err.Error(), "Expected different error message")
Expand Down Expand Up @@ -239,7 +239,7 @@ repositories:
Token: "myToken",
StatusCode: 200,
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
if assert.Error(t, err, "Expected error") {
assert.Equal(t, "Clone of repository / software component '/DMO/REPO_A', branch 'branchA', commit 'ABCD1234' failed on the ABAP system: Request to ABAP System not successful", err.Error(), "Expected different error message")
Expand Down Expand Up @@ -275,7 +275,7 @@ repositories:
Token: "myToken",
StatusCode: 200,
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
if assert.Error(t, err, "Expected error") {
assert.Equal(t, "Clone of repository / software component 'testRepo1', branch 'testBranch1' failed on the ABAP system: Request to ABAP System not successful", err.Error(), "Expected different error message")
Expand Down Expand Up @@ -310,7 +310,7 @@ repositories:
Token: "myToken",
StatusCode: 200,
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
if assert.Error(t, err, "Expected error") {
assert.Equal(t, "Clone of repository / software component 'testRepo1', branch 'testBranch1' failed on the ABAP system: Request to ABAP System not successful", err.Error(), "Expected different error message")
Expand Down Expand Up @@ -344,7 +344,7 @@ repositories:
Token: "myToken",
StatusCode: 200,
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
if assert.Error(t, err, "Expected error") {
assert.Equal(t, "Could not read repositories: Could not find filename.yaml", err.Error(), "Expected different error message")
Expand Down Expand Up @@ -385,7 +385,7 @@ repositories:
Token: "myToken",
StatusCode: 200,
}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCloneGitRepo(&config, &autils, apiManager)
if assert.Error(t, err, "Expected error") {
assert.Equal(t, "The provided configuration is not allowed: It is not allowed to configure the parameters `repositories`and `repositoryName` at the same time", err.Error(), "Expected different error message")
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestALreadyCloned(t *testing.T) {
CommitID: "abcd1234",
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := cloneSingleRepo(apiManager, autils.ReturnedConnectionDetailsHTTP, repo, &config, &autils)
assert.NoError(t, err, "Did not expect error")
})
Expand Down Expand Up @@ -487,7 +487,7 @@ func TestALreadyCloned(t *testing.T) {
CommitID: "abcd1234",
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond}
apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := cloneSingleRepo(apiManager, autils.ReturnedConnectionDetailsHTTP, repo, &config, &autils)
assert.NoError(t, err, "Did not expect error")
})
Expand Down
50 changes: 25 additions & 25 deletions cmd/abapEnvironmentCreateTag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ repositories:
}
client := &abaputils.ClientMock{
BodyList: []string{
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "S" } }`,
`{"d" : { "uuid" : "abc" } }`,
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "S" } }`,
`{"d" : { "uuid" : "abc" } }`,
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "S" } }`,
`{"d" : { "uuid" : "abc" } }`,
Expand All @@ -101,14 +101,14 @@ repositories:
_, hook := test.NewNullLogger()
log.RegisterHook(hook)

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager := &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCreateTag(config, autils, apiManager)

assert.NoError(t, err, "Did not expect error")
assert.Equal(t, 22, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `Created tag v4.5.6 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[11].Message, "Expected a different message")
assert.Equal(t, `Created tag -DMO-PRODUCT-1.2.3 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[16].Message, "Expected a different message")
assert.Equal(t, `Created tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[21].Message, "Expected a different message")
assert.Equal(t, 25, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `Created tag v4.5.6 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[12].Message, "Expected a different message")
assert.Equal(t, `Created tag -DMO-PRODUCT-1.2.3 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[18].Message, "Expected a different message")
assert.Equal(t, `Created tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[24].Message, "Expected a different message")
hook.Reset()
})

Expand Down Expand Up @@ -153,17 +153,17 @@ repositories:
}
client := &abaputils.ClientMock{
BodyList: []string{
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "E" } }`,
`{"d" : { "uuid" : "abc" } }`,
`{"d" : { "empty" : "body" } }`,
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "E" } }`,
`{"d" : { "uuid" : "abc" } }`,
`{"d" : { "empty" : "body" } }`,
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "E" } }`,
`{"d" : { "uuid" : "abc" } }`,
Expand All @@ -176,15 +176,15 @@ repositories:
_, hook := test.NewNullLogger()
log.RegisterHook(hook)

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager := &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCreateTag(config, autils, apiManager)

assert.Error(t, err, "Did expect error")
assert.Equal(t, 37, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `NOT created: Tag v4.5.6 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[11].Message, "Expected a different message")
assert.Equal(t, `NOT created: Tag -DMO-PRODUCT-1.2.3 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[23].Message, "Expected a different message")
assert.Equal(t, `NOT created: Tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[35].Message, "Expected a different message")
assert.Equal(t, `At least one tag has not been created`, hook.AllEntries()[36].Message, "Expected a different message")
assert.Equal(t, 40, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `NOT created: Tag v4.5.6 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[12].Message, "Expected a different message")
assert.Equal(t, `NOT created: Tag -DMO-PRODUCT-1.2.3 for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[25].Message, "Expected a different message")
assert.Equal(t, `NOT created: Tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[38].Message, "Expected a different message")
assert.Equal(t, `At least one tag has not been created`, hook.AllEntries()[39].Message, "Expected a different message")
hook.Reset()

})
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestRunAbapEnvironmentCreateTagConfigurations(t *testing.T) {
}
client := &abaputils.ClientMock{
BodyList: []string{
`{"d" : ` + executionLogStringClone + `}`,
`{"d" : ` + executionLogStringCreateTag + `}`,
logResultSuccess,
`{"d" : { "Status" : "S" } }`,
`{"d" : { "uuid" : "abc" } }`,
Expand All @@ -228,12 +228,12 @@ func TestRunAbapEnvironmentCreateTagConfigurations(t *testing.T) {
_, hook := test.NewNullLogger()
log.RegisterHook(hook)

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager := &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err := runAbapEnvironmentCreateTag(config, autils, apiManager)

assert.NoError(t, err, "Did not expect error")
assert.Equal(t, 12, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `Created tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[11].Message, "Expected a different message")
assert.Equal(t, 13, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `Created tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[12].Message, "Expected a different message")
hook.Reset()
})

Expand Down Expand Up @@ -296,7 +296,7 @@ repositories:
StatusCode: 200,
}

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager := &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCreateTag(config, autils, apiManager)

assert.Error(t, err, "Did expect error")
Expand Down Expand Up @@ -359,12 +359,12 @@ repositories:
_, hook := test.NewNullLogger()
log.RegisterHook(hook)

apiManager = &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Microsecond}
apiManager := &abaputils.SoftwareComponentApiManager{Client: client, PollIntervall: 1 * time.Nanosecond, Force0510: true}
err = runAbapEnvironmentCreateTag(config, autils, apiManager)

assert.NoError(t, err, "Did not expect error")
assert.Equal(t, 5, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `Created tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[4].Message, "Expected a different message")
assert.Equal(t, 6, len(hook.Entries), "Expected a different number of entries")
assert.Equal(t, `Created tag tag for repository /DMO/SWC with commitID 1234abcd`, hook.AllEntries()[5].Message, "Expected a different message")
hook.Reset()

})
Expand Down
Loading

0 comments on commit dbc3d41

Please sign in to comment.