Skip to content

Commit 1babfeb

Browse files
authored
Automate container registry configuration and private Quay image workflow (#24008)
* add ContainerRegistryTest test * check that added registry exists before deletion * Check the setting read before changing the CheCluster. * revert constant comment * fix(e2e): ensure container registry cleanup runs reliably * fix(e2e): report registry cleanup failures after teardown
1 parent a698b46 commit 1babfeb

6 files changed

Lines changed: 447 additions & 0 deletions

File tree

‎tests/e2e/configs/inversify.config.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/m
5252
import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../utils/KubernetesCommandLineToolsExecutor';
5353
import { ShellExecutor } from '../utils/ShellExecutor';
5454
import { UserPreferences } from '../pageobjects/dashboard/UserPreferences';
55+
import { ContainerRegistries } from '../pageobjects/dashboard/ContainerRegistries';
5556
import { WebTerminalPage } from '../pageobjects/webterminal/WebTerminalPage';
5657
import { TrustAuthorPopup } from '../pageobjects/dashboard/TrustAuthorPopup';
5758
import { ViewsMoreActionsButton } from '../pageobjects/ide/ViewsMoreActionsButton';
@@ -100,6 +101,7 @@ e2eContainer.bind<ShellExecutor>(CLASSES.ShellExecutor).to(ShellExecutor);
100101
e2eContainer.bind<ContainerTerminal>(CLASSES.ContainerTerminal).to(ContainerTerminal);
101102
e2eContainer.bind<WebTerminalPage>(CLASSES.WebTerminalPage).to(WebTerminalPage);
102103
e2eContainer.bind<UserPreferences>(CLASSES.UserPreferences).to(UserPreferences);
104+
e2eContainer.bind<ContainerRegistries>(CLASSES.ContainerRegistries).to(ContainerRegistries);
103105
e2eContainer.bind<Generator>(EXTERNAL_CLASSES.Generator).to(Generator);
104106
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);
105107
e2eContainer.bind<LocatorLoader>(EXTERNAL_CLASSES.LocatorLoader).to(LocatorLoader);

