Skip to content

Commit

Permalink
Enable OS Updates to pre-release versions of higher base semver
Browse files Browse the repository at this point in the history
Update balena-hup-action-utils from 5.0.0 to 6.1.0

Change-type: minor
  • Loading branch information
thgreasi committed Jan 4, 2024
1 parent 7c9d78e commit ded8ea6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"abortcontroller-polyfill": "^1.7.1",
"balena-auth": "^5.1.0",
"balena-errors": "^4.9.0",
"balena-hup-action-utils": "~5.0.0",
"balena-hup-action-utils": "~6.1.0",
"balena-register-device": "^9.0.1",
"balena-request": "^13.2.0",
"balena-semver": "^2.3.0",
Expand Down
124 changes: 86 additions & 38 deletions tests/integration/models/device.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3729,40 +3729,6 @@ describe('Device Model', function () {
);
}));

it('should throw when the device is running a pre-release version', () =>
[
['Resin OS 2.0.0-beta.1', ''],
['Resin OS 2.0.0-beta.3', ''],
['Resin OS 2.0.0-beta11.rev1', ''],
['Resin OS 2.0.0-beta.8', ''],
['Resin OS 2.0.0-beta.8', 'prod'],
['balenaOS 2.0.0-beta12.rev1', 'prod'],
['Resin OS 2.0.0-rc1.rev1', ''],
['Resin OS 2.0.0-rc1.rev2', 'prod'],
['Resin OS 2.0.0-rc1.rev2', ''],
['Resin OS 2.0.0-rc6.rev1 (prod)', ''],
['Resin OS 2.0.1-beta.4', ''],
['Resin OS 2.0.2-beta.2', ''],
['Resin OS 2.0.2-beta.7', ''],
['Resin OS 2.9.0-multi1+rev1', 'dev'],
['balenaOS 2.28.0-beta1.rev1', 'prod'],
].forEach(function ([osVersion, osVariant]) {
return expect(() =>
_checkOsUpdateTarget(
{
uuid,
is_of__device_type: [{ slug: 'raspberrypi3' }],
is_online: true,
os_version: osVersion,
os_variant: osVariant,
},
'2.29.2+rev1.prod',
),
).to.throw(
'Updates cannot be performed on pre-release balenaOS versions',
);
}));

describe('v1 -> v1 hup', () =>
['raspberrypi3', 'intel-nuc'].forEach((deviceType) =>
describe(`given a ${deviceType}`, function () {
Expand Down Expand Up @@ -3925,7 +3891,7 @@ describe('Device Model', function () {

describe('v2 -> v2 hup', function () {
describe('given a raspberrypi3', function () {
it('should throw when current os version is < 2.0.0+rev1', () =>
it('should throw when current os version is < 2.0.0+rev1', () => {
[['Resin OS 2.0.0.rev0 (prod)', 'prod']].forEach(function ([
osVersion,
osVariant,
Expand All @@ -3942,9 +3908,10 @@ describe('Device Model', function () {
'2.1.0+rev1.prod',
),
).to.throw('Current OS version must be >= 2.0.0+rev1');
}));
});
});

it('should not throw when it is a valid v2 -> v2 hup', () =>
it('should not throw when it is a valid v2 -> v2 hup', () => {
[
['Resin OS 2.0.0.rev1 (prod)', 'prod'],
['Resin OS 2.0.0.rev1 (prod)', ''],
Expand Down Expand Up @@ -3985,7 +3952,88 @@ describe('Device Model', function () {
'2.29.2+rev1.prod',
),
).to.not.throw();
}));
});
});

it('should throw when updating to a pre-release version with an older server', () => {
[
['balenaOS 2.29.2-1704382618288+rev1', 'prod'],
['balenaOS 2.29.2+rev1', 'prod'],
].forEach(function ([osVersion, osVariant]) {
expect(() =>
_checkOsUpdateTarget(
{
uuid,
is_of__device_type: [{ slug: 'raspberrypi3' }],
is_online: true,
os_version: osVersion,
os_variant: osVariant,
},
'2.28.0-1704382553234+rev1.prod',
),
).to.throw('OS downgrades are not allowed');
});
});

it('should not throw when updating to a pre-release version with a newer base server', () => {
[['balenaOS 2.28.0+rev1', 'prod']].forEach(function ([
osVersion,
osVariant,
]) {
expect(() =>
_checkOsUpdateTarget(
{
uuid,
is_of__device_type: [{ slug: 'raspberrypi3' }],
is_online: true,
os_version: osVersion,
os_variant: osVariant,
},
'2.29.2-1704382618288+rev1.prod',
),
).to.not.throw();
});
});

it('should not throw when updating a device that is running a pre-release version to a version with a newer base server', () => {
[['balenaOS 2.28.0-1704382553234', 'prod']].forEach(function ([
osVersion,
osVariant,
]) {
expect(() =>
_checkOsUpdateTarget(
{
uuid,
is_of__device_type: [{ slug: 'raspberrypi3' }],
is_online: true,
os_version: osVersion,
os_variant: osVariant,
},
'2.29.2+rev1.prod',
),
).to.not.throw();
});
});

it('should not throw when updating a device that is running a pre-release version updating to a pre-release version with a newer base server', () => {
[['balenaOS 2.28.0-1704382553234', 'prod']].forEach(function ([
osVersion,
osVariant,
]) {
expect(() =>
_checkOsUpdateTarget(
{
uuid,
is_of__device_type: [{ slug: 'raspberrypi3' }],
is_online: true,
os_version: osVersion,
os_variant: osVariant,
},
'2.29.2-1704382618288+rev1.prod',
),
).to.not.throw();
});
});
});

describe('given a jetson-tx2', function () {
Expand Down

0 comments on commit ded8ea6

Please sign in to comment.