Skip to content

Commit 2806414

Browse files
authored
Use RCD as the test runner (#1569)
The RC runner for Nodejs needs to be updated to download test artifacts. Instead of that, RCD can be used to to start the RC. * Use RCD as the test runner * Remove husky precommit hook
1 parent c641a1e commit 2806414

6 files changed

Lines changed: 72 additions & 215 deletions

File tree

.github/workflows/coverage_runner.yml

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
matrix:
4545
os: [ ubuntu-latest, windows-latest ]
46-
46+
hz_version: [ "5.6.0" ]
4747
steps:
4848
- name: Checkout code for PR
4949
if: github.event_name == 'pull_request_target'
@@ -74,27 +74,89 @@ jobs:
7474
with:
7575
node-version: ${{ needs.node-versions.outputs.default-version }}
7676

77-
- name: Checkout to test artifacts
77+
- name: Configure AWS Credentials
78+
uses: aws-actions/configure-aws-credentials@v5
79+
with:
80+
role-to-assume: ${{ secrets.AWS_HAZELCAST_OIDC_GITHUB_ACTIONS_ROLE_ARN }}
81+
aws-region: 'us-east-1'
82+
83+
- name: Get Secrets
84+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
85+
with:
86+
secret-ids: |
87+
HAZELCAST_ENTERPRISE_KEY,CN/HZ_LICENSE_KEY
88+
89+
- name: Checkout to certificates
7890
uses: actions/checkout@v4
7991
with:
80-
repository: hazelcast/private-test-artifacts
81-
path: certs
82-
ref: data
83-
token: ${{ secrets.GH_TOKEN }}
92+
repository: hazelcast/private-test-artifacts
93+
path: certs
94+
ref: data
95+
token: ${{ secrets.GH_TOKEN }}
96+
8497
- name: Copy certificates JAR to destination with the appropriate name
8598
run: |
8699
cp ${{ github.workspace }}/certs/certs.jar ${{ github.workspace }}/certs.jar
87100
unzip -p ${{ github.workspace }}/certs.jar com/hazelcast/nio/ssl/letsencrypt.jks > test/integration/backward_compatible/parallel/ssl/keystore.jks
88101
102+
- name: Create the test jar with certificates (Linux)
103+
if: matrix.os == 'ubuntu-latest'
104+
working-directory: certs
105+
run: |
106+
zip -r -j certs.jar $GITHUB_WORKSPACE/test/integration/backward_compatible/parallel/ssl/*.pem
107+
cp certs.jar ../hazelcast-enterprise-${{ matrix.hz_version }}-tests.jar
108+
109+
- name: Create the test jar with certificates (Windows)
110+
if: matrix.os == 'windows-latest'
111+
working-directory: certs
112+
run: |
113+
$compress = @{
114+
Path = "../test/integration/backward_compatible/parallel/ssl/*.pem"
115+
CompressionLevel = "Fastest"
116+
DestinationPath = "certs.jar"
117+
}
118+
Compress-Archive -Update @compress
119+
cp certs.jar ../hazelcast-enterprise-${{ matrix.hz_version }}-tests.jar
120+
121+
- name: Download RCD (Linux)
122+
if: matrix.os == 'ubuntu-latest'
123+
shell: bash
124+
run: |
125+
wget -q https://client-rcd-download.s3.us-east-2.amazonaws.com/rcd-ubuntu-latest
126+
127+
- name: Download RCD (Windows)
128+
if: matrix.os == 'windows-latest'
129+
run: |
130+
$ProgressPreference = 'SilentlyContinue'
131+
Invoke-WebRequest https://client-rcd-download.s3.us-east-2.amazonaws.com/rcd-windows-latest.exe -OutFile rcd-windows-latest.exe
132+
89133
- name: Install dependencies and compile client
90134
run: |
91135
npm install
92136
npm run compile
93137
94-
- name: Run all tests
138+
- name: Run all tests (Linux)
139+
if: matrix.os == 'ubuntu-latest'
140+
env:
141+
HZ_VERSION: ${{ matrix.hz_version }}
142+
run: |
143+
chmod +x rcd-ubuntu-latest
144+
./rcd-ubuntu-latest -version $HZ_VERSION -no-simple-server &
145+
# wait for a bit for RCD to download artifacts
146+
sleep 10
147+
npm run coverage
148+
149+
- name: Run all tests (Windows)
150+
if: matrix.os == 'windows-latest'
95151
env:
96-
HAZELCAST_ENTERPRISE_KEY: ${{ secrets.HAZELCAST_ENTERPRISE_KEY }}
152+
HZ_VERSION: ${{ matrix.hz_version }}
97153
run: |
154+
Start-Process -FilePath .\rcd-windows-latest -ArgumentList '-version', $Env:HZ_VERSION, '-no-simple-server' -RedirectStandardOutput rcd-stdout.log -RedirectStandardError rcd-stderr.log
155+
# wait for a bit for RCD to download artifacts
156+
sleep 10
157+
echo "RCD Log:"
158+
cat rcd-stdout.log
159+
cat rcd-stderr.log
98160
npm run coverage
99161
100162
- name: Publish results to Codecov for PR coming from hazelcast organization
@@ -122,12 +184,3 @@ jobs:
122184
files: coverage/lcov.info
123185
override_pr: ${{ github.event.inputs.pr_number }}
124186
fail_ci_if_error: true
125-
126-
- name: Upload remote controller logs if test run fails
127-
uses: actions/upload-artifact@v4
128-
if: failure()
129-
with:
130-
name: rc-logs-${{ matrix.os }}
131-
path: |
132-
rc_stderr.log
133-
rc_stdout.log

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/pre-commit

Lines changed: 0 additions & 9 deletions
This file was deleted.

scripts/download-rc.js

Lines changed: 0 additions & 82 deletions
This file was deleted.

scripts/test-runner.js

Lines changed: 2 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
'use strict';
22
const fs = require('fs');
33
const os = require('os');
4-
const net = require('net');
54
const {spawnSync, spawn} = require('child_process');
65
const codeSampleChecker = require('./code-sample-checker');
76

8-
const {
9-
HAZELCAST_RC_VERSION,
10-
HAZELCAST_TEST_VERSION,
11-
HAZELCAST_ENTERPRISE_VERSION,
12-
HAZELCAST_VERSION,
13-
downloadRC
14-
} = require('./download-rc.js');
15-
167
const DEV_CLUSTER_CONFIG = `
178
<hazelcast xmlns="http://www.hazelcast.com/schema/config"
189
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -23,8 +14,6 @@ const DEV_CLUSTER_CONFIG = `
2314
</hazelcast>
2415
`;
2516
const ON_WINDOWS = os.platform() === 'win32';
26-
const HAZELCAST_ENTERPRISE_KEY = process.env.HAZELCAST_ENTERPRISE_KEY ? process.env.HAZELCAST_ENTERPRISE_KEY : '';
27-
const PATH_SEPARATOR = ON_WINDOWS ? ';' : ':';
2817

2918
let cluster; // We create a cluster for checking code samples
3019

@@ -33,97 +22,12 @@ let testType;
3322
let rcProcess;
3423
let testProcess;
3524
let runTests = true;
36-
let CLASSPATH = `hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar${PATH_SEPARATOR}`
37-
+ `hazelcast-${HAZELCAST_TEST_VERSION}-tests.jar${PATH_SEPARATOR}`
38-
+ `hazelcast-sql-${HAZELCAST_VERSION}.jar${PATH_SEPARATOR}`;
39-
40-
if (HAZELCAST_ENTERPRISE_KEY) {
41-
CLASSPATH = `hazelcast-enterprise-${HAZELCAST_ENTERPRISE_VERSION}.jar${PATH_SEPARATOR}`
42-
+ `certs.jar${PATH_SEPARATOR}`
43-
+ CLASSPATH;
44-
} else {
45-
CLASSPATH = `hazelcast-${HAZELCAST_VERSION}.jar${PATH_SEPARATOR}${CLASSPATH}`;
46-
}
47-
48-
const isAddressReachable = (host, port, timeoutMs) => {
49-
return new Promise((resolve) => {
50-
const socket = new net.Socket();
51-
socket.setTimeout(timeoutMs);
52-
const onError = () => {
53-
socket.destroy();
54-
resolve(false);
55-
};
56-
socket.once('error', onError);
57-
socket.once('timeout', onError);
58-
socket.connect(port, host, () => {
59-
socket.end();
60-
resolve(true);
61-
});
62-
});
63-
};
6425

6526
// Import lazily to defer side affect of the import (connection attempt to 9701)
6627
const getRC = () => {
6728
return require('../test/integration/RC');
6829
};
6930

70-
const startRC = async () => {
71-
console.log('Starting Hazelcast Remote Controller ...');
72-
if (ON_WINDOWS) {
73-
const outFD = fs.openSync('rc_stdout.log', 'w');
74-
const errFD = fs.openSync('rc_stderr.log', 'w');
75-
rcProcess = spawn('java', [
76-
`-Dhazelcast.enterprise.license.key=${HAZELCAST_ENTERPRISE_KEY}`,
77-
'-cp',
78-
CLASSPATH,
79-
'com.hazelcast.remotecontroller.Main'
80-
], {
81-
stdio: [
82-
'ignore',
83-
outFD,
84-
errFD
85-
]
86-
});
87-
rcProcess.on('close', () => {
88-
fs.closeSync(outFD);
89-
fs.closeSync(errFD);
90-
});
91-
} else {
92-
const outFD = fs.openSync('rc_stdout.log', 'w');
93-
const errFD = fs.openSync('rc_stderr.log', 'w');
94-
rcProcess = spawn('java', [
95-
`-Dhazelcast.enterprise.license.key=${HAZELCAST_ENTERPRISE_KEY}`,
96-
'-cp',
97-
CLASSPATH,
98-
'com.hazelcast.remotecontroller.Main'
99-
], {
100-
stdio: [
101-
'ignore',
102-
outFD,
103-
errFD
104-
]
105-
});
106-
rcProcess.on('close', () => {
107-
fs.closeSync(outFD);
108-
fs.closeSync(errFD);
109-
});
110-
}
111-
112-
console.log('Please wait for Hazelcast Remote Controller to start ...');
113-
114-
const retryCount = 100;
115-
116-
for (let i = 0; i < retryCount; i++) {
117-
console.log('Trying to connect to Hazelcast Remote Controller (127.0.0.1:9701)...');
118-
const addressReachable = await isAddressReachable('127.0.0.1', 9701, 5000);
119-
if (addressReachable) {
120-
return;
121-
}
122-
await new Promise(r => setTimeout(r, 1000));
123-
}
124-
throw `Could not reach to Hazelcast Remote Controller (127.0.0.1:9701) after trying ${retryCount} times.`;
125-
};
126-
12731
const shutdown = async () => {
12832
if (testProcess && testProcess.exitCode === null) {
12933
stopTestProcess();
@@ -229,19 +133,11 @@ if (testType === 'unit') {
229133
process.exit(subprocess.status);
230134
}
231135

232-
// For other tests, download rc files if needed.
233-
try {
234-
downloadRC();
235-
} catch (err) {
236-
console.log('An error occurred downloading remote controller:');
237-
throw err;
238-
}
239-
240136
process.on('SIGINT', shutdown);
241137
process.on('SIGTERM', shutdown);
242138
process.on('SIGHUP', shutdown);
243139

244-
startRC().then(async () => {
140+
(async () => {
245141
console.log('Hazelcast Remote Controller is started!');
246142
if (runTests) {
247143
console.log(`Running ${testType}, Command: ${testCommand}`);
@@ -265,7 +161,7 @@ startRC().then(async () => {
265161
process.exit(exitCode);
266162
}
267163
}
268-
}).catch(err => {
164+
})().catch(err => {
269165
console.log('Could not start Hazelcast Remote Controller due to an error:');
270166
throw err;
271167
});
155 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)