Skip to content
Open
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
139 changes: 139 additions & 0 deletions .github/actions/setup-ccm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Set up CCM for integration tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing the ASF license header.

description: >
Install ccm and its Python toolchain, the Zulu JDKs Cassandra needs,
SSL certificates, Simulacron, and pre-download the Cassandra distribution.

inputs:
server-version:
description: 'Cassandra minor version (e.g. "4.1"); resolved to the latest patch release.'
required: true

runs:
using: composite
steps:
# ---- Python for ccm ----
- name: Set up Python 3.15.2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is another diff from the Node.js driver - installing python 3.9 started to fail on default github action runners because the default one is updated to Ubuntu 26.04, and python 3.9 is EOL.
so, the python version is updated to 3.15, and the below

python -m pip install --upgrade pip setuptools
pip install .

I will update the Node.js driver CI on this changes, too.

uses: actions/setup-python@v5
with:
python-version: "3.15.2"

- name: Install ccm
shell: bash
run: |
python -m pip install --upgrade pip setuptools
git clone --depth 1 --single-branch -b cassandra-test https://github.com/apache/cassandra-ccm.git
cd cassandra-ccm
pip install -r requirements.txt
pip install .

# ---- Install required Zulu JDKs (8/11/17) and capture their homes ----
- name: Install Zulu 11
id: z11
uses: actions/setup-java@v5
with:
distribution: zulu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any specific reason to go with Zulu? The docs CI uses temurin, which seems a more common choice.

java-version: "11"

- name: Install Zulu 17
id: z17
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: "17"

- name: Install Zulu 8
id: z8
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: "8"

- name: Export JAVA*_HOME variables
shell: bash
run: |
echo "JAVA8_HOME=${{ steps.z8.outputs.path }}" >> "$GITHUB_ENV"
echo "JAVA11_HOME=${{ steps.z11.outputs.path }}" >> "$GITHUB_ENV"
echo "JAVA17_HOME=${{ steps.z17.outputs.path }}" >> "$GITHUB_ENV"
echo "JAVA_HOME=${{ steps.z8.outputs.path }}" >> "$GITHUB_ENV"
echo "CCM_UPDATE_PID_DEFAULT_TIMEOUT=120" >> "$GITHUB_ENV"
# "-" tells bin/cassandra not to use jemalloc, skipping its unbounded `find` over the
# library dirs, which can exceed the pid timeout on a cold cache under parallel tests.
echo "CASSANDRA_LIBJEMALLOC=-" >> "$GITHUB_ENV"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This line is prolly the only essential difference from the Node.js driver's GHA. AI found it out this is the reason why sometimes the first integration test likes to fail with cassandra pid not found.
It makes sense to me. I think I will port this change to Node.js driver's GHA, too.


- name: Generate SSL certificates
shell: bash
run: |
mkdir -p /home/runner/workspace/tools/ccm/ssl/
cd /home/runner/workspace/tools/ccm/ssl/
keytool -genkey \
-keyalg RSA \
-alias cassandra \
-keystore keystore.jks \
-storepass cassandra \
-keypass cassandra \
-validity 364635 \
-dname "CN=Jane He, OU=TE, O=ASF, L=Santa Clara, ST=CA, C=TE"
keytool -export \
-alias cassandra \
-file cassandra.crt \
-keystore keystore.jks \
-storepass cassandra
openssl x509 \
-inform der \
-in cassandra.crt \
-out cassandra.pem
keytool -genkeypair \
-keyalg RSA \
-alias client \
-keystore truststore.jks \
-storepass cassandra \
-keypass cassandra \
-validity 364635 \
-dname "CN=Philip Thompson, OU=TE, O=DataStax, L=Santa Clara, ST=CA, C=TE"
keytool -importkeystore \
-srckeystore truststore.jks \
-destkeystore client.p12 \
-srcstorepass cassandra \
-deststorepass cassandra \
-deststoretype PKCS12
openssl pkcs12 \
-in client.p12 \
-passin pass:cassandra \
-nokeys \
-out client_cert.pem -legacy
openssl pkcs12 \
-in client.p12 \
-passin pass:cassandra \
-nodes \
-nocerts \
-out client_key.pem -legacy

- name: Install Simulacron
shell: bash
run: |
wget https://github.com/datastax/simulacron/releases/download/0.12.0/simulacron-standalone-0.12.0.jar -O /home/runner/simulacron.jar

- name: Resolve Cassandra latest patch version
shell: bash
env:
SERVER_VERSION: ${{ inputs.server-version }}
run: |
PATCH_SERVER_VERSION=$(
curl -s https://downloads.apache.org/cassandra/ \
| grep -oP '(?<=href=")[0-9]+\.[0-9]+\.[0-9]+(?=)' \
| sort -rV \
| uniq -w 3 \
| grep "^${SERVER_VERSION}\."
)
echo "Resolved Cassandra ${SERVER_VERSION}.x -> ${PATCH_SERVER_VERSION}"
echo "CCM_VERSION=$PATCH_SERVER_VERSION" >> "$GITHUB_ENV"

