Skip to content

Commit 2e0421e

Browse files
jakobbraunmorazow
andauthored
#10: Added a module for code coverage in UDFs (#12)
* #10: Added a module for code coverage in UDFs Co-authored-by: Muhammet Orazov <m.orazow@gmail.com>
1 parent 599cf57 commit 2e0421e

18 files changed

+532
-49
lines changed

.github/workflows/maven.yml renamed to .github/workflows/dependencies_check.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will build a Java project with Maven
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3-
41
name: Dependencies Check
52

63
on:
@@ -17,5 +14,12 @@ jobs:
1714
uses: actions/setup-java@v1
1815
with:
1916
java-version: 11
17+
- name: Cache local Maven repository
18+
uses: actions/cache@v2
19+
with:
20+
path: ~/.m2/repository
21+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
22+
restore-keys: |
23+
${{ runner.os }}-maven-
2024
- name: Checking dependencies for vulnerabilities
2125
run: mvn org.sonatype.ossindex.maven:ossindex-maven-plugin:audit -f pom.xml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Maven Central Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up Maven Central Repository
12+
uses: actions/setup-java@v1
13+
with:
14+
java-version: 11
15+
server-id: ossrh
16+
server-username: MAVEN_USERNAME
17+
server-password: MAVEN_PASSWORD
18+
- name: Import GPG Key
19+
run:
20+
gpg --import --batch <(echo "${{ secrets.OSSRH_GPG_SECRET_KEY }}")
21+
- name: Publish to Central Repository
22+
env:
23+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
24+
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
25+
run: mvn clean -Dgpg.skip=false -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} deploy

NOTICE

