Skip to content

Commit

Permalink
feat(System): new regexp shortname [YTFRONT-4386]
Browse files Browse the repository at this point in the history
  • Loading branch information
SimbiozizV committed Oct 16, 2024
1 parent a7462da commit e5409f6
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const cfg: Partial<CustomAppConfig> = {
reHashFromNodeVersion: '[^~]+~(?<hash>[^+]+)',

reShortNameFromAddress: '(?<shortname>.*)(\\.[^.]+)(\\.yt\\.my\\.domain)',
reShortNameSystemPage: '(?<shortname>.*)(\\.[^.]+)(\\.yt\\.my\\.domain)',
reShortNameFromTabletNodeAddress: '(?<shortname>[^-]+-[^-]+).*',

reUnipikaAllowTaggedSources: [
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/server/configs/e2e/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const e2eConfig: Partial<AppConfig> = {
},

reShortNameFromAddress: '(?<shortname>^(loca)).*(?<suffix>:\\d\\d\\d)',
reShortNameSystemPage: '(?<shortname>^(local))',
reShortNameFromTabletNodeAddress: '(?<shortname>^(local))[^:]+(?<suffix>:\\d\\d)',

reUnipikaAllowTaggedSources: ['^https://yastatic\\.net/'],
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/src/shared/ui-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ export interface UISettings {
*/
reShortNameFromTabletNodeAddress?: string;

/**
* Allows you to override the behavior of 'reShortNameSystemPage ` for masters / providers / schedulers / agents.
* @example reShortNameSystemPage: '(?<shortname>.*)((\\.msk\\.my-domain\\.ru)|(\\.vla\\.my-domain\\.net))'
*/
reShortNameSystemPage?: string;

/**
* Allows to define array of regexps for allowed urls of TaggedType of unipika to display media-content (audio/video/images).
* If there are no matched items in the array the TaggedType-item will be displayed as a json-object.
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/ui/pages/system/Masters/MasterGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import map_ from 'lodash/map';

import './MasterGroup.scss';
import {ChangeMaintenanceButton} from './ChangeMaintenanceButton';
import {calcShortNameByRegExp} from '../../../containers/Host/Host';
import {makeShortSystemAddress} from '../helpers/makeShortSystemAddress';

const b = block('master-group');

Expand Down Expand Up @@ -107,7 +107,7 @@ class Instance extends Component {
<div className={b('host')}>
<Tooltip content={addressWithoutPort}>
<div className={b('host-name')}>
{calcShortNameByRegExp(addressWithoutPort) || addressWithoutPort}
{makeShortSystemAddress(addressWithoutPort) || addressWithoutPort}
</div>
</Tooltip>
<Flex gap={1}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import NodeQuad from '../../NodeQuad/NodeQuad';

import '../Schedulers.scss';
import {ChangeMaintenanceButton} from '../../Masters/ChangeMaintenanceButton';
import {calcShortNameByRegExp} from '../../../../containers/Host/Host';
import {makeShortSystemAddress} from '../../helpers/makeShortSystemAddress';

const b = block('system');

Expand Down Expand Up @@ -47,7 +47,7 @@ export default function Scheduler({host, state, maintenanceMessage, type}: Sched
<div title={address} className={b('scheduler-host')}>
<Tooltip content={address}>
<div className={b('scheduler-host-address')}>
{calcShortNameByRegExp(address) || address}
{makeShortSystemAddress(address) || address}
</div>
</Tooltip>
<div className={b('scheduler-host-btn')}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {makeRegexpFromSettings} from '../../../../shared/utils';
import {uiSettings} from '../../../config/ui-settings';

const reShortNameSystemPage = makeRegexpFromSettings(uiSettings.reShortNameSystemPage);

export const makeShortSystemAddress = (address: string): string | undefined => {
const res = reShortNameSystemPage?.exec(address);
return res?.groups?.shortname;
};
20 changes: 20 additions & 0 deletions packages/ui/tests/e2e/pages/system.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {expect, test} from '@playwright/test';
import {makeClusterUrl} from '../../utils';

test('System: check short name', async ({page}) => {
const url = makeClusterUrl(`system/general`);
await page.goto(url);

await page.waitForSelector('.system');
await page.evaluate(() => {
const allMastersContainer = document.querySelector('.system-master__all-masters');
if (!allMastersContainer) {
const button = document.querySelector<HTMLSpanElement>('.collapsible-section__title');
if (button) button.click();
}
});

const mastersNameElements = await page.$$('.master-group__host-name');
const firstMasterName = await mastersNameElements[0].innerText();

Check failure on line 18 in packages/ui/tests/e2e/pages/system.spec.ts

View workflow job for this annotation

GitHub Actions / E2E for 'Local as remote'

[chromium] › pages/system.spec.ts:4:5 › System: check short name

1) [chromium] › pages/system.spec.ts:4:5 › System: check short name ────────────────────────────── TypeError: Cannot read properties of undefined (reading 'innerText') 16 | 17 | const mastersNameElements = await page.$$('.master-group__host-name'); > 18 | const firstMasterName = await mastersNameElements[0].innerText(); | ^ 19 | expect(firstMasterName).toEqual('local'); 20 | }); 21 | at /actions-runner/_work/ytsaurus-ui/ytsaurus-ui/packages/ui/tests/e2e/pages/system.spec.ts:18:58
expect(firstMasterName).toEqual('local');
});

0 comments on commit e5409f6

Please sign in to comment.