Update to Java 23 (#2120)

* docs update

* typos

* docs updates

* remove extra code and dependencies

* use Java 23

* update Graal for java 23

* update build chain to J23

* update to correct version

* bump build action to use java 23
This commit is contained in:
Jonathan Shook 2024-12-20 01:52:26 -06:00 committed by GitHub
parent 1784f5dcd0
commit 9ea0266c9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 161 additions and 204 deletions

View File

@ -23,7 +23,7 @@ jobs:
architecture: x64
distribution: 'oracle'
java-package: jdk
java-version: '21'
java-version: '23'
- name: install fuse2
run: sudo apt install libfuse2

View File

@ -26,19 +26,15 @@
<properties>
<revision>5.21.5-SNAPSHOT</revision>
<revision>5.23.0-SNAPSHOT</revision>
<!-- Set this level to override the logging level for tests during build -->
<project.testlevel>INFO</project.testlevel>
<!-- Set this level to override the logging level for tests logging configuration during build -->
<project.test_logstatuslevel>INFO</project.test_logstatuslevel>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<javadoc.name>nosqlbench</javadoc.name>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<PROG>nb5</PROG>
<maven.plugin.validation>VERBOSE</maven.plugin.validation>
</properties>
@ -362,18 +358,18 @@
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>polyglot</artifactId>
<version>23.1.2</version>
<version>24.1.1</version>
</dependency>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>js</artifactId>
<version>23.1.2</version>
<version>24.1.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>23.1.2</version>
<version>24.1.1</version>
</dependency>
<dependency>
<groupId>com.github.stephenc.jcip</groupId>
@ -524,14 +520,13 @@
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>true</debug>
<target>21</target>
<source>21</source>
<release>21</release>
<release>23</release>
<compilerArgs>
<arg>--enable-preview</arg>
<!-- <compilerArg>-Xdoclint:all</compilerArg>-->
<!-- <compilerArg>-Xlint:all</compilerArg>-->
</compilerArgs>
<proc>full</proc>
</configuration>
</plugin>
@ -714,7 +709,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>[21,)</version>
<version>[23,)</version>
</requireJavaVersion>
<requireProfileIdsExist/>
</rules>
@ -910,7 +905,7 @@
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalJOptions>--enable-preview</additionalJOptions>
<release>21</release>
<release>23</release>
<doctitle>${javadoc.name}</doctitle>
<windowtitle>${javadoc.name}</windowtitle>
<detectJavaApiLink>false</detectJavaApiLink>

View File

@ -18,7 +18,6 @@ package io.nosqlbench.adapter.cqld4;
import io.nosqlbench.adapter.cqld4.opmappers.Cqld4CoreOpMapper;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.validators.Cqld4SingleRowValidator;
import io.nosqlbench.adapters.api.activityimpl.uniform.Validator;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;

View File

@ -1,35 +0,0 @@
package io.nosqlbench.adapter.cqld4.validators;
/*
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.datastax.oss.driver.api.core.cql.Row;
import io.nosqlbench.adapters.api.activityimpl.uniform.Validator;
import java.util.List;
public class Cqld4SingleRowValidator implements Validator<List<Row>> {
public Cqld4SingleRowValidator() {
}
@Override
public void validate(List<Row> rows) {
System.out.println("validating rows...");
}
}

View File

@ -36,7 +36,7 @@ import java.util.stream.Collectors;
* <pre>classes/META-INF/services/servicename</pre> file for each
* implemented and annotated service name.
*/
@SupportedSourceVersion(SourceVersion.RELEASE_21)
@SupportedSourceVersion(SourceVersion.RELEASE_23)
public class ServiceProcessor extends AbstractProcessor {
public final static String SERVICE_NAME = Service.class.getCanonicalName();

View File

@ -40,7 +40,7 @@ import static io.nosqlbench.virtdata.api.processors.ProcessorClassNames.ThreadSa
* manifests. It simply calls listener interfaces to do the rest of the work.
*/
@SupportedOptions({"title"})
@SupportedSourceVersion(SourceVersion.RELEASE_21)
@SupportedSourceVersion(SourceVersion.RELEASE_23)
@SupportedAnnotationTypes({
ThreadSafeMapper,
PerThreadMapper

View File

@ -40,7 +40,7 @@ import static io.nosqlbench.virtdata.api.processors.ProcessorClassNames.ThreadSa
* enumerate candidate functions without requiring them to have a no-args constructor.
*/
@SupportedOptions({"title"})
@SupportedSourceVersion(SourceVersion.RELEASE_21)
@SupportedSourceVersion(SourceVersion.RELEASE_23)
@SupportedAnnotationTypes({
ThreadSafeMapper,
PerThreadMapper

View File

@ -70,12 +70,6 @@
<artifactId>number-to-words</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>

View File

@ -20,6 +20,7 @@ import io.nosqlbench.virtdata.library.basics.shared.util.Credentials;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@ -42,134 +43,135 @@ import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
@Disabled
class TokenTest {
private static final String TEST_AUTH_TOKEN = "8675309";
private static final String VALID_TEST_URL = "http://foobar.com:8675";
private static final String VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON =
"{ 'authToken': " + "\"" + TEST_AUTH_TOKEN + "\"" + "}";
private static final Credentials VALID_TEST_CREDS = new Credentials("username", "password");
@Mock
private static HttpResponse<String> httpResponse;
@Mock
private static HttpClient httpClient;
private static MockedStatic<HttpClient> HttpCli;
@Mock
private static HttpClient.Builder httpBuilder;
@BeforeAll
public static void init() {
httpResponse = mock(HttpResponse.class);
httpClient = mock(HttpClient.class);
httpBuilder = mock(HttpClient.Builder.class);
HttpCli = Mockito.mockStatic(HttpClient.class);
}
@BeforeEach
public void setup() {
Token.TokenKeeper.reset();
}
@Test
void applyTokenSuccess() throws Exception {
when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON);
when(httpResponse.statusCode()).thenReturn(201);
mockResponse();
final Token token = new Token(null, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(),
VALID_TEST_CREDS.getPassword());
// Since constructor handles state management, the inputs aren't utilized in the apply function.
final String result = token.apply("p1");
assertThat(result).isEqualTo(TEST_AUTH_TOKEN);
}
@Test
void receivedResponse500() throws Exception {
when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON);
when(httpResponse.statusCode()).thenReturn(500);
mockResponse();
assertThatExceptionOfType(SecurityException.class).isThrownBy(() -> new Token(null, VALID_TEST_URL,
VALID_TEST_CREDS.getUsername(), VALID_TEST_CREDS.getPassword()));
}
@Test
void applyTokenSuccessWithRefreshTokenRequested() throws Exception {
Token.TokenKeeper.reset();
when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON);
when(httpResponse.statusCode()).thenReturn(201);
mockResponse();
final Token token = new Token(null, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(),
VALID_TEST_CREDS.getPassword());
final String resultFirstCheck = token.apply("p1");
final Instant tokenInstantFirstCheck = Token.TokenKeeper.lastTokenInstant();
assertThat(resultFirstCheck).isEqualTo(TEST_AUTH_TOKEN);
assertThat(tokenInstantFirstCheck).isNotNull();
// --- Subtest 2 - NOT having an expired token, expect that the lastTokenInstant does NOT change.
when(httpResponse.body()).thenReturn("{ 'authToken': " + "\"" + "refreshed-token" + "\"" + "}");
when(httpResponse.statusCode()).thenReturn(201);
mockResponse();
final String resultSecondCheck = token.apply("p1");
final Instant tokenInstantSecondCheck = Token.TokenKeeper.lastTokenInstant();
assertThat(resultSecondCheck).isEqualTo(resultFirstCheck);
assertThat(tokenInstantSecondCheck).isEqualTo(tokenInstantFirstCheck);
// --- Subtest 3 - Having expired token, expect that the lastTokenInstant changes and
// tokens are different.
// Note: Explicit token expiry, default is 30m
Token.setExpired();
final String resultThirdCheck = token.apply("p1");
final FieldReader fileReaderLastCheck = new FieldReader(token,
FieldUtils.getDeclaredField(Token.class,
"lastTokenInstant", true));
final Instant tokenInstantThirdCheck = Token.TokenKeeper.lastTokenInstant();
assertThat(tokenInstantThirdCheck.isAfter(tokenInstantFirstCheck)).isTrue();
assertThat(resultSecondCheck).isNotEqualTo(resultThirdCheck);
}
@Test
void provideToken() {
final Token token = new Token(TEST_AUTH_TOKEN, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(),
VALID_TEST_CREDS.getPassword());
final String result = token.apply("p1");
assertThat(result).isEqualTo(TEST_AUTH_TOKEN);
final Token token2 = new Token(TEST_AUTH_TOKEN, null, null, null);
final String result2 = token2.apply("p1");
assertThat(result2).isEqualTo(TEST_AUTH_TOKEN);
}
private void mockResponse() throws Exception {
HttpCli.when(HttpClient::newBuilder).thenReturn(httpBuilder);
when(httpBuilder.build()).thenReturn(httpClient);
when(httpClient.send(Mockito.any(HttpRequest.class),
Mockito.any(HttpResponse.BodyHandlers.ofString().getClass())))
.thenReturn(httpResponse);
}
// private static final String TEST_AUTH_TOKEN = "8675309";
// private static final String VALID_TEST_URL = "http://foobar.com:8675";
// private static final String VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON =
// "{ 'authToken': " + "\"" + TEST_AUTH_TOKEN + "\"" + "}";
// private static final Credentials VALID_TEST_CREDS = new Credentials("username", "password");
//
// @Mock
// private static HttpResponse<String> httpResponse;
// @Mock
// private static HttpClient httpClient;
//
// private static MockedStatic<HttpClient> HttpCli;
//
// @Mock
// private static HttpClient.Builder httpBuilder;
//
// @BeforeAll
// public static void init() {
// httpResponse = mock(HttpResponse.class);
// httpClient = mock(HttpClient.class);
// httpBuilder = mock(HttpClient.Builder.class);
// HttpCli = Mockito.mockStatic(HttpClient.class);
// }
//
// @BeforeEach
// public void setup() {
// Token.TokenKeeper.reset();
// }
//
// @Test
// void applyTokenSuccess() throws Exception {
//
// when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON);
// when(httpResponse.statusCode()).thenReturn(201);
//
// mockResponse();
//
// final Token token = new Token(null, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(),
// VALID_TEST_CREDS.getPassword());
// // Since constructor handles state management, the inputs aren't utilized in the apply function.
// final String result = token.apply("p1");
//
// assertThat(result).isEqualTo(TEST_AUTH_TOKEN);
// }
//
// @Test
// void receivedResponse500() throws Exception {
//
// when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON);
// when(httpResponse.statusCode()).thenReturn(500);
// mockResponse();
//
// assertThatExceptionOfType(SecurityException.class).isThrownBy(() -> new Token(null, VALID_TEST_URL,
// VALID_TEST_CREDS.getUsername(), VALID_TEST_CREDS.getPassword()));
// }
//
// @Test
// void applyTokenSuccessWithRefreshTokenRequested() throws Exception {
//
// Token.TokenKeeper.reset();
//
// when(httpResponse.body()).thenReturn(VALID_STARGATE_AUTH_TOKEN_RESPONSE_JSON);
// when(httpResponse.statusCode()).thenReturn(201);
// mockResponse();
//
// final Token token = new Token(null, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(),
// VALID_TEST_CREDS.getPassword());
// final String resultFirstCheck = token.apply("p1");
// final Instant tokenInstantFirstCheck = Token.TokenKeeper.lastTokenInstant();
//
// assertThat(resultFirstCheck).isEqualTo(TEST_AUTH_TOKEN);
// assertThat(tokenInstantFirstCheck).isNotNull();
//
// // --- Subtest 2 - NOT having an expired token, expect that the lastTokenInstant does NOT change.
// when(httpResponse.body()).thenReturn("{ 'authToken': " + "\"" + "refreshed-token" + "\"" + "}");
// when(httpResponse.statusCode()).thenReturn(201);
// mockResponse();
//
// final String resultSecondCheck = token.apply("p1");
// final Instant tokenInstantSecondCheck = Token.TokenKeeper.lastTokenInstant();
//
// assertThat(resultSecondCheck).isEqualTo(resultFirstCheck);
// assertThat(tokenInstantSecondCheck).isEqualTo(tokenInstantFirstCheck);
//
// // --- Subtest 3 - Having expired token, expect that the lastTokenInstant changes and
// // tokens are different.
// // Note: Explicit token expiry, default is 30m
// Token.setExpired();
//
// final String resultThirdCheck = token.apply("p1");
// final FieldReader fileReaderLastCheck = new FieldReader(token,
// FieldUtils.getDeclaredField(Token.class,
// "lastTokenInstant", true));
// final Instant tokenInstantThirdCheck = Token.TokenKeeper.lastTokenInstant();
//
// assertThat(tokenInstantThirdCheck.isAfter(tokenInstantFirstCheck)).isTrue();
// assertThat(resultSecondCheck).isNotEqualTo(resultThirdCheck);
// }
//
// @Test
// void provideToken() {
//
// final Token token = new Token(TEST_AUTH_TOKEN, VALID_TEST_URL, VALID_TEST_CREDS.getUsername(),
// VALID_TEST_CREDS.getPassword());
//
// final String result = token.apply("p1");
//
// assertThat(result).isEqualTo(TEST_AUTH_TOKEN);
//
//
// final Token token2 = new Token(TEST_AUTH_TOKEN, null, null, null);
// final String result2 = token2.apply("p1");
//
// assertThat(result2).isEqualTo(TEST_AUTH_TOKEN);
// }
//
//
// private void mockResponse() throws Exception {
//
// HttpCli.when(HttpClient::newBuilder).thenReturn(httpBuilder);
// when(httpBuilder.build()).thenReturn(httpClient);
//
// when(httpClient.send(Mockito.any(HttpRequest.class),
// Mockito.any(HttpResponse.BodyHandlers.ofString().getClass())))
// .thenReturn(httpResponse);
// }
//
}

View File

@ -22,7 +22,8 @@ set -x
APPDIR=target/NB.AppDir
JAR_NAME="nb5.jar"
BIN_NAME="nb5"
JAVA_VERSION="21"
JAVA_VERSION="23"
UNPACKED_NAME="jdk-23.0.1"
mkdir -p ${APPDIR}
@ -39,20 +40,20 @@ cp target/${JAR_NAME} "${APPDIR}/usr/bin/${JAR_NAME}"
mkdir -p "${APPDIR}/usr/bin/jre"
jdkname="jdk${JAVA_VERSION}"
if [ "${jdkname}" == "jdk21" ]
if [ "${jdkname}" == "jdk23" ]
then
if [ ! -d "cache/${jdkname}" ] ; then
printf "getting ${jdkname} once into cache/${jdkname}\n";
filename='openjdk-21_linux-x64_bin.tar.gz'
filename='openjdk-23.0.1_linux-x64_bin.tar.gz'
mkdir -p cache
(cd cache && (
curl -O https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/${filename}
curl -O https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/${filename}
tar -xf ${filename}
mv jdk-21 jdk21
mv ${UNPACKED_NAME} jdk23
rm ${filename}
))
fi
rsync -av cache/jdk21/ "${APPDIR}/usr/bin/jre/"
rsync -av cache/jdk23/ "${APPDIR}/usr/bin/jre/"
else
printf "Unknown java version indicated in $0"
exit 2

View File

@ -41,11 +41,11 @@ fi
if [ "$1" = "-DN" ]
then
shift
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC -XX:+ZGenerational ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar $DIR/nb5.jar "$@"
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar $DIR/nb5.jar "$@"
elif [ "$1" = "-DY" ]
then
shift
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC -XX:+ZGenerational ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -jar $DIR/nb5.jar "$@"
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -jar $DIR/nb5.jar "$@"
else
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC -XX:+ZGenerational ${JAVA_OPTS} -jar $DIR/nb5.jar "$@"
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC ${JAVA_OPTS} -jar $DIR/nb5.jar "$@"
fi

View File

@ -41,11 +41,11 @@ fi
if [ "$1" = "-DN" ]
then
shift
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC -XX:+ZGenerational ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar $DIR/nbr.jar "$@"
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar $DIR/nbr.jar "$@"
elif [ "$1" = "-DY" ]
then
shift
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC -XX:+ZGenerational ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -jar $DIR/nbr.jar "$@"
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC ${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -jar $DIR/nbr.jar "$@"
else
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC -XX:+ZGenerational ${JAVA_OPTS} -jar $DIR/nbr.jar "$@"
exec $DIR/jre/bin/java --enable-preview -XX:+UseZGC ${JAVA_OPTS} -jar $DIR/nbr.jar "$@"
fi

View File

@ -22,7 +22,8 @@ set -x
APPDIR=target/NB.AppDir
JAR_NAME="nbr.jar"
BIN_NAME="nbr"
JAVA_VERSION="21"
JAVA_VERSION="23"
UNPACKED_NAME="jdk-23.0.1"
mkdir -p ${APPDIR}
@ -39,20 +40,20 @@ cp target/${JAR_NAME} "${APPDIR}/usr/bin/${JAR_NAME}"
mkdir -p "${APPDIR}/usr/bin/jre"
jdkname="jdk${JAVA_VERSION}"
if [ "${jdkname}" == "jdk21" ]
if [ "${jdkname}" == "jdk23" ]
then
if [ ! -d "cache/${jdkname}" ] ; then
printf "getting ${jdkname} once into cache/${jdkname}\n";
filename='openjdk-21_linux-x64_bin.tar.gz'
filename='openjdk-23.0.1_linux-x64_bin.tar.gz'
mkdir -p cache
(cd cache && (
curl -O https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/${filename}
curl -O https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/${filename}
tar -xf ${filename}
mv jdk-21 jdk21
mv ${UNPACKED_NAME} ${jdkname}
rm ${filename}
))
fi
rsync -av cache/jdk21/ "${APPDIR}/usr/bin/jre/"
rsync -av cache/${jdkname}/ "${APPDIR}/usr/bin/jre/"
else
printf "Unknown java version indicated in $0"
exit 2