Skip to content

Commit

Permalink
Bump to test suite 2.1 (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Oct 1, 2024
1 parent e4fe954 commit 61e60c1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: "Features integration test (sdk-test-suite version ${{ matrix.sdk-test-suite }})"
strategy:
matrix:
sdk-test-suite: ["1.5"]
sdk-test-suite: ["2.1"]
permissions:
contents: read
issues: read
Expand Down
8 changes: 7 additions & 1 deletion packages/restate-e2e-services/exclusions.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
exclusions: {}
exclusions:
"alwaysSuspending":
- "dev.restate.sdktesting.tests.RunRetry"
"default":
- "dev.restate.sdktesting.tests.RunRetry"
"singleThreadSinglePartition":
- "dev.restate.sdktesting.tests.RunRetry"
2 changes: 2 additions & 0 deletions packages/restate-e2e-services/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ const o = restate.object({
});

REGISTRY.addObject(o);

export type ListObject = typeof o;
2 changes: 2 additions & 0 deletions packages/restate-e2e-services/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ProxyRequest = {
virtualObjectKey?: string;
handlerName: string;
message: Array<number>;
delayMillis?: number;
};

type ManyCallRequest = {
Expand Down Expand Up @@ -46,6 +47,7 @@ function rawSend(ctx: restate.Context, request: ProxyRequest) {
key: request.virtualObjectKey,
inputSerde: restate.serde.binary,
parameter: new Uint8Array(request.message),
delay: request.delayMillis,
});
}

Expand Down
55 changes: 55 additions & 0 deletions packages/restate-e2e-services/src/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ import * as restate from "@restatedev/restate-sdk";
import { REGISTRY } from "./services.js";

import type { AwakeableHolder } from "./awakeable_holder.js";
import * as process from "node:process";
import { ListObject } from "./list.js";

const AwakeableHolder: AwakeableHolder = { name: "AwakeableHolder" };
const ListObject: ListObject = { name: "ListObject" };

type Command =
| { type: "createAwakeableAndAwaitIt"; awakeableKey: string }
| { type: "getEnvVariable"; envName: string };

interface InterpretRequest {
listName: string;
commands: Command[];
}

const o = restate.service({
name: "TestUtilsService",
Expand All @@ -32,6 +44,13 @@ const o = restate.service({
);
},

rawEcho: restate.handlers.handler(
{ input: restate.serde.binary, output: restate.serde.binary },
(ctx: restate.Context, input: Uint8Array) => {
return Promise.resolve(input);
}
),

async createAwakeableAndAwaitIt(
ctx: restate.Context,
req: { awakeableKey: string; awaitTimeout?: number }
Expand Down Expand Up @@ -82,6 +101,42 @@ const o = restate.service({

return invokedSideEffects;
},

async getEnvVariable(ctx: restate.Context, env: string): Promise<string> {
return ctx.run(() => process.env[env] ?? "");
},

async interpretCommands(
ctx: restate.Context,
req: InterpretRequest
): Promise<void> {
const listClient = ctx.objectSendClient(ListObject, req.listName);

async function createAwakeableAndAwaitIt(
awakeableKey: string
): Promise<string> {
const { id, promise } = ctx.awakeable<string>();
await ctx.objectClient(AwakeableHolder, awakeableKey).hold(id);
return promise;
}

async function getEnvVariable(envName: string): Promise<string> {
return ctx.run(() => process.env[envName] ?? "");
}

for (const command of req.commands) {
switch (command.type) {
case "createAwakeableAndAwaitIt":
listClient.append(
await createAwakeableAndAwaitIt(command.awakeableKey)
);
break;
case "getEnvVariable":
listClient.append(await getEnvVariable(command.envName));
break;
}
}
},
},
});

Expand Down

0 comments on commit 61e60c1

Please sign in to comment.