Skip to content

Commit 8b008ea

Browse files
authored
Add KillTest e2e (#414)
1 parent e3341c0 commit 8b008ea

File tree

5 files changed

+168
-0
lines changed

5 files changed

+168
-0
lines changed

.github/workflows/integration.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Integration
2+
3+
# Controls when the workflow will run
4+
on:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
schedule:
10+
- cron: "0 */6 * * *" # Every 6 hours
11+
workflow_dispatch:
12+
inputs:
13+
restateCommit:
14+
description: "restate commit"
15+
required: false
16+
default: ""
17+
type: string
18+
restateImage:
19+
description: "restate image, superseded by restate commit"
20+
required: false
21+
default: "ghcr.io/restatedev/restate:main"
22+
type: string
23+
workflow_call:
24+
inputs:
25+
restateCommit:
26+
description: "restate commit"
27+
required: false
28+
default: ""
29+
type: string
30+
restateImage:
31+
description: "restate image, superseded by restate commit"
32+
required: false
33+
default: "ghcr.io/restatedev/restate:main"
34+
type: string
35+
36+
jobs:
37+
sdk-test-suite:
38+
if: github.repository_owner == 'restatedev'
39+
runs-on: ubuntu-latest
40+
name: "Features integration test (sdk-test-suite version ${{ matrix.sdk-test-suite }})"
41+
strategy:
42+
matrix:
43+
sdk-test-suite: ["1.5"]
44+
permissions:
45+
contents: read
46+
issues: read
47+
checks: write
48+
pull-requests: write
49+
actions: read
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
repository: restatedev/sdk-typescript
55+
56+
### Download the Restate container image, if needed
57+
# Setup restate snapshot if necessary
58+
# Due to https://github.com/actions/upload-artifact/issues/53
59+
# We must use download-artifact to get artifacts created during *this* workflow run, ie by workflow call
60+
- name: Download restate snapshot from in-progress workflow
61+
if: ${{ inputs.restateCommit != '' && github.event_name != 'workflow_dispatch' }}
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: restate.tar
65+
# In the workflow dispatch case where the artifact was created in a previous run, we can download as normal
66+
- name: Download restate snapshot from completed workflow
67+
if: ${{ inputs.restateCommit != '' && github.event_name == 'workflow_dispatch' }}
68+
uses: dawidd6/action-download-artifact@v3
69+
with:
70+
repo: restatedev/restate
71+
workflow: ci.yml
72+
commit: ${{ inputs.restateCommit }}
73+
name: restate.tar
74+
- name: Install restate snapshot
75+
if: ${{ inputs.restateCommit != '' }}
76+
run: |
77+
output=$(docker load --input restate.tar)
78+
docker tag "${output#*: }" "localhost/restatedev/restate-commit-download:latest"
79+
docker image ls -a
80+
81+
- name: Setup Java
82+
uses: actions/setup-java@v4
83+
with:
84+
distribution: "temurin"
85+
java-version: "17"
86+
- name: Set up QEMU
87+
uses: docker/setup-qemu-action@v3
88+
- name: Set up Docker Buildx
89+
uses: docker/setup-buildx-action@v3
90+
- name: Setup sdk-test-suite
91+
run: wget --no-verbose https://github.com/restatedev/sdk-test-suite/releases/download/v${{ matrix.sdk-test-suite }}/restate-sdk-test-suite.jar
92+
93+
- name: Build Typescript test-services image
94+
id: build
95+
uses: docker/build-push-action@v6
96+
with:
97+
context: .
98+
file: "packages/restate-e2e-services/Dockerfile"
99+
push: false
100+
load: true
101+
tags: localhost/restatedev/test-services:latest
102+
cache-from: type=gha,scope=${{ github.workflow }}
103+
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
104+
105+
# Run test suite
106+
- name: Run test suite
107+
env:
108+
RESTATE_CONTAINER_IMAGE: ${{ inputs.restateCommit != '' && 'localhost/restatedev/restate-commit-download:latest' || (inputs.restateImage != '' && inputs.restateImage || 'ghcr.io/restatedev/restate:main') }}
109+
run: java -jar restate-sdk-test-suite.jar run --report-dir=test-report --exclusions-file packages/restate-e2e-services/exclusions.yaml localhost/restatedev/test-services:latest
110+
111+
# Upload logs and publish test result
112+
- uses: actions/upload-artifact@v4
113+
if: always() # Make sure this is run even when test fails
114+
with:
115+
name: sdk-typescript-integration-test-report
116+
path: test-report
117+
- name: Publish Test Results
118+
uses: EnricoMi/publish-unit-test-result-action@v2
119+
if: always()
120+
with:
121+
files: |
122+
test-report/*/*.xml

packages/restate-e2e-services/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ COPY . .
66

77
RUN npm install
88

9+
RUN npm run proto
910
RUN npm run build
1011

1112
FROM node:20 as prod
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exclusions: {}

packages/restate-e2e-services/src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import "./side_effect.js";
2121
import "./workflow.js";
2222
import "./proxy.js";
2323
import "./test_utils.js";
24+
import "./kill.js";
2425

2526
import { REGISTRY } from "./services.js";
2627

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
import { REGISTRY } from "./services.js";
12+
import type { AwakeableHolder } from "./awakeable_holder.js";
13+
14+
const kill = restate.service({
15+
name: "KillTestRunner",
16+
handlers: {
17+
async startCallTree(ctx: restate.ObjectContext) {
18+
await ctx.objectClient(killSingleton, "").recursiveCall();
19+
},
20+
},
21+
});
22+
23+
const killSingleton = restate.object({
24+
name: "KillTestSingleton",
25+
handlers: {
26+
async recursiveCall(ctx: restate.ObjectContext) {
27+
const { id, promise } = ctx.awakeable();
28+
ctx
29+
.objectSendClient<AwakeableHolder>({ name: "AwakeableHolder" }, "kill")
30+
.hold(id);
31+
await promise;
32+
33+
await ctx.objectClient(killSingleton, "").recursiveCall();
34+
},
35+
36+
isUnlocked() {
37+
return Promise.resolve();
38+
},
39+
},
40+
});
41+
42+
REGISTRY.addService(kill);
43+
REGISTRY.addObject(killSingleton);

0 commit comments

Comments
 (0)