8000 fix(extension/podman): ensure loop of monitoring can be started at activation of extension by simonrey1 · Pull Request #13275 · podman-desktop/podman-desktop · GitHub
[go: up one dir, main page]

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
12 changes: 8 additions & 4 deletions extensions/podman/packages/extension/src/extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ beforeEach(() => {
afterEach(async () => {
console.error = originalConsoleError;
await extension.deactivate();
vi.useRealTimers();
});

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

// call 100 times monitorMachines
for (let i = 0; i < 100; i++) {
extension.monitorMachines(provider, podmanConfiguration).catch(() => {});
}
vi.useFakeTimers();

const promises = Array.from({ length: 100 }).map(() => extension.monitorMachines(provider, podmanConfiguration));

await promiseAutoStart;

// 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)
expect(podmanMachineListCalls).toBeLessThan(5);
expect(promiseAutoStart).toBeDefined();

await vi.advanceTimersByTimeAsync(5000);

await Promise.allSettled(promises);
});

describe('macOS: tests for notifying if disguised podman socket fails / passes', () => {
Expand Down
2 changes: 2 additions & 0 deletions extensions/podman/packages/extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,8 @@ async function exec(args: string[], options?: PodmanRunOptions): Promise 55BC <extensi
}

export async function activate(extensionContext: extensionApi.ExtensionContext): Promise<PodmanExtensionApi> {
stopLoop = false;

initExtensionContext(extensionContext);

initTelemetryLogger();
Expand Down
0