Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/convert_v4_mirror.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ keeps the name, and each of the others gets a suffix ``-import-<id>``, where

The resulting names must be unique and valid v5 names, otherwise it is an error.

A machine whose name had a ``/`` or a ``%`` replaced gets a display name, which
is how the v5 web UI shows it: its v4 name, followed by the same suffix as its
v5 name if it has one. For example, v4 machines with IDs ``352`` and ``372``,
both named ``x86_64/O3``, become ``x86_64_O3``, shown as ``x86_64/O3``, and
``x86_64_O3-import-372``, shown as ``x86_64/O3-import-372``. A display name
need not be unique, but the suffix keeps duplicates apart. Other machines get no
display name.

Commits
~~~~~~~

Expand Down Expand Up @@ -156,6 +164,7 @@ With ``--schema-out FILE``, it also writes the target suite's schema to
``FILE``. The schema's ``name`` is the one given with ``--target-suite``, or the
mirrored suite's name by default.

The command reports on its standard error which machines it renamed, and every
run that cannot be converted, and carries on with the next run. It exits with a
non-zero status if any run cannot be converted.
The command reports on its standard error which machines it renamed, with
their display names, and every run that cannot be converted, and carries on
with the next run. It exits with a non-zero status if any run cannot be
converted.
27 changes: 17 additions & 10 deletions lnt/util/convert_v4_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
# one of the machine table, and a commit field one of the commit table. Keep
# in sync with v5/server/src/lnt_v5/suites/schema.py.
_METRIC_BUILTINS = {'run_id', 'test_id', 'repetition', 'machine_id'}
_MACHINE_FIELD_BUILTINS = {'id', 'name', 'tracked', 'first_seen_at',
'delete_after_inactive_days'}
_MACHINE_FIELD_BUILTINS = {'id', 'name', 'display_name', 'tracked',
'first_seen_at', 'delete_after_inactive_days'}
_COMMIT_FIELD_BUILTINS = {'id', 'commit', 'ordinal', 'tag', 'first_seen_at',
'delete_after_inactive_days'}

Expand Down Expand Up @@ -392,9 +392,8 @@ def _name_machines(mirrored: MirroredSuite,
v5_name = v4_name.replace('/', '_').replace('%', '_')
# The oldest machine of a name keeps it.
for i, machine_id in enumerate(ids):
name = v5_name
if i > 0:
name += DUPLICATE_SUFFIX % machine_id
suffix = DUPLICATE_SUFFIX % machine_id if i > 0 else ''
name = v5_name + suffix
fields = {}
for key, value in mirrored.machines[machine_id].items():
if key in _MACHINE_KEYS_DROPPED or value is None:
Expand All @@ -404,8 +403,13 @@ def _name_machines(mirrored: MirroredSuite,
'value for field %r'
% (machine_id, v4_name, value, key))
fields[key] = value
machines[machine_id] = {'name': name, 'tracked': False,
'fields': fields}
machine: JSONObject = {'name': name, 'tracked': False,
'fields': fields}
# Shown as it was in v4, with the suffix that tells duplicates
# apart.
if v5_name != v4_name:
machine['display_name'] = v4_name + suffix
machines[machine_id] = machine

owners: dict[str, list[str]] = collections.defaultdict(list)
for machine_id, machine in machines.items():
Expand Down Expand Up @@ -683,9 +687,12 @@ def convert(mirror_dir: str, suite: str, out: TextIO,
', from --schema' if override is not None else ''))
for machine_id in sorted(plan.machines, key=int):
v4_name = mirrored.machines[machine_id]['name']
if plan.machines[machine_id]['name'] != v4_name:
echo(' machine %s (%s) is renamed %r'
% (machine_id, v4_name, plan.machines[machine_id]['name']))
machine = plan.machines[machine_id]
if machine['name'] != v4_name:
shown = (', shown as %r' % machine['display_name']
if 'display_name' in machine else '')
echo(' machine %s (%s) is renamed %r%s'
% (machine_id, v4_name, machine['name'], shown))
ordered = sum(1 for value in plan.ordinals.values() if value is not None)
echo('Commits: %d, of which %d have an ordinal'
% (len(plan.ordinals), ordered))
Expand Down
21 changes: 17 additions & 4 deletions tests/lnttool/convert-v4-mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,33 @@ def dump(value):
# ---------------------------------------------------------------------------
print('# MACHINE NAMES')
# Among machines of the same name, the one with the lowest identifier keeps
# it. A "/" or a "%" becomes "_".
# it. A "/" or a "%" becomes "_". A machine whose name changed for either
# reason other than a suffix alone is shown by its v4 name, with its suffix.
D = [{'id': i, 'name': 'dup'} for i in (4, 9, 7)]
S = {'id': 5, 'name': 'with/slash'}
P = {'id': 6, 'name': 'build%2Fmain'}
names = make_mirror('names', [(m, []) for m in D + [S, P]])
S2 = {'id': 8, 'name': 'with/slash'}
names = make_mirror('names', [(m, []) for m in D + [S, P, S2]])
run_cli(names, '--suite', 'nts')
dump({machine_id: machine.get('display_name') for machine_id, machine
in make_plan(read_mirror(names, 'nts'), 'nts').machines.items()})
# The target suite has the mirrored suite's name by default.
# CHECK-LABEL: # MACHINE NAMES
# CHECK-NEXT: Converting suite 'nts' of http://v4.example.com (database 'default') into suite 'nts'
# CHECK: machine 5 (with/slash) is renamed 'with_slash'
# CHECK-NEXT: machine 6 (build%2Fmain) is renamed 'build_2Fmain'
# CHECK: machine 5 (with/slash) is renamed 'with_slash', shown as 'with/slash'
# CHECK-NEXT: machine 6 (build%2Fmain) is renamed 'build_2Fmain', shown as 'build%2Fmain'
# CHECK-NEXT: machine 7 (dup) is renamed 'dup-import-7'
# CHECK-NEXT: machine 8 (with/slash) is renamed 'with_slash-import-8', shown as 'with/slash-import-8'
# CHECK-NEXT: machine 9 (dup) is renamed 'dup-import-9'
# CHECK: exit: 0
# CHECK-NEXT: {
# CHECK-NEXT: "4": null,
# CHECK-NEXT: "5": "with/slash",
# CHECK-NEXT: "6": "build%2Fmain",
# CHECK-NEXT: "7": null,
# CHECK-NEXT: "8": "with/slash-import-8",
# CHECK-NEXT: "9": null
# CHECK-NEXT: }

