mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-02 09:02:56 +00:00
Merge pull request #2157 from balena-os/api-integration-test-restart-timeout-fix
Fix assertion error in restart-service
This commit is contained in:
commit
06f764ad77
@ -522,9 +522,19 @@ describe('manages application lifecycle', () => {
|
|||||||
|
|
||||||
it('should restart service by removing and recreating corresponding container', async () => {
|
it('should restart service by removing and recreating corresponding container', async () => {
|
||||||
containers = await waitForSetup(targetState);
|
containers = await waitForSetup(targetState);
|
||||||
const isRestartSuccessful = startTimesChanged(
|
const serviceName = serviceNames[0];
|
||||||
containers.map((ctn) => ctn.State.StartedAt),
|
const { State } = containers.filter((ctn) =>
|
||||||
);
|
ctn.Name.startsWith(`/${serviceName}`),
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
const { StartedAt: startedAt } = State;
|
||||||
|
|
||||||
|
const isRestartSuccessful = (ctns: Docker.ContainerInspectInfo[]) =>
|
||||||
|
ctns.some(
|
||||||
|
(ctn) =>
|
||||||
|
ctn.Name.startsWith(`/${serviceName}`) &&
|
||||||
|
ctn.State.StartedAt !== startedAt,
|
||||||
|
);
|
||||||
|
|
||||||
// Calling actions.executeServiceAction directly doesn't work
|
// Calling actions.executeServiceAction directly doesn't work
|
||||||
// because it relies on querying target state of the balena-supervisor
|
// because it relies on querying target state of the balena-supervisor
|
||||||
@ -543,10 +553,12 @@ describe('manages application lifecycle', () => {
|
|||||||
// containers have been restarted, but verify explcitly with an assertion
|
// containers have been restarted, but verify explcitly with an assertion
|
||||||
expect(isRestartSuccessful(restartedContainers)).to.be.true;
|
expect(isRestartSuccessful(restartedContainers)).to.be.true;
|
||||||
|
|
||||||
// Containers should have different Ids since they're recreated
|
// One container should have the same Id as before the restart call, since
|
||||||
expect(restartedContainers.map(({ Id }) => Id)).to.not.have.members(
|
// it wasn't restarted.
|
||||||
containers.map((ctn) => ctn.Id),
|
const sharedIds = restartedContainers
|
||||||
);
|
.map(({ Id }) => Id)
|
||||||
|
.filter((id) => containers.some((ctn) => ctn.Id === id));
|
||||||
|
expect(sharedIds.length).to.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should stop a running service', async () => {
|
it('should stop a running service', async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user