Skip to content

Commit e3341c0

Browse files
authored
Move the e2e tests to a separate package (#413)
This commit adds a new private package, that contains the services required by the e2e test driver. It also includes a Dockerfile to create an e2e image.
1 parent 777f760 commit e3341c0

25 files changed

+1019
-13
lines changed

package-lock.json

Lines changed: 52 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"packages/restate-sdk-core",
1919
"packages/restate-sdk",
2020
"packages/restate-sdk-clients",
21-
"packages/restate-sdk-examples"
21+
"packages/restate-sdk-examples",
22+
"packages/restate-e2e-services"
2223
],
2324
"type": "module",
2425
"scripts": {
@@ -29,7 +30,7 @@
2930
"format": "npm run format -ws --if-present",
3031
"format-check": "npm run format-check -ws --if-present",
3132
"verify": "npm run verify -ws --if-present",
32-
"clean": "rm -rf packages/restate-sdk/dist && rm -rf packages/restate-sdk-examples/dist && rm -rf packages/restate-sdk-ingress/dist"
33+
"clean": "rm -rf packages/restate-sdk/dist && rm -rf packages/restate-sdk-examples/dist && rm -rf packages/restate-sdk-ingress/dist && rm -rf packages/restate-e2e-services/dist && rm -rf packages/restate-sdk-core/dist"
3334
},
3435
"devDependencies": {
3536
"@arethetypeswrong/cli": "^0.15.3",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
build
3+
dist
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
src/generated
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es2021": true
6+
},
7+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
8+
"overrides": [],
9+
"parser": "@typescript-eslint/parser",
10+
"parserOptions": {
11+
"ecmaVersion": "latest"
12+
},
13+
"plugins": ["@typescript-eslint"],
14+
"rules": {
15+
"@typescript-eslint/no-empty-function": "off"
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
dist/
3+
generated/
4+
5+
.idea
6+
7+
npm-debug.log*
8+
*.tsbuildinfo
9+
.npm
10+
.eslintcache
11+
12+
# We ignore the package-lock.json because this is updated every time with dev releases of sdk-typescript
13+
package-lock.json
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:20 AS build
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY . .
6+
7+
RUN npm install
8+
9+
RUN npm run build
10+
11+
FROM node:20 as prod
12+
WORKDIR /usr/src/app
13+
14+
# Install app dependencies
15+
COPY ./packages/restate-e2e-services/package*.json ./
16+
RUN npm install --production
17+
18+
COPY --from=build /usr/src/app/packages/restate-e2e-services/dist /usr/src/app/dist
19+
20+
# Install Tini
21+
RUN apt-get update && apt-get -y install tini
22+
23+
EXPOSE 8080
24+
ENTRYPOINT ["tini", "--"]
25+
CMD ["node", "/usr/src/app/dist/src/app.js"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Build Docker image from the project root
2+
3+
```shell
4+
docker build . -f packages/restate-e2e-services/Dockerfile -t restatedev/node-test-services
5+
```
6+
7+
## Running the services locally
8+
9+
The Node services can be run via:
10+
11+
```shell
12+
SERVICES=<COMMA_SEPARATED_LIST_OF_SERVICES> gradle npm_run_app
13+
```
14+
15+
For the list of supported services see [here](src/app.ts).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "@restatedev/restate-e2e-services",
3+
"version": "1.1.2",
4+
"description": "Typescript SDK e2e tests",
5+
"private": true,
6+
"author": "Restate Developers",
7+
"license": "MIT",
8+
"email": "[email protected]",
9+
"homepage": "https://github.com/restatedev/sdk-typescript#readme",
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/restatedev/sdk-typescript.git"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/restatedev/sdk-typescript/issues"
16+
},
17+
"type": "module",
18+
"main": "./dist/src/public_api.js",
19+
"types": "./dist/src/public_api.d.ts",
20+
"files": [
21+
"dist"
22+
],
23+
"scripts": {
24+
"build": "tsc -b",
25+
"lint": "eslint --ignore-path .eslintignore --max-warnings=0 --ext .ts .",
26+
"format": "prettier --ignore-path .eslintignore --write \"**/*.+(js|ts|json)\"",
27+
"format-check": "prettier --ignore-path .eslintignore --check \"**/*.+(js|ts|json)\"",
28+
"test": "vitest run --silent",
29+
"verify": "npm run format-check && npm run lint && npm run build",
30+
"release": ""
31+
},
32+
"dependencies": {
33+
"@restatedev/restate-sdk": "^1.1.2",
34+
"@restatedev/restate-sdk-clients": "^1.1.2",
35+
"uuid": "^9.0.0"
36+
},
37+
"devDependencies": {
38+
"@types/node": "*",
39+
"@types/uuid": "^10.0.0",
40+
"tsx": "^4.15.7"
41+
},
42+
"engines": {
43+
"node": ">= 18"
44+
}
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
2+
//
3+
// This file is part of the Restate e2e tests,
4+
// which are released under the MIT license.
5+
//
6+
// You can find a copy of the license in file LICENSE in the root
7+
// directory of this repository or package, or at
8+
// https://github.com/restatedev/e2e/blob/main/LICENSE
9+
10+
import * as restate from "@restatedev/restate-sdk";
11+
12+
import "./awakeable_holder.js";
13+
import "./counter.js";
14+
import "./event_handler.js";
15+
import "./list.js";
16+
import "./map.js";
17+
import "./cancel_test.js";
18+
import "./non_determinism.js";
19+
import "./failing.js";
20+
import "./side_effect.js";
21+
import "./workflow.js";
22+
import "./proxy.js";
23+
import "./test_utils.js";
24+
25+
import { REGISTRY } from "./services.js";
26+
27+
if (!process.env.SERVICES) {
28+
throw new Error("Cannot find SERVICES env");
29+
}
30+
const fqdns = new Set(process.env.SERVICES.split(","));
31+
const endpoint = restate.endpoint();
32+
REGISTRY.register(fqdns, endpoint);
33+
34+
if (process.env.E2E_REQUEST_SIGNING) {
35+
endpoint.withIdentityV1(...process.env.E2E_REQUEST_SIGNING.split(","));
36+
}
37+
if (!process.env.AWS_LAMBDA_FUNCTION_NAME) {
38+
endpoint.listen().catch((e) => {
39+
// eslint-disable-next-line no-console
40+
console.error(e);
41+
});
42+
}
43+
44+
export const handler = endpoint.lambdaHandler();

0 commit comments

Comments
 (0)