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

CNDB-11508: Enable our test config explicitly for JDK22 and apply some test fixes #1398

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ekaterinadimitrova2
Copy link
Collaborator

@ekaterinadimitrova2 ekaterinadimitrova2 commented Oct 30, 2024

What is the issue

We cannot:

  • compile and run main on JDK22
  • run tests on JDK22 with the current config

What does this PR fix and why was it fixed

Porting CASSANDRA-18467, CASSANDRA-18179, CASSANDRA-18258 and adding updates based on testing we already did in a POC branch will enable us to build and run Cassandra on JDK22 plus run all test suites on JDK22 from the main branch. We also added numerous fixes that get CI to a very good state on JDK22.

Removes the use of CASSANDRA_USE_JDK11 (we should verify that will not affect CI systems and other infra scripts in any way) and introduces the build.xml properties java.default and java.supported.
ant generate-idea-files now support JDK 8, JDK 11, and JDK 22.
To add support for another JDK the java-jvmargs property must be set for the JDK in question (see how it's done in build.xml for Java 11 and 22)

Other minor, but notable changes are:

  • test jvmargs are now added to idea run configurations
  • .idea dir and project iml file are first removed and then recreated during ant generate-idea-files
    Adds some additional add-opens and add-exports needed and upgrades mockito for testing.

CI runs posted on the GH issue.

Checklist before you submit for review

  • Make sure there is a PR in the CNDB project updating the Converged Cassandra version
  • Use NoSpamLogger for log lines that may appear frequently in the logs
  • Verify test results on Butler
  • Test coverage for new/modified code is > 80%
  • Proper code formatting
  • Proper title for each commit staring with the project-issue number, like CNDB-1234
  • Each commit has a meaningful description
  • Each commit is not very long and contains related changes
  • Renames, moves and reformatting are in distinct commits

@ekaterinadimitrova2 ekaterinadimitrova2 self-assigned this Oct 30, 2024
@ekaterinadimitrova2 ekaterinadimitrova2 marked this pull request as draft October 30, 2024 23:41
build.xml Outdated
-->
<property name="java.default" value="11" />
<!-- Not sure whether we need 17 below, at least jvm options were added some time ago for 17 -->
<property name="java.supported" value="1.8,11,17,22" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should remove 1.8

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add 21?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 1.8 actually still supported? I don't think it is. I would leave this as 11/17/22 as those are the JVMs we are using.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think what we agreed is the cleaning of dead config for JDK8 is done in main-5.0 but we can remove it from supported here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we are compiling our binaries with 11, I think we should start making things show meaningful errors if someone uses 8 rather than the strange error you get when it actually tries to run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I removed 1.8 and now it shows: Unsupported JDK version used: 1.8
Same as any other version which is not on that list of java.supported

build.xml Outdated
Comment on lines 41 to 45
<!-- JDKs supported.
All releases are built with the default JDK.
Builds with non-default JDKs are considered experimental and for development and testing purposes.
When building, javac's source and target flags are set to the jdk used, so lower JDKs are not supported at runtime.
The use of both CASSANDRA_USE_JDK11 and use-jdk11 is deprecated.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether this is applicable for our CI, it was applicable for Apache, TBD

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this comment

<string>-XX:G1RSetUpdatingPauseTimePercent=5</string>
<string>-XX:MaxGCPauseMillis=100</string>

<!-- Copy-paste for now these options from cndb/docker-entrypoint.sh; we will verify later whether we
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be removed when things are settled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do these all work? You mention these are for tests in the comment, why are there both _jvm22_arg_items and _jvm22_test_arg_items?

It would be nice if we did not need to have all these duplicated here and also in the server.options files, but that is probably something for another ticket.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we did not need to have all these duplicated here and also in the server.options files, but that is probably something for another ticket.

Yes and no. Good reference: CASSANDRA-18263

So pre-CMS being out - Apache Cassandra was using CMS for testing, but a different config for prod. Optimization for our tests or so. When we moved past JDK8 - CASSANDRA-18263 was born. Until someone determines what we do in tests, we will keep the same configuration as the server.options files for now. So far no one has reported any issues around that, and I am not sure we will get to differ anything again. Exactly the opposite, @jacek-lewandowski did very good points in favor to keep G1GC and the same config as prod.
But there is one more caveat - sometimes we need to open/export some JDK internals just for some of the test frameworks we use, but not for prod code. In those cases we will want that to be done only in build.xml.

TLDR - let's consider a change in a different ticket.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a different ticket, and OSS first in this case;

we should get server.properties + extra options for testing;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe CASSANDRA-18263 can be used for that and there is no need of additional one. I will leave a comment there that we may want to reconsider how we stream options between server.options and build.xml to reduce duplications and minimize the potential for bugs.

Comment on lines +258 to +260
<!-- Below two are used in Cassandra, not in CNDB-->
<!--<string>-XX:MaxTenuringThreshold=1</string>
<string>-XX:G1HeapRegionSize=16m</string>-->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be removed when things are settled

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are really just for compilation/running tests, right?

Copy link
Collaborator Author

@ekaterinadimitrova2 ekaterinadimitrova2 Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options in build.xml are only for testing, yes. In prod we would use the ones in server.properties files for self-managed. For Astra, they are at a different place.

@@ -50,9 +50,6 @@ fi
if [[ -z "${java_version}" ]]; then
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//g' | awk -F. '{print $1}')
fi
if [[ ${java_version} -ge 11 ]]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing will show whether this is enough and whether CI is affected in some way by this change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use the new CCM, we should not observe problems; it should just use the Java version from the environment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure which the new CCM is, but so far I did not see any problems.

@ekaterinadimitrova2
Copy link
Collaborator Author

The PR is not finished, but I wanted to do preliminary JDK11 testing to see whether I broke anything so far


JAVA_VERSION=11
if [ "$JVM_VERSION" = "1.8.0" ] ; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just require 11+ given we are doing our builds with 11.

@JeremiahDJordan
Copy link
Member

I think this looks good for a full review. When you put it up for full review, please include links to 11/17/22 based CI runs.

@ekaterinadimitrova2
Copy link
Collaborator Author

ekaterinadimitrova2 commented Nov 6, 2024

Cleaned JDK1.8 from allowed JDKs and fixed a bug in the tooling config.
CI links and additional business-related questions will be posted on the ticket for discussion in a bit.
Moving out of draft to trigger the JDK11 CI run.
For anyone following - please check the ticket before starting full review

@ekaterinadimitrova2 ekaterinadimitrova2 marked this pull request as ready for review November 6, 2024 16:06
@ekaterinadimitrova2 ekaterinadimitrova2 marked this pull request as draft November 6, 2024 20:28
@ekaterinadimitrova2 ekaterinadimitrova2 marked this pull request as ready for review November 6, 2024 20:28
michaelsembwever and others added 8 commits November 6, 2024 15:29
…roperties `java.default` and `java.supported`.

ant generate-idea-files now support JDK 8, JDK 11 and JDK 22.
To add support of another JDK the java-jvmargs property must be set for the JDK in question (see how it's done in build.xml for Java 11 and 22)

Other minor, but notable changes are:
- test jvmargs are now added to idea run configurations
- .idea dir and project iml file are first removed and then recreated during `ant generate-idea-files`

Based on what was done in CASSANDRA-18467, CASSANDRA-18179, CASSANDRA-18258 for 17 plus additional stuff for 21

Co-authored-by: Ekaterina Dimitrova<[email protected]>
Co-authored-by: Mick Semb Wever <[email protected]>
Co-authored-by: Jakub Zytka <[email protected]>
@ekaterinadimitrova2
Copy link
Collaborator Author

There was some issue with CI.
I rebased the branch and force-pushed it to trigger it again, hoping that it was some environmental temporary problem.
The old build was also in a weird state in Jenkins—it was shown as failed, but some jobs were still marked in progress. Hopefully, the new trigger clears the old run and triggers a fresh new one without problems.

bin/cassandra.in.sh Show resolved Hide resolved
build.xml Outdated
Comment on lines 41 to 45
<!-- JDKs supported.
All releases are built with the default JDK.
Builds with non-default JDKs are considered experimental and for development and testing purposes.
When building, javac's source and target flags are set to the jdk used, so lower JDKs are not supported at runtime.
The use of both CASSANDRA_USE_JDK11 and use-jdk11 is deprecated.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this comment

When building, javac's source and target flags are set to the jdk used, so lower JDKs are not supported at runtime.
The use of both CASSANDRA_USE_JDK11 and use-jdk11 is deprecated.
-->
<property name="java.default" value="11" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure - why do we need this? Default Java version is the version of Java we run the build with

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, it is a placeholder one-stop-place to bump when we start building instead with another version.
We also warn people if they build on their own with different version that it is not a default one we ship with.

<condition><not><contains string="${java.supported}" substring="${ant.java.version}"/></not></condition>
</fail>
<condition property="is.java.default"><equals arg1="${ant.java.version}" arg2="${java.default}"/></condition>
<echo unless:true="${is.java.default}" message="Non default JDK version used: ${ant.java.version}"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really don't need this warning

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is port from OSS where it makes sense because people may build something themselves. In our case it may not be needed that much, but I think it doesn't hurt too. It may be helpful for people experimenting with the codebase to know what is really supported at the moment and where it is on them to experiment without expectations.

Comment on lines +258 to +260
<!-- Below two are used in Cassandra, not in CNDB-->
<!--<string>-XX:MaxTenuringThreshold=1</string>
<string>-XX:G1HeapRegionSize=16m</string>-->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are really just for compilation/running tests, right?

<javac
debug="true" debuglevel="${debuglevel}" encoding="utf-8"
destdir="${build.classes.main}" includeantruntime="false" source="${source.version}" target="${target.version}">
destdir="${build.classes.main}" includeantruntime="false" source="${ant.java.version}" target="${ant.java.version}">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need to explicitly pass it, isn't it the default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but I prefer us to be explicit for things. Makes it easier to reason.

@@ -1483,19 +1517,19 @@
<jvmarg value="-Dcassandra.test.sstableformatdevelopment=true"/>
<!-- The first time SecureRandom initializes can be slow if it blocks on /dev/random -->
<jvmarg value="-Djava.security.egd=file:/dev/urandom" />
<jvmarg value="-Dcassandra.testtag=${tag}"/>
<jvmarg value="-Dcassandra.testtag=${tag}.jdk${ant.java.version}"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't tag it with Java version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do it in a similar way in main-5.0 - https://github.com/datastax/cassandra/blob/main-5.0/build.xml#L1190? I find it helpful as we had troubles in the past when things were running in test with wrong JDKs. This makes it explicitly visible in CI.

<replace file="${eclipse.project.name}.iml" token="JDK_1_8" value="JDK_11"/>
<replace file=".idea/misc.xml" token="JDK_1_8" value="JDK_11"/>
<replace file=".idea/misc.xml" token="1.8" value="11"/>
<target name="_maybe_update_idea_to_java11plus" depends="init" unless="java.version.8">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless is probably not needed - the entire script should fail if we attempt to use 8

<replace file=".idea/misc.xml" token="1.8" value="11"/>
<target name="_maybe_update_idea_to_java11plus" depends="init" unless="java.version.8">
<replace file="${eclipse.project.name}.iml" token="JDK_1_8" value="JDK_${ant.java.version}"/>
<replace file=".idea/misc.xml" token="JDK_1_8" value="JDK_${ant.java.version}"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps the misc.xml should include 11 by default as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean we should update the token in misc.xml? Or anything else?
I was trying to skip the cleaning from CASSANDRA-18255 on main as we already have it in main-5.0 to keep it simple. As less changes we have, the less we can expect missed issues. Let me know if you prefer to clean 8 completely too.

@@ -2205,6 +2238,8 @@

<!-- Generate IDEA project description files -->
<target name="generate-idea-files" depends="init,maven-ant-tasks-init,resolver-dist-lib,gen-cql3-grammar,generate-jflex-java,createVersionPropFile" description="Generate IDEA files">
<delete dir=".idea"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't delete .idea. Whenever you want to just update your project you will lose all your local configuration, like configured tests, etc. Please just delete what we need to replace.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already in 5.0 after discussion on the mailing list - https://lists.apache.org/thread/o2fdkyv2skvf9ngy9jhpnhvo92qvr17m
Do you want to change it in datastax/cassandra all branches? It seems there was consensus.
By the way what config files for testing you have that may be useful and we can actually add for everyone? maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone runs ant generate-idea-files that says to me they want to start from freshly generated files? Otherwise why are you running it?

Copy link
Collaborator Author

@ekaterinadimitrova2 ekaterinadimitrova2 Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We run it when we switch between JDK versions for example. Before this change I had to invalidate caches and restart IDE almost every time...

@ekaterinadimitrova2
Copy link
Collaborator Author

Thank you for the reviews.
@jacek-lewandowski , I pushed a few small commits to address your feedback and I hope I responded to all your questions in comments. Please let me know.
Side note: The jdk22 server.options files mostly mimic what we had for JDK17 with additions for JDK22. Wondering what we want to leave as jvm options (other than add-exports/add-opens which are clear), probably just mimic what we would use in server.options for now? Same as we did in Apache?

@ekaterinadimitrova2 ekaterinadimitrova2 changed the title CNDB-11508: Enable our test config explicitly for JDK22 - WIP branch, NO COMMIT, NO REVIEW NEEDED YET CNDB-11508: Enable our test config explicitly for JDK22 Nov 8, 2024
@ekaterinadimitrova2 ekaterinadimitrova2 changed the title CNDB-11508: Enable our test config explicitly for JDK22 CNDB-11508: Enable our test config explicitly for JDK22 and apply some test fixes Nov 8, 2024
@ekaterinadimitrova2
Copy link
Collaborator Author

CI is in a bad shape today going up and down and I am not being able to really check test results.
I am pushing some review feedback updates to docs and I will move the PRs to draft so they do not trigger useless CI triggers. I will move to another issue I am working on and check back later.

@ekaterinadimitrova2 ekaterinadimitrova2 marked this pull request as draft November 8, 2024 17:12
@ekaterinadimitrova2 ekaterinadimitrova2 marked this pull request as ready for review November 12, 2024 21:18
Copy link

sonarcloud bot commented Nov 12, 2024

@cassci-bot
Copy link

❌ Build ds-cassandra-pr-gate/PR-1398 rejected by Butler


4 new test failure(s) in 3 builds
See build details here


Found 4 new test failures

Test Explanation Branch history Upstream history
...list,wide=false,scenario=MEMTABLE_QUERY] regression 🔴🔵🔵 🔵🔵🔵🔵🔵🔵🔵
...ap<int,int>,wide=false,scenario=MEMTABLE_QUERY] regression 🔴🔵🔵 🔵🔵🔵🔵🔵🔵🔵
o.a.c.i.s.p.PlanTest.testLazyAccessPropagation regression 🔴🔴🔵 🔵🔵🔵🔵🔵🔵🔵
...hUtilsTest.testDeleteQuietlyIgnoresIOExceptions regression 🔴🔴🔵 🔵🔵🔵🔵🔵🔵🔵

Found 13 known test failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants