Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TKSS-998: Run all unit tests on the native crypto provider #999

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Execute Gradle build
run: ./gradlew clean build
- name: Execute tests with the pure Java crypto
run: ./gradlew clean test

- name: Execute tests with the native crypto
run: ./gradlew clean testNativeOnCurrent
40 changes: 37 additions & 3 deletions buildSrc/src/main/kotlin/kona-common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ tasks {
}

val testOnCurrent = register("testOnCurrent", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

doFirst {
println("Testing JDK: " + javaLauncher.get().metadata.installationPath)
}
}

register("testNativeOnCurrent", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=true")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

doFirst {
Expand All @@ -68,6 +80,8 @@ tasks {
}

register("testOnAdop8", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand All @@ -81,7 +95,8 @@ tasks {
}

register("testOnAdop11", CommonTest::class) {
jvmArgs("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED")
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

Expand All @@ -96,7 +111,8 @@ tasks {
}

register("testOnAdop17", CommonTest::class) {
jvmArgs("--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

Expand All @@ -111,7 +127,8 @@ tasks {
}

register("testOnAdop21", CommonTest::class) {
jvmArgs("--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

Expand All @@ -126,6 +143,8 @@ tasks {
}

register("testOnKona8", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false");

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand All @@ -139,6 +158,9 @@ tasks {
}

register("testOnKona11", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand All @@ -152,6 +174,9 @@ tasks {
}

register("testOnKona17", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand All @@ -165,6 +190,9 @@ tasks {
}

register("testOnKona21", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand All @@ -178,6 +206,9 @@ tasks {
}

register("testOnGraal17", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand All @@ -191,6 +222,9 @@ tasks {
}

register("testOnGraal21", CommonTest::class) {
jvmArgs("-Dcom.tencent.kona.useNativeCrypto=false",
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED")

systemProperty("test.classpath", classpath.joinToString(separator = ":"))

javaLauncher.set(javaToolchains.launcherFor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package com.tencent.kona.ssl.interop;

import com.tencent.kona.crypto.CryptoUtils;
import com.tencent.kona.ssl.TestUtils;

import javax.net.ssl.KeyManagerFactory;
Expand Down Expand Up @@ -198,6 +199,8 @@ public Jdk getProduct() {
public void connect(String host, int port) throws IOException {
props.put(JdkProcUtils.PROP_HOST, host);
props.put(JdkProcUtils.PROP_PORT, port + "");
props.put(JdkProcUtils.PROP_USE_NATIVE_CRYPTO,
CryptoUtils.useNativeCrypto() + "");

process = JdkProcUtils.java(jdk, Collections.emptyList(), getClass(),
props, getLogPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package com.tencent.kona.ssl.interop;

import com.tencent.kona.crypto.CryptoUtils;
import com.tencent.kona.ssl.TestUtils;

import javax.net.ssl.KeyManagerFactory;
Expand Down Expand Up @@ -213,6 +214,9 @@ public boolean isAlive() {

@Override
public void accept() throws IOException {
props.put(JdkProcUtils.PROP_USE_NATIVE_CRYPTO,
CryptoUtils.useNativeCrypto() + "");

process = JdkProcUtils.java(jdk, Collections.emptyList(), getClass(),
props, getLogPath());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class JdkProcUtils {
public static final String PROP_MESSAGE = "test.message";
public static final String PROP_READ_RESPONSE = "test.read.response";

public static final String PROP_USE_NATIVE_CRYPTO = "com.tencent.kona.useNativeCrypto";

/*
* Converts a Cert instance to a string, which contains the field values of
* the Cert. The values are separated by comma.
Expand Down
Loading