Skip to content

Commit

Permalink
Remove dbconnect from optin options (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikgupta-db authored Apr 17, 2023
1 parent 1b9fabd commit 2be752d
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 36 deletions.
15 changes: 0 additions & 15 deletions packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,21 +607,6 @@
"type": "string",
"default": "",
"description": "Similar to python.envFile. Absolute path to a file containing environment variable definitions."
},
"databricks.experiments.optInto": {
"type": "array",
"default": [],
"items": {
"enum": [
"debugging.dbconnect"
],
"enumDescriptions": [
"Interactive debugging using dbconnect V2."
],
"type": "string"
},
"uniqueItems": true,
"description": "Opt into experimental features."
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/* eslint-disable @typescript-eslint/naming-convention */

import {mock, instance} from "ts-mockito";
import {ConnectionManager} from "./ConnectionManager";
import {Disposable} from "vscode";
import {CliWrapper} from "../cli/CliWrapper";

describe(__filename, () => {
let mockedCliWrapper: CliWrapper;
let disposables: Array<Disposable>;

beforeEach(() => {
disposables = [];
mockedCliWrapper = mock(CliWrapper);
});

afterEach(() => {
disposables.forEach((d) => d.dispose());
});

it("should create an instance", async () => {
new ConnectionManager(instance(mockedCliWrapper));
});

// TODO
// login
// logout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {NamedLogger} from "@databricks/databricks-sdk/dist/logging";
import {Loggers} from "../logger";
import {CustomWhenContext} from "../vscode-objs/CustomWhenContext";
import {workspaceConfigs} from "../vscode-objs/WorkspaceConfigs";
import {WorkspaceStateManager} from "../vscode-objs/WorkspaceState";

export type ConnectionState = "CONNECTED" | "CONNECTING" | "DISCONNECTED";

Expand Down Expand Up @@ -63,7 +64,10 @@ export class ConnectionManager {

public metadataServiceUrl?: string;

constructor(private cli: CliWrapper) {}
constructor(
private cli: CliWrapper,
private workspaceState: WorkspaceStateManager
) {}

get state(): ConnectionState {
return this._state;
Expand Down Expand Up @@ -218,7 +222,8 @@ export class ConnectionManager {

if (
this.databricksWorkspace &&
workspaceConfigs.enableFilesInWorkspace
(workspaceConfigs.enableFilesInWorkspace ||
this.workspaceState.wsfsFeatureFlag)
) {
await this.createRootDirectory(
workspaceClient,
Expand Down
2 changes: 1 addition & 1 deletion packages/databricks-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function activate(
const cli = new CliWrapper(context);

// Configuration group
const connectionManager = new ConnectionManager(cli);
const connectionManager = new ConnectionManager(cli, workspaceStateManager);
context.subscriptions.push(
connectionManager.onDidChangeState(async () => {
telemetry.setMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "./utils.ts";
import {sleep} from "wdio-vscode-service";

describe("Run job on cluster", async function () {
describe("Run job on cluster with repo", async function () {
let projectDir: string;
this.timeout(2 * 60 * 1000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import {
} from "./utils.ts";
import {sleep} from "wdio-vscode-service";

describe("Run job on cluster", async function () {
describe("Run job on cluster with workspace", async function () {
let projectDir: string;
this.timeout(2 * 60 * 1000);

before(async () => {
assert(process.env.TEST_DEFAULT_CLUSTER_ID);
assert(process.env.TEST_REPO_PATH);
assert(process.env.TEST_WORKSPACE_FOLDER_PATH);
assert(process.env.WORKSPACE_PATH);
projectDir = process.env.WORKSPACE_PATH;

Expand All @@ -40,7 +40,7 @@ describe("Run job on cluster", async function () {
JSON.stringify({
clusterId: process.env["TEST_DEFAULT_CLUSTER_ID"],
profile: "DEFAULT",
workspacePath: process.env["TEST_REPO_PATH"],
workspacePath: process.env["TEST_WORKSPACE_FOLDER_PATH"],
})
);
await fs.writeFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from "./utils.ts";
import {sleep} from "wdio-vscode-service";

describe("Run python on cluster", async function () {
describe("Run python on cluster with repo", async function () {
let projectDir: string;
this.timeout(3 * 60 * 1000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
} from "./utils.ts";
import {sleep} from "wdio-vscode-service";

describe("Run python on cluster", async function () {
describe("Run python on cluster with workspace", async function () {
let projectDir: string;
this.timeout(3 * 60 * 1000);

before(async () => {
assert(process.env.DATABRICKS_HOST);
assert(process.env.TEST_DEFAULT_CLUSTER_ID);
assert(process.env.TEST_REPO_PATH);
assert(process.env.TEST_WORKSPACE_FOLDER_PATH);
assert(process.env.WORKSPACE_PATH);
projectDir = process.env.WORKSPACE_PATH;

Expand Down Expand Up @@ -47,7 +47,7 @@ describe("Run python on cluster", async function () {
authType: "profile",
profile: "DEFAULT",
clusterId: process.env["TEST_DEFAULT_CLUSTER_ID"],
workspacePath: process.env["TEST_REPO_PATH"],
workspacePath: process.env["TEST_WORKSPACE_FOLDER_PATH"],
})
);
await fs.mkdir(path.join(projectDir, "nested"), {recursive: true});
Expand Down
10 changes: 10 additions & 0 deletions packages/databricks-vscode/src/test/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ export async function dismissNotifications() {
}

export async function waitForSyncComplete() {
await browser.waitUntil(
async () => {
return await getViewSubSection("CONFIGURATION", "Sync Destination");
},
{
timeout: 20000,
interval: 2000,
timeoutMsg: "Couldn't find sync destination tree items.",
}
);
await browser.waitUntil(
async () => {
const repoConfigItem = await getViewSubSection(
Expand Down
32 changes: 31 additions & 1 deletion packages/databricks-vscode/src/test/e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import path from "node:path";
import {fileURLToPath} from "url";
import assert from "assert";
import fs from "fs/promises";
import {WorkspaceClient, Cluster, Repo} from "@databricks/databricks-sdk";
import {
WorkspaceClient,
Cluster,
Repo,
WorkspaceFsEntity,
WorkspaceFsUtils,
} from "@databricks/databricks-sdk";
import * as ElementCustomCommands from "./customCommands/elementCustomCommands.ts";
import {execFile, ExecFileOptions} from "node:child_process";
import {mkdirSync} from "node:fs";
Expand Down Expand Up @@ -259,12 +265,14 @@ export const config: Options.Testrunner = {
process.env["DATABRICKS_TOKEN"]
);
const repoPath = await createRepo(client);
const workspaceFolderPath = await createWsFolder(client);
const configFile = await writeDatabricksConfig();
await startCluster(client, process.env["TEST_DEFAULT_CLUSTER_ID"]);

process.env.DATABRICKS_CONFIG_FILE = configFile;
process.env.WORKSPACE_PATH = WORKSPACE_PATH;
process.env.TEST_REPO_PATH = repoPath;
process.env.TEST_WORKSPACE_FOLDER_PATH = workspaceFolderPath;
} catch (e) {
console.error(e);
process.exit(1);
Expand Down Expand Up @@ -545,6 +553,28 @@ async function createRepo(workspaceClient: WorkspaceClient): Promise<string> {
return repo.path;
}

/**
* Create a workspace folder for the integration tests to use
*/
async function createWsFolder(
workspaceClient: WorkspaceClient
): Promise<string> {
const me = (await workspaceClient.currentUser.me()).userName!;
const wsFolderPath = `/Users/${me}/.ide/${REPO_NAME}`;

console.log(`Creating test Workspace Folder: ${wsFolderPath}`);

await workspaceClient.workspace.mkdirs({path: wsFolderPath});
const repo = await WorkspaceFsEntity.fromPath(
workspaceClient,
wsFolderPath
);
if (WorkspaceFsUtils.isDirectory(repo)) {
return repo.path;
}
throw Error(`Couldn't create worspace folder at ${wsFolderPath}`);
}

async function startCluster(
workspaceClient: WorkspaceClient,
clusterId: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class WorkspaceFsAccessVerifier implements Disposable {
} else {
if (
workspaceConfigs.syncDestinationType === "workspace" ||
!this.workspaceState.wsfsFeatureFlag ||
!(await this.isEnabledForWorkspace()) ||
this.workspaceState.skipSwitchToWorkspace
) {
Expand Down

0 comments on commit 2be752d

Please sign in to comment.