+14-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ This project has the following dependencies:
44
asm-analysis under BSD-3-Clause
55
asm-commons under BSD-3-Clause
66
asm-tree under BSD-3-Clause
7+
Byte Buddy (without dependencies) under Apache License, Version 2.0
8+
Byte Buddy agent under Apache License, Version 2.0
9+
docker-java-api under The Apache Software License, Version 2.0
10+
docker-java-transport under The Apache Software License, Version 2.0
11+
docker-java-transport-zerodep under The Apache Software License, Version 2.0
712
Duct Tape under MIT
13+
error-reporting-java under MIT
14+
Exasol Database fundamentals for Java under MIT
815
EXASolution JDBC Driver under EXAClient License
16+
Hamcrest All under New BSD License
917
Hamcrest Core under New BSD License
10-
JaCoCo :: Agent under Eclipse Public License 2.0
18+
Jackson-annotations under The Apache Software License, Version 2.0
1119
JaCoCo :: Core under Eclipse Public License 2.0
1220
Java Native Access under LGPL, version 2.1 or Apache License v2.0
13-
Java Native Access Platform under LGPL, version 2.1 or Apache License v2.0
14-
JetBrains Java Annotations under The Apache Software License, Version 2.0
1521
JSR 374 (JSON Processing) API under Dual license consisting of the CDDL v1.1 and GPL v2
1622
JUnit under Eclipse Public License 1.0
1723
JUnit Jupiter API under Eclipse Public License v2.0
@@ -22,15 +28,16 @@ This project has the following dependencies:
2228
JUnit Platform Launcher under Eclipse Public License v2.0
2329
JUnit Platform Runner under Eclipse Public License v2.0
2430
JUnit Platform Suite API under Eclipse Public License v2.0
25-
junixsocket-common under Apache License, Version 2.0
26-
junixsocket-native-common under Apache License, Version 2.0
27-
Native Library Loader under CC0 1.0 Universal License
31+
mockito-core under The MIT License
32+
MySQL Connector/J under The GNU General Public License, v2 with FOSS exception
33+
Objenesis under Apache License, Version 2.0
2834
org.apiguardian:apiguardian-api under The Apache License, Version 2.0
2935
org.opentest4j:opentest4j under The Apache License, Version 2.0
36+
Protocol Buffers [Core] under 3-Clause BSD License
3037
SLF4J API Module under MIT License
3138
SLF4J JDK14 Binding under MIT License
32-
TCP to Unix Socket Proxy under MIT
3339
Test containers for Exasol on Docker under MIT
40+
Test Database Builder for Java under MIT
3441
Testcontainers :: Database-Commons under MIT
3542
Testcontainers :: JDBC under MIT
3643
Testcontainers :: JUnit Jupiter Extension under MIT

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ You can get the dependency declaration by clicking the maven badge above.
1515
Typically, you use this package together with [test-db-builder-java](https://github.com/exasol/test-db-builder-java) and [exasol-testcontainers](https://github.com/exasol/exasol-testcontainers) as follows:
1616

1717
```java
18-
final UdfTestSetup udfTestSetup = new UdfTestSetup(getTestHostIp());
18+
19+
private static final ExasolContainer<? extends ExasolContainer<?>> EXASOL = new ExasolContainer<>();
20+
final UdfTestSetup udfTestSetup = new UdfTestSetup(getTestHostIp(), EXASOL.getDefaultBucket());
1921
final ExasolObjectFactory testDbBuilder = new ExasolObjectFactory(EXASOL.createConnection(),
2022
ExasolObjectConfiguration.builder().withJvmOptions(udfTestSetup.getJvmOptions()).build());
2123
```
@@ -32,6 +34,14 @@ System property: `test.debug`
3234

3335
This module instructs the UDF JVMs to connect to a Java debugger listening on the default port 8000 on you machine, running the tests.
3436

37+
### Code Coverage
38+
39+
System property: `test.coverage`
40+
41+
This module installs a jacoco agent to the UDF JVM and receives the execution data using a TCP socket.
42+
43+
This module requires additional maven configuration. Use the [project-keeper's](https://github.com/exasol/project-keeper-maven-plugin) `udf_coverage` module to verify it.
44+
3545

3646
## Additional Information
3747

doc/changes/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changes
22

3+
* [0.3.0](changes_0.3.0.md)
34
* [0.2.0](changes_0.2.0.md)
45
* [0.1.0](changes_0.1.0.md)

doc/changes/changes_0.3.0.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# udf-debugging-java 0.3.0, released 2020-11-23
2+
3+
Code name: Test setup for UDF code coverage
4+
5+
## Features / Enhancements
6+
7+
* #10: Added a module for code coverage in UDFs
8+
9+
## Dependency Updates:
10+
11+
* Updated to `com:exasol:project-keeper-maven-plugin:0.3.0` (was 0.2.0)
12+
* Added `com.exasol:error-reporting-java:0.2.0`
13+
* Added `org.jacoco:org.jacoco.core:0.8.6`
14+
* Added `com.exasol:exasol-testcontainers:3.3.1`
15+
* Added `org.mockito:mockito-core:3.6.0`
16+
* Added `org.hamcrest:hamcrest-all:1.3`
17+
* Added `com.exasol:test-db-builder-java:2.0.0`
18+
* Updated to `org.jacoco:jacoco-maven-plugin:0.8.6` (was 0.8.5)
19+
* Added `org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8`
20+
* Updated `org.jacoco:org.jacoco.agent0.8.6` (was 0.8.5)

pom.xml

+73-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.exasol</groupId>
66
<artifactId>udf-debugging-java</artifactId>
7-
<version>0.2.0</version>
7+
<version>0.3.0</version>
88
<name>udf-debugging-java</name>
99
<description>Utilities for debugging, profiling and code coverage measure for UDFs.</description>
1010
<url>https://github.com/exasol/udf-debugging-javat</url>
@@ -14,9 +14,9 @@
1414
<java.version>11</java.version>
1515
<junit.version>5.6.2</junit.version>
1616
<junit.platform.version>1.6.2</junit.platform.version>
17-
<jacoco.version>0.8.5</jacoco.version>
1817
<vscommon.version>11.0.0</vscommon.version>
1918
<gpg.skip>true</gpg.skip>
19+
<jacoco.version>0.8.6</jacoco.version>
2020
<org.testcontainers.version>1.14.3</org.testcontainers.version>
2121
<surefire.and.failsafe.plugin.version>3.0.0-M4</surefire.and.failsafe.plugin.version>
2222
</properties>
@@ -76,6 +76,30 @@
7676
<artifactId>javax.json-api</artifactId>
7777
<version>1.1.4</version>
7878
</dependency>
79+
<dependency>
80+
<groupId>com.exasol</groupId>
81+
<artifactId>error-reporting-java</artifactId>
82+
<version>0.2.0</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.jacoco</groupId>
86+
<artifactId>org.jacoco.core</artifactId>
87+
<version>${jacoco.version}</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.jacoco</groupId>
91+
<artifactId>org.jacoco.agent</artifactId>
92+
<version>${jacoco.version}</version>
93+
<classifier>runtime</classifier>
94+
<scope>test</scope>
95+
</dependency>
96+
<!-- This is a compile dependency for accessing Bucket from testcontainers.
97+
It is planned to move it out there: -->
98+
<dependency>
99+
<groupId>com.exasol</groupId>
100+
<artifactId>exasol-testcontainers</artifactId>
101+
<version>3.3.1</version>
102+
</dependency>
79103
<!-- test dependencies -->
80104
<dependency>
81105
<groupId>org.junit.jupiter</groupId>
@@ -95,31 +119,29 @@
95119
<version>${junit.version}</version>
96120
<scope>test</scope>
97121
</dependency>
98-
<!--Integration test dependencies-->
99122
<dependency>
100-
<groupId>com.exasol</groupId>
101-
<artifactId>exasol-testcontainers</artifactId>
102-
<version>3.2.0</version>
123+
<groupId>org.mockito</groupId>
124+
<artifactId>mockito-core</artifactId>
125+
<version>3.6.0</version>
103126
<scope>test</scope>
104127
</dependency>
105128
<dependency>
106-
<groupId>org.testcontainers</groupId>
107-
<artifactId>junit-jupiter</artifactId>
108-
<version>${org.testcontainers.version}</version>
129+
<groupId>org.hamcrest</groupId>
130+
<artifactId>hamcrest-all</artifactId>
131+
<version>1.3</version>
109132
<scope>test</scope>
110133
</dependency>
134+
<!--Integration test dependencies-->
111135
<dependency>
112-
<groupId>org.jacoco</groupId>
113-
<artifactId>org.jacoco.agent</artifactId>
114-
<version>${jacoco.version}</version>
115-
<classifier>runtime</classifier>
136+
<groupId>org.testcontainers</groupId>
137+
<artifactId>junit-jupiter</artifactId>
138+
<version>${org.testcontainers.version}</version>
116139
<scope>test</scope>
117140
</dependency>
118141
<dependency>
119-
<groupId>org.jacoco</groupId>
120-
<artifactId>org.jacoco.core</artifactId>
121-
<version>${jacoco.version}</version>
122-
<scope>test</scope>
142+
<groupId>com.exasol</groupId>
143+
<artifactId>test-db-builder-java</artifactId>
144+
<version>2.0.0</version>
123145
</dependency>
124146
<dependency>
125147
<groupId>org.slf4j</groupId>
@@ -324,6 +346,12 @@
324346
</goals>
325347
</execution>
326348
</executions>
349+
<configuration>
350+
<excludeVulnerabilityIds>
351+
<!-- Ignores CVE-2020-15250, because we use Java 11 and junit 4.13.1 which contains a fix: https://ossindex.sonatype.org/vuln/7ea56ad4-8a8b-4e51-8ed9-5aad83d8efb1 -->
352+
<exclude>7ea56ad4-8a8b-4e51-8ed9-5aad83d8efb1</exclude>
353+
</excludeVulnerabilityIds>
354+
</configuration>
327355
</plugin>
328356
<plugin>
329357
<groupId>org.apache.maven.plugins</groupId>
@@ -348,7 +376,7 @@
348376
<plugin>
349377
<groupId>com.exasol</groupId>
350378
<artifactId>project-keeper-maven-plugin</artifactId>
351-
<version>0.2.0</version>
379+
<version>0.3.0</version>
352380
<executions>
353381
<execution>
354382
<goals>
@@ -358,6 +386,7 @@
358386
</executions>
359387
<configuration>
360388
<modules>
389+
<module>maven_central</module>
361390
</modules>
362391
</configuration>
363392
</plugin>
@@ -382,6 +411,32 @@
382411
</executions>
383412
</plugin>
384413
-->
414+
<plugin>
415+
<groupId>org.apache.maven.plugins</groupId>
416+
<artifactId>maven-deploy-plugin</artifactId>
417+
<configuration>
418+
<skip>true</skip>
419+
</configuration>
420+
</plugin>
421+
<plugin>
422+
<groupId>org.sonatype.plugins</groupId>
423+
<artifactId>nexus-staging-maven-plugin</artifactId>
424+
<version>1.6.8</version>
425+
<configuration>
426+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
427+
<serverId>ossrh</serverId>
428+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
429+
</configuration>
430+
<executions>
431+
<execution>
432+
<id>default-deploy</id>
433+
<phase>deploy</phase>
434+
<goals>
435+
<goal>deploy</goal>
436+
</goals>
437+
</execution>
438+
</executions>
439+
</plugin>
385440
</plugins>
386441
<testResources>
387442
<testResource>

src/main/java/com/exasol/udfdebugging/Module.java

+8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
import java.util.stream.Stream;
44

5+
/**
6+
* Modules define a specific functionality that users can enable using system properties.
7+
*/
58
public interface Module {
69

10+
/**
11+
* Get JVM options required by this module.
12+
*
13+
* @return JVM options
14+
*/
715
public Stream<String> getJvmOptions();
816
}

src/main/java/com/exasol/udfdebugging/ModuleFactory.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.exasol.udfdebugging;
22

3+
import com.exasol.bucketfs.Bucket;
4+
35
public interface ModuleFactory {
46

57
/**
@@ -20,7 +22,8 @@ public interface ModuleFactory {
2022
* Build the {@link Module}.
2123
*
2224
* @param testHostIpAddress IP address of the host running this UDF Test Setup under which UDFs can reach it
25+
* @param bucket BucketFS bucket to upload resource to
2326
* @return built {@link Module}
2427
*/
25-
public Module buildModule(final String testHostIpAddress);
28+
public Module buildModule(final String testHostIpAddress, Bucket bucket);
2629
}

src/main/java/com/exasol/udfdebugging/UdfTestSetup.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,29 @@
66
import org.slf4j.Logger;
77
import org.slf4j.LoggerFactory;
88

9+
import com.exasol.bucketfs.Bucket;
10+
import com.exasol.udfdebugging.modules.coverage.CoverageModuleFactory;
911
import com.exasol.udfdebugging.modules.debugging.DebuggingModuleFactory;
1012

1113
/**
1214
* Test setup for testing UDFs in the database.
1315
*/
1416
public class UdfTestSetup {
15-
private static final List<ModuleFactory> AVAILABLE_MODULES = List.of(new DebuggingModuleFactory());
17+
private static final List<ModuleFactory> AVAILABLE_MODULES = List.of(new DebuggingModuleFactory(),
18+
new CoverageModuleFactory());
1619
private static final Logger LOGGER = LoggerFactory.getLogger(UdfTestSetup.class);
1720
private final List<Module> enabledModules;
1821

1922
/**
2023
* Create a new instance of {@link UdfTestSetup}.
2124
*
2225
* @param testHostIpAddress IP address of the host running this UDF Test Setup under which UDFs can reach it
26+
* @param bucket BucketFS bucket to upload resource to
2327
*/
24-
public UdfTestSetup(final String testHostIpAddress) {
28+
public UdfTestSetup(final String testHostIpAddress, final Bucket bucket) {
2529
this.enabledModules = AVAILABLE_MODULES.stream().filter(ModuleFactory::isEnabled)
26-
.map(moduleFactory -> moduleFactory.buildModule(testHostIpAddress)).collect(Collectors.toList());
30+
.map(moduleFactory -> moduleFactory.buildModule(testHostIpAddress, bucket))
31+
.collect(Collectors.toList());
2732
printInfoMessage();
2833
}
2934

0 commit comments

Comments
 (0)