-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GraalVM native testing and fix metadata (#307)
- Loading branch information
1 parent
52c8879
commit f2621c2
Showing
14 changed files
with
200 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
plugins { | ||
id 'groovy-gradle-plugin' | ||
} | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation libs.gradle.micronaut | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
rootProject.name = 'cassandra-parent' | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
libs { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
buildSrc/src/main/groovy/io.micronaut.build.internal.cassandra-base.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
repositories { | ||
mavenCentral() | ||
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" } | ||
} |
5 changes: 1 addition & 4 deletions
5
buildSrc/src/main/groovy/io.micronaut.build.internal.cassandra-module.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
plugins { | ||
id "io.micronaut.build.internal.module" | ||
id "io.micronaut.build.internal.cassandra-base" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" } | ||
} |
31 changes: 31 additions & 0 deletions
31
buildSrc/src/main/groovy/io.micronaut.build.internal.cassandra-native-tests.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
plugins { | ||
id "io.micronaut.build.internal.cassandra-base" | ||
id "io.micronaut.application" | ||
id "io.micronaut.test-resources" | ||
id 'org.graalvm.buildtools.native' | ||
} | ||
|
||
tasks.named("check") { task -> | ||
def graal = ["jvmci.Compiler", "java.vendor.version", "java.vendor"].any { | ||
System.getProperty(it)?.toLowerCase(Locale.ENGLISH)?.contains("graal") | ||
} | ||
if (graal) { | ||
task.dependsOn("nativeTest") | ||
} | ||
} | ||
|
||
tasks.named("test") { | ||
useJUnitPlatform() | ||
} | ||
|
||
graalvmNative { | ||
toolchainDetection = false | ||
metadataRepository { | ||
enabled = true | ||
} | ||
binaries { | ||
all { | ||
resources.autodetect() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
plugins { | ||
id "io.micronaut.application" | ||
id "io.micronaut.build.internal.cassandra-native-tests" | ||
} | ||
|
||
mainClassName = "helloworld.Application" | ||
micronaut { | ||
version "4.0.0-M1" | ||
testRuntime "junit5" | ||
enableNativeImage false | ||
processing { | ||
incremental(true) | ||
annotations("helloworld.*") | ||
} | ||
testResources { | ||
clientTimeout = 600 | ||
} | ||
} | ||
|
||
configurations.all { | ||
resolutionStrategy.dependencySubstitution { | ||
substitute module('io.micronaut.cassandra:micronaut-cassandra') using project(':micronaut-cassandra') | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation mn.micronaut.context | ||
implementation mn.micronaut.jackson.databind | ||
implementation project(':micronaut-cassandra') | ||
implementation mn.snakeyaml | ||
runtimeOnly mn.logback.classic | ||
} | ||
|
||
graalvmNative { | ||
binaries { | ||
all { | ||
buildArgs.add("--trace-class-initialization=com.datastax.oss.driver.internal.core.util.Dependency") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package example; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
|
||
@Introspected | ||
public class CassandraInfo { | ||
private final String clusterName; | ||
private final String releaseVersion; | ||
|
||
public CassandraInfo(String clusterName, String releaseVersion) { | ||
this.clusterName = clusterName; | ||
this.releaseVersion = releaseVersion; | ||
} | ||
|
||
public String getClusterName() { | ||
return clusterName; | ||
} | ||
|
||
public String getReleaseVersion() { | ||
return releaseVersion; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test-suite-graal/src/main/java/example/CassandraRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package example; | ||
|
||
import com.datastax.oss.driver.api.core.CqlSession; | ||
import com.datastax.oss.driver.api.core.cql.ResultSet; | ||
import com.datastax.oss.driver.api.core.cql.Row; | ||
import jakarta.inject.Singleton; | ||
|
||
import java.util.Optional; | ||
|
||
@Singleton | ||
public class CassandraRepository { | ||
private final CqlSession cqlSession; | ||
|
||
public CassandraRepository(CqlSession cqlSession) { | ||
this.cqlSession = cqlSession; | ||
} | ||
|
||
public Optional<CassandraInfo> getInfo() { | ||
ResultSet resultSet = cqlSession.execute("select cluster_name, release_version from system.local"); | ||
Row row = resultSet.one(); | ||
|
||
if (row != null) { | ||
return Optional.of( | ||
new CassandraInfo( | ||
row.getString("cluster_name"), | ||
row.getString("release_version") | ||
) | ||
); | ||
} | ||
return Optional.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
micronaut: | ||
application: | ||
name: cassandra | ||
cassandra: | ||
default: | ||
basic: | ||
contact-points: | ||
- "127.0.0.1:${cassandra.port}" | ||
load-balancing-policy: | ||
local-datacenter: datacenter1 | ||
test-resources: | ||
containers: | ||
cassandra: | ||
startup-timeout: 600s | ||
image-name: cassandra | ||
exposed-ports: | ||
- cassandra.port: 9042 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package example; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
|
||
@MicronautTest | ||
class CassandraTest { | ||
|
||
@Test | ||
void testCassandra(CassandraRepository repository) { | ||
assertTrue(repository.getInfo().isPresent()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
|
||
<!-- <logger name="io.micronaut.context.env" level="trace" />--> | ||
</configuration> |