# Names that end up the same, or that v5 does not accept, are errors.
clash = make_mirror('clash', [
Expand Down
44 changes: 33 additions & 11 deletions v5/client/src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ export interface paths {
head?: never;
/**
* Update a machine
* @description Rename a machine, change whether it is tracked or when it is deleted, or set or clear its
* fields.
* @description Rename a machine, set or clear its display name, change whether it is tracked or when it is
* deleted, or set or clear its fields.
*
* Only include what you want to change. If you change a field here, later run submissions that
* still send the old value are rejected with a 409 `conflict` until they are updated. If you
Expand Down Expand Up @@ -1734,6 +1734,12 @@ export interface components {
* @example linux-x86_64
*/
name: string;
/**
* Display Name
* @description How the web UI names the machine, instead of its `name`. Not empty, and at most 256 characters; unlike the name, it can contain '/' and '%'. Several machines can have the same display name. Only the name addresses the machine in the API. Null if there is none. A run submission only sets this when it creates the machine; use PATCH to change it afterwards.
* @example Linux / x86-64
*/
display_name: string | null;
/**
* Tracked
* @description Whether the machine is picked automatically, for example when a dashboard chooses which machines to show. Untracked machines are still listed and usable as usual.
Expand All @@ -1755,7 +1761,8 @@ export interface components {
* MachineField
* @description A piece of information a machine can have in its `fields`, such as its operating system.
*
* The name can't be `id`, `name`, `tracked`, `first_seen_at` or `delete_after_inactive_days`.
* The name can't be `id`, `name`, `tracked`, `display_name`, `first_seen_at` or
* `delete_after_inactive_days`.
* @example {
* "display_name": null,
* "listed": true,
Expand Down Expand Up @@ -1814,7 +1821,8 @@ export interface components {
* MachineFieldInput
* @description A piece of information a machine can have in its `fields`, such as its operating system.
*
* The name can't be `id`, `name`, `tracked`, `first_seen_at` or `delete_after_inactive_days`.
* The name can't be `id`, `name`, `tracked`, `display_name`, `first_seen_at` or
* `delete_after_inactive_days`.
* @example {
* "display_name": null,
* "listed": true,
Expand Down Expand Up @@ -1888,7 +1896,8 @@ export interface components {
};
/**
* MachineObject
* @description A machine: its name, whether it is tracked, when it is deleted, and its fields.
* @description A machine: its name, its display name, whether it is tracked, when it is deleted, and its
* fields.
*/
MachineObject: {
/**
Expand All @@ -1904,6 +1913,12 @@ export interface components {
* @example linux-x86_64
*/
name: string;
/**
* Display Name
* @description How the web UI names the machine, instead of its `name`. Not empty, and at most 256 characters; unlike the name, it can contain '/' and '%'. Several machines can have the same display name. Only the name addresses the machine in the API. Null if there is none. A run submission only sets this when it creates the machine; use PATCH to change it afterwards.
* @example Linux / x86-64
*/
display_name?: string | null;
/**
* Tracked
* @description Whether the machine is picked automatically, for example when a dashboard chooses which machines to show. Untracked machines are still listed and usable as usual.
Expand All @@ -1920,8 +1935,8 @@ export interface components {
/**
* MachineUpdate
* @description Changes to a machine. Only include what you want to change; this also applies to the keys
* of `fields`. Set a field or `delete_after_inactive_days` to null to clear it. Set `name` to
* rename the machine. `name` and `tracked` can't be null.
* of `fields`. Set a field, `display_name` or `delete_after_inactive_days` to null to clear it.
* Set `name` to rename the machine. `name` and `tracked` can't be null.
*/
MachineUpdate: {
/**
Expand All @@ -1937,6 +1952,12 @@ export interface components {
* @example linux-x86_64
*/
name?: string;
/**
* Display Name
* @description How the web UI names the machine, instead of its `name`. Not empty, and at most 256 characters; unlike the name, it can contain '/' and '%'. Several machines can have the same display name. Only the name addresses the machine in the API. Null if there is none. A run submission only sets this when it creates the machine; use PATCH to change it afterwards.
* @example Linux / x86-64
*/
display_name?: string | null;
/**
* Tracked
* @description Whether the machine is picked automatically, for example when a dashboard chooses which machines to show. Untracked machines are still listed and usable as usual.
Expand Down Expand Up @@ -2946,8 +2967,9 @@ export interface components {
* must agree with what is stored: fields, ordinal and tag that have no value yet are filled in,
* but a value that differs from the stored one is rejected with a 409 `conflict`. Use `PATCH` to
* change stored values. Keys you leave out, or set to null, aren't checked. The exceptions are
* the machine's `tracked` and the `delete_after_inactive_days` of the machine and the commit,
* which are only used when the machine or the commit is created, and ignored otherwise.
* the machine's `display_name` and `tracked`, and the `delete_after_inactive_days` of the machine
* and the commit, which are only used when the machine or the commit is created, and ignored
* otherwise.
*/
RunSubmission: {
/**
Expand Down Expand Up @@ -4438,7 +4460,7 @@ export interface operations {
list_machines: {
parameters: {
query?: {
/** @description Only return machines whose name, or any searchable field, contains this text. Not case-sensitive. */
/** @description Only return machines whose name, display name or any searchable field contains this text. Not case-sensitive. */
search?: string | null;
/** @description Only return tracked machines (`true`) or untracked ones (`false`). Leave out to return both. */
tracked?: boolean | null;
Expand Down Expand Up @@ -5221,7 +5243,7 @@ export interface operations {
query?: {
/** @description To get the next page, set this to `cursor.next` from the previous response, and keep the other parameters the same (except `limit`). Omit it to get the first page. If it is rejected with `invalid_cursor`, start again from the first page. */
cursor?: string | null;
/** @description Only return runs whose machine (its name or any searchable field) or commit (its value, its tag or any searchable field) contains this text, or whose UUID starts with it. Not case-sensitive. */
/** @description Only return runs whose machine (its name, its display name or any searchable field) or commit (its value, its tag or any searchable field) contains this text, or whose UUID starts with it. Not case-sensitive. */
search?: string | null;
/** @description Only return runs on this machine. Returns 404 if the machine doesn't exist. */
machine?: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('nameProblems', () => {
for (const name of ['id', 'commit', 'ordinal', 'tag']) {
expect(problemOf('commit_fields', name)).toBeDefined()
}
for (const name of ['id', 'name', 'tracked']) {
for (const name of ['id', 'name', 'tracked', 'display_name']) {
expect(problemOf('machine_fields', name)).toBeDefined()
}
// Compared exactly: D4 makes names case-sensitive.
Expand Down
9 changes: 8 additions & 1 deletion v5/client/src/pages/test-suites/schema/schema-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ export const LIST_INFO: Record<ListName, ListInfo> = {
noun: 'machine field',
keys: ['display_name', 'searchable', 'listed'],
type: 'text',
reserved: ['delete_after_inactive_days', 'first_seen_at', 'id', 'name', 'tracked'],
reserved: [
'delete_after_inactive_days',
'display_name',
'first_seen_at',
'id',
'name',
'tracked',
],
},
}

Expand Down
1 change: 1 addition & 0 deletions v5/client/src/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function machine(
): Schemas['Machine'] {
return {
name,
display_name: null,
tracked: true,
delete_after_inactive_days: null,
fields: { hardware: null, os: null, core_count: null },
Expand Down
6 changes: 3 additions & 3 deletions v5/docs/design/client/test-suites.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ path and params to restore state. On changes, updates the URL.
| Tab | Content | API | Search/Filter |
|-----|---------|-----|---------------|
| Runs | Run list with cursor pagination, most recently submitted first | `GET runs?search=...&sort=-submitted_at&limit=25` | Machine, commit or UUID prefix (see O4) |
| Machines | Every machine, by name | `GET machines?search=...` | Substring match on machine name and searchable machine fields |
| Machines | Every machine, by name | `GET machines?search=...` | Substring match on machine name, display name and searchable machine fields |
| Commits | Commit list with cursor pagination, most recently seen first | `GET commits?search=...&sort=-first_seen&limit=25` | Substring match on commit, tag and searchable commit fields |
| Regressions | Full regression triage interface (see below) | `GET regressions?state=...&machine=...&metric=...&has_commit=...&search=...&sort=-created_at&limit=25` | State chips, machine combobox, metric selector, "No commit set" checkbox, title or UUID prefix search |
| Schema | The suite's schema, its export, editing, renaming, moving and deletion (see TS6 and TS7) | `GET /api/projects` (E13); writes in TS6 and TS7 | -- |
Expand Down Expand Up @@ -105,8 +105,8 @@ are listed regardless of `tracked`, by name; the badge is informational, marking
that are excluded from the Dashboard's trend overview and listed last in machine pickers (see
AR18). Hovering the badge explains that.

Above the table, a `Search machines...` box searches the machines by name and searchable fields
(see O4).
Above the table, a `Search machines...` box searches the machines by name, display name and
searchable fields (see O4).

## TS4: Commits tab

Expand Down
9 changes: 7 additions & 2 deletions v5/docs/design/server/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,17 @@ and the tables below are named that way.
|--------|------|-------------|
| id | INTEGER | PK |
| name | VARCHAR(256) | unique, not null |
| display_name | VARCHAR(256) | nullable |
| tracked | BOOLEAN | not null, default `true` |
| first_seen_at | TIMESTAMP WITH TIME ZONE | not null, default `now()` |
| delete_after_inactive_days | INTEGER | nullable, between 1 and 36500 |
| _(dynamic)_ | per machine_fields | nullable |

- `name` is unique.
- `display_name` is how the UI names the machine when it is set. The API never
addresses the machine by it; only `name` does. It follows the rules of a
suite's `display_name` (D4). It never appears in a path, so unlike the name,
it may contain `/` or `%` (see I1), and it is not unique.
- A suite is expected to have few machines: at most a few thousand, retired ones
included. The machine list (E2) is not paginated, and `last_run_at` (below) is
computed per machine, on that assumption.
Expand All @@ -595,8 +600,8 @@ and the tables below are named that way.
the type-to-column mapping). Keys submitted for a machine that are not
declared as `machine_fields` are rejected (see O1).
- `machine_fields` names must not collide with the built-in column names
(`id`, `name`, `tracked`, `first_seen_at`, `delete_after_inactive_days`); the
schema parser rejects them.
(`id`, `name`, `display_name`, `tracked`, `first_seen_at`,
`delete_after_inactive_days`); the schema parser rejects them.
- `last_run_at` is not a column. It is the latest `measured_at` among the
machine's runs, or null if the machine has no runs, computed when read; the
machine endpoints return it and can sort on it. It is deliberately not
Expand Down
Loading
Loading