Skip to content

Commit 9b7751d

Browse files
Merge pull request #113 from ChannelFinder/code-coverage-it
Code coverage it
2 parents 3ee20b7 + 72bb089 commit 9b7751d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+591
-453
lines changed

.github/workflows/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
shell: bash
3838
run: docker image prune -af
3939
- name: Integration Test with Maven
40-
run: mvn clean install test-compile failsafe:integration-test failsafe:verify jacoco:report --batch-mode --fail-at-end
40+
run: mvn clean install test-compile failsafe:integration-test failsafe:verify verify --batch-mode --fail-at-end -Djacoco.skip=false -DskipITs=false -DskipITCoverage=false
4141
- name: Publish Test Report
4242
uses: mikepenz/action-junit-report@v3
4343
if: success() || failure() # always run even if the previous step fails

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
shell: bash
7575
run: docker image prune -af
7676
- name: Integration Test with Maven
77-
run: mvn clean install test-compile failsafe:integration-test failsafe:verify --batch-mode --fail-at-end
77+
run: mvn clean install test-compile failsafe:integration-test failsafe:verify --batch-mode --fail-at-end -Djacoco.skip=true -DskipITs=false -DskipITCoverage=true
7878
- name: Publish Test Report
7979
uses: mikepenz/action-junit-report@v4
8080
if: success() || failure() # always run even if the previous step fails

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
.idea
1111

1212
### Eclipse ###
13+
.settings/org.eclipse.core.resources.prefs
1314
.settings/org.eclipse.jdt.core.prefs
15+
.settings/org.eclipse.m2e.core.prefs
1416

1517
### Docker ###
1618
docker-compose-local*
1719

1820
### Spring ###
19-
spring-shell.log
21+
spring-shell.log

.settings/org.eclipse.core.resources.prefs

Lines changed: 0 additions & 6 deletions
This file was deleted.

.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 14 deletions
This file was deleted.

.settings/org.eclipse.m2e.core.prefs

Lines changed: 0 additions & 4 deletions
This file was deleted.

Dockerfile.integrationtest

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ FROM openjdk:11
2121
# deployment unit
2222
COPY target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar
2323

