Skip to content

Commit 85958d7

Browse files
committed
chore(test): add test for multiple typegate instances for wasmedge sync mode
1 parent 870f90c commit 85958d7

File tree

2 files changed

+55
-95
lines changed

2 files changed

+55
-95
lines changed

.ghjk/lock.json

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": "0",
3-
"platform": "x86_64-linux",
3+
"platform": "aarch64-darwin",
44
"moduleEntries": {
55
"ports": {
66
"version": "0",
@@ -470,7 +470,6 @@
470470
"dd83a99f49f3f0fba11cdd014ff718cc9539316b",
471471
"4d1916871a40b6ac730709f7721f740df192c84d",
472472
"4df902463d60efc5b8e760ea4899f6ab6df0f16e",
473-
"88f6aa5ddb513712623d31a17096ea26286064da",
474473
"40d9babcd5c8e79379e58dbc2f2a967ef68fbb09",
475474
"5549508f1f5eddf9cb2465f07cf0c7603dc0c849",
476475
"5c041a4209ae50657ea5acacc26683688f2913a9",
@@ -885,25 +884,6 @@
885884
},
886885
"packageName": "node-gyp"
887886
},
888-
"88f6aa5ddb513712623d31a17096ea26286064da": {
889-
"version": "v2.4.0",
890-
"port": {
891-
"ty": "denoWorker@v1",
892-
"name": "mold_ghrel",
893-
"platforms": [
894-
"aarch64-linux",
895-
"x86_64-linux"
896-
],
897-
"version": "0.1.0",
898-
"deps": [
899-
{
900-
"name": "tar_aa"
901-
}
902-
],
903-
"moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/mold.ts"
904-
},
905-
"replaceLd": false
906-
},
907887
"40d9babcd5c8e79379e58dbc2f2a967ef68fbb09": {
908888
"version": "3.8.18",
909889
"port": {

typegate/tests/runtimes/wasmedge/wasmedge_sync_test.ts

Lines changed: 54 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ Meta.test(
6565
const port = metaTest.port;
6666
const gate = `http://localhost:${port}`;
6767

68-
await metaTest.should("work after deploying artifact to S3", async () => {
69-
const s3 = new S3Client(syncConfig.s3);
70-
assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 0);
71-
72-
const { serialized, typegate: gateResponseAdd } = await tgDeploy(tg, {
73-
baseUrl: gate,
74-
auth,
75-
artifactsConfig: {
76-
prismaMigration: {
77-
globalAction: {
78-
create: true,
79-
reset: false,
80-
},
81-
migrationDir: "prisma-migrations",
68+
const { serialized, typegate: gateResponseAdd } = await tgDeploy(tg, {
69+
baseUrl: gate,
70+
auth,
71+
artifactsConfig: {
72+
prismaMigration: {
73+
globalAction: {
74+
create: true,
75+
reset: false,
8276
},
83-
dir: cwd,
77+
migrationDir: "prisma-migrations",
8478
},
85-
typegraphPath: path.join(cwd, "wasmedge.ts"),
86-
secrets: {},
87-
});
79+
dir: cwd,
80+
},
81+
typegraphPath: path.join(cwd, "wasmedge.ts"),
82+
secrets: {},
83+
});
84+
85+
await metaTest.should("work after deploying artifact to S3", async () => {
86+
const s3 = new S3Client(syncConfig.s3);
87+
assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 2);
8888

8989
assertExists(serialized, "serialized has a value");
9090
assertEquals(gateResponseAdd, {
@@ -109,6 +109,41 @@ Meta.test(
109109
})
110110
.on(engine);
111111

112+
await engine.terminate();
113+
s3.destroy();
114+
});
115+
116+
await metaTest.should("work with multiple typegate instances", async () => {
117+
const s3 = new S3Client(syncConfig.s3);
118+
119+
// typegraphs are pushed to s3 whenever pushed to a typegate
120+
assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 3);
121+
122+
const engine = await metaTest.engineFromDeployed(serialized);
123+
124+
await gql`
125+
query {
126+
test_wasi_ts(a: 11, b: 12)
127+
}
128+
`
129+
.expectData({
130+
test_wasi_ts: 23,
131+
})
132+
.on(engine);
133+
134+
// second engine on the other typegate instance
135+
const engine2 = await metaTest.engineFromDeployed(serialized);
136+
137+
await gql`
138+
query {
139+
test_wasi_ts(a: 15, b: 2)
140+
}
141+
`
142+
.expectData({
143+
test_wasi_ts: 17,
144+
})
145+
.on(engine2);
146+
112147
const { typegate: gateResponseRem } = await tgRemove(tg, {
113148
baseUrl: gate,
114149
auth,
@@ -117,63 +152,8 @@ Meta.test(
117152
assertEquals(gateResponseRem, { data: { removeTypegraphs: true } });
118153

119154
await engine.terminate();
155+
await engine2.terminate();
120156
s3.destroy();
121157
});
122158
},
123159
);
124-
125-
// Meta.test(
126-
// {
127-
// name: "WasmEdge Runtime typescript SDK: Multiple typegate instances",
128-
// syncConfig,
129-
// async setup() {
130-
// await cleanUp();
131-
// },
132-
// async teardown() {
133-
// await cleanUp();
134-
// },
135-
// port: true,
136-
// multipleTypegates: 3,
137-
// },
138-
// async (metaTest) => {
139-
// const port = metaTest.port;
140-
// const gate = `http://localhost:${port}`;
141-
// await metaTest.should("work with multiple typegate instances", async () => {
142-
// const s3 = new S3Client(syncConfig.s3);
143-
// assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 0);
144-
145-
// const { serialized, typegate: _gateResponseAdd } = await tgDeploy(tg, {
146-
// baseUrl: gate,
147-
// auth,
148-
// artifactsConfig: {
149-
// prismaMigration: {
150-
// globalAction: {
151-
// create: true,
152-
// reset: false,
153-
// },
154-
// migrationDir: "prisma-migrations",
155-
// },
156-
// dir: cwd,
157-
// },
158-
// typegraphPath: path.join(cwd, "wasmedge.ts"),
159-
// secrets: {},
160-
// });
161-
162-
// assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 1);
163-
164-
// const engine = await metaTest.engineFromDeployed(serialized);
165-
166-
// await gql`
167-
// query {
168-
// test_wasi_ts(a: 11, b: 2)
169-
// }
170-
// `
171-
// .expectData({
172-
// test_wasi_ts: 13,
173-
// })
174-
// .on(engine);
175-
// await engine.terminate();
176-
// s3.destroy();
177-
// });
178-
// },
179-
// );

0 commit comments

Comments
 (0)