Skip to content

Commit 97ef36d

Browse files
store/cockpit: delete cloud config
The image-builder cli handles the the available target clouds based on environment variables set on the host. For example, if configs and credentials exist in `~/.aws`, then aws image types will be surfaced as available image types. We will need a way to provide the image-build with the name of the aws bucket, so we need to add this as an option in the AWS step of the wizard.
1 parent bdf7414 commit 97ef36d

File tree

29 files changed

+277
-826
lines changed

29 files changed

+277
-826
lines changed

.github/workflows/unit-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ jobs:
3838
cockpit-unit-tests:
3939
name: Cockpit Tests
4040
runs-on: ubuntu-latest
41+
container:
42+
image: registry.fedoraproject.org/fedora:42
4143
steps:
4244
- uses: actions/checkout@v4
4345
- name: Use Node.js 22
4446
uses: actions/setup-node@v4
4547
with:
4648
node-version: 22
4749
cache: 'npm'
50+
- name: 'Install image builder'
51+
run: 'dnf install -y image-builder'
4852
- name: Install dependencies
4953
run: npm ci
5054
- name: Run unit tests with cockpit

playwright/test.spec.ts

Lines changed: 5 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
import { readFileSync, writeFileSync } from 'node:fs';
2-
import os from 'node:os';
3-
import path from 'node:path';
4-
5-
import TOML from '@ltd/j-toml';
61
import { expect, test } from '@playwright/test';
72
import { v4 as uuidv4 } from 'uuid';
83

94
import { closePopupsIfExist, isHosted } from './helpers/helpers';
105
import { ensureAuthenticated } from './helpers/login';
116
import { ibFrame, navigateToLandingPage } from './helpers/navHelpers';
127

