Skip to content

Commit 8b95c11

Browse files
committed
Use RCD as the test runner, removed husky
1 parent 6080b51 commit 8b95c11

4 files changed

Lines changed: 73 additions & 134 deletions

File tree

.github/workflows/coverage_runner.yml

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
strategy:
4242
matrix:
4343
os: [ ubuntu-latest, windows-latest ]
44-
44+
hz_version: [ "5.6.0" ]
4545
steps:
4646
- name: Checkout code for PR
4747
if: github.event_name == 'pull_request_target'
@@ -72,27 +72,89 @@ jobs:
7272
with:
7373
node-version: ${{ needs.node-versions.outputs.default-version }}
7474

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

0 commit comments

Comments
 (0)