Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions frontend/jetkvm-ui/e2e/mini/os-services-install.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ import {
// button's menu:
//
// 1. the Mini saves the offline ISO to its TF card, then mounts it;
// 2. the test mounts the disc as above and opens the disc's Linux AppImage
// in the user's graphical session, as a double-click does, from a copy
// in the home folder if the disc is mounted noexec;
// 2. the test mounts the disc as above and follows the disc's README for
// Linux: it copies the .tar.gz to the home folder, extracts it and opens
// the AppImage in the user's graphical session, as a double-click does;
// 3. the sender cannot open the KVM and asks "Allow USB access?". The
// test installs the access that "Allow USB Access" installs through
// pkexec, the AppImage with --install-linux-access, with sudo: pkexec
Expand Down Expand Up @@ -330,20 +330,11 @@ test.describe("OS Services install from the installer disc (Mini)", () => {

let image = "";
let opened = 0;
await test.step("the desktop mounts the disc; the user opens the AppImage", async () => {
await test.step("the desktop mounts the disc; the user extracts and opens the AppImage", async () => {
const mountRequested = Date.now();
const mountPoint = await host.discMountPoint(DISC_LIMIT_MS);
times.disc = Date.now() - mountRequested;
image = await host.appImage(mountPoint);
if (!(await host.allowsPrograms(mountPoint))) {
// A noexec mount, such as Debian's /etc/fstab line for /dev/sr0,
// cannot run the AppImage where it is; the user copies it first.
test.info().annotations.push({
type: "disc",
description: `${mountPoint} is mounted noexec; the AppImage runs from a copy in the home folder`,
});
image = await host.copyToHome(image);
}
image = await host.extractAppImage(mountPoint);
opened = Date.now();
run = await host.open(image);
const exit = await host.opened(run, 30_000);
Expand Down
43 changes: 20 additions & 23 deletions frontend/jetkvm-ui/e2e/mini/os-services-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,36 +328,33 @@ export class InstallerHost {
return { files, links };
}

/** Whether programs on the mount at `mountPoint` can run (no noexec). */
async allowsPrograms(mountPoint: string): Promise<boolean> {
const options = await this.target.text(`findmnt -rn -o OPTIONS -T ${quote(mountPoint)}`);
return !options.trim().split(",").includes("noexec");
}

/**
* Copies `image` to a folder of the user's, as install.md's first step
* says, and returns the copy. The folder goes with restore().
* Follows the disc's README for Linux: copies the one .tar.gz to a folder
* of the user's, extracts it there and returns the AppImage it held. The
* folder goes with restore().
*/
async copyToHome(image: string): Promise<string> {
return (
async extractAppImage(mountPoint: string): Promise<string> {
const found = (
await this.target.text(`ls -1 ${quote(mountPoint)}/*_linux-x86_64.tar.gz`)
).trim();
const archives = found.split("\n").filter(Boolean);
if (archives.length !== 1)
throw new Error(`${mountPoint} holds ${archives.length} Linux archives: ${found}`);
const images = (
await this.target.text(
PATHS +
'mkdir -p "$dir/app" && ' +
`cp ${quote(image)} "$dir/app/" && chmod 755 "$dir/app/$(basename ${quote(image)})" && ` +
`echo "$dir/app/$(basename ${quote(image)})"`,
'rm -rf "$dir/app" && mkdir -p "$dir/app" && ' +
`cp ${quote(archives[0])} "$dir/app/" && ` +
`tar -xzf "$dir/app/$(basename ${quote(archives[0])})" -C "$dir/app" && ` +
'ls -1 "$dir"/app/*.AppImage',
{ timeoutMs: 60_000 },
)
).trim();
}

/** The Linux AppImage on the disc. */
async appImage(mountPoint: string): Promise<string> {
const found = (
await this.target.text(`ls -1 ${quote(mountPoint)}/*_linux-x86_64.AppImage`)
).trim();
const images = found.split("\n").filter(Boolean);
)
.trim()
.split("\n")
.filter(Boolean);
if (images.length !== 1)
throw new Error(`${mountPoint} holds ${images.length} Linux AppImages: ${found}`);
throw new Error(`${archives[0]} holds ${images.length} AppImages: ${images.join(", ")}`);
return images[0];
}

Expand Down
4 changes: 1 addition & 3 deletions tools/integration/tests/sender_update.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,11 @@ describe('the Mini updates the OS Services sender on the host', () => {
assert.deepEqual(only(ended.guestUpdate, 'phase', 'version', 'available', 'error'),
{ phase: 'done', version: target.version, available: false, error: undefined }, 'the Mini\'s update state');
assert.equal(ended.osServices.sender?.version, target.version, 'the version that the sender reports');
// The sender's service runs the new program in a new process. The Linux
// package is the program itself.
// The sender's service runs the new program in a new process.
const now = { ...await host.sender(), programSum: await host.programSum() };
assert.equal(now.running, true, 'the sender runs');
assert.notEqual(now.pid, before.pid, 'the sender\'s process is a new one');
assert.notEqual(now.programSum, before.programSum, 'the sender\'s program was replaced');
if (host.system === 'linux') assert.equal(now.programSum, target.sha256, 'the sender\'s program is the package');

const seen = await updates(updateSince);
// Before the start the Mini can still report the end of the update before.
Expand Down
Loading