CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/project/kucalc.test.ts
Views: 687
1
import * as kucalc from "./kucalc";
2
3
test("compute status is doing something", async () => {
4
const status = await kucalc.test_compute_status();
5
expect(new Set(Object.keys(status))).toEqual(
6
new Set([
7
"cpu",
8
"disk_MB",
9
"memory",
10
"oom_kills",
11
"processes",
12
"session_id",
13
"start_ts",
14
"time",
15
])
16
);
17
expect(status.memory.rss).toBeDefined();
18
});
19
20
test("prometheus metric", async () => {
21
await kucalc.test_compute_status();
22
const project_id = "d9f0af23-6415-4df8-9888-84dbcaeee7f0";
23
const metrics = await kucalc.prometheus_metrics(project_id);
24
expect(metrics).toMatch(new RegExp(project_id));
25
expect(metrics).toMatch(/cocalc_project_memory_usage_ki/);
26
// check last character of metrics is a newline
27
expect(metrics[metrics.length - 1]).toBe("\n");
28
});
29
30