forked from arangodb/arangojs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmoke-test.js
55 lines (53 loc) · 1.52 KB
/
smoke-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"use strict";
const puppeteer = require("puppeteer");
const express = require("express");
const proxy = require("express-http-proxy");
const { createReadStream } = require("fs");
const app = express();
app.get("/smoke", (_req, res) => {
res.type("html");
res.end('<!DOCTYPE html><script src="/smoke/web.js"></script>');
});
app.get("/smoke/web.js", (_req, res) => {
res.type("js");
createReadStream("build/web.js").pipe(res);
});
app.get("/smoke/web.js.map", (_req, res) => {
res.type("js");
createReadStream("build/web.js.map").pipe(res);
});
app.use("/", proxy("arangodb:8529"));
app.listen(8529, () => {
(async () => {
let info;
try {
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
const page = await browser.newPage();
await page.goto("http://localhost:8529/smoke", {
waitUntil: "networkidle2",
});
const response = await page.evaluate(async () => {
// eslint-disable-next-line no-undef
const Database = arangojs.Database;
const db = new Database();
try {
const info = await db.version();
return JSON.stringify(info);
} catch (e) {
return JSON.stringify(e);
}
});
info = JSON.parse(response);
await browser.close();
} catch (e) {
console.error(e);
}
if (info.server !== "arango") {
console.error("Smoke test failed:", info);
process.exit(1);
} else {
console.log("Smoke test passed", info);
process.exit(0);
}
})();
});