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
1710 views
1
import { getPythonKernelName } from "../kernel/kernel-data";
2
import jupyterExecute from "./execute";
3
import { delay } from "awaiting";
4
import Kernel from "./kernel";
5
6
const count = 3;
7
jest.setTimeout(15000);
8
describe(`execute code ${count} times in a row to test for race conditions`, () => {
9
// this would randomly hang at one point due to running the init code
10
// without using the usual execution queue.
11
it("does the test", async () => {
12
const kernel = await getPythonKernelName();
13
for (let i = 0; i < count; i++) {
14
const outputs = await jupyterExecute({ kernel, input: "2+3" });
15
expect(outputs).toEqual([{ data: { "text/plain": "5" } }]);
16
await delay(100);
17
}
18
});
19
});
20
21
afterAll(async () => {
22
Kernel.closeAll();
23
});
24
25