‎tests/e2e/configs/inversify.types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const CLASSES: any = {
4949
ShellExecutor: 'ShellExecutor',
5050
ContainerTerminal: 'ContainerTerminal',
5151
UserPreferences: 'UserPreferences',
52+
ContainerRegistries: 'ContainerRegistries',
5253
WebTerminalPage: 'WebTerminalPage',
5354
RevokeOauthPage: 'RevokeOauthPage',
5455
TrustAuthorPopup: 'TrustAuthorPopup',
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/** *******************************************************************
2+
* copyright (c) 2026 Red Hat, Inc.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
**********************************************************************/
10+
11+
export const CONTAINER_REGISTRY_TEST_CONSTANTS: {
12+
TS_SELENIUM_CONTAINER_REGISTRY_IMAGE: string;
13+
TS_SELENIUM_CONTAINER_REGISTRY_PASSWORD: string;
14+
TS_SELENIUM_CONTAINER_REGISTRY_URL: string;
15+
TS_SELENIUM_CONTAINER_REGISTRY_USERNAME: string;
16+
} = {
17+
/**
18+
* registry host added in User Preferences.
19+
*/
20+
TS_SELENIUM_CONTAINER_REGISTRY_URL: process.env.TS_SELENIUM_CONTAINER_REGISTRY_URL || 'quay.io',
21+
22+
/**
23+
* username for the private registry. A Quay robot-account username is also supported.
24+
*/
25+
TS_SELENIUM_CONTAINER_REGISTRY_USERNAME: process.env.TS_SELENIUM_CONTAINER_REGISTRY_USERNAME || '',
26+
27+
/**
28+
* password or token for the private registry.
29+
*/
30+
TS_SELENIUM_CONTAINER_REGISTRY_PASSWORD: process.env.TS_SELENIUM_CONTAINER_REGISTRY_PASSWORD || '',
31+
32+
/**
33+
* full private image name, including a reusable test tag, for example
34+
* quay.io/example/che-private-registry-test:latest.
35+
*/
36+
TS_SELENIUM_CONTAINER_REGISTRY_IMAGE: process.env.TS_SELENIUM_CONTAINER_REGISTRY_IMAGE || ''
37+
};

‎tests/e2e/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export * from './utils/workspace/ApiUrlResolver';
2222
export * from './utils/workspace/ITestWorkspaceUtil';
2323
export * from './utils/workspace/TestWorkspaceUtil';
2424
export * from './utils/workspace/WorkspaceStatus';
25+
export * from './pageobjects/dashboard/ContainerRegistries';
2526
export * from './pageobjects/dashboard/CreateWorkspace';
2627
export * from './pageobjects/dashboard/Dashboard';
2728
export * from './pageobjects/dashboard/TrustAuthorPopup';
@@ -60,6 +61,7 @@ export * from './tests-library/WorkspaceHandlingTests';
6061
export * from './constants/API_TEST_CONSTANTS';
6162
export * from './constants/BASE_TEST_CONSTANTS';
6263
export * from './constants/CHROME_DRIVER_CONSTANTS';
64+
export * from './constants/CONTAINER_REGISTRY_TEST_CONSTANTS';
6365
export * from './constants/EDITOR_CONSTANTS';
6466
export * from './constants/FACTORY_TEST_CONSTANTS';
6567
export * from './constants/MOCHA_CONSTANTS';
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/** *******************************************************************
2+
* copyright (c) 2026 Red Hat, Inc.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
**********************************************************************/
10+
11+
import { inject, injectable } from 'inversify';
12+
import { By } from 'selenium-webdriver';
13+
import { CLASSES } from '../../configs/inversify.types';
14+
import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
15+
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
16+
import { DriverHelper } from '../../utils/DriverHelper';
17+
import { Logger } from '../../utils/Logger';
18+
import { Dashboard } from './Dashboard';
19+
import { UserPreferences } from './UserPreferences';
20+
21+
@injectable()
22+
export class ContainerRegistries {
23+
private static readonly OPEN_ADD_REGISTRY_DIALOG_BUTTON: By = By.xpath('//button//span[text()="Add Container Registry"]');
24+
private static readonly ADD_REGISTRY_DIALOG: By = By.xpath('//div[@aria-label="edit-registry-info"]');
25+
private static readonly REGISTRY_URL_INPUT: By = By.xpath('//input[@aria-label="Url input"]');
26+
private static readonly USERNAME_INPUT: By = By.xpath('//input[@aria-label="Username input"]');
27+
private static readonly PASSWORD_INPUT: By = By.xpath('//input[@data-testid="registry-password-input"]');
28+
private static readonly ADD_REGISTRY_BUTTON: By = By.xpath('//button[@data-testid="edit-button"]');
29+
private static readonly DELETE_REGISTRY_MENU_ITEM: By = By.xpath('//button[@role="menuitem" and normalize-space(.)="Delete registry"]');
30+
private static readonly DELETE_CONFIRMATION_WINDOW: By = By.css('div[aria-label="warning-info"]');
31+
private static readonly DELETE_CONFIRMATION_CHECKBOX: By = By.css('[data-testid="warning-info-checkbox"]');
32+
private static readonly DELETE_REGISTRY_BUTTON_ENABLED: By = By.css('button[data-testid="delete-button"]:not([disabled])');
33+
34+
constructor(
35+
@inject(CLASSES.DriverHelper)
36+
private readonly driverHelper: DriverHelper,
37+
@inject(CLASSES.BrowserTabsUtil)
38+
private readonly browserTabsUtil: BrowserTabsUtil,
39+
@inject(CLASSES.Dashboard)
40+
private readonly dashboard: Dashboard,
41+
@inject(CLASSES.UserPreferences)
42+
private readonly userPreferences: UserPreferences
43+
) {}
44+
45+
async openAddContainerRegistryDialog(): Promise<void> {
46+
Logger.debug();
47+
48+
await this.driverHelper.waitAndClick(ContainerRegistries.OPEN_ADD_REGISTRY_DIALOG_BUTTON);
49+
await this.driverHelper.waitVisibility(ContainerRegistries.ADD_REGISTRY_DIALOG);
50+
}
51+
52+
async addContainerRegistry(registryUrl: string, username: string, password: string): Promise<void> {
53+
Logger.debug(`registryUrl: "${registryUrl}", username: "${username}"`);
54+
55+
await this.userPreferences.openUserPreferencesPage();
56+
await this.userPreferences.openContainerRegistriesTab();
57+
await this.deleteContainerRegistryIfExists(registryUrl);
58+
await this.openAddContainerRegistryDialog();
59+
await this.driverHelper.enterValue(ContainerRegistries.REGISTRY_URL_INPUT, registryUrl);
60+
await this.driverHelper.enterValue(ContainerRegistries.USERNAME_INPUT, username);
61+
await this.driverHelper.enterValue(ContainerRegistries.PASSWORD_INPUT, password);
62+
await this.driverHelper.waitAndClick(ContainerRegistries.ADD_REGISTRY_BUTTON);
63+
64+
const attempts: number = Math.ceil(
65+
TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT / TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
66+
);
67+
await this.driverHelper.waitDisappearance(
68+
ContainerRegistries.ADD_REGISTRY_DIALOG,
69+
attempts,
70+
TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
71+
);
72+
}
73+
74+
async waitContainerRegistryListItem(
75+
registryUrl: string,
76+
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
77+
): Promise<void> {
78+
Logger.debug(`"${registryUrl}"`);
79+
80+
await this.driverHelper.waitVisibility(this.getContainerRegistryListItemLocator(registryUrl), timeout);
81+
}
82+
83+
async clickActionsButton(registryUrl: string): Promise<void> {
84+
Logger.debug(`of the '${registryUrl}' list item`);
85+
86+
await this.driverHelper.waitAndClick(this.getActionsLocator(registryUrl));
87+
}
88+
89+
async clickActionsDeleteButton(registryUrl: string): Promise<void> {
90+
Logger.debug(`for the '${registryUrl}' list item`);
91+
92+
await this.driverHelper.waitAndClick(ContainerRegistries.DELETE_REGISTRY_MENU_ITEM);
93+
}
94+
95+
async waitDeleteRegistryConfirmationWindow(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
96+
Logger.debug();
97+
98+
await this.driverHelper.waitVisibility(ContainerRegistries.DELETE_CONFIRMATION_WINDOW, timeout);
99+
}
100+
101+
async clickToDeleteConfirmationCheckbox(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
102+
Logger.debug();
103+
104+
await this.driverHelper.waitAndClick(ContainerRegistries.DELETE_CONFIRMATION_CHECKBOX, timeout);
105+
}
106+
107+
async waitAndClickEnabledConfirmationWindowDeleteButton(
108+
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
109+
): Promise<void> {
110+
Logger.debug();
111+
112+
await this.driverHelper.waitAndClick(ContainerRegistries.DELETE_REGISTRY_BUTTON_ENABLED, timeout);
113+
}
114+
115+
async deleteContainerRegistryByActionsButton(
116+
registryUrl: string,
117+
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
118+
): Promise<void> {
119+
Logger.debug(`"${registryUrl}"`);
120+
121+
await this.waitContainerRegistryListItem(registryUrl, timeout);
122+
await this.clickActionsButton(registryUrl);
123+
await this.clickActionsDeleteButton(registryUrl);
124+
await this.waitDeleteRegistryConfirmationWindow(timeout);
125+
await this.clickToDeleteConfirmationCheckbox(timeout);
126+
await this.waitAndClickEnabledConfirmationWindowDeleteButton(timeout);
127+
}
128+
129+
async deleteContainerRegistry(registryUrl: string): Promise<void> {
130+
Logger.debug(`"${registryUrl}"`);
131+
132+
await this.dashboard.openDashboard();
133+
await this.browserTabsUtil.closeAllTabsExceptCurrent();
134+
await this.userPreferences.openUserPreferencesPage();
135+
await this.userPreferences.openContainerRegistriesTab();
136+
await this.deleteContainerRegistryIfExists(registryUrl);
137+
}
138+
139+
async deleteContainerRegistryIfExists(
140+
registryUrl: string,
141+
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
142+
): Promise<void> {
143+
Logger.debug(`"${registryUrl}"`);
144+
145+
const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
146+
const attempts: number = Math.ceil(timeout / polling);
147+
const isPresent: boolean = await this.driverHelper.waitVisibilityBoolean(
148+
this.getContainerRegistryListItemLocator(registryUrl),
149+
attempts,
150+
polling
151+
);
152+
153+
if (!isPresent) {
154+
Logger.info(`Container registry "${registryUrl}" does not exist`);
155+
return;
156+
}
157+
158+
await this.deleteContainerRegistryByActionsButton(registryUrl, timeout);
159+
await this.waitContainerRegistryListItemAbsence(registryUrl, timeout);
160+
}
161+
162+
async waitContainerRegistryListItemAbsence(
163+
registryUrl: string,
164+
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
165+
): Promise<void> {
166+
Logger.debug(`"${registryUrl}"`);
167+
168+
const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
169+
const attempts: number = Math.ceil(timeout / polling);
170+
171+
await this.driverHelper.waitDisappearance(this.getContainerRegistryListItemLocator(registryUrl), attempts, polling);
172+
}
173+
174+
private getContainerRegistryListItemLocator(registryUrl: string): By {
175+
return By.xpath(`//table[@aria-label='Container credentials']//tr[td[@data-label='Host' and normalize-space(.)='${registryUrl}']]`);
176+
}
177+
178+
private getActionsLocator(registryUrl: string): By {
179+
return By.xpath(`${this.getContainerRegistryListItemLocator(registryUrl).value}//button[@aria-label='Actions']`);
180+
}
181+
}

0 commit comments

Comments
 (0)