-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathdestroy.e2e.ts
More file actions
188 lines (169 loc) · 6.4 KB
/
Copy pathdestroy.e2e.ts
File metadata and controls
188 lines (169 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import assert from "node:assert";
import {
dismissNotifications,
getUniqueResourceName,
getViewSection,
waitForLogin,
waitForTreeItems,
} from "./utils/commonUtils.ts";
import {Workbench} from "wdio-vscode-service";
import {WorkspaceClient} from "@databricks/sdk-experimental";
import {createProjectWithJob} from "./utils/dabsFixtures.ts";
describe("Deploy and destroy", async function () {
let workbench: Workbench;
let vscodeWorkspaceRoot: string;
let jobName: string;
let clusterId: string;
this.timeout(3 * 60 * 1000);
before(async function () {
assert(
process.env.TEST_DEFAULT_CLUSTER_ID,
"TEST_DEFAULT_CLUSTER_ID env var doesn't exist"
);
assert(
process.env.WORKSPACE_PATH,
"WORKSPACE_PATH env var doesn't exist"
);
assert(
process.env.DATABRICKS_HOST,
"DATABRICKS_HOST env var doesn't exist"
);
clusterId = process.env.TEST_DEFAULT_CLUSTER_ID;
workbench = await browser.getWorkbench();
vscodeWorkspaceRoot = process.env.WORKSPACE_PATH;
const job = await createProjectWithJob(
getUniqueResourceName("deploy_and_destroy_bundle"),
vscodeWorkspaceRoot,
clusterId
);
jobName = job.name!;
await dismissNotifications();
});
it("should wait for extension activation", async () => {
const section = await getViewSection("CONFIGURATION");
assert(section);
});
it("should wait for connection", async () => {
await waitForLogin("DEFAULT");
await dismissNotifications();
});
it("should find resource explorer view", async function () {
const section = await getViewSection("BUNDLE RESOURCE EXPLORER");
assert(section);
await waitForTreeItems(section, 20_000);
});
it("should deploy and run the current job", async () => {
const wsClient = new WorkspaceClient({
configFile: process.env.DATABRICKS_CONFIG_FILE,
profile: "DEFAULT",
});
const prefix = `[dev ${(await wsClient.currentUser.me()).userName
?.split("@")[0]
.replaceAll(/[^a-zA-Z0-9]/g, "_")}]`;
const outputView = await workbench.getBottomBar().openOutputView();
await outputView.selectChannel("Databricks Bundle Logs");
await outputView.clearText();
await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand("databricks.bundle.deploy");
});
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) {
return false;
}
},
{
timeout: 60_000,
interval: 1_000,
timeoutMsg:
"Can't find 'Bundle deployed successfully' message in output channel",
}
);
let found = false;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for await (const j of wsClient.jobs.list({
name: `${prefix} ${jobName}`,
})) {
found = true;
}
assert(found, `Job ${jobName} not found in workspace`);
await browser.executeWorkbench(async (vscode) => {
await vscode.commands.executeCommand(
"databricks.bundle.destroy",
false, // Don't force it
false // Skip the modal warning dialog, as they don't work in tests
);
});
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 (
logs.includes("Bundle destroyed successfully") &&
logs.includes("Bundle configuration refreshed")
);
} catch (e) {
return false;
}
},
{
timeout: 120_000,
interval: 2_000,
timeoutMsg:
"The run status didn't reach success within 120 seconds",
}
);
found = false;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for await (const j of wsClient.jobs.list({
name: `${prefix} ${jobName}`,
})) {
found = true;
}
assert(!found, `Job ${jobName} still found in workspace`);
});
});