Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/jupyter/stateless-api/execute-stress.test.ts
1447 views
1
import { getPythonKernelName } from "../kernel/kernel-data";
2
import jupyterExecute from "./execute";
3
import { delay } from "awaiting";
4
5
const count = 5;
6
jest.setTimeout(10000);
7
describe(`execute code ${count} times in a row to test for race conditions`, () => {
8
// this would randomly hang at one point due to running the init code
9
// without using the usual execution queue.
10
it("does the test", async () => {
11
const kernel = await getPythonKernelName();
12
for (let i = 0; i < count; i++) {
13
const outputs = await jupyterExecute({ kernel, input: "2+3" });
14
expect(outputs).toEqual([{ data: { "text/plain": "5" } }]);
15
await delay(100);
16
}
17
});
18
});
19
20