Skip to content

Commit b85401a

Browse files
authored
Merge pull request #73 from DataSQRL/easy-coverage
Easy coverage
2 parents 181c577 + b4e1592 commit b85401a

File tree

8 files changed

+63
-161
lines changed

8 files changed

+63
-161
lines changed

.mvn/extensions.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
3+
Copyright © 2024 DataSQRL (contact@datasqrl.com)
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
-->
18+
<extensions>
19+
<extension>
20+
<groupId>com.marvinformatics.jacoco</groupId>
21+
<artifactId>easy-jacoco-maven-plugin</artifactId>
22+
<version>0.1.1</version>
23+
</extension>
24+
</extensions>

flink-sql-runner/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,23 @@
272272
</executions>
273273
</plugin>
274274

275+
<plugin>
276+
<groupId>com.marvinformatics.jacoco</groupId>
277+
<artifactId>easy-jacoco-maven-plugin</artifactId>
278+
<executions>
279+
<execution>
280+
<id>instrument-uber-jar</id>
281+
<goals>
282+
<goal>instrument-jar</goal>
283+
</goals>
284+
<configuration>
285+
<source>${project.build.directory}/flink-sql-runner.uber.jar</source>
286+
<destination>${project.build.directory}/flink-sql-runner.jacoco.jar</destination>
287+
</configuration>
288+
</execution>
289+
</executions>
290+
</plugin>
291+
275292
<plugin>
276293
<groupId>org.codehaus.mojo</groupId>
277294
<artifactId>exec-maven-plugin</artifactId>

flink-sql-runner/src/test/java/com/datasqrl/FlinkMainIT.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929
import com.nextbreakpoint.flink.client.model.TerminationMode;
3030
import com.nextbreakpoint.flink.client.model.UploadStatus;
3131
import java.io.File;
32-
import java.io.FileInputStream;
33-
import java.io.FileOutputStream;
34-
import java.io.IOException;
35-
import java.io.InputStream;
36-
import java.io.OutputStream;
3732
import java.nio.file.Files;
3833
import java.nio.file.Path;
3934
import java.sql.SQLException;
@@ -50,8 +45,6 @@
5045
import org.apache.flink.shaded.curator5.com.google.common.base.Objects;
5146
import org.apache.flink.shaded.curator5.com.google.common.collect.Lists;
5247
import org.awaitility.core.ThrowingRunnable;
53-
import org.jacoco.core.instr.Instrumenter;
54-
import org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator;
5548
import org.jdbi.v3.core.Jdbi;
5649
import org.jdbi.v3.core.statement.SqlLogger;
5750
import org.jdbi.v3.core.statement.StatementContext;
@@ -250,29 +243,11 @@ JarRunResponseBody execute(String... arguments) {
250243
return restoreAndExecute(null, arguments);
251244
}
252245

253-
private int instrument(final File src, final File dest) throws IOException {
254-
if (dest.exists()) {
255-
return 0;
256-
}
257-
var instrumenter = new Instrumenter(new OfflineInstrumentationAccessGenerator());
258-
259-
dest.getParentFile().mkdirs();
260-
try (final InputStream input = new FileInputStream(src);
261-
final OutputStream output = new FileOutputStream(dest)) {
262-
return instrumenter.instrumentAll(input, output, src.getAbsolutePath());
263-
} catch (final IOException e) {
264-
dest.delete();
265-
throw e;
266-
}
267-
}
268-
269246
@SneakyThrows
270247
JarRunResponseBody restoreAndExecute(String savepointPath, String... arguments) {
271-
var originalFile = new File("target/flink-sql-runner.uber.jar");
272-
var instrumentedJarFile = new File("target/flink-sql-runner.jacoco.jar");
273-
instrument(originalFile, instrumentedJarFile);
248+
var originalFile = new File("target/flink-sql-runner.jacoco.jar");
274249

275-
var uploadResponse = client.uploadJar(instrumentedJarFile);
250+
var uploadResponse = client.uploadJar(originalFile);
276251

277252
assertThat(uploadResponse.getStatus()).isEqualTo(UploadStatus.SUCCESS);
278253

pom.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,26 @@
286286
</plugin>
287287

288288
<plugin>
289-
<groupId>org.jacoco</groupId>
290-
<artifactId>jacoco-maven-plugin</artifactId>
291-
<version>0.8.13</version>
292-
<executions>
293-
<execution>
294-
<goals>
295-
<goal>prepare-agent</goal>
296-
<goal>prepare-agent-integration</goal>
297-
<goal>report</goal>
298-
<goal>report-integration</goal>
299-
</goals>
300-
</execution>
301-
</executions>
289+
<groupId>com.marvinformatics.jacoco</groupId>
290+
<artifactId>easy-jacoco-maven-plugin</artifactId>
291+
<version>0.1.1</version>
292+
<configuration>
293+
<projectRules>
294+
<rule>
295+
<limits>
296+
<limit>
297+
<counter>INSTRUCTION</counter>
298+
<value>COVEREDRATIO</value>
299+
<minimum>0.70</minimum>
300+
</limit>
301+
</limits>
302+
</rule>
303+
</projectRules>
304+
<haltOnFailure>true</haltOnFailure>
305+
<projectExtraProperties>
306+
<license.skip>true</license.skip>
307+
</projectExtraProperties>
308+
</configuration>
302309
</plugin>
303310
</plugins>
304311
</build>

testing/coverage/pom.xml

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

testing/coverage/src/main/java/hoop/Code.java

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

testing/coverage/src/test/java/packagereport/ReportTest.java

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

testing/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<modules>
3333
<module>system-functions-sample</module>
3434
<module>udf-sample</module>
35-
<module>coverage</module>
3635
</modules>
3736

3837
</project>

0 commit comments

Comments
 (0)