Skip to content

Commit 8b1d00a

Browse files
chore(test): improve test cleanup (#3633)
* chore(test): test cleanup Signed-off-by: serbangeorge-m <[email protected]> * chore(test): improve cleanup Signed-off-by: serbangeorge-m <[email protected]> * chore(test): change logs Signed-off-by: serbangeorge-m <[email protected]> * chore(test): test ci cleanup before running tests Signed-off-by: serbangeorge-m <[email protected]> * chore(test): test cleanup Signed-off-by: serbangeorge-m <[email protected]> * chore(test): minor update Signed-off-by: serbangeorge-m <[email protected]> --------- Signed-off-by: serbangeorge-m <[email protected]>
1 parent edc74a4 commit 8b1d00a

File tree

4 files changed

+72
-21
lines changed

4 files changed

+72
-21
lines changed

.github/workflows/pr-check.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
- uses: actions/setup-node@v5
8888
with:
8989
node-version: 22
90+
9091
# Checkout podman desktop
9192
- uses: actions/checkout@v5
9293
with:
@@ -159,6 +160,16 @@ jobs:
159160
podman rm -f $CONTAINER_ID
160161
podman rmi -f localhost/local_ai_lab_image:latest
161162
163+
# Show disk space before cleanup
164+
- name: Show disk space before cleanup
165+
run: df -h
166+
# Minimal disk cleanup after install/build
167+
- name: Free up disk space
168+
run: |
169+
sudo apt-get clean
170+
sudo rm -rf /var/lib/apt/lists/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost /usr/local/share/powershell /usr/local/share/chromium /usr/local/share/edge /usr/local/share/firefox /usr/local/share/google
171+
df -h
172+
162173
- name: Run E2E Smoke tests
163174
working-directory: ./podman-desktop-extension-ai-lab
164175
env:

tests/playwright/src/ai-lab-extension.spec.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,11 @@ test.describe.serial(`AI Lab extension installation and verification`, () => {
394394
.toBeFalsy();
395395
});
396396

397-
test.afterAll(`Cleaning up service model`, async () => {
398-
test.setTimeout(60_000);
397+
test.afterAll(`Cleaning up service model`, async ({ navigationBar }) => {
398+
test.setTimeout(120_000);
399399
await cleanupServices();
400400
await deleteAllModels();
401+
await deleteUnusedImages(navigationBar);
401402
});
402403
});
403404
});
@@ -533,7 +534,7 @@ test.describe.serial(`AI Lab extension installation and verification`, () => {
533534
});
534535

