Skip to content

Commit cb2d5ac

Browse files
CopilotYunchuWang
andauthored
Set up E2E testing infrastructure aligned with durabletask-python (#74)
* Testing pipeline setup Co-Authored-By: YunchuWang <12449837+YunchuWang@users.noreply.github.com> * add ver 24 * module mapping * skip * cleanup * jest test path adjust * fix import * fix test * fix * fix insecure * refactor * fix callback in tests * linting fix --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
1 parent 4540ced commit cb2d5ac

File tree

19 files changed

+744
-228
lines changed

19 files changed

+744
-228
lines changed

.eslintignore

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# don't ever lint node_modules
2-
node_modules
3-
# don't lint build output (make sure it's set to your correct build folder name)
4-
build
5-
dist
6-
# don't lint nyc coverage output
7-
coverage
8-
# don't lint proto files and output
9-
proto
1+
# don't ever lint node_modules
2+
node_modules
3+
# don't lint build output (make sure it's set to your correct build folder name)
4+
build
5+
dist
6+
# don't lint nyc coverage output
7+
coverage
8+
# don't lint proto files and output
9+
proto
10+
# don't lint auto-generated version files
11+
**/version.ts
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 🧪 DTS Emulator E2E Tests
2+
3+
# This workflow runs E2E tests against the Durable Task Scheduler (DTS) emulator.
4+
# It mirrors the Python testing setup at durabletask-python for Azure-managed tests.
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
dts-e2e-tests:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node-version: ["22.x", "24.x"]
23+
env:
24+
EMULATOR_VERSION: "latest"
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: 📥 Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: 🐳 Pull Docker image
32+
run: docker pull mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION
33+
34+
- name: 🚀 Run Docker container
35+
run: |
36+
docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION
37+
38+
- name: ⏳ Wait for container to be ready
39+
run: sleep 10 # Adjust if your service needs more time to start
40+
41+
- name: 🔧 Set environment variables
42+
run: |
43+
echo "TASKHUB=default" >> $GITHUB_ENV
44+
echo "ENDPOINT=localhost:8080" >> $GITHUB_ENV
45+
46+
- name: ⚙️ NodeJS - Install
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
registry-url: "https://registry.npmjs.org"
51+
52+
- name: ⚙️ Install dependencies
53+
run: npm install
54+
55+
- name: ✅ Run E2E tests against DTS emulator
56+
run: npm run test:e2e:azuremanaged:internal
Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,73 @@
1-
name: 🚀 Test and Build
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
10-
11-
jobs:
12-
build:
13-
runs-on: ubuntu-latest
14-
15-
env:
16-
NODE_VER: 22
17-
18-
services:
19-
# docker run --name durabletask-sidecar -p 4001:4001 --env 'DURABLETASK_SIDECAR_LOGLEVEL=Debug' --rm cgillum/durabletask-sidecar:latest start --backend Emulator
20-
durabletask-sidecar:
21-
image: cgillum/durabletask-sidecar:latest
22-
ports:
23-
- 4001:4001
24-
env:
25-
DURABLETASK_SIDECAR_LOGLEVEL: Debug
26-
DURABLETASK_STORAGE_PROVIDER: Emulator
27-
28-
steps:
29-
- name: 📥 Checkout code
30-
uses: actions/checkout@v4
31-
32-
- name: ⚙️ NodeJS - Install
33-
uses: actions/setup-node@v4
34-
with:
35-
node-version: ${{ env.NODE_VER }}
36-
registry-url: "https://registry.npmjs.org"
37-
38-
- name: ⚙️ Install dependencies
39-
run: npm install
40-
41-
- name: 🔨 Build packages
42-
run: npm run build
43-
44-
- name: ✅ Run unit tests
45-
run: npm run test:unit
46-
47-
- name: ✅ Run e2e tests
48-
run: npm run test:e2e
1+
name: 🚀 Test and Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
lint-and-unit-tests:
16+
runs-on: ubuntu-latest
17+
18+
env:
19+
NODE_VER: 18.x
20+
21+
steps:
22+
- name: 📥 Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: ⚙️ NodeJS - Install
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ env.NODE_VER }}
29+
registry-url: "https://registry.npmjs.org"
30+
31+
- name: ⚙️ Install dependencies
32+
run: npm install
33+
34+
- name: 🔍 Run linting
35+
run: npm run lint
36+
37+
- name: ✅ Run unit tests
38+
run: npm run test:unit
39+
40+
e2e-tests:
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
node-version: ["22.x", "24.x"]
45+
needs: lint-and-unit-tests
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: 📥 Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: ⚙️ NodeJS - Install
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: ${{ matrix.node-version }}
56+
registry-url: "https://registry.npmjs.org"
57+
58+
- name: ⚙️ Install dependencies
59+
run: npm install
60+
61+
# Install Go SDK for durabletask-go sidecar
62+
- name: 🔧 Install Go SDK
63+
uses: actions/setup-go@v5
64+
with:
65+
go-version: "stable"
66+
67+
# Install and run the durabletask-go sidecar for running e2e tests
68+
- name: ✅ Run E2E tests with durabletask-go sidecar
69+
run: |
70+
go install github.com/microsoft/durabletask-go@main
71+
durabletask-go --port 4001 &
72+
sleep 5 # Wait for sidecar to be ready
73+
npm run test:e2e:internal

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
module.exports = {
33
preset: "ts-jest",
44
testEnvironment: "node",
5-
testMatch: ["**/tests/**/*.spec.ts"],
5+
testMatch: ["**/tests/**/*.spec.ts", "**/test/**/*.spec.ts"],
66
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
7+
moduleNameMapper: {
8+
"^@microsoft/durabletask-js$": "<rootDir>/packages/durabletask-js/src/index.ts",
9+
"^@microsoft/durabletask-js-azuremanaged$": "<rootDir>/packages/durabletask-js-azuremanaged/src/index.ts",
10+
},
711
transform: {
812
"^.+\\.tsx?$": [
913
"ts-jest",

package.json

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,62 @@
1-
{
2-
"name": "durabletask-js-monorepo",
3-
"version": "0.0.0",
4-
"private": true,
5-
"description": "Durable Task JavaScript SDK monorepo",
6-
"workspaces": [
7-
"packages/*"
8-
],
9-
"scripts": {
10-
"build": "npm run build --workspaces",
11-
"build:core": "npm run build -w @microsoft/durabletask-js",
12-
"build:azuremanaged": "npm run build -w @microsoft/durabletask-js-azuremanaged",
13-
"test": "npm run test --workspaces",
14-
"test:unit": "npm run test:unit --workspaces --if-present",
15-
"test:e2e": "./scripts/test-e2e.sh",
16-
"test:e2e:internal": "jest tests/e2e --runInBand --detectOpenHandles",
17-
"test:e2e:one": "jest tests/e2e --runInBand --detectOpenHandles --testNamePattern",
18-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
19-
"pretty": "prettier --list-different \"**/*.{ts,tsx,js,jsx,json,md}\"",
20-
"pretty-fix": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
21-
"download-proto": "./scripts/download-proto.sh",
22-
"generate-grpc": "./tools/generate-grpc-javascript.sh ./packages/durabletask-js/src/proto",
23-
"example": "ts-node --swc"
24-
},
25-
"engines": {
26-
"node": ">=22.0.0"
27-
},
28-
"repository": {
29-
"type": "git",
30-
"url": "git+https://github.com/microsoft/durabletask-js.git"
31-
},
32-
"license": "MIT",
33-
"bugs": {
34-
"url": "https://github.com/microsoft/durabletask-js/issues"
35-
},
36-
"homepage": "https://github.com/microsoft/durabletask-js#readme",
37-
"devDependencies": {
38-
"@swc/core": "^1.3.55",
39-
"@swc/helpers": "^0.5.1",
40-
"@types/jest": "^29.5.1",
41-
"@types/node": "^18.16.1",
42-
"@typescript-eslint/eslint-plugin": "^5.1.0",
43-
"@typescript-eslint/parser": "^5.1.0",
44-
"dotenv": "^17.2.3",
45-
"eslint": "^8.1.0",
46-
"eslint-config-prettier": "^8.5.0",
47-
"eslint-plugin-header": "^3.1.1",
48-
"eslint-plugin-prettier": "^4.2.1",
49-
"grpc_tools_node_protoc_ts": "^5.3.3",
50-
"grpc-tools": "^1.13.1",
51-
"husky": "^8.0.1",
52-
"jest": "^29.5.0",
53-
"nodemon": "^3.1.4",
54-
"prettier": "^2.4.0",
55-
"pretty-quick": "^3.1.3",
56-
"ts-jest": "^29.1.0",
57-
"ts-node": "^10.9.1",
58-
"typescript": "^5.0.4"
59-
}
60-
}
1+
{
2+
"name": "durabletask-js-monorepo",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "Durable Task JavaScript SDK monorepo",
6+
"workspaces": [
7+
"packages/*"
8+
],
9+
"scripts": {
10+
"build": "npm run build --workspaces",
11+
"build:core": "npm run build -w @microsoft/durabletask-js",
12+
"build:azuremanaged": "npm run build -w @microsoft/durabletask-js-azuremanaged",
13+
"test": "npm run test --workspaces",
14+
"test:unit": "npm run test:unit --workspaces --if-present",
15+
"test:e2e": "./scripts/test-e2e.sh",
16+
"test:e2e:internal": "jest tests/e2e --runInBand --detectOpenHandles",
17+
"test:e2e:one": "jest tests/e2e --runInBand --detectOpenHandles --testNamePattern",
18+
"test:e2e:azuremanaged:internal": "jest test/e2e-azuremanaged --runInBand --detectOpenHandles",
19+
"test:e2e:azuremanaged": "./scripts/test-e2e-azuremanaged.sh",
20+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
21+
"pretty": "prettier --list-different \"**/*.{ts,tsx,js,jsx,json,md}\"",
22+
"pretty-fix": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
23+
"download-proto": "./scripts/download-proto.sh",
24+
"generate-grpc": "./tools/generate-grpc-javascript.sh ./packages/durabletask-js/src/proto",
25+
"example": "ts-node --swc"
26+
},
27+
"engines": {
28+
"node": ">=22.0.0"
29+
},
30+
"repository": {
31+
"type": "git",
32+
"url": "git+https://github.com/microsoft/durabletask-js.git"
33+
},
34+
"license": "MIT",
35+
"bugs": {
36+
"url": "https://github.com/microsoft/durabletask-js/issues"
37+
},
38+
"homepage": "https://github.com/microsoft/durabletask-js#readme",
39+
"devDependencies": {
40+
"@swc/core": "^1.3.55",
41+
"@swc/helpers": "^0.5.1",
42+
"@types/jest": "^29.5.1",
43+
"@types/node": "^18.16.1",
44+
"@typescript-eslint/eslint-plugin": "^5.1.0",
45+
"@typescript-eslint/parser": "^5.1.0",
46+
"dotenv": "^17.2.3",
47+
"eslint": "^8.1.0",
48+
"eslint-config-prettier": "^8.5.0",
49+
"eslint-plugin-header": "^3.1.1",
50+
"eslint-plugin-prettier": "^4.2.1",
51+
"grpc_tools_node_protoc_ts": "^5.3.3",
52+
"grpc-tools": "^1.13.1",
53+
"husky": "^8.0.1",
54+
"jest": "^29.5.0",
55+
"nodemon": "^3.1.4",
56+
"prettier": "^2.4.0",
57+
"pretty-quick": "^3.1.3",
58+
"ts-jest": "^29.1.0",
59+
"ts-node": "^10.9.1",
60+
"typescript": "^5.0.4"
61+
}
62+
}

packages/durabletask-js-azuremanaged/src/client-builder.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export class DurableTaskAzureManagedClientBuilder {
131131
build(): TaskHubGrpcClient {
132132
const hostAddress = this._options.getHostAddress();
133133
const channelCredentials = this._options.createChannelCredentials();
134+
const metadataGenerator = this._options.createMetadataGenerator();
134135

135136
const defaultOptions: grpc.ChannelOptions = {
136137
"grpc.primary_user_agent": "durabletask-js-azuremanaged",
@@ -143,8 +144,10 @@ export class DurableTaskAzureManagedClientBuilder {
143144
...this._grpcChannelOptions,
144145
};
145146

146-
// Use the core TaskHubGrpcClient with custom credentials (no inheritance needed)
147-
return new TaskHubGrpcClient(hostAddress, combinedOptions, true, channelCredentials);
147+
// Use the core TaskHubGrpcClient with custom credentials and metadata generator
148+
// For insecure connections, metadata is passed via the metadataGenerator parameter
149+
// For secure connections, metadata is included in the channel credentials
150+
return new TaskHubGrpcClient(hostAddress, combinedOptions, true, channelCredentials, metadataGenerator);
148151
}
149152
}
150153

0 commit comments

Comments
 (0)