Integration test failing after upgrading to 4.10.0
Mazhar0910 opened this issue · 1 comments
Integration test execution failing with destination not found error after moving to 4.10.0
We have enabled integration test for our cloud application which does make a http call and uses MockUtil and MockDestination.
So we expect a mock destination to be created which shall be utilised when call is being made to fetch the destination .
After we upgraded the cloud sdk version to 4.10.0, we realised integration started connecting to our cloud system using default-env.json and trying to fetch the destination details.
As a result of this , destination could not be fetched and our integration started failing.
Important information:
We expect below code should work as it is and sdk on runtime should make use of mock destination.
protected void destinationCallMock(String url, String responseFile, String mockdata_folder)
throws ODataException {
final MockUtil mockUtil = new MockUtil();
wireMockRule.start();
MockDestination destination =
MockDestination.builder(
DESTINATION_NAME,
URI.create(wireMockRule.baseUrl() + DESTINATION_ENDPOINT))
.build();
mockUtil.mockDestination(destination);
wireMockRule.stubFor(
head(urlEqualTo(url))
.willReturn(
aResponse().withStatus(200).withHeader("x-csrf-token", "test")));
wireMockRule.stubFor(
post(urlEqualTo(url))
.willReturn(
aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(
readResponseFromFile(
responseFile, mockdata_folder))));
}
Our part of integration suite can be found out here https://github.tools.sap/Industry-Process-Framework/IPF/blob/development/srv/src/test/java/com/sap/ic/maestro/runtime/api/tests/EndToEndApiTest.java
Impact / Priority
Affected development phase
Error Message
Destination not found due to invalid access token but in general test should have used mocked destination
Maven Dependency Tree
mvn dependency:tree | grep 'com.sap.cloud.sdk'
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.sap.cloud.sdk.cloudplatform:scp-cf:jar -> duplicate declaration of version (?) @ line 173, column 21
[INFO] +- com.sap.cloud.sdk.cloudplatform:scp-cf:jar:4.10.0:provided
[INFO] | +- com.sap.cloud.sdk.cloudplatform:auditlog-scp-cf:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:auditlog:jar:4.10.0:provided
[INFO] | +- com.sap.cloud.sdk.cloudplatform:caching:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:security:jar:4.10.0:provided
[INFO] | | - com.sap.cloud.sdk.cloudplatform:tenant:jar:4.10.0:provided
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core-scp-cf:jar:4.10.0:provided
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp-cf:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:connectivity-oauth:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:resilience:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.frameworks:resilience4j:jar:4.10.0:provided
[INFO] | +- com.sap.cloud.sdk.cloudplatform:security-scp-cf:jar:4.10.0:provided
[INFO] | +- com.sap.cloud.sdk.cloudplatform:servlet:jar:4.10.0:provided
[INFO] | - com.sap.cloud.sdk.cloudplatform:tenant-scp-cf:jar:4.10.0:provided
[INFO] | | | - com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:4.10.0:provided
[INFO] | | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:4.10.0:provided
[INFO] | | | +- com.sap.cloud.sdk.cloudplatform:caching:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:tenant:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:security:jar:4.10.0:provided
[INFO] | | - com.sap.cloud.sdk.frameworks:resilience4j:jar:4.10.0:provided
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:resilience:jar:4.10.0:provided
[INFO] | | | | - com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:4.10.0:runtime
[INFO] | | | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:4.10.0:runtime
[INFO] | | | | +- com.sap.cloud.sdk.cloudplatform:caching:jar:4.10.0:runtime
[INFO] | | | | | - com.sap.cloud.sdk.cloudplatform:tenant:jar:4.10.0:runtime
[INFO] | | | | +- com.sap.cloud.sdk.cloudplatform:security:jar:4.10.0:runtime
[INFO] +- com.sap.cloud.sdk.cloudplatform:scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:auditlog-scp-cf:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:auditlog:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:caching:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:security:jar:4.10.0:compile
[INFO] | | - com.sap.cloud.sdk.cloudplatform:tenant:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core-scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp-cf:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:connectivity-oauth:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:resilience:jar:4.10.0:compile
[INFO] | | - com.sap.cloud.sdk.frameworks:resilience4j:jar:4.10.0:runtime
[INFO] | +- com.sap.cloud.sdk.cloudplatform:security-scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:servlet:jar:4.10.0:compile
[INFO] | - com.sap.cloud.sdk.cloudplatform:tenant-scp-cf:jar:4.10.0:compile
[INFO] +- com.sap.cloud.sdk.cloudplatform:scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:auditlog-scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:caching:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core-scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp-cf:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity-scp:jar:4.10.0:compile
[INFO] | | - com.sap.cloud.sdk.cloudplatform:connectivity-oauth:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:security-scp-cf:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:servlet:jar:4.10.0:compile
[INFO] | - com.sap.cloud.sdk.cloudplatform:tenant-scp-cf:jar:4.10.0:compile
[INFO] +- com.sap.cloud.sdk.s4hana:s4hana-all:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.s4hana:s4hana-core:jar:4.10.0:compile
[INFO] | | - com.sap.cloud.sdk.datamodel:fluent-result:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.s4hana:s4hana-connectivity:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.s4hana:s4hana-api-odata:jar:4.10.0:compile
[INFO] | | - com.sap.cloud.sdk.datamodel:odata-core:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.s4hana:s4hana-api-odata-v4:jar:4.10.0:compile
[INFO] | | +- com.sap.cloud.sdk.datamodel:odata-v4-core:jar:4.10.0:compile
[INFO] | | - com.sap.cloud.sdk.datamodel:odata-client:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.datamodel:soap:jar:4.10.0:compile
[INFO] | - com.sap.cloud.sdk.s4hana:rfc:jar:4.10.0:compile
[INFO] +- com.sap.cloud.sdk.testutil:testutil-core:jar:4.10.0:test
[INFO] | +- com.sap.cloud.sdk.cloudplatform:auditlog:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-core:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:cloudplatform-connectivity:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:security:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:tenant:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.testutil:testutil-resources:jar:4.10.0:test
[INFO] +- com.sap.cloud.sdk.frameworks:resilience4j:jar:4.10.0:compile
[INFO] | +- com.sap.cloud.sdk.cloudplatform:resilience:jar:4.10.0:compile
Project Details
-
SAP Cloud SDK Version: 4.10.0
-
Link to GitHub repository: IPF
-
Project type:
- CAP Project
-
Platform:
- Cloud Foundry
Thanks,
Mazhar
Hi Mazhar,
with version 4 we sort of discontinued the MockUtil
classes since mocking destinations is relatively simple now with code that can also be used productively. You can register destinations programatically as described here and we recommend this for testing.
However, I can see that you are using @Autowired ScpCfDestinationLoader scpCfDestinationLoader
. The MockUtil should not have any interaction with that, since MockUtil only changes DestinationAccessor
. So I'm not quite sure how this worked before, it probably depends on how you provide the bean ScpCfDestinationLoader
. So I would recommend looking into that too.