Skip to content

Commit a435996

Browse files
committed
Wait for package network results
Avoid the redundant global environment refresh that can block Conda setup, and poll boundedly for package installation, removal, and registry version results across hosted runners. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: edcaaa35-9a42-4351-98fa-55bcf8f1968e
1 parent 6f93cf0 commit a435996

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

src/test/integration/packageManager.integration.test.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ for (const profile of profiles) {
144144
}
145145

146146
if (profile.reuseExistingEnvironment) {
147-
await api.refreshEnvironments(undefined);
148147
environment = (await api.getEnvironments('global')).find(
149148
(candidate) => candidate.envId.managerId === profile.environmentManagerId,
150149
);
@@ -205,11 +204,15 @@ for (const profile of profiles) {
205204
if (!wasInstalled) {
206205
await api.managePackages(environment!, { install: [packageName], runHeadless: true });
207206
}
208-
let packages = await api.getPackages(environment!, { skipCache: true });
209-
assert.ok(packages, 'Unable to list packages after installation');
210-
assert.ok(
211-
packages.some((pkg) => pkg.name.toLowerCase() === packageName),
207+
let packages: Package[] | undefined;
208+
await waitForCondition(
209+
async () => {
210+
packages = await api.getPackages(environment!, { skipCache: true });
211+
return packages?.some((pkg) => pkg.name.toLowerCase() === packageName) ?? false;
212+
},
213+
30_000,
212214
'Package not installed',
215+
1_000,
213216
);
214217

215218
const directPackageNames = await vscode.commands.executeCommand<string[] | undefined>(
@@ -222,11 +225,14 @@ for (const profile of profiles) {
222225

223226
if (!wasInstalled) {
224227
await api.managePackages(environment!, { uninstall: [packageName], runHeadless: true });
225-
packages = await api.getPackages(environment!, { skipCache: true });
226-
assert.ok(packages, 'Unable to list packages after uninstallation');
227-
assert.ok(
228-
!packages.some((pkg) => pkg.name.toLowerCase() === packageName),
228+
await waitForCondition(
229+
async () => {
230+
packages = await api.getPackages(environment!, { skipCache: true });
231+
return packages !== undefined && !packages.some((pkg) => pkg.name.toLowerCase() === packageName);
232+
},
233+
30_000,
229234
'Package not uninstalled',
235+
1_000,
230236
);
231237
}
232238
});
@@ -239,9 +245,15 @@ for (const profile of profiles) {
239245
return;
240246
}
241247

242-
const versions = await api.getPackageAvailableVersions(environment!, profile.packageName);
243-
assert.ok(versions, `${profile.name} unexpectedly failed to retrieve package versions`);
244-
assert.ok(versions.length > 0, 'No package versions available');
248+
await waitForCondition(
249+
async () => {
250+
const versions = await api.getPackageAvailableVersions(environment!, profile.packageName);
251+
return versions !== undefined && versions.length > 0;
252+
},
253+
30_000,
254+
`${profile.name} unexpectedly failed to retrieve package versions`,
255+
2_000,
256+
);
245257
});
246258

247259
suiteTeardown(async () => {

0 commit comments

Comments
 (0)