13-
const awsCredentials = `
14-
[default]
15-
aws_access_key_id = supersecret
16-
aws_secret_access_key = secretsquirrel
17-
`;
18-
198
test.describe.serial('test', () => {
209
const blueprintName = uuidv4();
2110
test('create blueprint', async ({ page }) => {
@@ -191,96 +180,12 @@ test.describe.serial('test', () => {
191180
await frame.getByRole('button', { name: 'Delete' }).click();
192181
});
193182

194-
test('cockpit worker config', async ({ page }) => {
195-
if (isHosted()) {
196-
return;
197-
}
198-
199-
await ensureAuthenticated(page);
200-
await closePopupsIfExist(page);
201-
// Navigate to IB landing page and get the frame
202-
await navigateToLandingPage(page);
203-
await page.goto('/cockpit-image-builder');
204-
const frame = ibFrame(page);
205-
206-
const header = frame.getByText('Configure AWS Uploads');
207-
if (!(await header.isVisible())) {
208-
await frame
209-
.getByRole('button', { name: 'Configure Cloud Providers' })
210-
.click();
211-
await expect(header).toBeVisible();
212-
}
213-
214-
const bucket = 'cockpit-ib-playwright-bucket';
215-
const credentials = '/test/credentials';
216-
const switchInput = frame.locator('#aws-config-switch');
217-
await expect(switchInput).toBeVisible();
218-
219-
// introduce a wait time, since it takes some time to load the
220-
// worker config file.
221-
await page.waitForTimeout(1000);
222-
223-
// If this test fails for any reason, the config should already be loaded
224-
// and visible on the retury. If it is go back to the landing page
225-
if (await switchInput.isChecked()) {
226-
await frame.getByRole('button', { name: 'Cancel' }).click();
227-
await expect(
228-
frame.getByRole('heading', { name: 'All images' }),
229-
).toBeVisible();
230-
} else {
231-
const switchToggle = frame.locator('.pf-v6-c-switch');
232-
await switchToggle.click();
233-
234-
await frame
235-
.getByPlaceholder('AWS bucket')
236-
// this doesn't need to exist, we're just testing that
237-
// the form works as expected
238-
.fill(bucket);
239-
await frame.getByPlaceholder('Path to AWS credentials').fill(credentials);
240-
await frame.getByRole('button', { name: 'Submit' }).click();
241-
await expect(
242-
frame.getByRole('heading', { name: 'All images' }),
243-
).toBeVisible();
244-
}
245-
246-
await frame
247-
.getByRole('button', { name: 'Configure Cloud Providers' })
248-
.click();
249-
await expect(header).toBeVisible();
250-
251-
// introduce a wait time, since it takes some time to load the
252-
// worker config file.
253-
await page.waitForTimeout(1500);
254-
255-
await expect(frame.locator('#aws-config-switch')).toBeChecked();
256-
257-
await expect(frame.getByPlaceholder('AWS bucket')).toHaveValue(bucket);
258-
await expect(frame.getByPlaceholder('Path to AWS credentials')).toHaveValue(
259-
credentials,
260-
);
261-
await frame.getByRole('button', { name: 'Cancel' }).click();
262-
263-
const config = readFileSync('/etc/osbuild-worker/osbuild-worker.toml');
264-
// this is for testing, the field `aws` should exist
265-
// eslint-disable-next-line
266-
const parsed = TOML.parse(config.toString()) as any;
267-
expect(parsed.aws?.bucket).toBe(bucket);
268-
expect(parsed.aws?.credentials).toBe(credentials);
269-
});
270-
271183
const cockpitBlueprintname = uuidv4();
272184
test('cockpit cloud upload', async ({ page }) => {
273185
if (isHosted()) {
274186
return;
275187
}
276188

277-
// this needs to be set so ibcli will list aws targets
278-
// as an available image type
279-
writeFileSync(
280-
path.join(os.homedir(), '.aws', 'credentials'),
281-
awsCredentials,
282-
);
283-
284189
await ensureAuthenticated(page);
285190
await closePopupsIfExist(page);
286191
// Navigate to IB landing page and get the frame
@@ -296,6 +201,11 @@ test.describe.serial('test', () => {
296201
// the first card should be the AWS card
297202
await frame.locator('.pf-v6-c-card').first().click();
298203
await frame.getByRole('button', { name: 'Next', exact: true }).click();
204+
await frame
205+
.getByPlaceholder('AWS bucket')
206+
// this doesn't need to exist, we're just testing that
207+
// the form works as expected
208+
.fill('some-random-bucket');
299209
await frame.getByRole('button', { name: 'Next', exact: true }).click();
300210
await frame.getByRole('button', { name: 'Review and finish' }).click();
301211
await frame.getByRole('button', { name: 'Back', exact: true }).click();

schutzbot/Containerfile-Playwright

Lines changed: 0 additions & 14 deletions
This file was deleted.

schutzbot/make_rpm_and_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44
source /etc/os-release
55

66
sudo dnf install -y \
7-
libappstream-glib
7+
libappstream-glib image-builder
88

99
if [[ "$ID" == rhel && ${VERSION_ID%.*} == 10 ]]; then
1010
sudo dnf install -y nodejs-npm \

schutzbot/playwright_tests.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ sudo useradd admin -p "$(openssl passwd foobar)"
2121
sudo usermod -aG wheel admin
2222
echo "admin ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee "/etc/sudoers.d/admin-nopasswd"
2323

24-
sudo podman build --tag playwright -f $(pwd)/schutzbot/Containerfile-Playwright .
25-
2624
function upload_artifacts {
2725
if [ -n "${TMT_TEST_DATA:-}" ]; then
2826
mv playwright-report "$TMT_TEST_DATA"/playwright-report
@@ -76,6 +74,13 @@ EOF
7674
sudo systemctl enable --now osbuild-composer.socket osbuild-local-worker.socket
7775
sudo systemctl start osbuild-worker@1
7876

77+
sudo mkdir -p $HOME/.aws
78+
cat <<EOF | sudo tee -a $HOME/.aws/credentials
79+
[default]
80+
aws_access_key_id = supersecret
81+
aws_secret_access_key = secretsquirrel
82+
EOF
83+
7984
sudo podman run \
8085
-e "PLAYWRIGHT_HTML_OPEN=never" \
8186
-e "CI=true" \
@@ -90,5 +95,5 @@ sudo podman run \
9095
--privileged \
9196
--rm \
9297
--init \
93-
localhost/playwright \
98+
mcr.microsoft.com/playwright:v1.51.1-noble \
9499
/bin/sh -c "cd tests && npx -y [email protected] test --workers=${PW_WORKERS}"

0 commit comments

Comments
 (0)