Skip to content

Commit f03f595

Browse files
Revert "Increase timeouts" (#313)
Reverts #311
1 parent 81d4e81 commit f03f595

File tree

4 files changed

+92
-147
lines changed

4 files changed

+92
-147
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from "node:path";
33
import * as fs from "fs/promises";
44
import {
55
getViewSection,
6-
waitForPythonExtensionWithRetry,
6+
waitForPythonExtension,
77
waitForTreeItems,
88
} from "./utils";
99
import {
@@ -21,7 +21,7 @@ describe("Configure Databricks Extension", async function () {
2121
let host: string;
2222
let workbench: Workbench;
2323

24-
this.timeout(5 * 60 * 1000);
24+
this.timeout(3 * 60 * 1000);
2525

2626
before(async function () {
2727
assert(
@@ -41,7 +41,7 @@ describe("Configure Databricks Extension", async function () {
4141
host = process.env.DATABRICKS_HOST;
4242

4343
workbench = await browser.getWorkbench();
44-
await waitForPythonExtensionWithRetry(1.5 * 60 * 1000, 2);
44+
await waitForPythonExtension();
4545
});
4646

4747
it("should open VSCode", async function () {

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

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import * as fs from "fs/promises";
33
import assert from "node:assert";
44
import {
55
getViewSection,
6-
startSyncIfStopped,
7-
waitForPythonExtensionWithRetry,
8-
waitForSyncComplete,
6+
getViewSubSection,
7+
waitForPythonExtension,
8+
waitForTreeItems,
99
} from "./utils";
10-
import {sleep} from "wdio-vscode-service";
10+
import {sleep, TreeItem} from "wdio-vscode-service";
1111

12-
describe("Run as workflow on cluster", async function () {
12+
describe("Run python on cluster", async function () {
1313
let projectDir: string;
14-
this.timeout(5 * 60 * 1000);
14+
this.timeout(2 * 60 * 1000);
1515

1616
before(async () => {
1717
assert(process.env.TEST_DEFAULT_CLUSTER_ID);
@@ -42,15 +42,59 @@ describe("Run as workflow on cluster", async function () {
4242
].join("\n")
4343
);
4444

45-
await waitForPythonExtensionWithRetry(1.5 * 60 * 1000, 2);
46-
47-
await (await getViewSection("CLUSTERS"))?.collapse();
45+
const section = await getViewSection("CONFIGURATION");
46+
assert(section);
47+
await waitForTreeItems(section);
48+
await waitForPythonExtension();
4849
});
4950

5051
beforeEach(async () => {
51-
await startSyncIfStopped();
52+
const section = await getViewSection("CLUSTERS");
53+
await section?.collapse();
54+
55+
const repoConfigItem = await getViewSubSection("CONFIGURATION", "Repo");
56+
assert(repoConfigItem);
5257

53-
await waitForSyncComplete();
58+
let status: TreeItem | undefined = undefined;
59+
for (const i of await repoConfigItem.getChildren()) {
60+
if ((await i.getLabel()).includes("State:")) {
61+
status = i;
62+
break;
63+
}
64+
}
65+
assert(status);
66+
if ((await status.getDescription())?.includes("STOPPED")) {
67+
const buttons = await repoConfigItem.getActionButtons();
68+
await buttons[0].elem.click();
69+
}
70+
71+
await browser.waitUntil(
72+
async () => {
73+
const repoConfigItem = await getViewSubSection(
74+
"CONFIGURATION",
75+
"Repo"
76+
);
77+
assert(repoConfigItem);
78+
79+
status = undefined;
80+
for (const i of await repoConfigItem.getChildren()) {
81+
if ((await i.getLabel()).includes("State:")) {
82+
status = i;
83+
break;
84+
}
85+
}
86+
assert(status);
87+
const description = await status?.getDescription();
88+
return (
89+
description !== undefined &&
90+
description.includes("WATCHING_FOR_CHANGES")
91+
);
92+
},
93+
{
94+
timeout: 20000,
95+
timeoutMsg: "Couldn't finish sync in 20s",
96+
}
97+
);
5498
});
5599

56100
it("should run a python notebook as a job on a cluster", async () => {
@@ -126,7 +170,7 @@ describe("Run as workflow on cluster", async function () {
126170
await sleep(200);
127171
await input.setText("file.py");
128172
await input.confirm();
129-
await sleep(2000);
173+
await sleep(500);
130174

131175
// run file
132176
await workbench.executeQuickPick(

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import * as fs from "fs/promises";
33
import assert from "node:assert";
44
import {
55
getViewSection,
6-
startSyncIfStopped,
7-
waitForPythonExtensionWithRetry,
8-
waitForSyncComplete,
6+
getViewSubSection,
7+
waitForPythonExtension,
98
waitForTreeItems,
109
} from "./utils";
1110
import {sleep} from "wdio-vscode-service";
1211

1312
describe("Run python on cluster", async function () {
1413
let projectDir: string;
15-
this.timeout(5 * 60 * 1000);
14+
this.timeout(3 * 60 * 1000);
1615

1716
before(async () => {
1817
assert(process.env.DATABRICKS_HOST);
@@ -37,7 +36,7 @@ describe("Run python on cluster", async function () {
3736
path.join(projectDir, "hello.py"),
3837
`spark.sql('SELECT "hello world"').show()`
3938
);
40-
await waitForPythonExtensionWithRetry(1.5 * 60 * 1000, 2);
39+
await waitForPythonExtension();
4140
});
4241

4342
it("should connect to Databricks", async () => {
@@ -50,10 +49,22 @@ describe("Run python on cluster", async function () {
5049
const section = await getViewSection("CLUSTERS");
5150
await section?.collapse();
5251

53-
await startSyncIfStopped();
52+
const repoConfigItem = await getViewSubSection("CONFIGURATION", "Repo");
53+
assert(repoConfigItem);
54+
const buttons = await repoConfigItem.getActionButtons();
55+
await buttons[0].elem.click();
5456

5557
// wait for sync to finish
56-
await waitForSyncComplete();
58+
const workbench = await driver.getWorkbench();
59+
const terminalView = await workbench.getBottomBar().openTerminalView();
60+
61+
while (true) {
62+
await sleep(500);
63+
const text = await terminalView.getText();
64+
if (text.includes("Sync Complete")) {
65+
break;
66+
}
67+
}
5768
});
5869

5970
it("should run a python file on a cluster", async () => {

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

Lines changed: 15 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,23 @@ export async function waitForTreeItems(
8282
}
8383
}
8484

85-
export async function waitForPythonExtension(timeoutMs: number) {
85+
export async function waitForPythonExtension() {
8686
const section = await getViewSection("CONFIGURATION");
8787
assert(section);
88+
const welcome = await section.findWelcomeContent();
89+
assert(welcome);
90+
sleep(1000);
8891
const workbench = await browser.getWorkbench();
89-
90-
await browser.waitUntil(
91-
async () => {
92-
const notifs = await workbench.getNotifications();
93-
let found = false;
94-
for (const n of notifs) {
95-
if (
96-
(await n.getActions()).find(
97-
(btn) => btn.getTitle() === "Install and Reload"
98-
) !== undefined
99-
) {
100-
await n.takeAction("Install and Reload");
101-
found = true;
102-
}
103-
}
104-
return found;
105-
},
106-
{
107-
timeout: 5 * 1000,
108-
interval: 500,
109-
timeoutMsg:
110-
"Can't find notification to install ms-python extension",
92+
const notifs = await workbench.getNotifications();
93+
for (const n of notifs) {
94+
if (
95+
(await n.getActions()).find(
96+
(btn) => btn.getTitle() === "Install and Reload"
97+
) !== undefined
98+
) {
99+
await n.takeAction("Install and Reload");
111100
}
112-
);
101+
}
113102

114103
await browser.waitUntil(
115104
async () =>
@@ -119,115 +108,16 @@ export async function waitForPythonExtension(timeoutMs: number) {
119108
)?.getTitle()
120109
)?.includes("README.quickstart.md") === true,
121110
{
122-
timeout: timeoutMs,
111+
timeout: 120000,
123112
timeoutMsg:
124113
"Timeout when installing python extension and reloading",
125114
}
126115
);
127116

128-
await sleep(500);
117+
sleep(500);
129118
try {
130-
const notifs = await workbench.getNotifications();
131119
for (const n of notifs) {
132120
await n.dismiss();
133121
}
134122
} catch {}
135123
}
136-
137-
export async function waitForPythonExtensionWithRetry(
138-
timeoutMs: number,
139-
retryCount: number
140-
) {
141-
for (let i = 0; i < retryCount; i++) {
142-
try {
143-
const section = await getViewSection("CONFIGURATION");
144-
assert(section);
145-
await waitForPythonExtension(timeoutMs);
146-
} catch (e) {
147-
// eslint-disable-next-line no-console
148-
console.error(e);
149-
const wb = await browser.getWorkbench();
150-
await wb.executeCommand("Developer: Reload Window");
151-
if (i === retryCount - 1) {
152-
throw e;
153-
}
154-
continue;
155-
}
156-
break;
157-
}
158-
}
159-
160-
export async function waitForSyncComplete() {
161-
await browser.waitUntil(
162-
async () => {
163-
const repoConfigItem = await getViewSubSection(
164-
"CONFIGURATION",
165-
"Repo"
166-
);
167-
if (repoConfigItem === undefined) {
168-
return false;
169-
}
170-
await repoConfigItem.expand();
171-
172-
let status: TreeItem | undefined = undefined;
173-
for (const i of await repoConfigItem.getChildren()) {
174-
if ((await i.getLabel()).includes("State:")) {
175-
status = i;
176-
break;
177-
}
178-
}
179-
if (status === undefined) {
180-
return false;
181-
}
182-
183-
const description = await status?.getDescription();
184-
return (
185-
description !== undefined &&
186-
description.includes("WATCHING_FOR_CHANGES")
187-
);
188-
},
189-
{
190-
timeout: 60000,
191-
interval: 20000,
192-
timeoutMsg: "Couldn't finish sync in 1m",
193-
}
194-
);
195-
}
196-
197-
export async function startSyncIfStopped() {
198-
browser.waitUntil(
199-
async () => {
200-
const repoConfigItem = await getViewSubSection(
201-
"CONFIGURATION",
202-
"Repo"
203-
);
204-
if (repoConfigItem === undefined) {
205-
return false;
206-
}
207-
await repoConfigItem.expand();
208-
209-
let status: TreeItem | undefined = undefined;
210-
for (const i of await repoConfigItem.getChildren()) {
211-
if ((await i.getLabel()).includes("State:")) {
212-
status = i;
213-
break;
214-
}
215-
}
216-
if (status === undefined) {
217-
return false;
218-
}
219-
220-
if ((await status.getDescription())?.includes("STOPPED")) {
221-
const buttons = await repoConfigItem.getActionButtons();
222-
if (buttons.length === 0) {
223-
return false;
224-
}
225-
await buttons[0].elem.click();
226-
}
227-
return true;
228-
},
229-
{
230-
timeout: 20000,
231-
}
232-
);
233-
}

0 commit comments

Comments
 (0)