535536
test(`${appName}: Restart, Stop, Delete.`, async () => {
536-
test.setTimeout(150_000);
537+
test.setTimeout(240_000);
537538
test.skip(
538539
appName === 'Object Detection' && isCI && !isMac,
539540
'Currently we are facing issues with the Object Detection app installation on Windows and Linux CI.',
@@ -547,7 +548,7 @@ test.describe.serial(`AI Lab extension installation and verification`, () => {
547548
});
548549

549550
test(`Ensure cleanup of "${appModel}", related services, and images`, async ({ runner, page, navigationBar }) => {
550-
test.setTimeout(150_000);
551+
test.setTimeout(180_000);
551552
aiLabPage = await reopenAILabDashboard(runner, page, navigationBar);
552553
await cleanupServices();
553554
await deleteAllModels();
@@ -758,11 +759,15 @@ async function stopAndDeleteApp(appName: string): Promise<void> {
758759
}
759760

760761
async function deleteUnusedImages(navigationBar: NavigationBar): Promise<void> {
761-
const imagesPage = await navigationBar.openImages();
762-
await playExpect(imagesPage.heading).toBeVisible();
762+
try {
763+
const imagesPage = await navigationBar.openImages();
764+
await playExpect(imagesPage.heading).toBeVisible();
763765

764-
await imagesPage.deleteAllUnusedImages();
765-
await playExpect.poll(async () => await imagesPage.getCountOfImagesByStatus('UNUSED'), { timeout: 60_000 }).toBe(0);
766+
await imagesPage.deleteAllUnusedImages();
767+
await playExpect.poll(async () => await imagesPage.getCountOfImagesByStatus('UNUSED'), { timeout: 90_000 }).toBe(0);
768+
} catch (error) {
769+
console.error('Error during deleteUnusedImages:', error);
770+
}
766771
}
767772

768773
async function waitForCatalogModel(modelName: string): Promise<boolean> {

tests/playwright/src/model/ai-lab-catalog-page.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,27 @@ export class AILabCatalogPage extends AILabBasePage {
9999
}
100100

101101
async deleteAllModels(): Promise<void> {
102-
const modelRows = await this.getAllModelRows();
103-
if (modelRows.length === 0) {
104-
return;
105-
}
102+
try {
103+
const modelRows = await this.getAllModelRows();
104+
if (modelRows.length === 0) {
105+
return;
106+
}
106107

107-
for (const modelRow of modelRows) {
108-
const modelName = await this.getModelNameByRow(modelRow);
109-
if (await this.isModelDownloaded(modelName)) {
110-
await this.deleteModel(modelName);
108+
for (const modelRow of modelRows) {
109+
const modelName = await this.getModelNameByRow(modelRow);
110+
if (await this.isModelDownloaded(modelName)) {
111+
await this.deleteModel(modelName);
112+
}
113+
}
114+
115+
await playExpect.poll(async () => (await this.getAllModelRows()).length === 0, { timeout: 60_000 }).toBeTruthy();
116+
} catch (error) {
117+
const remainingModels = await this.getAllModelRows();
118+
const remainingModelNames = [];
119+
for (const modelRow of remainingModels) {
120+
remainingModelNames.push(await this.getModelNameByRow(modelRow));
111121
}
122+
console.error('Error during deleteAllModels:', error, 'Remaining models:', remainingModelNames);
112123
}
113124
}
114125

tests/playwright/src/model/ai-lab-model-service-page.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,37 @@ export class AiModelServicePage extends AILabBasePage {
5454
}
5555

5656
async deleteAllCurrentModels(): Promise<void> {
57-
if (!(await this.toggleAllCheckbox.count())) return;
57+
try {
58+
if (!(await this.toggleAllCheckbox.count())) return;
5859

59-
await this.checkAllModelsForDeletion();
60-
await playExpect(this.deleteSelectedItems).toBeEnabled();
61-
await this.deleteSelectedItems.click();
60+
await this.checkAllModelsForDeletion();
61+
await playExpect(this.deleteSelectedItems).toBeEnabled();
62+
await this.deleteSelectedItems.click();
6263

63-
await handleConfirmationDialog(this.page, podmanAILabExtension.extensionName, true, 'Confirm');
64+
await handleConfirmationDialog(this.page, podmanAILabExtension.extensionName, true, 'Confirm');
65+
66+
await playExpect.poll(async () => (await this.getCurrentModelCount()) === 0, { timeout: 60_000 }).toBeTruthy();
67+
} catch (error) {
68+
const remainingRows = await this.getAllTableRows();
69+
const remainingNames: string[] = [];
70+
for (let rowNum = 1; rowNum < remainingRows.length; rowNum++) {
71+
const serviceModel = remainingRows[rowNum].getByRole('cell').nth(4);
72+
const modelName = await serviceModel.textContent();
73+
if (modelName) {
74+
remainingNames.push(modelName);
75+
}
76+
}
77+
console.group('Model Service Cleanup');
78+
console.log(`[${new Date().toISOString()}] Model service deletion failed.`);
79+
if (remainingNames.length > 0) {
80+
console.log('Could not delete:');
81+
remainingNames.forEach(name => console.log(` - ${name}`));
82+
} else {
83+
console.log('All model services deleted successfully.');
84+
}
85+
console.error('Error details:', error);
86+
console.groupEnd();
87+
}
6488
}
6589

6690
async getCurrentModelCount(): Promise<number> {

0 commit comments

Comments
 (0)