diff --git a/.github/workflows/coverage_runner.yml b/.github/workflows/coverage_runner.yml index 3bbbfe8c0..b8fe5feff 100644 --- a/.github/workflows/coverage_runner.yml +++ b/.github/workflows/coverage_runner.yml @@ -43,7 +43,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, windows-latest ] - + hz_version: [ "5.6.0" ] steps: - name: Checkout code for PR if: github.event_name == 'pull_request_target' @@ -74,27 +74,89 @@ jobs: with: node-version: ${{ needs.node-versions.outputs.default-version }} - - name: Checkout to test artifacts + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v5 + with: + role-to-assume: ${{ secrets.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }} + aws-region: 'us-east-1' + + - name: Get Secrets + uses: aws-actions/aws-secretsmanager-get-secrets@v2 + with: + secret-ids: | + HAZELCAST_ENTERPRISE_KEY,CN/HZ_LICENSE_KEY + + - name: Checkout to certificates uses: actions/checkout@v4 with: - repository: hazelcast/private-test-artifacts - path: certs - ref: data - token: ${{ secrets.GH_TOKEN }} + repository: hazelcast/private-test-artifacts + path: certs + ref: data + token: ${{ secrets.GH_TOKEN }} + - name: Copy certificates JAR to destination with the appropriate name run: | cp ${{ github.workspace }}/certs/certs.jar ${{ github.workspace }}/certs.jar unzip -p ${{ github.workspace }}/certs.jar com/hazelcast/nio/ssl/letsencrypt.jks > test/integration/backward_compatible/parallel/ssl/keystore.jks + - name: Create the test jar with certificates (Linux) + if: matrix.os == 'ubuntu-latest' + working-directory: certs + run: | + zip -r -j certs.jar $GITHUB_WORKSPACE/test/integration/backward_compatible/parallel/ssl/*.pem + cp certs.jar ../hazelcast-enterprise-${{ matrix.hz_version }}-tests.jar + + - name: Create the test jar with certificates (Windows) + if: matrix.os == 'windows-latest' + working-directory: certs + run: | + $compress = @{ + Path = "../test/integration/backward_compatible/parallel/ssl/*.pem" + CompressionLevel = "Fastest" + DestinationPath = "certs.jar" + } + Compress-Archive -Update @compress + cp certs.jar ../hazelcast-enterprise-${{ matrix.hz_version }}-tests.jar + + - name: Download RCD (Linux) + if: matrix.os == 'ubuntu-latest' + shell: bash + run: | + wget -q https://client-rcd-download.s3.us-east-2.amazonaws.com/rcd-ubuntu-latest + + - name: Download RCD (Windows) + if: matrix.os == 'windows-latest' + run: | + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest https://client-rcd-download.s3.us-east-2.amazonaws.com/rcd-windows-latest.exe -OutFile rcd-windows-latest.exe + - name: Install dependencies and compile client run: | npm install npm run compile - - name: Run all tests + - name: Run all tests (Linux) + if: matrix.os == 'ubuntu-latest' + env: + HZ_VERSION: ${{ matrix.hz_version }} + run: | + chmod +x rcd-ubuntu-latest + ./rcd-ubuntu-latest -version $HZ_VERSION -no-simple-server & + # wait for a bit for RCD to download artifacts + sleep 10 + npm run coverage + + - name: Run all tests (Windows) + if: matrix.os == 'windows-latest' env: - HAZELCAST_ENTERPRISE_KEY: ${{ secrets.HAZELCAST_ENTERPRISE_KEY }} + HZ_VERSION: ${{ matrix.hz_version }} run: | + Start-Process -FilePath .\rcd-windows-latest -ArgumentList '-version', $Env:HZ_VERSION, '-no-simple-server' -RedirectStandardOutput rcd-stdout.log -RedirectStandardError rcd-stderr.log + # wait for a bit for RCD to download artifacts + sleep 10 + echo "RCD Log:" + cat rcd-stdout.log + cat rcd-stderr.log npm run coverage - name: Publish results to Codecov for PR coming from hazelcast organization @@ -122,12 +184,3 @@ jobs: files: coverage/lcov.info override_pr: ${{ github.event.inputs.pr_number }} fail_ci_if_error: true - - - name: Upload remote controller logs if test run fails - uses: actions/upload-artifact@v4 - if: failure() - with: - name: rc-logs-${{ matrix.os }} - path: | - rc_stderr.log - rc_stdout.log diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index 31354ec13..000000000 --- a/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index 357da4b9c..000000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -# See https://github.com/typicode/husky/issues/1072#issuecomment-1784006332 -npm_exec=$([[ $OS == "Windows_NT" ]] && echo "npm.cmd" || echo "npm") - -"${npm_exec}" run compile -"${npm_exec}" run lint -"${npm_exec}" run validate-user-code diff --git a/scripts/download-rc.js b/scripts/download-rc.js deleted file mode 100644 index 1ace79e1c..000000000 --- a/scripts/download-rc.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; -const HZ_VERSION = '5.4.0'; -const HZ_TEST_VERSION = '5.4.0'; -const HAZELCAST_TEST_VERSION = HZ_TEST_VERSION; -const HAZELCAST_VERSION = HZ_VERSION; -const HAZELCAST_ENTERPRISE_VERSION = HZ_VERSION; -const HAZELCAST_RC_VERSION = '0.8-SNAPSHOT'; -const SNAPSHOT_REPO = 'https://oss.sonatype.org/content/repositories/snapshots'; -const RELEASE_REPO = 'https://repo.maven.apache.org/maven2'; -const ENTERPRISE_RELEASE_REPO = 'https://repository.hazelcast.com/release/'; -const ENTERPRISE_SNAPSHOT_REPO = 'https://repository.hazelcast.com/snapshot/'; - -const downloadRC = () => { - const fs = require('fs'); - const os = require('os'); - const {spawnSync} = require('child_process'); - - let REPO; - let ENTERPRISE_REPO; - let TEST_REPO; - - if (HZ_VERSION.endsWith('-SNAPSHOT')) { - REPO = SNAPSHOT_REPO; - ENTERPRISE_REPO = ENTERPRISE_SNAPSHOT_REPO; - } else { - REPO = RELEASE_REPO; - ENTERPRISE_REPO = ENTERPRISE_RELEASE_REPO; - } - - if (HZ_TEST_VERSION.endsWith('-SNAPSHOT')) { - TEST_REPO = SNAPSHOT_REPO; - } else { - TEST_REPO = RELEASE_REPO; - } - - downloadArtifact(ENTERPRISE_SNAPSHOT_REPO, 'hazelcast-remote-controller', HAZELCAST_RC_VERSION); - downloadArtifact(TEST_REPO, 'hazelcast', HAZELCAST_TEST_VERSION, 'tests'); - downloadArtifact(REPO, 'hazelcast-sql', HAZELCAST_VERSION); - - if (process.env.HAZELCAST_ENTERPRISE_KEY) { - downloadArtifact(ENTERPRISE_REPO, 'hazelcast-enterprise', HAZELCAST_ENTERPRISE_VERSION); - } else { - downloadArtifact(REPO, 'hazelcast', HAZELCAST_VERSION); - } - - function downloadArtifact(repo, artifactId, version, classifier = '') { - const filename = classifier ? `${artifactId}-${version}-${classifier}.jar` : `${artifactId}-${version}.jar`; - let artifact = `com.hazelcast:${artifactId}:${version}:jar`; - if (classifier) { - artifact += `:${classifier}`; - } - - if (fs.existsSync(filename)) { - console.log('${filename} already exists, download not required'); - } else { - console.log(`Downloading: ${artifact} to ${filename}`); - const subprocess = spawnSync('mvn', [ - '-q', - 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get', - '-Dtransitive=false', - `-DremoteRepositories=${repo}`, - `-Dartifact=${artifact}`, - `-Ddest=${filename}` - ], { - stdio: 'inherit', - shell: os.platform() === 'win32' - }); - if (subprocess.status !== 0) { - const subprocessTrace = subprocess.error ? subprocess.error.stack : ''; - throw `Failed to download ${artifact} to ${filename} - ${subprocessTrace}`; - } - } - } -}; - -module.exports = { - HAZELCAST_VERSION: HAZELCAST_VERSION, - HAZELCAST_TEST_VERSION: HAZELCAST_TEST_VERSION, - HAZELCAST_ENTERPRISE_VERSION: HAZELCAST_ENTERPRISE_VERSION, - HAZELCAST_RC_VERSION: HAZELCAST_RC_VERSION, - downloadRC: downloadRC -}; diff --git a/scripts/test-runner.js b/scripts/test-runner.js index 8a30c0032..5a12f0190 100644 --- a/scripts/test-runner.js +++ b/scripts/test-runner.js @@ -1,18 +1,9 @@ 'use strict'; const fs = require('fs'); const os = require('os'); -const net = require('net'); const {spawnSync, spawn} = require('child_process'); const codeSampleChecker = require('./code-sample-checker'); -const { - HAZELCAST_RC_VERSION, - HAZELCAST_TEST_VERSION, - HAZELCAST_ENTERPRISE_VERSION, - HAZELCAST_VERSION, - downloadRC -} = require('./download-rc.js'); - const DEV_CLUSTER_CONFIG = ` `; const ON_WINDOWS = os.platform() === 'win32'; -const HAZELCAST_ENTERPRISE_KEY = process.env.HAZELCAST_ENTERPRISE_KEY ? process.env.HAZELCAST_ENTERPRISE_KEY : ''; -const PATH_SEPARATOR = ON_WINDOWS ? ';' : ':'; let cluster; // We create a cluster for checking code samples @@ -33,97 +22,12 @@ let testType; let rcProcess; let testProcess; let runTests = true; -let CLASSPATH = `hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar${PATH_SEPARATOR}` - + `hazelcast-${HAZELCAST_TEST_VERSION}-tests.jar${PATH_SEPARATOR}` - + `hazelcast-sql-${HAZELCAST_VERSION}.jar${PATH_SEPARATOR}`; - -if (HAZELCAST_ENTERPRISE_KEY) { - CLASSPATH = `hazelcast-enterprise-${HAZELCAST_ENTERPRISE_VERSION}.jar${PATH_SEPARATOR}` - + `certs.jar${PATH_SEPARATOR}` - + CLASSPATH; -} else { - CLASSPATH = `hazelcast-${HAZELCAST_VERSION}.jar${PATH_SEPARATOR}${CLASSPATH}`; -} - -const isAddressReachable = (host, port, timeoutMs) => { - return new Promise((resolve) => { - const socket = new net.Socket(); - socket.setTimeout(timeoutMs); - const onError = () => { - socket.destroy(); - resolve(false); - }; - socket.once('error', onError); - socket.once('timeout', onError); - socket.connect(port, host, () => { - socket.end(); - resolve(true); - }); - }); -}; // Import lazily to defer side affect of the import (connection attempt to 9701) const getRC = () => { return require('../test/integration/RC'); }; -const startRC = async () => { - console.log('Starting Hazelcast Remote Controller ...'); - if (ON_WINDOWS) { - const outFD = fs.openSync('rc_stdout.log', 'w'); - const errFD = fs.openSync('rc_stderr.log', 'w'); - rcProcess = spawn('java', [ - `-Dhazelcast.enterprise.license.key=${HAZELCAST_ENTERPRISE_KEY}`, - '-cp', - CLASSPATH, - 'com.hazelcast.remotecontroller.Main' - ], { - stdio: [ - 'ignore', - outFD, - errFD - ] - }); - rcProcess.on('close', () => { - fs.closeSync(outFD); - fs.closeSync(errFD); - }); - } else { - const outFD = fs.openSync('rc_stdout.log', 'w'); - const errFD = fs.openSync('rc_stderr.log', 'w'); - rcProcess = spawn('java', [ - `-Dhazelcast.enterprise.license.key=${HAZELCAST_ENTERPRISE_KEY}`, - '-cp', - CLASSPATH, - 'com.hazelcast.remotecontroller.Main' - ], { - stdio: [ - 'ignore', - outFD, - errFD - ] - }); - rcProcess.on('close', () => { - fs.closeSync(outFD); - fs.closeSync(errFD); - }); - } - - console.log('Please wait for Hazelcast Remote Controller to start ...'); - - const retryCount = 100; - - for (let i = 0; i < retryCount; i++) { - console.log('Trying to connect to Hazelcast Remote Controller (127.0.0.1:9701)...'); - const addressReachable = await isAddressReachable('127.0.0.1', 9701, 5000); - if (addressReachable) { - return; - } - await new Promise(r => setTimeout(r, 1000)); - } - throw `Could not reach to Hazelcast Remote Controller (127.0.0.1:9701) after trying ${retryCount} times.`; -}; - const shutdown = async () => { if (testProcess && testProcess.exitCode === null) { stopTestProcess(); @@ -229,19 +133,11 @@ if (testType === 'unit') { process.exit(subprocess.status); } -// For other tests, download rc files if needed. -try { - downloadRC(); -} catch (err) { - console.log('An error occurred downloading remote controller:'); - throw err; -} - process.on('SIGINT', shutdown); process.on('SIGTERM', shutdown); process.on('SIGHUP', shutdown); -startRC().then(async () => { +(async () => { console.log('Hazelcast Remote Controller is started!'); if (runTests) { console.log(`Running ${testType}, Command: ${testCommand}`); @@ -265,7 +161,7 @@ startRC().then(async () => { process.exit(exitCode); } } -}).catch(err => { +})().catch(err => { console.log('Could not start Hazelcast Remote Controller due to an error:'); throw err; }); diff --git a/test/integration/backward_compatible/parallel/ssl/keystore.jks b/test/integration/backward_compatible/parallel/ssl/keystore.jks index b5d9abc65..44a1f1155 100644 Binary files a/test/integration/backward_compatible/parallel/ssl/keystore.jks and b/test/integration/backward_compatible/parallel/ssl/keystore.jks differ