Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DIR-1444] [DIR-724] [DIR-1506] migrate to new instances api #1497

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
8e25c47
rename to instance API folder to _obsolete
stefan-kracht Apr 25, 2024
f6463ba
rename tree to tree_obsolete
stefan-kracht Apr 25, 2024
7b5ae69
delete unused schema
stefan-kracht Apr 25, 2024
8e2ba96
delete unused schema
stefan-kracht Apr 25, 2024
e8a0bbf
move and rename FileNameSchema
stefan-kracht Apr 25, 2024
ae174b1
add new createInstance api hook
stefan-kracht Apr 25, 2024
aee5f4a
use new create instance hook
stefan-kracht Apr 25, 2024
c6b96a0
update e2e test
stefan-kracht Apr 25, 2024
e35490d
remove old run workflow api
stefan-kracht Apr 25, 2024
2563913
Merge branch 'main' into stefankracht/dir-1444-migrate-to-new-instanc…
stefan-kracht Apr 25, 2024
2adf8ab
fix typo
stefan-kracht Apr 25, 2024
cf7e4bc
accidentally messed up name validation during refactoring
stefan-kracht Apr 25, 2024
2114466
add new cancel instance
stefan-kracht Apr 26, 2024
dc581dd
delete old cancel instance endpoint
stefan-kracht Apr 26, 2024
81f62f5
rename old cache keys
stefan-kracht Apr 26, 2024
28084cd
add minimal instance list call
stefan-kracht Apr 26, 2024
d7fd36f
skip the data attribute
stefan-kracht Apr 26, 2024
3e7f27d
update instance schema
stefan-kracht Apr 26, 2024
563e164
update buildSearchParamsString
stefan-kracht Apr 26, 2024
705d766
add limit and offset
stefan-kracht Apr 26, 2024
1220205
use new useInstanceList
stefan-kracht Apr 26, 2024
c3c40b7
change updatedAt to finishedAt
stefan-kracht Apr 26, 2024
35a039b
update schema
stefan-kracht Apr 26, 2024
2537004
update row
stefan-kracht Apr 26, 2024
c6c1d2a
add MinimalPagination
stefan-kracht Apr 26, 2024
df8b90e
use MinimalPagination
stefan-kracht Apr 26, 2024
a003e4d
add refetch instances button
stefan-kracht Apr 26, 2024
407c870
typo
stefan-kracht Apr 29, 2024
8443495
add instancesDetails to keys
stefan-kracht Apr 29, 2024
d293d8f
add blank InstancesDetailSchema
stefan-kracht Apr 29, 2024
b31fd31
add new useInstanceDetails
stefan-kracht Apr 29, 2024
cc827ba
skip data field
stefan-kracht Apr 29, 2024
c60675e
update schema
stefan-kracht Apr 29, 2024
7f117e5
add todo comment
stefan-kracht Apr 29, 2024
e41d143
update header to work with new API
stefan-kracht Apr 29, 2024
24a0093
change updatedAt to finished at
stefan-kracht Apr 29, 2024
482e58c
update schema import
stefan-kracht Apr 29, 2024
e2b39cb
update diagram to use v2 API
stefan-kracht Apr 29, 2024
1f62146
use v2 api to get isntance status
stefan-kracht Apr 29, 2024
855b6b8
add useInstanceInput
stefan-kracht Apr 29, 2024
b76354e
make new input endpoint work
stefan-kracht Apr 29, 2024
7df3b7b
make output work with v2 api
stefan-kracht Apr 29, 2024
c27ccca
update e2e test to use new instance API
stefan-kracht Apr 29, 2024
8a0f795
Merge branch 'main' into stefankracht/dir-1444-migrate-to-new-instanc…
stefan-kracht Apr 29, 2024
c64f453
Merge branch 'main' into stefankracht/dir-1444-migrate-to-new-instanc…
stefan-kracht Apr 29, 2024
18c68aa
update schema names
stefan-kracht Apr 30, 2024
c6ddcc0
make streaming work
stefan-kracht Apr 30, 2024
7c187a8
move streaming into separate folder
stefan-kracht Apr 30, 2024
b58779b
add filter
stefan-kracht Apr 30, 2024
a748303
add filters back to query
stefan-kracht Apr 30, 2024
409e2bf
link filter status and trigger to schema
stefan-kracht Apr 30, 2024
9e9e420
use filters in list
stefan-kracht Apr 30, 2024
a9e3e75
update some imports
stefan-kracht Apr 30, 2024
c3def54
handle questionmark
stefan-kracht Apr 30, 2024
23483d7
update monitoring and workflow overview components
stefan-kracht Apr 30, 2024
8967318
use template literal type to support instance:INSTANCE_ID for filter.…
stefan-kracht Apr 30, 2024
13a6dd2
updatzze E2E test to use finished at instead of last updarted
stefan-kracht Apr 30, 2024
f38bf8b
delete old API hooks
stefan-kracht Apr 30, 2024
6cdcb9c
make linter happy
stefan-kracht Apr 30, 2024
e12f439
Merge branch 'main' into stefankracht/dir-1444-migrate-to-new-instanc…
stefan-kracht Apr 30, 2024
be3bc19
Merge branch 'main' into stefankracht/dir-1444-migrate-to-new-instanc…
stefan-kracht May 2, 2024
efb6677
update schema
stefan-kracht May 2, 2024
587db4a
use namesapce attribute from the response
stefan-kracht May 2, 2024
27dca17
update schema
stefan-kracht May 2, 2024
53db954
remove select
stefan-kracht May 2, 2024
3073c5e
update instance lists
stefan-kracht May 2, 2024
2638b13
update props
stefan-kracht May 2, 2024
55976bc
delete minimal pagination
stefan-kracht May 2, 2024
63ede9b
back to normal pagination
stefan-kracht May 2, 2024
0b29247
type the payload
stefan-kracht May 2, 2024
d44d715
update api link
stefan-kracht May 2, 2024
c70584c
update endpoints in api commands component
stefan-kracht May 2, 2024
f52c436
explicitly set the method
stefan-kracht May 2, 2024
acf335a
update file update example
stefan-kracht May 2, 2024
70b0008
encode data
stefan-kracht May 2, 2024
507cdcc
stop streaming
stefan-kracht May 2, 2024
571f514
change order
stefan-kracht May 2, 2024
dfc22a6
rename cancelInstance to updateInstance
stefan-kracht May 2, 2024
d98ee6c
rename variable
stefan-kracht May 2, 2024
009915e
add back asChild
stefan-kracht May 2, 2024
3ac6a9c
remove unnecessary optional chaining
stefan-kracht May 2, 2024
230e0e9
change order
stefan-kracht May 2, 2024
17543d8
clean up monitoring instance
stefan-kracht May 2, 2024
3f17935
fix typo in sucessful
stefan-kracht May 6, 2024
eb58962
fix endetAt typo
stefan-kracht May 6, 2024
96b7608
rename cache key
stefan-kracht May 6, 2024
8e93688
update variable details cache key
stefan-kracht May 6, 2024
3d63171
Fix spelling (successful)
sebxian May 6, 2024
0b392a3
rename getInstanceList
stefan-kracht May 6, 2024
9afd767
Fix spelling (plurals)
sebxian May 6, 2024
9a905be
Fix camelCase
sebxian May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/e2e/explorer/consumer/index.spec.ts
Expand Up @@ -49,7 +49,7 @@ test("it is possible to create a consumer", async ({ page }) => {

await expect(
page,
"it creates the service and opens the file in the explorer"
"it creates the consumer and opens the file in the explorer"
).toHaveURL(`/n/${namespace}/explorer/consumer/${filename}`);

/* fill in form */
Expand Down
14 changes: 7 additions & 7 deletions ui/e2e/explorer/workflow/run.spec.ts
Expand Up @@ -10,7 +10,7 @@ import { noop as basicWorkflow } from "~/pages/namespace/Explorer/Tree/component
import { createFile } from "e2e/utils/files";
import { decode } from "js-base64";
import { faker } from "@faker-js/faker";
import { getInput } from "~/api/instances/query/input";
import { getInstanceInput } from "~/api/instances/query/input";
import { headers } from "e2e/utils/testutils";
import { prettifyJsonString } from "~/util/helpers";

Expand Down Expand Up @@ -150,7 +150,7 @@ test("it is possible to run the workflow by setting an input JSON via the editor
}

// check the server state of the input
const res = await getInput({
const res = await getInstanceInput({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
instanceId,
Expand All @@ -159,7 +159,7 @@ test("it is possible to run the workflow by setting an input JSON via the editor
headers,
});

const inputResponseString = decode(res.data);
const inputResponseString = decode(res.data.input);

expect(
inputResponseString,
Expand Down Expand Up @@ -331,7 +331,7 @@ test("it is possible to provide the input via generated form", async ({
}

// check the server state of the input
const res = await getInput({
const res = await getInstanceInput({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
instanceId,
Expand All @@ -348,7 +348,7 @@ test("it is possible to provide the input via generated form", async ({
select: "guest",
file: `data:text/plain;base64,SSBhbSBqdXN0IGEgdGVzdGZpbGUgdGhhdCBjYW4gYmUgdXNlZCB0byB0ZXN0IGFuIHVwbG9hZCBmb3JtIHdpdGhpbiBhIHBsYXl3cmlnaHQgdGVzdA==`,
};
const inputResponseAsJson = JSON.parse(decode(res.data));
const inputResponseAsJson = JSON.parse(decode(res.data.input));
expect(inputResponseAsJson).toEqual(expectedJson);
});

Expand Down Expand Up @@ -424,7 +424,7 @@ test("it is possible to provide the input via generated form and resolve form er
}

// check the server state of the input
const res = await getInput({
const res = await getInstanceInput({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
instanceId,
Expand All @@ -438,7 +438,7 @@ test("it is possible to provide the input via generated form and resolve form er
lastName: "McFly",
select: "guest",
};
const inputResponseAsJson = JSON.parse(decode(res.data));
const inputResponseAsJson = JSON.parse(decode(res.data.input));
expect(inputResponseAsJson).toEqual(expectedJson);
});

Expand Down
4 changes: 2 additions & 2 deletions ui/e2e/explorer/workflow/settings.spec.ts
Expand Up @@ -4,13 +4,13 @@ import { waitForSuccessToast, workflowThatCreatesVariable } from "./utils";

import { noop as basicWorkflow } from "~/pages/namespace/Explorer/Tree/components/modals/CreateNew/Workflow/templates";
import { createFile } from "e2e/utils/files";
import { createInstance } from "~/api/instances/mutate/create";
import { createVar } from "~/api/variables/mutate/create";
import { createWorkflowVariables } from "e2e/utils/variables";
import { encode } from "js-base64";
import { faker } from "@faker-js/faker";
import { forceLeadingSlash } from "~/api/files/utils";
import { headers } from "e2e/utils/testutils";
import { runWorkflow } from "~/api/tree/mutate/runWorkflow";

let namespace = "";
let workflow = "";
Expand Down Expand Up @@ -260,7 +260,7 @@ test("it is possible to rename a variable that doesn't have a mimeType", async (
yaml: workflowThatCreatesVariable,
});

await runWorkflow({
await createInstance({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
namespace,
Expand Down
16 changes: 8 additions & 8 deletions ui/e2e/instances/details/index.spec.ts
Expand Up @@ -47,7 +47,7 @@ test("the header of the instance page shows the relevant data for the workflow",
namespace,
path: simpleWorkflowName,
})
).instance;
).data.id;
await page.goto(`/n/${namespace}/instances/${instanceId}`);

const header = page.getByTestId("instance-header-container");
Expand Down Expand Up @@ -80,8 +80,8 @@ test("the header of the instance page shows the relevant data for the workflow",
"It renders the category 'started at'"
).toBeVisible();
await expect(
header.getByText("last updated"),
"It renders the category 'last updated'"
header.getByText("finished at"),
"It renders the category 'finished at'"
).toBeVisible();

await expect(
Expand Down Expand Up @@ -110,7 +110,7 @@ test("the diagram panel on the instance page responds to user interaction", asyn
namespace,
path: simpleWorkflowName,
})
).instance;
).data.id;
await page.goto(`/n/${namespace}/instances/${instanceId}`);

const diagramPanel = page.getByTestId("rf__wrapper");
Expand Down Expand Up @@ -172,7 +172,7 @@ test("the diagram on the instance page changes appearance dynamically", async ({
namespace,
path: delayedWorkflowName,
})
).instance;
).data.id;
await page.goto(`/n/${namespace}/instances/${instanceId}`);

const diagramPanel = page.getByTestId("rf__wrapper");
Expand Down Expand Up @@ -268,7 +268,7 @@ test("the input/output panel responds to user interaction", async ({
namespace,
path: simpleWorkflowName,
})
).instance;
).data.id;
await page.goto(`/n/${namespace}/instances/${instanceId}`);

const inputOutputPanel = page.getByTestId("inputOutputPanel");
Expand Down Expand Up @@ -363,7 +363,7 @@ test("The output is shown when the workflow finished running", async ({
namespace,
path: delayedWorkflowName,
})
).instance;
).data.id;
await page.goto(`/n/${namespace}/instances/${instanceId}`);

const inputOutputPanel = page.getByTestId("inputOutputPanel");
Expand Down Expand Up @@ -407,7 +407,7 @@ test("after a running instance finishes, the output tab is automatically selecte
namespace,
path: delayedWorkflowName,
})
).instance;
).data.id;
await page.goto(`/n/${namespace}/instances/${instanceId}`);

const inputOutputPanel = page.getByTestId("inputOutputPanel");
Expand Down
11 changes: 1 addition & 10 deletions ui/e2e/instances/filter/index.spec.ts
Expand Up @@ -9,8 +9,6 @@ import {
import { createFile } from "e2e/utils/files";
import { createInstance } from "../utils";
import { faker } from "@faker-js/faker";
import { headers } from "e2e/utils/testutils";
import { runWorkflow } from "~/api/tree/mutate/runWorkflow";

let namespace = "";
const simpleWorkflowName = faker.system.commonFileName("yaml");
Expand Down Expand Up @@ -62,14 +60,7 @@ const createTriggerFilterInstances = async () => {
}),
});

await runWorkflow({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
namespace,
path: parentWorkflowName,
},
headers,
});
await createInstance({ namespace, path: parentWorkflowName });
};

test("it is possible to navigate to the instances list, it renders and paginates instances", async ({
Expand Down
71 changes: 29 additions & 42 deletions ui/e2e/instances/list/index.spec.ts
Expand Up @@ -12,9 +12,8 @@ import { faker } from "@faker-js/faker";
import { getInstances } from "~/api/instances/query/get";
import { headers } from "e2e/utils/testutils";
import moment from "moment";
import { runWorkflow } from "~/api/tree/mutate/runWorkflow";

type Instance = Awaited<ReturnType<typeof runWorkflow>>;
type Instance = Awaited<ReturnType<typeof createInstance>>;

let namespace = "";
const simpleWorkflowName = faker.system.commonFileName("yaml");
Expand Down Expand Up @@ -76,20 +75,20 @@ test("it renders the instance item correctly for failed and success status", asy
headers,
});

const instanceDetail = instancesList.instances.results.find(
(x) => x.id === instance.instance
const instanceDetail = instancesList.data.find(
(x) => x.id === instance.data.id
);

if (!instanceDetail?.status) {
throw new Error("instanceDetail?.status is not defined");
if (!instanceDetail) {
throw new Error("instance not found");
}

const workflowName = instanceDetail?.as.split(":")[0];
const workflowName = instanceDetail?.path.split(":")[0];

if (!workflowName) throw new Error("workflowName is not defined");

const instanceItemRow = page.getByTestId(
`instance-row-${instance.instance}`
`instance-row-${instance.data.id}`
);

await expect(
Expand All @@ -103,14 +102,14 @@ test("it renders the instance item correctly for failed and success status", asy
await expect(
instanceItemIdColumn.getByTestId(`tooltip-copy-trigger`),
"id badge shows the first 8 digits of the id"
).toContainText(instance.instance.slice(0, 8));
).toContainText(instance.data.id.slice(0, 8));

await instanceItemIdColumn.getByTestId(`tooltip-copy-trigger`).hover();

await expect(
instanceItemIdColumn.getByTestId("tooltip-copy-content"),
"on hover, a tooltip reveals full id"
).toContainText(instance.instance);
).toContainText(instance.data.id);

await page
.getByRole("heading", { name: "Recently executed instances" })
Expand Down Expand Up @@ -166,21 +165,21 @@ test("it renders the instance item correctly for failed and success status", asy
.click(); // click on header to close all tooltips opened

await expect(
instanceItemRow.getByTestId("instance-column-updated-time"),
`the "last updated" column should display a relative time of the updatedAt api response`
).toContainText(moment(instanceDetail.updatedAt).fromNow(true));
instanceItemRow.getByTestId("instance-column-ended-time"),
`the "endedAt" column should display a relative time of the endedAt api response`
).toContainText(moment(instanceDetail.endedAt).fromNow(true));

await instanceItemRow
.getByTestId("instance-column-updated-time")
.getByTestId("instance-column-ended-time")
.getByTestId("tooltip-trigger")
.hover();

await expect(
instanceItemRow
.getByTestId("instance-column-updated-time")
.getByTestId("instance-column-ended-time")
.getByTestId("tooltip-content"),
"on hover, the absolute time should appear"
).toContainText(instanceDetail.updatedAt);
).toContainText(instanceDetail.endedAt ?? "no endedAt");

await instanceItemRow
.getByTestId("instance-column-name")
Expand All @@ -198,7 +197,7 @@ test("it renders the instance item correctly for failed and success status", asy
await expect(
page,
"on click row, page should navigate to the instance detail page"
).toHaveURL(`/n/${namespace}/instances/${instance.instance}`);
).toHaveURL(`/n/${namespace}/instances/${instance.data.id}`);
await page.goBack();
};

Expand Down Expand Up @@ -234,21 +233,13 @@ test("it provides a proper pagination", async ({ page }) => {
yaml,
});

await runWorkflow({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
namespace,
path: parentWorkflow,
},
headers,
});

/**
* child workflows are spawned asynchronously in the backend and the page
* does not refresh, so we need to wait until they are initialized before
* visiting the page.
*/
await page.waitForTimeout(500);
await createInstance({ namespace, path: parentWorkflow }),
/**
* child workflows are spawned asynchronously in the backend and the page
* does not refresh, so we need to wait until they are initialized before
* visiting the page.
*/
await page.waitForTimeout(500);

await page.goto(`/n/${namespace}/instances/`, { waitUntil: "networkidle" });

Expand Down Expand Up @@ -304,7 +295,7 @@ test("it provides a proper pagination", async ({ page }) => {
headers,
});

const firstInstance = instancesListPage3.instances.results[0];
const firstInstance = instancesListPage3.data[0];
if (!firstInstance) throw new Error("there should be at least one instance");

const instanceItemRow = page.getByTestId(`instance-row-${firstInstance.id}`);
Expand All @@ -328,13 +319,9 @@ test("It will display child instances as well", async ({ page }) => {
}),
});

const parentInstance = await runWorkflow({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
namespace,
path: parentWorkflow,
},
headers,
const parentInstance = await createInstance({
namespace,
path: parentWorkflow,
});

await page.goto(`/n/${namespace}/instances/`, { waitUntil: "networkidle" });
Expand All @@ -349,8 +336,8 @@ test("It will display child instances as well", async ({ page }) => {
headers,
});

const childInstanceDetail = instancesList.instances.results.find(
(x) => x.id !== parentInstance.instance
const childInstanceDetail = instancesList.data.find(
(x) => x.id !== parentInstance.data.id
);

if (!childInstanceDetail)
Expand Down
4 changes: 2 additions & 2 deletions ui/e2e/instances/utils/index.ts
@@ -1,5 +1,5 @@
import { createInstance as createInstanceRequest } from "~/api/instances/mutate/create";
import { headers } from "e2e/utils/testutils";
import { runWorkflow } from "~/api/tree/mutate/runWorkflow";

export const createInstance = async ({
namespace,
Expand All @@ -10,7 +10,7 @@ export const createInstance = async ({
path: string;
payload?: string;
}) =>
await runWorkflow({
await createInstanceRequest({
urlParams: {
baseUrl: process.env.PLAYWRIGHT_UI_BASE_URL,
namespace,
Expand Down
7 changes: 4 additions & 3 deletions ui/public/locales/en/translation.json
Expand Up @@ -528,6 +528,7 @@
"instances": {
"list": {
"title": "Recently executed instances",
"refetchLabel": "Refetch instances",
"empty": {
"noInstances": "There are no recently executed instances",
"noFilterResults": "No recently executed instances found with these filter criteria"
Expand All @@ -538,7 +539,7 @@
"invoker": "trigger",
"state": "state",
"startedAt": "started at",
"updatedAt": "last updated",
"finishedAt": "finished at",
"childInstances": {
"label": "spawned",
"instanceCount": "{{count}} instances",
Expand Down Expand Up @@ -584,7 +585,7 @@
"invoker": "trigger",
"state": "state",
"startedAt": "started at",
"updatedAt": "last updated",
"finishedAt": "finished at",
"realtiveTime": "{{relativeTime}} ago"
},
"logs": {
Expand Down Expand Up @@ -1532,4 +1533,4 @@
}
}
}
}
}