Skip to content

Commit 4d5b5c7

Browse files
committed
chore(engine): move smoke test to engine/tests/ (#3337)
1 parent eed42d1 commit 4d5b5c7

File tree

13 files changed

+162
-84
lines changed

13 files changed

+162
-84
lines changed

engine/tests/load/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@rivet/load-tests",
2+
"name": "test-load",
33
"private": true,
44
"scripts": {
55
"build": "tsc",
File renamed without changes.

examples/smoke-test/README.md renamed to engine/tests/smoke/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# Smoke Test for RivetKit
22

3-
Example project demonstrating a simple getOrCreate smoke test with [RivetKit](https://rivetkit.org).
4-
5-
[Learn More →](https://github.com/rivet-dev/rivetkit)
6-
7-
[Discord](https://rivet.dev/discord)[Documentation](https://rivetkit.org)[Issues](https://github.com/rivet-dev/rivetkit/issues)
8-
93
## Getting Started
104

115
### Prerequisites
@@ -34,6 +28,5 @@ npm run smoke
3428

3529
Set `TOTAL_ACTOR_COUNT` and `SPAWN_ACTOR_INTERVAL` environment variables to adjust the workload.
3630

37-
## License
31+
Set `BEHAVIOR` to change the test type.
3832

39-
Apache 2.0

examples/smoke-test/package.json renamed to engine/tests/smoke/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "example-smoke-test",
2+
"name": "test-smoke",
33
"version": "2.0.21",
44
"private": true,
55
"type": "module",
File renamed without changes.

examples/smoke-test/src/server/registry.ts renamed to engine/tests/smoke/src/server/registry.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const counter = actor({
77
state: {
88
count: 0,
99
},
10+
onStart: async () => {
11+
await new Promise((resolve) => setTimeout(resolve, 1000));
12+
},
13+
onStop: async () => {
14+
await new Promise((resolve) => setTimeout(resolve, 1000));
15+
},
1016
actions: {
1117
increment: (c, x: number) => {
1218
c.state.count += x;
File renamed without changes.

examples/smoke-test/src/smoke-test/spawn-actor.ts renamed to engine/tests/smoke/src/smoke-test/spawn-actor.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function spawnActor(opts: SpawnActorOptions): Promise<void> {
3333
}
3434
}
3535

36-
export async function spawnActorSleepCycle({
36+
export async function spawnActorHttp({
3737
client,
3838
index,
3939
testId,
@@ -52,15 +52,14 @@ export async function spawnActorSleepCycle({
5252
const iterationDuration = iterationEnd - iterationStart;
5353
iterationDurations.push(iterationDuration);
5454

55-
succeeded = true;
5655
onSuccess();
5756
} catch (error) {
5857
errors.push({ index, error });
5958
onFailure();
6059
}
6160
}
6261

63-
export async function spawnActorHttp({
62+
export async function spawnActorSleepCycle({
6463
client,
6564
index,
6665
testId,
@@ -89,6 +88,13 @@ export async function spawnActorHttp({
8988
const iterationEnd = performance.now();
9089
const iterationDuration = iterationEnd - iterationStart;
9190
iterationDurations.push(iterationDuration);
91+
92+
// Wait for actor to sleep
93+
// const sleepTime = 1_100 + Math.random() * 800;
94+
const sleepTime = Math.random() * 2500;
95+
console.log("sleeping", sleepTime);
96+
// const sleepTime = 1000;
97+
await new Promise((res) => setTimeout(res, sleepTime));
9298
}
9399

94100
succeeded = true;
File renamed without changes.

0 commit comments

Comments
 (0)