Skip to content

Commit 7efcc38

Browse files
TillK17I750911newtork
authored
ci: Fix jacoco coverage (#296)
* current coverage on local run * increase coverage threshold * increase coverage threshold * change POM of core to support coverage check * Revert "change POM of core to support coverage check" This reverts commit 8a44aed. * fix jacoco command in CI * set orchestration test coverage to 100% for testing * set core threshold to actual coverage * Revert "set core threshold to actual coverage" This reverts commit a8fc127. * CI test * test for OpenAI coverage * fix orchestration * test * test * test pom config * test pom config * original pom config * Update AiCoreServiceTest.java * run with new test * fix * with report * fix with report * fix with report * final test * final test * final coverage orchestration * final coverage openAI --------- Co-authored-by: I750911 <[email protected]> Co-authored-by: Alexander Dümont <[email protected]>
1 parent a173e05 commit 7efcc38

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

.github/workflows/continuous-integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
6868
- name: "Run Unit Tests"
6969
run: |
70-
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report"
70+
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report org.jacoco:jacoco-maven-plugin:check@default-check"
7171
mvn $MVN_ARGS
7272
7373
- name: "Slack Notification"

core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
</developers>
3131
<properties>
3232
<project.rootdir>${project.basedir}/../</project.rootdir>
33-
<coverage.complexity>62%</coverage.complexity>
34-
<coverage.line>76%</coverage.line>
35-
<coverage.instruction>76%</coverage.instruction>
33+
<coverage.complexity>64%</coverage.complexity>
34+
<coverage.line>78%</coverage.line>
35+
<coverage.instruction>79%</coverage.instruction>
3636
<coverage.branch>60%</coverage.branch>
37-
<coverage.method>74%</coverage.method>
37+
<coverage.method>77%</coverage.method>
3838
<coverage.class>90%</coverage.class>
3939
</properties>
4040

core/src/test/java/com/sap/ai/sdk/core/AiCoreServiceTest.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.sap.ai.sdk.core;
22

3+
import static com.github.tomakehurst.wiremock.client.WireMock.get;
4+
import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
5+
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
6+
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
37
import static org.assertj.core.api.Assertions.assertThat;
48
import static org.assertj.core.api.Assertions.assertThatCode;
59
import static org.assertj.core.api.Assertions.assertThatThrownBy;
610

11+
import com.github.tomakehurst.wiremock.WireMockServer;
712
import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination;
813
import com.sap.cloud.sdk.cloudplatform.connectivity.Header;
914
import com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination;
@@ -63,17 +68,30 @@ void testCustomBaseDestination() {
6368

6469
@Test
6570
void testGetInferenceDestination() {
66-
var builder = service.getInferenceDestination();
71+
// default resource group destination
72+
val builder = service.getInferenceDestination();
6773
assertThatThrownBy(() -> builder.forScenario("doesn't exist"))
6874
.isExactlyInstanceOf(DeploymentResolutionException.class);
6975

76+
// custom resource group destination
7077
val destination = service.getInferenceDestination("foo").usingDeploymentId("123");
71-
7278
assertThat(destination.getUri())
7379
.hasHost("api.ai.com")
7480
.hasPath("/v2/inference/deployments/123/");
75-
7681
assertThat(destination.getHeaders()).containsExactly(new Header("AI-Resource-Group", "foo"));
82+
83+
// scenario-based destination
84+
val d = "{\"count\":1,\"resources\":[{\"id\":\"0123456789abcdef\",\"scenarioId\":\"foobar\"}]}";
85+
val server = new WireMockServer(wireMockConfig().dynamicPort());
86+
server.start();
87+
server.stubFor(get(urlEqualTo("/v2/lm/deployments")).willReturn(okJson(d)));
88+
HttpDestination foobar =
89+
service
90+
.withBaseDestination(DefaultHttpDestination.builder(server.baseUrl() + "/v2/").build())
91+
.getInferenceDestination()
92+
.forScenario("foobar");
93+
assertThat(foobar.getUri()).hasPath("/v2/inference/deployments/0123456789abcdef/");
94+
server.stop();
7795
}
7896

7997
@Test

foundation-models/openai/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
</developers>
3434
<properties>
3535
<project.rootdir>${project.basedir}/../../</project.rootdir>
36-
<coverage.complexity>71%</coverage.complexity>
36+
<coverage.complexity>72%</coverage.complexity>
3737
<coverage.line>80%</coverage.line>
3838
<coverage.instruction>76%</coverage.instruction>
39-
<coverage.branch>69%</coverage.branch>
39+
<coverage.branch>70%</coverage.branch>
4040
<coverage.method>83%</coverage.method>
4141
<coverage.class>84%</coverage.class>
4242
</properties>

orchestration/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
</developers>
3232
<properties>
3333
<project.rootdir>${project.basedir}/../</project.rootdir>
34-
<coverage.complexity>76%</coverage.complexity>
35-
<coverage.line>90%</coverage.line>
36-
<coverage.instruction>91%</coverage.instruction>
37-
<coverage.branch>69%</coverage.branch>
38-
<coverage.method>70%</coverage.method>
34+
<coverage.complexity>77%</coverage.complexity>
35+
<coverage.line>92%</coverage.line>
36+
<coverage.instruction>92%</coverage.instruction>
37+
<coverage.branch>70%</coverage.branch>
38+
<coverage.method>92%</coverage.method>
3939
<coverage.class>100%</coverage.class>
4040
</properties>
4141

0 commit comments

Comments
 (0)