Skip to content

Commit 168d69f

Browse files
authored
Add e2e tests for standalone running flows (#1085)
- Run on cluster - Run as a workflow
1 parent efa3c6b commit 168d69f

File tree

9 files changed

+284
-814
lines changed

9 files changed

+284
-814
lines changed

packages/databricks-vscode/package.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,6 @@
131131
"title": "Refresh",
132132
"enablement": "databricks.context.activated && databricks.context.loggedIn"
133133
},
134-
{
135-
"command": "databricks.connection.attachSyncDestination",
136-
"title": "Configure sync destination",
137-
"category": "Databricks",
138-
"enablement": "databricks.context.activated && databricks.context.loggedIn",
139-
"icon": "$(gear)"
140-
},
141-
{
142-
"command": "databricks.connection.detachSyncDestination",
143-
"title": "Detach sync destination",
144-
"category": "Databricks",
145-
"enablement": "databricks.context.activated && databricks.context.loggedIn",
146-
"icon": "$(debug-disconnect)"
147-
},
148134
{
149135
"command": "databricks.run.runEditorContentsAsWorkflow",
150136
"title": "Run File as Workflow",

packages/databricks-vscode/src/test/e2e/auth.e2e.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
import path from "node:path";
21
import assert from "node:assert";
32
import * as fs from "fs/promises";
43
import {
54
dismissNotifications,
65
waitForInput,
76
getViewSection,
87
waitForLogin,
8+
clearBundleConfig,
9+
createBasicBundleConfig,
910
} from "./utils.ts";
1011
import {CustomTreeSection} from "wdio-vscode-service";
1112

12-
const BUNDLE = `
13-
bundle:
14-
name: hello_test
15-
16-
targets:
17-
dev_test:
18-
mode: development
19-
default: true
20-
workspace:
21-
host: _HOST_
22-
`;
23-
24-
let projectDir: string;
25-
let bundleConfig: string;
2613
let cfgPath: string;
2714
let cfgContent: Buffer;
2815

@@ -36,15 +23,17 @@ describe("Configure Databricks Extension", async function () {
3623
"DATABRICKS_CONFIG_FILE doesn't exist"
3724
);
3825
cfgPath = process.env.DATABRICKS_CONFIG_FILE;
39-
projectDir = process.env.WORKSPACE_PATH;
40-
bundleConfig = path.join(projectDir, "databricks.yml");
4126
cfgContent = await fs.readFile(cfgPath);
4227
});
4328

4429
after(async function () {
45-
await fs.unlink(bundleConfig);
46-
if (cfgContent) {
47-
await fs.writeFile(cfgPath, cfgContent);
30+
try {
31+
await clearBundleConfig();
32+
if (cfgContent) {
33+
await fs.writeFile(cfgPath, cfgContent);
34+
}
35+
} catch (e) {
36+
console.error(e);
4837
}
4938
});
5039

@@ -81,11 +70,7 @@ describe("Configure Databricks Extension", async function () {
8170
});
8271

8372
it("should automatically login after detecting bundle configuration", async () => {
84-
assert(process.env.DATABRICKS_HOST, "DATABRICKS_HOST doesn't exist");
85-
await fs.writeFile(
86-
bundleConfig,
87-
BUNDLE.replace("_HOST_", process.env.DATABRICKS_HOST)
88-
);
73+
await createBasicBundleConfig();
8974
await waitForLogin("DEFAULT");
9075
});
9176

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import path from "node:path";
2+
import * as fs from "fs/promises";
3+
import assert from "node:assert";
4+
import {
5+
clearBundleConfig,
6+
createBasicBundleConfig,
7+
dismissNotifications,
8+
openFile,
9+
waitForLogin,
10+
waitForWorkflowWebview,
11+
} from "./utils.ts";
12+
import {sleep} from "wdio-vscode-service";
13+
14+
describe("Run files", async function () {
15+
let projectDir: string;
16+
this.timeout(3 * 60 * 1000);
17+
18+
before(async () => {
19+
assert(process.env.WORKSPACE_PATH);
20+
projectDir = process.env.WORKSPACE_PATH;
21+
22+
await fs.writeFile(
23+
path.join(projectDir, "lib.py"),
24+
[
25+
"def func(spark):",
26+
`\tspark.sql('SELECT "hello world"').show()`,
27+
].join("\n")
28+
);
29+
const nestedDir = path.join(projectDir, "nested");
30+
await fs.mkdir(nestedDir, {recursive: true});
31+
await fs.writeFile(
32+
path.join(nestedDir, "hello.py"),
33+
[`from lib import func`, "func(spark)"].join("\n")
34+
);
35+
36+
await createBasicBundleConfig();
37+
await waitForLogin("DEFAULT");
38+
await dismissNotifications();
39+
});
40+
41+
after(async () => {
42+
try {
43+
await clearBundleConfig();
44+
} catch (e) {
45+
console.error(e);
46+
}
47+
});
48+
49+
beforeEach(async () => {
50+
await openFile("hello.py");
51+
});
52+
53+
it("should run a python file on a cluster", async () => {
54+
const workbench = await driver.getWorkbench();
55+
await workbench.executeQuickPick("Databricks: Upload and Run File");
56+
57+
const debugOutput = await workbench
58+
.getBottomBar()
59+
.openDebugConsoleView();
60+
61+
while (true) {
62+
await dismissNotifications();
63+
await sleep(2000);
64+
const text = await (await debugOutput.elem).getHTML();
65+
if (text && text.includes("hello world")) {
66+
break;
67+
}
68+
}
69+
});
70+
71+
it("should run a python file as a workflow", async () => {
72+
const workbench = await driver.getWorkbench();
73+
await workbench.executeQuickPick("Databricks: Run File as Workflow");
74+
await dismissNotifications();
75+
await waitForWorkflowWebview("hello world");
76+
});
77+
});

packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_repo.e2e.ts

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)