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
7 changes: 6 additions & 1 deletion packages/databricks-vscode/src/test/e2e/auth.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from "node:assert";
import {
dismissNotifications,
getActionButton,
waitForInput,
getViewSection,
waitForLogin,
Expand Down Expand Up @@ -70,8 +71,12 @@ describe("Configure Databricks Extension", async function () {
const items = await section.getVisibleItems();
for (const item of items) {
const label = await item.getLabel();
console.log(
"Looking for signin button, got item:",
await (await item.elem).getHTML()
);
if (label.toLowerCase().includes("auth type")) {
return item.getActionButton("Sign in");
return getActionButton(item, "Sign in");
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import assert from "node:assert";
import {
dismissNotifications,
getActionButton,
getUniqueResourceName,
getViewSection,
selectOutputChannel,
waitForDeployment,
waitForLogin,
waitForTreeItems,
Expand Down Expand Up @@ -65,7 +67,7 @@ describe("Deploy and run job", async function () {

it("should deploy and run the current job", async () => {
const outputView = await workbench.getBottomBar().openOutputView();
await outputView.selectChannel("Databricks Bundle Logs");
await selectOutputChannel(outputView, "Databricks Bundle Logs");
await outputView.clearText();

const jobItem = await getResourceViewItem(
Expand All @@ -75,7 +77,8 @@ describe("Deploy and run job", async function () {
);
assert(jobItem, `Job ${jobName} not found in resource explorer`);

const deployAndRunButton = await jobItem.getActionButton(
const deployAndRunButton = await getActionButton(
jobItem,
"Deploy the bundle and run the job"
);
assert(deployAndRunButton, "Deploy and run button not found");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import assert from "node:assert";
import {
dismissNotifications,
getActionButton,
getViewSection,
selectOutputChannel,
waitForDeployment,
waitForLogin,
waitForTreeItems,
Expand Down Expand Up @@ -62,7 +64,7 @@ describe("Deploy and run pipeline", async function () {

it("should deploy and run the current pipeline", async () => {
const outputView = await workbench.getBottomBar().openOutputView();
await outputView.selectChannel("Databricks Bundle Logs");
await selectOutputChannel(outputView, "Databricks Bundle Logs");
await outputView.clearText();

const pipelineItem = await getResourceViewItem(
Expand All @@ -75,13 +77,14 @@ describe("Deploy and run pipeline", async function () {
`Pipeline ${pipelineName} not found in resource explorer`
);

const deployAndRunButton = await pipelineItem.getActionButton(
const deployAndRunButton = await getActionButton(
pipelineItem,
"Deploy the bundle and run the pipeline"
);
assert(deployAndRunButton, "Deploy and run button not found");
await deployAndRunButton.elem.click();

await waitForDeployment();
await waitForDeployment(outputView);

await waitForRunStatus(
resourceExplorerView,
Expand Down
58 changes: 20 additions & 38 deletions packages/databricks-vscode/src/test/e2e/destroy.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
dismissNotifications,
getUniqueResourceName,
getViewSection,
selectOutputChannel,
waitForLogin,
waitForTreeItems,
} from "./utils/commonUtils.ts";
Expand Down Expand Up @@ -71,42 +72,33 @@ describe("Deploy and destroy", async function () {
.replaceAll(/[^a-zA-Z0-9]/g, "_")}]`;

const outputView = await workbench.getBottomBar().openOutputView();
await outputView.selectChannel("Databricks Bundle Logs");
await selectOutputChannel(outputView, "Databricks Bundle Logs");
await outputView.clearText();

await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand("databricks.bundle.deploy");
});

await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand(
"workbench.panel.output.focus"
);
});

await selectOutputChannel(outputView, "Databricks Bundle Logs");

console.log("Waiting for deployment to finish");
// Wait for the deployment to finish
await browser.waitUntil(
async () => {
try {
await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand(
"workbench.panel.output.focus"
);
});
const outputView = await workbench
.getBottomBar()
.openOutputView();

if (
(await outputView.getCurrentChannel()) !==
"Databricks Bundle Logs"
) {
await outputView.selectChannel(
"Databricks Bundle Logs"
);
}

const logs = (await outputView.getText()).join("");
console.log(logs);
return (
logs.includes("Bundle deployed successfully") &&
logs.includes("Bundle configuration refreshed")
);
} catch (e) {
console.log("Error waiting for deployment to finish:", e);
return false;
}
},
Expand Down Expand Up @@ -135,29 +127,19 @@ describe("Deploy and destroy", async function () {
);
});

await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand(
"workbench.panel.output.focus"
);
});

await selectOutputChannel(outputView, "Databricks Bundle Logs");

console.log("Waiting for bundle to destroy");
// Wait for status to reach success
await browser.waitUntil(
async () => {
try {
await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand(
"workbench.panel.output.focus"
);
});
const outputView = await workbench
.getBottomBar()
.openOutputView();

if (
(await outputView.getCurrentChannel()) !==
"Databricks Bundle Logs"
) {
await outputView.selectChannel(
"Databricks Bundle Logs"
);
}

const logs = (await outputView.getText()).join("");
console.log(logs);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {CustomTreeSection} from "wdio-vscode-service";
import {
dismissNotifications,
getViewSection,
selectOutputChannel,
waitForLogin,
} from "./utils/commonUtils.ts";
import {
Expand Down Expand Up @@ -78,7 +79,8 @@ describe("Automatically refresh resource explorer", async function () {
const outputView = await (await browser.getWorkbench())
.getBottomBar()
.openOutputView();
await outputView.selectChannel("Databricks Bundle Logs");

await selectOutputChannel(outputView, "Databricks Bundle Logs");

const jobDef = await createProjectWithJob(
projectName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,15 @@ describe("Run files on serverless compute", async function () {

// Install dependencies from the requirements.txt
const dependenciesInput = await waitForInput();
await dependenciesInput.toggleAllQuickPicks(true);
try {
await dependenciesInput.toggleAllQuickPicks(true);
} catch (e) {
console.log(
"Failed to toggle all quick picks, moving on. Error:",
e
);
}
await dependenciesInput.confirm();

await waitForNotification("The following environment is selected");
await waitForNotification("Databricks Connect", "Install");

Expand Down
14 changes: 13 additions & 1 deletion packages/databricks-vscode/src/test/e2e/run_files.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,22 @@ describe("Run files", async function () {
await executeCommandWhenAvailable("Databricks: Upload and Run File");
await browser.waitUntil(async () => {
const notifications = await workbench.getNotifications();
console.log("Notifications:", notifications.length);
for (const notification of notifications) {
const message = await notification.getMessage();
console.log("Message:", message);
if (message.includes("Uploading bundle assets")) {
await notification.takeAction("Cancel");
const elements = await notification.actions$.$$(
notification.locators.action
);
console.log("Elements:", elements.length);
for (const element of elements) {
const text = await element.getText();
if (text === "Cancel") {
await element.click();
break;
}
}
return true;
}
}
Expand Down
61 changes: 41 additions & 20 deletions packages/databricks-vscode/src/test/e2e/utils/commonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
ViewControl,
ViewSection,
InputBox,
OutputView,
TreeItem,
} from "wdio-vscode-service";

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand All @@ -19,6 +21,17 @@ const ViewSectionTypes = [
] as const;
export type ViewSectionType = (typeof ViewSectionTypes)[number];

export async function selectOutputChannel(
outputView: OutputView,
channelName: string
) {
if ((await outputView.getCurrentChannel()) === channelName) {
return;
}
outputView.locatorMap.BottomBarViews.outputChannels = `ul[aria-label="Output actions"] select`;
await outputView.selectChannel(channelName);
}

export async function findViewSection(name: ViewSectionType) {
const workbench = await browser.getWorkbench();

Expand All @@ -41,12 +54,14 @@ export async function findViewSection(name: ViewSectionType) {
);
const views =
(await (await control?.openView())?.getContent()?.getSections()) ?? [];
console.log("Views:", views.length);
for (const v of views) {
const title = await v.getTitle();
const title = await v.elem.getText();
console.log("View title:", title);
if (title === null) {
continue;
}
if (title.toUpperCase() === name) {
if (title.toUpperCase().includes(name)) {
return v;
}
}
Expand Down Expand Up @@ -335,28 +350,15 @@ export async function waitForNotification(message: string, action?: string) {
);
}

export async function waitForDeployment() {
export async function waitForDeployment(outputView: OutputView) {
console.log("Waiting for deployment to finish");
const workbench = await driver.getWorkbench();
await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand("workbench.panel.output.focus");
});
await selectOutputChannel(outputView, "Databricks Bundle Logs");
await browser.waitUntil(
async () => {
try {
await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand(
"workbench.panel.output.focus"
);
});
const outputView = await workbench
.getBottomBar()
.openOutputView();

if (
(await outputView.getCurrentChannel()) !==
"Databricks Bundle Logs"
) {
await outputView.selectChannel("Databricks Bundle Logs");
}

const logs = (await outputView.getText()).join("");
console.log("------------ Bundle Output ------------");
console.log(logs);
Expand All @@ -376,3 +378,22 @@ export async function waitForDeployment() {
}
);
}

export async function getActionButton(item: TreeItem, label: string) {
const actions = await item.getActionButtons();
if (actions.length > 0) {
for (const item of actions) {
console.log("Checking action button:", item.getLabel());
console.log(
"Action button element:",
await (await item.elem).getHTML()
);
const itemLabel =
item.getLabel() ?? (await item.elem.getAttribute("aria-label"));
if (itemLabel.indexOf(label) > -1) {
return item;
}
}
}
return undefined;
}
2 changes: 1 addition & 1 deletion packages/databricks-vscode/src/test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const config: Options.Testrunner = {
return [
{
"browserName": "vscode",
"browserVersion": engines.vscode.replace("^", ""),
"browserVersion": engines.vscode.replace(/\^/, ""),
"wdio:vscodeOptions": {
extensionPath: path.resolve(
__dirname,
Expand Down
Loading