mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
TransportRequestUploadFile migration to Go - RFC (#3097)
* UploadFile RFC - migrate to GO code
This commit is contained in:
parent
bab369c6d4
commit
bd8ca941b6
@ -246,7 +246,19 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void uploadFileToTransportRequestRFCSuccessTest() {
|
public void uploadFileToTransportRequestRFCSuccessTest() {
|
||||||
|
|
||||||
def cmUtilsReceivedParams
|
def calledWithParameters,
|
||||||
|
calledWithStepName,
|
||||||
|
calledWithMetadata,
|
||||||
|
calledWithCredentials
|
||||||
|
|
||||||
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
||||||
|
params, stepName, metaData, creds ->
|
||||||
|
calledWithParameters = params
|
||||||
|
calledWithStepName = stepName
|
||||||
|
calledWithMetadata = metaData
|
||||||
|
calledWithCredentials = creds
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
nullScript.commonPipelineEnvironment.configuration =
|
nullScript.commonPipelineEnvironment.configuration =
|
||||||
[general:
|
[general:
|
||||||
@ -257,42 +269,6 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
def cm = new ChangeManagement(nullScript) {
|
|
||||||
|
|
||||||
void uploadFileToTransportRequestRFC(
|
|
||||||
Map docker,
|
|
||||||
String transportRequestId,
|
|
||||||
String applicationId,
|
|
||||||
String applicationURL,
|
|
||||||
String endpoint,
|
|
||||||
String credentialsId,
|
|
||||||
String developmentInstance,
|
|
||||||
String developmentClient,
|
|
||||||
String applicationDescription,
|
|
||||||
String abapPackage,
|
|
||||||
String codePage,
|
|
||||||
boolean acceptUnixStyleLineEndings,
|
|
||||||
boolean failUploadOnWarning,
|
|
||||||
boolean verbose) {
|
|
||||||
|
|
||||||
cmUtilsReceivedParams = [
|
|
||||||
docker: docker,
|
|
||||||
transportRequestId: transportRequestId,
|
|
||||||
applicationName: applicationId,
|
|
||||||
applicationURL: applicationURL,
|
|
||||||
endpoint: endpoint,
|
|
||||||
credentialsId: credentialsId,
|
|
||||||
developmentInstance: developmentInstance,
|
|
||||||
developmentClient: developmentClient,
|
|
||||||
applicationDescription: applicationDescription,
|
|
||||||
abapPackage: abapPackage,
|
|
||||||
codePage: codePage,
|
|
||||||
acceptUnixStyleLineEndings: acceptUnixStyleLineEndings,
|
|
||||||
failUploadOnWarning: failUploadOnWarning,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stepRule.step.transportRequestUploadFile(script: nullScript,
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
||||||
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
||||||
codePage: 'UTF-9',
|
codePage: 'UTF-9',
|
||||||
@ -308,29 +284,22 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
|||||||
applicationName: '42',
|
applicationName: '42',
|
||||||
applicationDescription: 'Lorem ipsum',
|
applicationDescription: 'Lorem ipsum',
|
||||||
abapPackage: 'XYZ',
|
abapPackage: 'XYZ',
|
||||||
cmUtils: cm,)
|
credentialsId: 'CM'
|
||||||
|
)
|
||||||
|
|
||||||
assert cmUtilsReceivedParams ==
|
assertThat(calledWithStepName, is('transportRequestUploadRFC'))
|
||||||
[
|
assertThat(calledWithParameters.applicationName, is('42'))
|
||||||
docker: [
|
assertThat(calledWithParameters.applicationUrl, is('http://example.org/blobstore/xyz.zip'))
|
||||||
image: 'rfc',
|
assertThat(calledWithParameters.endpoint, is('https://example.org/rfc'))
|
||||||
options: [],
|
assertThat(calledWithParameters.uploadCredentialsId, is('CM'))
|
||||||
envVars: [:],
|
assertThat(calledWithParameters.instance, is('001'))
|
||||||
pullImage: true
|
assertThat(calledWithParameters.client, is('002'))
|
||||||
],
|
assertThat(calledWithParameters.applicationDescription, is('Lorem ipsum'))
|
||||||
transportRequestId: '123456',
|
assertThat(calledWithParameters.abapPackage, is('XYZ'))
|
||||||
applicationName: '42',
|
assertThat(calledWithParameters.codePage, is('UTF-9'))
|
||||||
applicationURL: 'http://example.org/blobstore/xyz.zip',
|
assertThat(calledWithParameters.acceptUnixStyleLineEndings, is(true))
|
||||||
endpoint: 'https://example.org/rfc',
|
assertThat(calledWithParameters.failUploadOnWarning, is(true))
|
||||||
credentialsId: 'CM',
|
assertThat(calledWithParameters.transportRequestId, is('123456'))
|
||||||
developmentInstance: '001',
|
|
||||||
developmentClient: '002',
|
|
||||||
applicationDescription: 'Lorem ipsum',
|
|
||||||
abapPackage:'XYZ',
|
|
||||||
codePage: 'UTF-9',
|
|
||||||
acceptUnixStyleLineEndings: true,
|
|
||||||
failUploadOnWarning: true,
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -339,26 +308,10 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
|||||||
thrown.expect(AbortException)
|
thrown.expect(AbortException)
|
||||||
thrown.expectMessage('upload failed')
|
thrown.expectMessage('upload failed')
|
||||||
|
|
||||||
def cm = new ChangeManagement(nullScript) {
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
||||||
|
throw new AbortException('upload failed')
|
||||||
void uploadFileToTransportRequestRFC(
|
|
||||||
Map docker,
|
|
||||||
String transportRequestId,
|
|
||||||
String applicationId,
|
|
||||||
String applicationURL,
|
|
||||||
String endpoint,
|
|
||||||
String credentialsId,
|
|
||||||
String developmentInstance,
|
|
||||||
String developmentClient,
|
|
||||||
String applicationDescription,
|
|
||||||
String abapPackage,
|
|
||||||
String codePage,
|
|
||||||
boolean acceptUnixStyleLineEndings,
|
|
||||||
boolean failOnUploadWarning,
|
|
||||||
boolean verbose) {
|
|
||||||
throw new ChangeManagementException('upload failed')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
stepRule.step.transportRequestUploadFile(script: nullScript,
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
||||||
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
||||||
@ -381,7 +334,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
|||||||
applicationName: '42',
|
applicationName: '42',
|
||||||
applicationDescription: 'Lorem ipsum',
|
applicationDescription: 'Lorem ipsum',
|
||||||
abapPackage: 'XYZ',
|
abapPackage: 'XYZ',
|
||||||
cmUtils: cm,)
|
credentialsId: 'CM'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -276,22 +276,20 @@ void call(Map parameters = [:]) {
|
|||||||
case BackendType.RFC:
|
case BackendType.RFC:
|
||||||
|
|
||||||
echo "[INFO] Uploading file '${configuration.applicationUrl}' to transport request '${configuration.transportRequestId}'."
|
echo "[INFO] Uploading file '${configuration.applicationUrl}' to transport request '${configuration.transportRequestId}'."
|
||||||
|
transportRequestUploadRFC(script: script,
|
||||||
cm.uploadFileToTransportRequestRFC(
|
transportRequestId: configuration.transportRequestId,
|
||||||
configuration.changeManagement.rfc.docker ?: [:],
|
applicationName: configuration.applicationName,
|
||||||
configuration.transportRequestId,
|
applicationUrl: configuration.applicationUrl,
|
||||||
configuration.applicationName,
|
endpoint: configuration.changeManagement.endpoint,
|
||||||
configuration.applicationUrl,
|
uploadCredentialsId: configuration.changeManagement.credentialsId,
|
||||||
configuration.changeManagement.endpoint,
|
instance: configuration.changeManagement.rfc.developmentInstance,
|
||||||
configuration.changeManagement.credentialsId,
|
client: configuration.changeManagement.rfc.developmentClient,
|
||||||
configuration.changeManagement.rfc.developmentInstance,
|
applicationDescription: configuration.applicationDescription,
|
||||||
configuration.changeManagement.rfc.developmentClient,
|
abapPackage: configuration.abapPackage,
|
||||||
configuration.applicationDescription,
|
codePage: configuration.codePage,
|
||||||
configuration.abapPackage,
|
acceptUnixStyleLineEndings: configuration.acceptUnixStyleLineEndings,
|
||||||
configuration.codePage,
|
failUploadOnWarning: configuration.failOnWarning,
|
||||||
configuration.acceptUnixStyleLineEndings,
|
verbose: configuration.verbose
|
||||||
configuration.failOnWarning,
|
|
||||||
configuration.verbose
|
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "[INFO] File 'configuration.applicationUrl' has been successfully uploaded to transport request '${configuration.transportRequestId}'."
|
echo "[INFO] File 'configuration.applicationUrl' has been successfully uploaded to transport request '${configuration.transportRequestId}'."
|
||||||
|
Loading…
Reference in New Issue
Block a user