10000 fix(extension/podman): ensure loop of monitoring can be started at ac… · simonrey1/podman-desktop@3564ead · GitHub
[go: up one dir, main page]

Skip to content

Commit 3564ead

Browse files
committed
fix(extension/podman): ensure loop of monitoring can be started at activation of extension (podman-desktop#13275)
* fix(extension/podman): ensure loop of monitoring can be started at activation of extension Signed-off-by: Simon Rey <sfbrey+eqqe@gmail.com> * test: fix instability Signed-off-by: Simon Rey <sfbrey+eqqe@gmail.com> * test: good practice to make sure called even failed test Signed-off-by: Simon Rey <sfbrey+eqqe@gmail.com> --------- Signed-off-by: Simon Rey <sfbrey+eqqe@gmail.com>
1 parent 373c1f3 commit 3564ead

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

extensions/podman/packages/extension/src/extension.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ beforeEach(() => {
384384
afterEach(async () => {
385385
console.error = originalConsoleError;
386386
await extension.deactivate();
387+
vi.useRealTimers();
387388
});
388389

389390
describe.each([
@@ -3300,16 +3301,19 @@ test('activate and autostart should not duplicate machines ', async () => {
33003301
// call the autostart method
33013302
const promiseAutoStart = autoStartMethod?.start();
33023303

3303-
// call 100 times monitorMachines
3304-
for (let i = 0; i < 100; i++) {
3305-
extension.monitorMachines(provider, podmanConfiguration).catch(() => {});
3306-
}
3304+
vi.useFakeTimers();
3305+
3306+
const promises = Array.from({ length: 100 }).map(() => extension.monitorMachines(provider, podmanConfiguration));
33073307

33083308
await promiseAutoStart;
33093309

33103310
// should be only 1 but we allow some more calls (if there is not a check to check during the autostart it would be 100+ calls)
33113311
expect(podmanMachineListCalls).toBeLessThan(5);
33123312
expect(promiseAutoStart).toBeDefined();
3313+
3314+
await vi.advanceTimersByTimeAsync(5000);
3315+
3316+
await Promise.allSettled(promises);
33133317
});
33143318

33153319
describe('macOS: tests for notifying if disguised podman socket fails / passes', () => {

extensions/podman/packages/extension/src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,8 @@ async function exec(args: string[], options?: PodmanRunOptions): Promise<extensi
12881288
}
12891289

12901290
export async function activate(extensionContext: extensionApi.ExtensionContext): Promise<PodmanExtensionApi> {
1291+
stopLoop = false;
1292+
12911293
initExtensionContext(extensionContext);
12921294

12931295
initTelemetryLogger();

0 commit comments

Comments
 (0)
0