24+
# code coverage
25+
COPY target/jacoco/jacocoagent.jar /channelfinder/jacocoagent.jar
26+
2427
CMD ["java", "-jar", "/channelfinder/ChannelFinder-*.jar", "--spring.config.name=application"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ There are tests for properties, tags and channels separately and in combination.
141141
Integration tests can be run in IDE and via Maven.
142142

143143
```
144-
mvn failsafe:integration-test
144+
mvn failsafe:integration-test -DskipITs=false
145145
```
146146

147147
See

docker-compose-integrationtest.yml

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,6 @@
1818

1919
version: "3.7"
2020
services:
21-
elasticsearch:
22-
image: docker.elastic.co/elasticsearch/elasticsearch:8.2.0
23-
hostname: elasticsearch-cf
24-
networks:
25-
- channelfinder-net
26-
environment:
27-
cluster.name: channelfinder
28-
bootstrap.memory_lock: "true"
29-
discovery.type: single-node
30-
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
31-
xpack.security.enabled: "false"
32-
volumes:
33-
- channelfinder-es-data:/usr/share/elasticsearch/data
34-
healthcheck:
35-
test: curl -f http://elasticsearch-cf:9200/_cluster/health
36-
interval: 30s
37-
timeout: 60s
38-
retries: 5
39-
4021
channelfinder:
4122
build:
4223
context: .
@@ -58,14 +39,39 @@ services:
5839
ldap.enabled: "false"
5940
embedded_ldap.enabled: "false"
6041
demo_auth.enabled: "true"
61-
command: "java -jar /channelfinder/ChannelFinder-*.jar --spring.config.name=application"
42+
skipITCoverage: "true"
43+
command: >
44+
/bin/bash -c "
45+
if [ ${skipITCoverage} == false ]; then
46+
export JAVA_TOOL_OPTIONS=-javaagent:/channelfinder/jacocoagent.jar=destfile=/channelfinder/jacoco.exec,output=file,append=false
47+
fi
48+
java -jar /channelfinder/ChannelFinder-*.jar --spring.config.name=application"
6249
restart: on-failure
6350
healthcheck:
6451
test: curl -s -f http://channelfinder:8080/ChannelFinder
6552
interval: 30s
6653
timeout: 60s
6754
retries: 5
6855

56+
elasticsearch:
57+
image: docker.elastic.co/elasticsearch/elasticsearch:8.2.0
58+
hostname: elasticsearch-cf
59+
networks:
60+
- channelfinder-net
61+
environment:
62+
cluster.name: channelfinder
63+
bootstrap.memory_lock: "true"
64+
discovery.type: single-node
65+
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
66+
xpack.security.enabled: "false"
67+
volumes:
68+
- channelfinder-es-data:/usr/share/elasticsearch/data
69+
healthcheck:
70+
test: curl -f http://elasticsearch-cf:9200/_cluster/health
71+
interval: 30s
72+
timeout: 60s
73+
retries: 5
74+
6975

7076
volumes:
7177
channelfinder-es-data:
@@ -74,12 +80,3 @@ volumes:
7480
networks:
7581
channelfinder-net:
7682
driver: bridge
77-
78-
79-
# ------------------------------------------------------------------------------
80-
# Note
81-
# ------------------------------------------------------------------------------
82-
# elasticsearch port numbers
83-
# can be exposed differently externally to avoid interference with any running instance
84-
# to be reflected in docker integration tests
85-
# ------------------------------------------------------------------------------

pom.xml

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<spring.boot-version>2.7.3</spring.boot-version>
3939
<elasticsearch.version>8.2.0</elasticsearch.version>
4040
<junit-jupiter.version>5.10.0</junit-jupiter.version>
41+
<skipITs>true</skipITs>
42+
<skipITCoverage>true</skipITCoverage>
43+
<jacoco.skip>true</jacoco.skip>
4144
</properties>
4245
<dependencyManagement>
4346
<dependencies>
@@ -148,13 +151,22 @@
148151
<groupId>org.springframework.security</groupId>
149152
<artifactId>spring-security-test</artifactId>
150153
</dependency>
154+
151155
<dependency>
152156
<groupId>org.epics</groupId>
153157
<artifactId>epics-core</artifactId>
154158
<type>pom</type>
155159
<version>7.0.2</version>
156160
<scope>compile</scope>
157161
</dependency>
162+
163+
<dependency>
164+
<groupId>org.jacoco</groupId>
165+
<artifactId>org.jacoco.agent</artifactId>
166+
<version>0.8.11</version>
167+
<scope>runtime</scope>
168+
</dependency>
169+
158170
<dependency>
159171
<groupId>org.springframework</groupId>
160172
<artifactId>spring-test</artifactId>
@@ -173,7 +185,7 @@
173185
<dependency>
174186
<groupId>org.testcontainers</groupId>
175187
<artifactId>junit-jupiter</artifactId>
176-
<version>1.19.0</version>
188+
<version>1.19.3</version>
177189
<scope>test</scope>
178190
<exclusions>
179191
<exclusion>
@@ -235,12 +247,13 @@
235247
<artifactId>maven-surefire-plugin</artifactId>
236248
<version>3.1.2</version>
237249
</plugin>
250+
<!-- use self-contained integration tests - org.phoebus.channelfinder.docker -->
238251
<plugin>
239252
<groupId>org.apache.maven.plugins</groupId>
240253
<artifactId>maven-failsafe-plugin</artifactId>
241254
<version>3.1.2</version>
242255
<configuration>
243-
<skipTests>false</skipTests>
256+
<skipITs>${skipITs}</skipITs>
244257
<includes>
245258
<include>**/*IT.java</include>
246259
</includes>
@@ -261,6 +274,30 @@
261274
</execution>
262275
</executions>
263276
</plugin>
277+
<plugin>
278+
<groupId>org.apache.maven.plugins</groupId>
279+
<artifactId>maven-dependency-plugin</artifactId>
280+
<executions>
281+
<execution>
282+
<id>copy</id>
283+
<phase>package</phase>
284+
<goals>
285+
<goal>copy</goal>
286+
</goals>
287+
<configuration>
288+
<artifactItems>
289+
<artifactItem>
290+
<groupId>org.jacoco</groupId>
291+
<artifactId>org.jacoco.agent</artifactId>
292+
<classifier>runtime</classifier>
293+
<outputDirectory>${project.build.directory}/jacoco</outputDirectory>
294+
<destFileName>jacocoagent.jar</destFileName>
295+
</artifactItem>
296+
</artifactItems>
297+
</configuration>
298+
</execution>
299+
</executions>
300+
</plugin>
264301
<plugin>
265302
<groupId>org.jacoco</groupId>
266303
<artifactId>jacoco-maven-plugin</artifactId>
@@ -271,12 +308,35 @@
271308
<goal>prepare-agent</goal>
272309
</goals>
273310
</execution>
311+
<execution>
312+
<id>merge</id>
313+
<phase>verify</phase>
314+
<goals>
315+
<goal>merge</goal>
316+
</goals>
317+
<configuration>
318+
<fileSets>
319+
<fileSet>
320+
<directory>${project.build.directory}</directory>
321+
<includes>
322+
<include>jacoco*.exec</include>
323+
</includes>
324+
</fileSet>
325+
</fileSets>
326+
<destFile>${project.build.directory}/site/jacoco/jacoco.exec</destFile>
327+
</configuration>
328+
</execution>
274329
<execution>
275330
<id>report</id>
276-
<phase>prepare-package</phase>
331+
<!-- <phase>prepare-package</phase> -->
332+
<phase>verify</phase>
277333
<goals>
278334
<goal>report</goal>
279335
</goals>
336+
<configuration>
337+
<dataFile>${project.build.directory}/site/jacoco/jacoco.exec</dataFile>
338+
<outputDirectory>${project.build.directory}/site/jacoco</outputDirectory>
339+
</configuration>
280340
</execution>
281341
</executions>
282342
</plugin>
@@ -416,6 +476,25 @@
416476
</plugins>
417477
</build>
418478
</profile>
479+
<!-- profile for integrationtest with docker -->
480+
<profile>
481+
<id>integrationtest-docker</id>
482+
<build>
483+
<plugins>
484+
<plugin>
485+
<groupId>org.apache.maven.plugins</groupId>
486+
<artifactId>maven-failsafe-plugin</artifactId>
487+
<version>3.1.2</version>
488+
<configuration>
489+
<skipITs>${skipITs}</skipITs>
490+
<includes>
491+
<include>**/docker/*IT.java</include>
492+
</includes>
493+
</configuration>
494+
</plugin>
495+
</plugins>
496+
</build>
497+
</profile>
419498
</profiles>
420499
<repositories>
421500
<repository>

0 commit comments

Comments
 (0)