Skip to content

Commit

Permalink
chore(tests/screenshots): add tests for Scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-efremoff committed Jun 19, 2024
1 parent fc25ad4 commit b0066eb
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/ui/scripts/dev.localmode-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if [ $? -ne 0 ]; then
echo -e "\n\nrun_local_cluster.sh is downloaded, to run your cluster use command:"

command="./run_local_cluster.sh --yt-version dev --docker-hostname $(hostname) --fqdn localhost --node-count 2 --ui-app-installation ${APP_INSTALLATION:-''}"
if [ "$SKIP_PULL" != "" ]; then
command="$command --ui-skip-pull true --yt-skip-pull true"
fi

if [ "$UI_VERSION_LOCAL" != "" ]; then
docker tag $(npm run -s show:docker-image-name):local $(npm run -s show:docker-image-name:stable):local
command="$command --ui-version $UI_VERSION_LOCAL --ui-skip-pull true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import {Page, expect, test} from '@playwright/test';
import {makeClusterUrl} from '../../../utils';
import {BasePage} from '../../../utils/BasePage';
import {replaceInnerHtml} from '../../../utils/dom';

class Scheduling extends BasePage {
async waitForLoadedPool() {
await this.page.waitForSelector('.elements-table__row :text("yt-e2e-pool-1")');
}

async setDetailsMode(
mode: 'CPU' | 'Memory' | 'GPU' | 'User slots' | 'Operations' | 'Integral guarantees',
) {
await this.page.click(`.scheduling-details__toolbar :text("${mode}")`, {force: true});
}

async replaceEstimatedGuarantee(type: 'cpu' | 'memory') {
await replaceInnerHtml(this.page, {
[`tbody .scheduling-details__table-item_type_abs-guaranteed-${type}`]: '0.00',
});
}

async showPoolEditor(pool: string) {
const editBtn = await this.page.getByTitle(`edit pool ${pool}`);
await editBtn.scrollIntoViewIfNeeded();
await editBtn.click();
}
}

const scheduling = (page: Page) => new Scheduling({page});

test('Scheduling - Overview', async ({page}) => {
await page.goto(makeClusterUrl(`scheduling/overview?pool=yt-e2e-pool-1&tree=default`));

await scheduling(page).waitForLoadedPool();

await expect(page).toHaveScreenshot();
});

test('Scheduling - ACL', async ({page}) => {
await page.goto(makeClusterUrl(`scheduling/acl?pool=yt-e2e-pool-1&tree=default`));

await scheduling(page).waitForACL();

await expect(page).toHaveScreenshot();
});

test('Scheduling - Details', async ({page}) => {
await page.goto(
makeClusterUrl(`scheduling/details?pool=yt-e2e-pool-1&tree=default&contentMode=cpu`),
);

await scheduling(page).waitForLoadedPool();

await test.step('CPU', async () => {
await scheduling(page).replaceEstimatedGuarantee('cpu');
await expect(page).toHaveScreenshot();
});

await test.step('Memory', async () => {
await scheduling(page).setDetailsMode('Memory');
await scheduling(page).replaceEstimatedGuarantee('memory');
await expect(page).toHaveScreenshot();
});

await test.step('GPU', async () => {
await scheduling(page).setDetailsMode('GPU');
await expect(page).toHaveScreenshot();
});

await test.step('User slots', async () => {
await scheduling(page).setDetailsMode('User slots');
await expect(page).toHaveScreenshot();
});

await test.step('Operations', async () => {
await scheduling(page).setDetailsMode('Operations');
await expect(page).toHaveScreenshot();
});

await test.step('Integral guarantees', async () => {
await scheduling(page).setDetailsMode('Integral guarantees');
await expect(page).toHaveScreenshot();
});
});

test('Scheduling - Editor', async ({page}) => {
await page.goto(
makeClusterUrl(`scheduling/details?pool=yt-e2e-pool-1&tree=default&contentMode=cpu`),
);

await scheduling(page).showPoolEditor('yt-e2e-pool-1');

await test.step('General', async () => {
await scheduling(page).dfDialog.waitForField('Max running operation count');

await expect(page).toHaveScreenshot();
});

await test.step('Strong Guarantee', async () => {
await scheduling(page).dfDialog.showTab('Strong Guarantee');
await scheduling(page).dfDialog.waitForField('CPU');

await expect(page).toHaveScreenshot();
});

await test.step('Integral Guarantee', async () => {
await scheduling(page).dfDialog.showTab('Integral Guarantee');
await scheduling(page).dfDialog.waitForField('Burst CPU');

await expect(page).toHaveScreenshot();
});

await test.step('Resource limits', async () => {
await scheduling(page).dfDialog.showTab('Resource limits');
await scheduling(page).dfDialog.waitForField('User slots');

await expect(page).toHaveScreenshot();
});

await test.step('Other settings', async () => {
await scheduling(page).dfDialog.showTab('Other settings');
await scheduling(page).dfDialog.waitForField('Create ephemeral subpools');

await expect(page).toHaveScreenshot();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions packages/ui/tests/utils/BasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@ import {Page} from '@playwright/test';
import {replaceInnerHtml} from './dom';
import {E2E_DIR_NAME} from '.';

class DFDialogComponent {
readonly page;

constructor(page: Page) {
this.page = page;
}

async showTab(name: string) {
await this.page.click(`.df-dialog-tab__name :text("${name}")`);
await this.page.mouse.move(0, 0);
}

async waitForField(title: string) {
await this.page.waitForSelector(`.df-dialog__label :text("${title}")`);
}
}

export class BasePage {
readonly page: Page;
readonly dfDialog: DFDialogComponent;

constructor({page}: {page: Page}) {
this.page = page;
this.dfDialog = new DFDialogComponent(page);
}

async waitForTable(selector: string, rowCount: number) {
Expand All @@ -22,4 +41,8 @@ export class BasePage {
async replaceBreadcrumbsTestDir() {
await this.replaceBreadcrumbsByTitle(E2E_DIR_NAME, 'e2e.1970-01-01.00:00:00.xxxxxxxxxxx');
}

async waitForACL() {
await this.page.waitForSelector('.navigation-acl__row .yt-subject-link');
}
}

0 comments on commit b0066eb

Please sign in to comment.