2020-05-13 19:30:30 +00:00
|
|
|
import { stripIndent } from 'common-tags';
|
2021-04-26 19:54:04 +00:00
|
|
|
import { promises as fs } from 'fs';
|
2022-02-09 21:47:19 +00:00
|
|
|
import * as path from 'path';
|
2024-02-29 22:00:39 +00:00
|
|
|
import type { SinonStub, SinonSpy } from 'sinon';
|
|
|
|
import { stub, spy } from 'sinon';
|
2021-04-26 19:54:04 +00:00
|
|
|
import { expect } from 'chai';
|
2021-05-07 01:47:10 +00:00
|
|
|
|
2022-08-17 23:35:08 +00:00
|
|
|
import * as deviceConfig from '~/src/device-config';
|
|
|
|
import * as fsUtils from '~/lib/fs-utils';
|
|
|
|
import * as logger from '~/src/logger';
|
|
|
|
import { Extlinux } from '~/src/config/backends/extlinux';
|
|
|
|
import { ConfigTxt } from '~/src/config/backends/config-txt';
|
|
|
|
import { Odmdata } from '~/src/config/backends/odmdata';
|
|
|
|
import { ConfigFs } from '~/src/config/backends/config-fs';
|
|
|
|
import { SplashImage } from '~/src/config/backends/splash-image';
|
2023-02-21 06:11:27 +00:00
|
|
|
import { pathOnBoot, pathOnRoot } from '~/lib/host-utils';
|
|
|
|
import {
|
|
|
|
configJsonPath as configJson,
|
|
|
|
hostOSVersionPath as osRelease,
|
|
|
|
} from '~/src/lib/constants';
|
2020-08-18 00:05:31 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
import { testfs } from 'mocha-pod';
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2020-08-07 17:34:32 +00:00
|
|
|
const extlinuxBackend = new Extlinux();
|
|
|
|
const configTxtBackend = new ConfigTxt();
|
2020-08-18 00:05:31 +00:00
|
|
|
const odmdataBackend = new Odmdata();
|
2020-09-22 19:36:33 +00:00
|
|
|
const configFsBackend = new ConfigFs();
|
2021-01-05 21:37:53 +00:00
|
|
|
const splashImageBackend = new SplashImage();
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2022-02-09 21:47:19 +00:00
|
|
|
// TODO: Since the getBootConfig method is simple enough
|
|
|
|
// these tests could probably be removed if each backend has its own
|
|
|
|
// test and the src/config/utils module is properly tested.
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('device-config', () => {
|
2023-02-21 06:11:27 +00:00
|
|
|
const configFsJson = pathOnBoot('configfs.json');
|
|
|
|
const configTxt = pathOnBoot('config.txt');
|
|
|
|
const deviceTypeJson = pathOnBoot('device-type.json');
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2020-07-10 14:02:07 +00:00
|
|
|
let logSpy: SinonSpy;
|
2020-06-10 18:50:26 +00:00
|
|
|
|
|
|
|
before(async () => {
|
2020-07-10 14:02:07 +00:00
|
|
|
logSpy = spy(logger, 'logSystemMessage');
|
2020-06-10 18:50:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
2022-10-21 13:59:51 +00:00
|
|
|
logSpy.restore();
|
2020-06-08 12:57:31 +00:00
|
|
|
});
|
|
|
|
|
2020-06-10 18:50:26 +00:00
|
|
|
afterEach(() => {
|
|
|
|
logSpy.resetHistory();
|
2020-05-13 19:30:30 +00:00
|
|
|
});
|
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('formatConfigKeys', () => {
|
|
|
|
it('accepts RESIN_ and BALENA_ variables', async () => {
|
|
|
|
return expect(
|
|
|
|
deviceConfig.formatConfigKeys({
|
|
|
|
FOO: 'bar', // should be removed
|
|
|
|
BAR: 'baz', // should be removed
|
|
|
|
RESIN_SUPERVISOR_LOCAL_MODE: 'false', // any device
|
|
|
|
BALENA_SUPERVISOR_OVERRIDE_LOCK: 'false', // any device
|
|
|
|
BALENA_SUPERVISOR_POLL_INTERVAL: '100', // any device
|
|
|
|
RESIN_HOST_CONFIG_dtparam: 'i2c_arm=on","spi=on","audio=on', // config.txt backend
|
|
|
|
RESIN_HOST_CONFIGFS_ssdt: 'spidev1.0', // configfs backend
|
|
|
|
BALENA_HOST_EXTLINUX_isolcpus: '1,2,3', // extlinux backend
|
|
|
|
}),
|
|
|
|
).to.deep.equal({
|
|
|
|
SUPERVISOR_LOCAL_MODE: 'false',
|
|
|
|
SUPERVISOR_OVERRIDE_LOCK: 'false',
|
|
|
|
SUPERVISOR_POLL_INTERVAL: '100',
|
|
|
|
HOST_CONFIG_dtparam: 'i2c_arm=on","spi=on","audio=on',
|
|
|
|
HOST_CONFIGFS_ssdt: 'spidev1.0',
|
|
|
|
HOST_EXTLINUX_isolcpus: '1,2,3',
|
|
|
|
});
|
2020-06-10 18:50:26 +00:00
|
|
|
});
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
2020-06-10 18:50:26 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('getDefaults', () => {
|
|
|
|
it('returns default configuration values', () => {
|
|
|
|
const conf = deviceConfig.getDefaults();
|
|
|
|
return expect(conf).to.deep.equal({
|
|
|
|
HOST_FIREWALL_MODE: 'off',
|
|
|
|
HOST_DISCOVERABILITY: 'true',
|
|
|
|
SUPERVISOR_VPN_CONTROL: 'true',
|
|
|
|
SUPERVISOR_POLL_INTERVAL: '900000',
|
|
|
|
SUPERVISOR_LOCAL_MODE: 'false',
|
|
|
|
SUPERVISOR_CONNECTIVITY_CHECK: 'true',
|
|
|
|
SUPERVISOR_LOG_CONTROL: 'true',
|
|
|
|
SUPERVISOR_DELTA: 'false',
|
|
|
|
SUPERVISOR_DELTA_REQUEST_TIMEOUT: '59000',
|
|
|
|
SUPERVISOR_DELTA_APPLY_TIMEOUT: '0',
|
|
|
|
SUPERVISOR_DELTA_RETRY_COUNT: '30',
|
|
|
|
SUPERVISOR_DELTA_RETRY_INTERVAL: '10000',
|
|
|
|
SUPERVISOR_DELTA_VERSION: '2',
|
|
|
|
SUPERVISOR_INSTANT_UPDATE_TRIGGER: 'true',
|
|
|
|
SUPERVISOR_OVERRIDE_LOCK: 'false',
|
|
|
|
SUPERVISOR_PERSISTENT_LOGGING: 'false',
|
|
|
|
SUPERVISOR_HARDWARE_METRICS: 'true',
|
|
|
|
});
|
|
|
|
});
|
2020-05-13 19:30:30 +00:00
|
|
|
});
|
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('config.txt', () => {
|
2022-10-21 13:59:51 +00:00
|
|
|
const tFs = testfs({
|
|
|
|
// This is only needed so config.get doesn't fail
|
|
|
|
[configJson]: JSON.stringify({ deviceType: 'fincm3' }),
|
|
|
|
[configTxt]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
enable_uart=1
|
|
|
|
dtparam=i2c_arm=on
|
|
|
|
dtparam=spi=on
|
|
|
|
disable_splash=1
|
|
|
|
avoid_warnings=1
|
|
|
|
dtparam=audio=on
|
|
|
|
gpu_mem=16`,
|
2022-10-21 13:59:51 +00:00
|
|
|
[osRelease]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
PRETTY_NAME="balenaOS 2.88.5+rev1"
|
|
|
|
META_BALENA_VERSION="2.88.5"
|
2023-02-21 06:11:27 +00:00
|
|
|
VERSION="2.88.5+rev1"
|
|
|
|
VARIANT_ID="dev"
|
|
|
|
`,
|
2022-10-21 13:59:51 +00:00
|
|
|
[deviceTypeJson]: JSON.stringify({
|
|
|
|
slug: 'fincm3',
|
|
|
|
arch: 'armv7hf',
|
|
|
|
}),
|
|
|
|
});
|
2020-06-10 18:50:26 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
beforeEach(async () => {
|
|
|
|
await tFs.enable();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
afterEach(async () => {
|
2022-01-26 21:56:08 +00:00
|
|
|
// Reset the state of the fs after each test to
|
|
|
|
// prevent tests leaking into each other
|
2022-10-21 13:59:51 +00:00
|
|
|
await tFs.restore();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
2020-06-10 18:50:26 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('correctly parses a config.txt file', async () => {
|
|
|
|
// Will try to parse /test/data/mnt/boot/config.txt
|
|
|
|
await expect(
|
|
|
|
deviceConfig.getBootConfig(configTxtBackend),
|
|
|
|
).to.eventually.deep.equal({
|
|
|
|
HOST_CONFIG_dtparam: '"i2c_arm=on","spi=on","audio=on"',
|
|
|
|
HOST_CONFIG_enable_uart: '1',
|
|
|
|
HOST_CONFIG_disable_splash: '1',
|
|
|
|
HOST_CONFIG_avoid_warnings: '1',
|
|
|
|
HOST_CONFIG_gpu_mem: '16',
|
|
|
|
});
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
// Update config.txt to include initramfs and array variables
|
|
|
|
await fs.writeFile(
|
|
|
|
configTxt,
|
|
|
|
stripIndent`
|
|
|
|
initramfs initramf.gz 0x00800000
|
|
|
|
dtparam=i2c=on
|
|
|
|
dtparam=audio=on
|
|
|
|
dtoverlay=ads7846
|
|
|
|
dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=13
|
|
|
|
foobar=baz`,
|
|
|
|
);
|
2020-06-10 18:50:26 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
await expect(
|
|
|
|
deviceConfig.getBootConfig(configTxtBackend),
|
|
|
|
).to.eventually.deep.equal({
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=on"',
|
|
|
|
HOST_CONFIG_dtoverlay:
|
|
|
|
'"ads7846","lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'baz',
|
|
|
|
});
|
|
|
|
});
|
2020-06-10 18:50:26 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('does not allow setting forbidden keys', async () => {
|
|
|
|
const current = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=on"',
|
|
|
|
HOST_CONFIG_dtoverlay:
|
|
|
|
'"ads7846","lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'baz',
|
|
|
|
};
|
|
|
|
// Create another target with only change being initramfs which is blacklisted
|
|
|
|
const target = {
|
|
|
|
...current,
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00810000',
|
|
|
|
};
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(() =>
|
2022-09-19 15:33:52 +00:00
|
|
|
// @ts-expect-error accessing private value
|
2022-01-26 21:56:08 +00:00
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configTxtBackend,
|
|
|
|
current,
|
|
|
|
target,
|
|
|
|
),
|
|
|
|
).to.throw('Attempt to change blacklisted config value initramfs');
|
2021-01-05 21:30:07 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
// Check if logs were called
|
|
|
|
expect(logSpy).to.be.calledOnce;
|
|
|
|
expect(logSpy).to.be.calledWith(
|
|
|
|
'Attempt to change blacklisted config value initramfs',
|
|
|
|
{
|
|
|
|
error: 'Attempt to change blacklisted config value initramfs',
|
|
|
|
},
|
|
|
|
'Apply boot config error',
|
|
|
|
);
|
|
|
|
});
|
2021-01-05 21:30:07 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('does not try to change config.txt if it should not change', async () => {
|
|
|
|
const current = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=on"',
|
|
|
|
HOST_CONFIG_dtoverlay:
|
|
|
|
'"ads7846","lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'baz',
|
|
|
|
};
|
|
|
|
const target = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=on"',
|
|
|
|
HOST_CONFIG_dtoverlay:
|
|
|
|
'"ads7846","lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'baz',
|
|
|
|
};
|
2021-01-05 21:30:07 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(
|
2022-09-19 15:33:52 +00:00
|
|
|
// @ts-expect-error accessing private value
|
2022-01-26 21:56:08 +00:00
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configTxtBackend,
|
|
|
|
current,
|
|
|
|
target,
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
expect(logSpy).to.not.be.called;
|
2020-06-10 18:50:26 +00:00
|
|
|
});
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('writes the target config.txt', async () => {
|
|
|
|
const current = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=on"',
|
|
|
|
HOST_CONFIG_dtoverlay:
|
|
|
|
'"ads7846","lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'baz',
|
|
|
|
};
|
|
|
|
const target = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=off"',
|
|
|
|
HOST_CONFIG_dtoverlay: '"lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'bat',
|
|
|
|
HOST_CONFIG_foobaz: 'bar',
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configTxtBackend,
|
|
|
|
current,
|
|
|
|
target,
|
|
|
|
'fincm3',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
|
|
|
|
await deviceConfig.setBootConfig(configTxtBackend, target);
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
|
|
|
expect(await fs.readFile(configTxt, 'utf-8')).to.equal(
|
|
|
|
stripIndent`
|
|
|
|
initramfs initramf.gz 0x00800000
|
|
|
|
dtparam=i2c=on
|
|
|
|
dtparam=audio=off
|
|
|
|
foobar=bat
|
|
|
|
foobaz=bar
|
2024-02-06 15:50:00 +00:00
|
|
|
dtoverlay=lirc-rpi
|
|
|
|
dtparam=gpio_out_pin=17
|
|
|
|
dtparam=gpio_in_pin=13
|
|
|
|
dtoverlay=balena-fin
|
2022-01-26 21:56:08 +00:00
|
|
|
` + '\n', // add newline because stripIndent trims last newline
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ensures required fields are written to config.txt', async () => {
|
|
|
|
const current = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=on"',
|
|
|
|
HOST_CONFIG_dtoverlay:
|
|
|
|
'"ads7846","lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'baz',
|
|
|
|
};
|
|
|
|
const target = {
|
|
|
|
HOST_CONFIG_initramfs: 'initramf.gz 0x00800000',
|
|
|
|
HOST_CONFIG_dtparam: '"i2c=on","audio=off"',
|
|
|
|
HOST_CONFIG_dtoverlay: '"lirc-rpi,gpio_out_pin=17,gpio_in_pin=13"',
|
|
|
|
HOST_CONFIG_foobar: 'bat',
|
|
|
|
HOST_CONFIG_foobaz: 'bar',
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
2022-09-19 15:33:52 +00:00
|
|
|
// @ts-expect-error accessing private value
|
2022-01-26 21:56:08 +00:00
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configTxtBackend,
|
|
|
|
current,
|
|
|
|
target,
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
|
|
|
|
await deviceConfig.setBootConfig(configTxtBackend, target);
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
|
|
|
expect(await fs.readFile(configTxt, 'utf-8')).to.equal(
|
|
|
|
stripIndent`
|
|
|
|
initramfs initramf.gz 0x00800000
|
|
|
|
dtparam=i2c=on
|
|
|
|
dtparam=audio=off
|
|
|
|
foobar=bat
|
|
|
|
foobaz=bar
|
2024-02-06 15:50:00 +00:00
|
|
|
dtoverlay=lirc-rpi
|
|
|
|
dtparam=gpio_out_pin=17
|
|
|
|
dtparam=gpio_in_pin=13
|
|
|
|
dtoverlay=balena-fin
|
2022-01-26 21:56:08 +00:00
|
|
|
` + '\n', // add newline because stripIndent trims last newline
|
|
|
|
);
|
2020-05-13 19:30:30 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('extlinux', () => {
|
2023-02-21 06:11:27 +00:00
|
|
|
const extlinuxConf = pathOnBoot('extlinux/extlinux.conf');
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
const tFs = testfs({
|
|
|
|
// This is only needed so config.get doesn't fail
|
|
|
|
[configJson]: JSON.stringify({}),
|
|
|
|
[osRelease]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
PRETTY_NAME="balenaOS 2.88.5+rev1"
|
|
|
|
META_BALENA_VERSION="2.88.5"
|
2023-02-21 06:11:27 +00:00
|
|
|
VERSION="2.88.5+rev1"
|
2022-01-26 21:56:08 +00:00
|
|
|
VARIANT_ID="dev"
|
|
|
|
`,
|
2022-10-21 13:59:51 +00:00
|
|
|
[deviceTypeJson]: JSON.stringify({
|
|
|
|
slug: 'fincm3',
|
|
|
|
arch: 'armv7hf',
|
|
|
|
}),
|
|
|
|
[extlinuxConf]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
DEFAULT primary
|
|
|
|
TIMEOUT 30
|
|
|
|
MENU TITLE Boot Options
|
|
|
|
LABEL primary
|
|
|
|
MENU LABEL primary Image
|
|
|
|
LINUX /Image
|
|
|
|
APPEND \${cbootargs} \${resin_kernel_root} ro rootwait
|
|
|
|
`,
|
2022-10-21 13:59:51 +00:00
|
|
|
});
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
beforeEach(async () => {
|
|
|
|
await tFs.enable();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
afterEach(async () => {
|
2022-01-26 21:56:08 +00:00
|
|
|
// Reset the state of the fs after each test to
|
|
|
|
// prevent tests leaking into each other
|
2022-10-21 13:59:51 +00:00
|
|
|
await tFs.restore();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
2020-05-13 19:30:30 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('should correctly write to extlinux.conf files', async () => {
|
2020-05-13 19:30:30 +00:00
|
|
|
const target = {
|
|
|
|
HOST_EXTLINUX_isolcpus: '2',
|
2020-06-16 20:05:42 +00:00
|
|
|
HOST_EXTLINUX_fdt: '/boot/mycustomdtb.dtb',
|
2020-05-13 19:30:30 +00:00
|
|
|
};
|
|
|
|
|
2020-06-10 18:50:26 +00:00
|
|
|
await deviceConfig.setBootConfig(extlinuxBackend, target);
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(await fs.readFile(extlinuxConf, 'utf-8')).to.equal(
|
2020-06-16 20:05:42 +00:00
|
|
|
stripIndent`
|
|
|
|
DEFAULT primary
|
|
|
|
TIMEOUT 30
|
|
|
|
MENU TITLE Boot Options
|
|
|
|
LABEL primary
|
|
|
|
MENU LABEL primary Image
|
|
|
|
LINUX /Image
|
|
|
|
APPEND \${cbootargs} \${resin_kernel_root} ro rootwait isolcpus=2
|
|
|
|
FDT /boot/mycustomdtb.dtb
|
2020-06-10 18:50:26 +00:00
|
|
|
` + '\n', // add newline because stripIndent trims last newline
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Balena fin', () => {
|
|
|
|
it('should always add the balena-fin dtoverlay', () => {
|
2021-01-05 21:30:07 +00:00
|
|
|
expect(configTxtBackend.ensureRequiredConfig('fincm3', {})).to.deep.equal(
|
|
|
|
{
|
|
|
|
dtoverlay: ['balena-fin'],
|
|
|
|
},
|
|
|
|
);
|
2020-07-08 09:50:52 +00:00
|
|
|
|
2020-05-13 19:30:30 +00:00
|
|
|
expect(
|
2021-01-05 21:30:07 +00:00
|
|
|
configTxtBackend.ensureRequiredConfig('fincm3', {
|
2020-05-13 19:30:30 +00:00
|
|
|
test: '123',
|
|
|
|
test2: ['123'],
|
|
|
|
test3: ['123', '234'],
|
|
|
|
}),
|
|
|
|
).to.deep.equal({
|
|
|
|
test: '123',
|
|
|
|
test2: ['123'],
|
|
|
|
test3: ['123', '234'],
|
|
|
|
dtoverlay: ['balena-fin'],
|
|
|
|
});
|
|
|
|
expect(
|
2021-01-05 21:30:07 +00:00
|
|
|
configTxtBackend.ensureRequiredConfig('fincm3', {
|
2020-05-13 19:30:30 +00:00
|
|
|
dtoverlay: 'test',
|
|
|
|
}),
|
|
|
|
).to.deep.equal({ dtoverlay: ['test', 'balena-fin'] });
|
2020-06-10 18:50:26 +00:00
|
|
|
expect(
|
2021-01-05 21:30:07 +00:00
|
|
|
configTxtBackend.ensureRequiredConfig('fincm3', {
|
2020-05-13 19:30:30 +00:00
|
|
|
dtoverlay: ['test'],
|
|
|
|
}),
|
|
|
|
).to.deep.equal({ dtoverlay: ['test', 'balena-fin'] });
|
|
|
|
});
|
|
|
|
|
2020-06-10 18:50:26 +00:00
|
|
|
it('should not cause a config change when the cloud does not specify the balena-fin overlay', () => {
|
2020-05-13 19:30:30 +00:00
|
|
|
expect(
|
2020-06-10 18:50:26 +00:00
|
|
|
deviceConfig.bootConfigChangeRequired(
|
2020-08-07 17:34:32 +00:00
|
|
|
configTxtBackend,
|
2020-05-13 19:30:30 +00:00
|
|
|
{ HOST_CONFIG_dtoverlay: '"test","balena-fin"' },
|
|
|
|
{ HOST_CONFIG_dtoverlay: '"test"' },
|
|
|
|
'fincm3',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
|
|
|
|
expect(
|
2020-06-10 18:50:26 +00:00
|
|
|
deviceConfig.bootConfigChangeRequired(
|
2020-08-07 17:34:32 +00:00
|
|
|
configTxtBackend,
|
2020-05-13 19:30:30 +00:00
|
|
|
{ HOST_CONFIG_dtoverlay: '"test","balena-fin"' },
|
|
|
|
{ HOST_CONFIG_dtoverlay: 'test' },
|
|
|
|
'fincm3',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
|
2020-06-10 18:50:26 +00:00
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
2020-08-07 17:34:32 +00:00
|
|
|
configTxtBackend,
|
2020-05-13 19:30:30 +00:00
|
|
|
{ HOST_CONFIG_dtoverlay: '"test","test2","balena-fin"' },
|
|
|
|
{ HOST_CONFIG_dtoverlay: '"test","test2"' },
|
|
|
|
'fincm3',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-08-18 00:05:31 +00:00
|
|
|
describe('ODMDATA', () => {
|
|
|
|
it('requires change when target is different', () => {
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
odmdataBackend,
|
|
|
|
{ HOST_ODMDATA_configuration: '2' },
|
|
|
|
{ HOST_ODMDATA_configuration: '5' },
|
|
|
|
'jetson-tx2',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
});
|
|
|
|
it('requires change when no target is set', () => {
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
odmdataBackend,
|
|
|
|
{ HOST_ODMDATA_configuration: '2' },
|
|
|
|
{},
|
|
|
|
'jetson-tx2',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('config-fs', () => {
|
2023-02-21 06:11:27 +00:00
|
|
|
const acpiTables = pathOnRoot('boot/acpi-tables');
|
|
|
|
const sysKernelAcpiTable = pathOnRoot('sys/kernel/config/acpi/table');
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
const tFs = testfs({
|
|
|
|
// This is only needed so config.get doesn't fail
|
|
|
|
[configJson]: JSON.stringify({}),
|
|
|
|
[osRelease]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
PRETTY_NAME="balenaOS 2.88.5+rev1"
|
|
|
|
META_BALENA_VERSION="2.88.5"
|
2023-02-21 06:11:27 +00:00
|
|
|
VERSION="2.88.5+rev1"
|
2022-01-26 21:56:08 +00:00
|
|
|
VARIANT_ID="dev"
|
|
|
|
`,
|
2022-10-21 13:59:51 +00:00
|
|
|
[configFsJson]: JSON.stringify({
|
|
|
|
ssdt: ['spidev1.1'],
|
|
|
|
}),
|
|
|
|
|
|
|
|
[deviceTypeJson]: JSON.stringify({
|
|
|
|
slug: 'fincm3',
|
|
|
|
arch: 'armv7hf',
|
|
|
|
}),
|
|
|
|
[acpiTables]: {
|
|
|
|
'spidev1.0.aml': '',
|
|
|
|
'spidev1.1.aml': '',
|
|
|
|
},
|
|
|
|
[sysKernelAcpiTable]: {
|
|
|
|
// Add necessary files to avoid the module reporting an error
|
|
|
|
'spidev1.1': {
|
|
|
|
oem_id: '',
|
|
|
|
oem_table_id: '',
|
|
|
|
oem_revision: '',
|
2022-01-26 21:56:08 +00:00
|
|
|
},
|
2022-10-21 13:59:51 +00:00
|
|
|
},
|
|
|
|
});
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
beforeEach(async () => {
|
|
|
|
await tFs.enable();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
afterEach(async () => {
|
2022-01-26 21:56:08 +00:00
|
|
|
// Reset the state of the fs after each test to
|
|
|
|
// prevent tests leaking into each other
|
2022-10-21 13:59:51 +00:00
|
|
|
await tFs.restore();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
2020-09-22 19:36:33 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('should correctly write to configfs.json files', async () => {
|
2020-09-22 19:36:33 +00:00
|
|
|
const current = {};
|
|
|
|
const target = {
|
|
|
|
HOST_CONFIGFS_ssdt: 'spidev1.0',
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
current,
|
|
|
|
target,
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
|
|
|
|
await deviceConfig.setBootConfig(configFsBackend, target);
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(await fs.readFile(configFsJson, 'utf-8')).to.equal(
|
2020-09-22 19:36:33 +00:00
|
|
|
'{"ssdt":["spidev1.0"]}',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-11-11 16:28:45 +00:00
|
|
|
// This test is skipped because it depends on internal details of the config-fs
|
|
|
|
// backend. We need to refactor that module to make this more testable
|
|
|
|
// properly
|
|
|
|
it.skip('should correctly load the configfs.json file', async () => {
|
2022-10-21 13:59:51 +00:00
|
|
|
await configFsBackend.initialise();
|
|
|
|
|
2021-04-26 19:54:04 +00:00
|
|
|
stub(fsUtils, 'exec').resolves();
|
2020-09-22 19:36:33 +00:00
|
|
|
await configFsBackend.initialise();
|
2022-10-21 13:59:51 +00:00
|
|
|
|
|
|
|
// TODO: unfortunately there is no way to test initialization without stubbing
|
|
|
|
// modprobe cannot be replaced by something else and the up-board modules
|
|
|
|
// will not be present within the container environment. OS tests need
|
|
|
|
// to check that applying configurations actually succeds
|
2021-04-26 19:54:04 +00:00
|
|
|
expect(fsUtils.exec).to.be.calledWith('modprobe acpi_configfs');
|
2022-01-26 21:56:08 +00:00
|
|
|
|
|
|
|
// If the module performs this call, it's because all the prior checks succeeded
|
2021-04-26 19:54:04 +00:00
|
|
|
expect(fsUtils.exec).to.be.calledWith(
|
2022-10-21 13:59:51 +00:00
|
|
|
'cat /mnt/root/boot/acpi-tables/spidev1.1.aml > /mnt/root/sys/kernel/config/acpi/table/spidev1.1/aml',
|
2020-09-22 19:36:33 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Restore stubs
|
2021-04-26 19:54:04 +00:00
|
|
|
(fsUtils.exec as SinonStub).restore();
|
2020-09-22 19:36:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('requires change when target is different', () => {
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: '' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: 'spidev1.0' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: '' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: '"spidev1.0"' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: '"spidev1.0"' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: '"spidev1.0","spidev1.1"' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not report change when target is equal to current', () => {
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: '' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: '' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: 'spidev1.0' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: 'spidev1.0' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: 'spidev1.0' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: '"spidev1.0"' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
configFsBackend,
|
|
|
|
{ HOST_CONFIGFS_ssdt: '"spidev1.0"' },
|
|
|
|
{ HOST_CONFIGFS_ssdt: 'spidev1.0' },
|
|
|
|
'up-board',
|
|
|
|
),
|
|
|
|
).to.equal(false);
|
|
|
|
});
|
|
|
|
});
|
2021-01-05 21:37:53 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('splash config', () => {
|
2021-01-05 21:37:53 +00:00
|
|
|
const defaultLogo =
|
|
|
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/wQDLA+84AAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg==';
|
|
|
|
const png =
|
|
|
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUeJxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII=';
|
|
|
|
const uri = `data:image/png;base64,${png}`;
|
|
|
|
|
2023-02-21 06:11:27 +00:00
|
|
|
const splash = pathOnBoot('splash');
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
const mockFs = testfs(
|
|
|
|
{
|
2022-01-26 21:56:08 +00:00
|
|
|
// This is only needed so config.get doesn't fail
|
|
|
|
[configJson]: JSON.stringify({}),
|
|
|
|
[osRelease]: stripIndent`
|
|
|
|
PRETTY_NAME="balenaOS 2.88.5+rev1"
|
|
|
|
META_BALENA_VERSION="2.88.5"
|
2023-02-21 06:11:27 +00:00
|
|
|
VERSION="2.88.5+rev1"
|
2022-01-26 21:56:08 +00:00
|
|
|
VARIANT_ID="dev"
|
|
|
|
`,
|
|
|
|
[deviceTypeJson]: JSON.stringify({
|
|
|
|
slug: 'raspberrypi4-64',
|
|
|
|
arch: 'aarch64',
|
|
|
|
}),
|
|
|
|
[splash]: {
|
2022-10-21 13:59:51 +00:00
|
|
|
dummy: '', // to ensure the directory is created
|
2022-01-26 21:56:08 +00:00
|
|
|
},
|
2022-10-21 13:59:51 +00:00
|
|
|
},
|
|
|
|
{ cleanup: [`${splash}/*.png`] },
|
|
|
|
);
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
beforeEach(async () => {
|
|
|
|
await mockFs.enable();
|
2021-01-05 21:37:53 +00:00
|
|
|
});
|
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
afterEach(async () => {
|
|
|
|
await mockFs.restore();
|
2021-01-05 21:37:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly write to resin-logo.png', async () => {
|
|
|
|
// Devices with balenaOS < 2.51 use resin-logo.png
|
2022-10-21 13:59:51 +00:00
|
|
|
// Devices with balenaOS >= 2.51 use balena-logo.png
|
|
|
|
const tTfs = await testfs({
|
|
|
|
[splash]: {
|
|
|
|
'resin-logo.png': Buffer.from(png, 'base64'),
|
|
|
|
},
|
|
|
|
}).enable();
|
2021-01-05 21:37:53 +00:00
|
|
|
|
|
|
|
const target = {
|
|
|
|
HOST_SPLASH_image: png,
|
|
|
|
};
|
|
|
|
|
|
|
|
await deviceConfig.setBootConfig(splashImageBackend, target);
|
|
|
|
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(
|
|
|
|
await fs.readFile(path.join(splash, 'resin-logo.png'), 'base64'),
|
|
|
|
).to.equal(png);
|
2022-10-21 13:59:51 +00:00
|
|
|
|
|
|
|
await tTfs.restore();
|
2021-01-05 21:37:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly write to balena-logo.png', async () => {
|
|
|
|
// Devices with balenaOS >= 2.51 use balena-logo.png
|
2022-10-21 13:59:51 +00:00
|
|
|
const tTfs = await testfs({
|
|
|
|
[splash]: {
|
|
|
|
'balena-logo.png': Buffer.from(png, 'base64'),
|
|
|
|
},
|
|
|
|
}).enable();
|
2021-01-05 21:37:53 +00:00
|
|
|
|
|
|
|
const target = {
|
|
|
|
HOST_SPLASH_image: png,
|
|
|
|
};
|
|
|
|
|
|
|
|
await deviceConfig.setBootConfig(splashImageBackend, target);
|
|
|
|
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(
|
|
|
|
await fs.readFile(path.join(splash, 'balena-logo.png'), 'base64'),
|
|
|
|
).to.equal(png);
|
2022-10-21 13:59:51 +00:00
|
|
|
|
|
|
|
await tTfs.restore();
|
2021-01-05 21:37:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly write to balena-logo.png if no default logo is found', async () => {
|
|
|
|
// Devices with balenaOS >= 2.51 use balena-logo.png
|
|
|
|
const current = {};
|
|
|
|
const target = {
|
|
|
|
HOST_SPLASH_image: png,
|
|
|
|
};
|
|
|
|
|
|
|
|
// This should work with every device type, but testing on a couple
|
|
|
|
// of options
|
|
|
|
expect(
|
|
|
|
deviceConfig.bootConfigChangeRequired(
|
|
|
|
splashImageBackend,
|
|
|
|
current,
|
|
|
|
target,
|
|
|
|
'raspberrypi3',
|
|
|
|
),
|
|
|
|
).to.equal(true);
|
|
|
|
|
|
|
|
await deviceConfig.setBootConfig(splashImageBackend, target);
|
|
|
|
|
|
|
|
expect(logSpy).to.be.calledTwice;
|
|
|
|
expect(logSpy.getCall(1).args[2]).to.equal('Apply boot config success');
|
2022-01-26 21:56:08 +00:00
|
|
|
expect(
|
|
|
|
await fs.readFile(path.join(splash, 'balena-logo.png'), 'base64'),
|
|
|
|
).to.equal(png);
|
2021-01-05 21:37:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly read the splash logo if different from the default', async () => {
|
2022-10-21 13:59:51 +00:00
|
|
|
const tTfs = await testfs({
|
|
|
|
[splash]: {
|
|
|
|
'balena-logo.png': Buffer.from(png, 'base64'),
|
|
|
|
'balena-logo-default.png': Buffer.from(defaultLogo, 'base64'),
|
|
|
|
},
|
|
|
|
}).enable();
|
2021-01-05 21:37:53 +00:00
|
|
|
|
|
|
|
expect(
|
|
|
|
await deviceConfig.getBootConfig(splashImageBackend),
|
|
|
|
).to.deep.equal({
|
|
|
|
HOST_SPLASH_image: uri,
|
|
|
|
});
|
2022-10-21 13:59:51 +00:00
|
|
|
await tTfs.restore();
|
2021-01-05 21:37:53 +00:00
|
|
|
});
|
|
|
|
});
|
2022-02-09 21:47:19 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
describe('getRequiredSteps', () => {
|
2023-02-21 06:11:27 +00:00
|
|
|
const splash = pathOnBoot('splash/balena-logo.png');
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
const tFs = testfs({
|
|
|
|
// This is only needed so config.get doesn't fail
|
|
|
|
[configJson]: JSON.stringify({}),
|
|
|
|
[configTxt]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
enable_uart=true
|
|
|
|
`,
|
2022-10-21 13:59:51 +00:00
|
|
|
[osRelease]: stripIndent`
|
2022-01-26 21:56:08 +00:00
|
|
|
PRETTY_NAME="balenaOS 2.88.5+rev1"
|
|
|
|
META_BALENA_VERSION="2.88.5"
|
2023-02-21 06:11:27 +00:00
|
|
|
VERSION="2.88.5+rev1"
|
2022-01-26 21:56:08 +00:00
|
|
|
VARIANT_ID="dev"
|
|
|
|
`,
|
2022-10-21 13:59:51 +00:00
|
|
|
[deviceTypeJson]: JSON.stringify({
|
|
|
|
slug: 'raspberrypi4-64',
|
|
|
|
arch: 'aarch64',
|
|
|
|
}),
|
|
|
|
[splash]: Buffer.from(
|
|
|
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
|
|
|
|
'base64',
|
|
|
|
),
|
|
|
|
});
|
2022-01-26 21:56:08 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
beforeEach(async () => {
|
|
|
|
await tFs.enable();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
2022-02-09 21:47:19 +00:00
|
|
|
|
2022-10-21 13:59:51 +00:00
|
|
|
afterEach(async () => {
|
|
|
|
await tFs.restore();
|
2022-01-26 21:56:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns required steps to config.json first if any', async () => {
|
|
|
|
const steps = await deviceConfig.getRequiredSteps(
|
|
|
|
{
|
|
|
|
local: {
|
|
|
|
config: {
|
|
|
|
SUPERVISOR_POLL_INTERVAL: 900000,
|
|
|
|
HOST_CONFIG_enable_uart: true,
|
|
|
|
},
|
2022-02-09 21:47:19 +00:00
|
|
|
},
|
2022-01-26 21:56:08 +00:00
|
|
|
} as any,
|
|
|
|
{
|
|
|
|
local: {
|
|
|
|
config: {
|
|
|
|
SUPERVISOR_POLL_INTERVAL: 600000,
|
|
|
|
HOST_CONFIG_enable_uart: false,
|
|
|
|
},
|
2022-02-09 21:47:19 +00:00
|
|
|
},
|
2022-01-26 21:56:08 +00:00
|
|
|
} as any,
|
|
|
|
);
|
|
|
|
expect(steps.map((s) => s.action)).to.have.members([
|
|
|
|
// No reboot is required by this config change
|
|
|
|
'changeConfig',
|
|
|
|
'noop', // The noop has to be here since there are also changes from config backends
|
|
|
|
]);
|
|
|
|
});
|
2022-02-09 21:47:19 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('sets the rebooot breadcrumb for config steps that require a reboot', async () => {
|
|
|
|
const steps = await deviceConfig.getRequiredSteps(
|
|
|
|
{
|
|
|
|
local: {
|
|
|
|
config: {
|
|
|
|
SUPERVISOR_POLL_INTERVAL: 900000,
|
|
|
|
SUPERVISOR_PERSISTENT_LOGGING: false,
|
|
|
|
},
|
2022-02-10 19:26:22 +00:00
|
|
|
},
|
2022-01-26 21:56:08 +00:00
|
|
|
} as any,
|
|
|
|
{
|
|
|
|
local: {
|
|
|
|
config: {
|
|
|
|
SUPERVISOR_POLL_INTERVAL: 600000,
|
|
|
|
SUPERVISOR_PERSISTENT_LOGGING: true,
|
|
|
|
},
|
2022-02-10 19:26:22 +00:00
|
|
|
},
|
2022-01-26 21:56:08 +00:00
|
|
|
} as any,
|
|
|
|
);
|
|
|
|
expect(steps.map((s) => s.action)).to.have.members([
|
|
|
|
'setRebootBreadcrumb',
|
|
|
|
'changeConfig',
|
|
|
|
'noop',
|
|
|
|
]);
|
|
|
|
});
|
2022-02-10 19:26:22 +00:00
|
|
|
|
2022-01-26 21:56:08 +00:00
|
|
|
it('returns required steps for backends if no steps are required for config.json', async () => {
|
|
|
|
const steps = await deviceConfig.getRequiredSteps(
|
|
|
|
{
|
|
|
|
local: {
|
|
|
|
config: {
|
|
|
|
SUPERVISOR_POLL_INTERVAL: 900000,
|
|
|
|
SUPERVISOR_PERSISTENT_LOGGING: true,
|
|
|
|
HOST_CONFIG_enable_uart: true,
|
|
|
|
},
|
2022-02-09 21:47:19 +00:00
|
|
|
},
|
2022-01-26 21:56:08 +00:00
|
|
|
} as any,
|
|
|
|
{
|
|
|
|
local: {
|
|
|
|
config: {
|
|
|
|
SUPERVISOR_POLL_INTERVAL: 900000,
|
|
|
|
SUPERVISOR_PERSISTENT_LOGGING: true,
|
|
|
|
HOST_CONFIG_enable_uart: false,
|
|
|
|
},
|
2022-02-09 21:47:19 +00:00
|
|
|
},
|
2022-01-26 21:56:08 +00:00
|
|
|
} as any,
|
|
|
|
);
|
|
|
|
expect(steps.map((s) => s.action)).to.have.members([
|
|
|
|
'setRebootBreadcrumb',
|
|
|
|
'setBootConfig',
|
|
|
|
]);
|
|
|
|
});
|
2022-02-09 21:47:19 +00:00
|
|
|
});
|
|
|
|
});
|