Skip to content

Commit fa12563

Browse files
tjzhang-BQYury-Fridlyandcyip10
authored
Node: Add CI support for server modules (#2472)
* Node: add server modules CI support --------- Signed-off-by: TJ Zhang <tj.zhang@improving.com> Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com> Signed-off-by: Chloe <chloe.yip@improving.com> Co-authored-by: TJ Zhang <tj.zhang@improving.com> Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com> Co-authored-by: Chloe <chloe.yip@improving.com>
1 parent adcc76f commit fa12563

File tree

7 files changed

+131
-24
lines changed

7 files changed

+131
-24
lines changed

.github/workflows/build-node-wrapper/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inputs:
3131
required: true
3232
engine-version:
3333
description: "Engine version to install"
34-
required: true
34+
required: false
3535
type: string
3636
publish:
3737
description: "Enable building the wrapper in release mode"

.github/workflows/install-shared-dependencies/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ inputs:
2222
- aarch64-unknown-linux-musl
2323
- x86_64-unknown-linux-musl
2424
engine-version:
25-
description: "Engine version to install"
26-
required: true
27-
type: string
28-
25+
description: "Engine version to install"
26+
required: false
27+
type: string
2928
github-token:
3029
description: "GITHUB_TOKEN, GitHub App installation access token"
3130
required: true
@@ -72,6 +71,7 @@ runs:
7271
github-token: ${{ inputs.github-token }}
7372

7473
- name: Install Valkey
74+
if: ${{ inputs.engine-version != '' }}
7575
uses: ./.github/workflows/install-valkey
7676
with:
7777
engine-version: ${{ inputs.engine-version }}

.github/workflows/node.yml

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515
- .github/workflows/lint-rust/action.yml
1616
- .github/workflows/install-valkey/action.yml
1717
- .github/json_matrices/build-matrix.json
18+
- .github/workflows/start-self-hosted-runner/action.yml
1819
pull_request:
1920
paths:
2021
- glide-core/src/**
@@ -28,6 +29,7 @@ on:
2829
- .github/workflows/lint-rust/action.yml
2930
- .github/workflows/install-valkey/action.yml
3031
- .github/json_matrices/build-matrix.json
32+
- .github/workflows/start-self-hosted-runner/action.yml
3133
workflow_dispatch:
3234

3335
concurrency:
@@ -39,17 +41,17 @@ env:
3941

4042
jobs:
4143
load-engine-matrix:
42-
runs-on: ubuntu-latest
43-
outputs:
44-
matrix: ${{ steps.load-engine-matrix.outputs.matrix }}
45-
steps:
46-
- name: Checkout
47-
uses: actions/checkout@v4
48-
49-
- name: Load the engine matrix
50-
id: load-engine-matrix
51-
shell: bash
52-
run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT
44+
runs-on: ubuntu-latest
45+
outputs:
46+
matrix: ${{ steps.load-engine-matrix.outputs.matrix }}
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Load the engine matrix
52+
id: load-engine-matrix
53+
shell: bash
54+
run: echo "matrix=$(jq -c . < .github/json_matrices/engine-matrix.json)" >> $GITHUB_OUTPUT
5355

5456
test-ubuntu-latest:
5557
runs-on: ubuntu-latest
@@ -84,18 +86,18 @@ jobs:
8486

8587
- name: test hybrid node modules - commonjs
8688
run: |
87-
npm install --package-lock-only
88-
npm ci
89-
npm run build-and-test
89+
npm install --package-lock-only
90+
npm ci
91+
npm run build-and-test
9092
working-directory: ./node/hybrid-node-tests/commonjs-test
9193
env:
9294
JEST_HTML_REPORTER_OUTPUT_PATH: test-report-commonjs.html
9395

9496
- name: test hybrid node modules - ecma
9597
run: |
96-
npm install --package-lock-only
97-
npm ci
98-
npm run build-and-test
98+
npm install --package-lock-only
99+
npm ci
100+
npm run build-and-test
99101
working-directory: ./node/hybrid-node-tests/ecmascript-test
100102
env:
101103
JEST_HTML_REPORTER_OUTPUT_PATH: test-report-ecma.html
@@ -269,3 +271,45 @@ jobs:
269271
node/test-report*.html
270272
utils/clusters/**
271273
benchmarks/results/**
274+
275+
test-modules:
276+
if: (github.repository_owner == 'valkey-io' && github.event_name == 'workflow_dispatch') || github.event.pull_request.head.repo.owner.login == 'valkey-io'
277+
environment: AWS_ACTIONS
278+
name: Running Module Tests
279+
runs-on: [self-hosted, linux, ARM64]
280+
timeout-minutes: 15
281+
282+
steps:
283+
- name: Setup self-hosted runner access
284+
run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/valkey-glide
285+
286+
- uses: actions/checkout@v4
287+
with:
288+
submodules: recursive
289+
290+
- name: Use Node.js 18.x
291+
uses: actions/setup-node@v4
292+
with:
293+
node-version: 18.x
294+
295+
- name: Build Node wrapper
296+
uses: ./.github/workflows/build-node-wrapper
297+
with:
298+
os: ubuntu
299+
named_os: linux
300+
arch: arm64
301+
target: aarch64-unknown-linux-gnu
302+
github-token: ${{ secrets.GITHUB_TOKEN }}
303+
304+
- name: test
305+
run: npm run test-modules -- --cluster-endpoints=${{ secrets.MEMDB_MODULES_ENDPOINT }} --tls=true
306+
working-directory: ./node
307+
308+
- name: Upload test reports
309+
if: always()
310+
continue-on-error: true
311+
uses: actions/upload-artifact@v4
312+
with:
313+
name: test-report-node-modules-ubuntu
314+
path: |
315+
node/test-report*.html

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#### Operational Enhancements
2121

2222
* Java: Add modules CI ([#2388](https://github.com/valkey-io/valkey-glide/pull/2388), [#2404](https://github.com/valkey-io/valkey-glide/pull/2404), [#2416](https://github.com/valkey-io/valkey-glide/pull/2416))
23+
* Node: Add modules CI ([#2472](https://github.com/valkey-io/valkey-glide/pull/2472))
2324

2425
## 1.1.0 (2024-09-24)
2526

node/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
"build-protobuf": "npm run compile-protobuf-files && npm run fix-protobuf-file",
3232
"compile-protobuf-files": "cd src && pbjs -t static-module -o ProtobufMessage.js ../../glide-core/src/protobuf/*.proto && pbts -o ProtobufMessage.d.ts ProtobufMessage.js",
3333
"fix-protobuf-file": "replace 'this\\.encode\\(message, writer\\)\\.ldelim' 'this.encode(message, writer && writer.len ? writer.fork() : writer).ldelim' src/ProtobufMessage.js",
34-
"test": "npm run build-test-utils && jest --verbose --runInBand --testPathIgnorePatterns='RedisModules'",
34+
"test": "npm run build-test-utils && jest --verbose --runInBand --testPathIgnorePatterns='ServerModules'",
3535
"build-test-utils": "cd ../utils && npm i && npm run build",
3636
"lint:fix": "npm run install-linting && npx eslint -c ../eslint.config.mjs --fix && npm run prettier:format",
3737
"lint": "npm run install-linting && npx eslint -c ../eslint.config.mjs && npm run prettier:check:ci",
3838
"install-linting": "cd ../ & npm install",
3939
"prepack": "npmignore --auto",
4040
"prettier:check:ci": "npx prettier --check . --ignore-unknown '!**/*.{js,d.ts}'",
41-
"prettier:format": "npx prettier --write . --ignore-unknown '!**/*.{js,d.ts}'"
41+
"prettier:format": "npx prettier --write . --ignore-unknown '!**/*.{js,d.ts}'",
42+
"test-modules": "npm run build-test-utils && jest --verbose --runInBand --testNamePattern='ServerModules'"
4243
},
4344
"devDependencies": {
4445
"@jest/globals": "^29.7.0",

node/tests/ServerModules.test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
3+
*/
4+
import {
5+
afterAll,
6+
afterEach,
7+
beforeAll,
8+
describe,
9+
expect,
10+
it,
11+
} from "@jest/globals";
12+
import { GlideClusterClient, InfoOptions, ProtocolVersion } from "..";
13+
import { ValkeyCluster } from "../../utils/TestUtils";
14+
import {
15+
flushAndCloseClient,
16+
getClientConfigurationOption,
17+
getServerVersion,
18+
parseCommandLineArgs,
19+
parseEndpoints,
20+
} from "./TestUtilities";
21+
22+
const TIMEOUT = 50000;
23+
describe("GlideJson", () => {
24+
const testsFailed = 0;
25+
let cluster: ValkeyCluster;
26+
let client: GlideClusterClient;
27+
beforeAll(async () => {
28+
const clusterAddresses = parseCommandLineArgs()["cluster-endpoints"];
29+
cluster = await ValkeyCluster.initFromExistingCluster(
30+
true,
31+
parseEndpoints(clusterAddresses),
32+
getServerVersion,
33+
);
34+
}, 20000);
35+
36+
afterEach(async () => {
37+
await flushAndCloseClient(true, cluster.getAddresses(), client);
38+
});
39+
40+
afterAll(async () => {
41+
if (testsFailed === 0) {
42+
await cluster.close();
43+
}
44+
}, TIMEOUT);
45+
46+
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
47+
"ServerModules check modules loaded",
48+
async (protocol) => {
49+
client = await GlideClusterClient.createClient(
50+
getClientConfigurationOption(cluster.getAddresses(), protocol),
51+
);
52+
const info = await client.info({
53+
sections: [InfoOptions.Modules],
54+
route: "randomNode",
55+
});
56+
expect(info).toContain("# json_core_metrics");
57+
expect(info).toContain("# search_index_stats");
58+
},
59+
);
60+
});

node/tests/TestUtilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ export const getClientConfigurationOption = (
387387
port,
388388
})),
389389
protocol,
390+
useTLS: parseCommandLineArgs()["tls"] == "true",
390391
...configOverrides,
391392
};
392393
};

0 commit comments

Comments
 (0)