- name: Print environment
shell: bash
run: printenv | sort
Comment on lines +131 to +133

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can print sensitive data. Do we need it?


- name: Pre-download Cassandra distribution
shell: bash
run: |
ccm create predownload -v $CCM_VERSION
ccm remove
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

name: Unit and Integration Tests

on:
push:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: restrict to pushes to main branches only:

Suggested change
push:
push:
branches:
- trunk # default branch; adjust if it's named differently
- '[0-9]*.x' # release branches: 3.x, 4.x, 4.5.x, ...

pull_request:
workflow_dispatch: # allow manual trigger from the Actions page
Comment on lines +22 to +25

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean, I guess...

The only thing scheduled builds are going to do for us are pick up variation in the patch version of a given Cassandra major/minor tree. Same is true for ccm, right, and ccm changes even less frequently. I guess I don't mind scheduled builds but it seems like the benefit here would be pretty small.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added cron.
As for other branches, I think we can get this PR merged first, and we will see whether it works well, then we can talk about migrating other branches from Jenkins to GHA, too.

schedule:
# Saturday 23:00 PST / Sunday 00:00 PDT; cron is in UTC and runs on the default branch only
- cron: "0 7 * * 0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems that on Jenkins, a weekly job would run on every release branch. Here, we are losing that (this cron applies only to the main branch, afaik). To recover the ability to run CI weekly on all release branches, we'd need a separate workflow.


permissions:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: add a concurrency section to limit the number of concurrent runs, since the matrix is quite large:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

contents: read
actions: read
checks: write

jobs:
unit-integration-tests:
name: Unit and Integration Tests (JDK ${{ matrix.TEST_JAVA_VERSION }}, C* ${{ matrix.SERVER_VERSION }})
runs-on: ubuntu-latest
strategy:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: add a hard timeout:

timeout-minutes: 120

fail-fast: false
matrix:
TEST_JAVA_VERSION: ["17", "21"]
SERVER_VERSION: ["3.11", "4.0", "4.1", "5.0"] # Cassandra minor versions

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up CCM
uses: ./.github/actions/setup-ccm
with:
server-version: ${{ matrix.SERVER_VERSION }}

- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 17
cache: maven

- name: Build (skip tests)
run: mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true

- name: Set up JDK ${{ matrix.TEST_JAVA_VERSION }}
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: ${{ matrix.TEST_JAVA_VERSION }}
cache: maven

- name: Run unit and integration tests
run: |
mvn -B -V verify -T 1 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The old invocation was:

mvn -B -V verify -T 1 -Ptest-jdk-${TEST_JAVA_MAJOR_VERSION} -DtestJavaHome=$(jabba which ${TEST_JAVA_VERSION}) -Dccm.version=${PATCH_SERVER_VERSION} -Dccm.dse=false -Dmaven.test.failure.ignore=true -Dmaven.javadoc.skip=true

It seems we are missing -Ptest-jdk-${TEST_JAVA_MAJOR_VERSION} is that intentional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, have we explored the option of using more threads? -T 1 is the slowest option (but also the safest).

-DtestJavaHome="$JAVA_HOME" \
-Dccm.version="$CCM_VERSION" \
-Dccm.dse=false \
-Dmaven.test.failure.ignore=true \
-Dmaven.javadoc.skip=true

- name: Check test results
run: |
failed=$(find . -path '*/target/*-reports/TEST-*.xml' \
-exec grep -lE '<testsuite[^>]* (failures|errors)="[1-9]' {} + || true)
if [ -n "$failed" ]; then
echo "Test failures or errors in:"
echo "$failed"
exit 1
fi

- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: it-results-jdk${{ matrix.TEST_JAVA_VERSION }}-cassandra${{ matrix.SERVER_VERSION }}
path: |
**/target/surefire-reports/TEST-*.xml
**/target/failsafe-reports/TEST-*.xml
**/hs_err_pid*.log
if-no-files-found: ignore

publish-test-results:
name: Publish test results
needs: [unit-integration-tests]
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
if: ${{ !cancelled() }}

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I double-checked that this action is allow-listed by the ASF, and it is. That said, it would be safer to pin it to a specific commit SHA rather than a tag.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, I wonder if this action will fail when executed from a forked repo, because of the required privileges: checks: write pull-requests: write. I haven't confirmed this though.

If that proves correct, it could be solved by switching off checks and comments and keeping only the summary:

- uses: EnricoMi/publish-unit-test-result-action@v2
  with:
    files: artifacts/**/TEST-*.xml
    comment_mode: off
    check_run: false

... in which case, we don't need checks: write pull-requests: write.

with:
files: artifacts/**/TEST-*.xml
Comment thread
SiyaoIsHiding marked this conversation as resolved.
Resolved
6 changes: 3 additions & 3 deletions .github/workflows/publish-docs-gp-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
with:
path: java-driver

# 2. Java 8
- name: Set up Java 8
# 2. Java 17
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "8"
java-version: "17"
cache: maven

# 3. Python 3.10.19 + MkDocs + plugins
Expand Down
85 changes: 0 additions & 85 deletions Jenkinsfile-asf

This file was deleted.

Loading
Loading