diff --git a/packages/databricks-vscode/package.json b/packages/databricks-vscode/package.json index b3662e31b..1c30fd2fb 100644 --- a/packages/databricks-vscode/package.json +++ b/packages/databricks-vscode/package.json @@ -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." } } } diff --git a/packages/databricks-vscode/src/configuration/ConnectionManager.test.ts b/packages/databricks-vscode/src/configuration/ConnectionManager.test.ts index d6b1fe3d1..57801b5b5 100644 --- a/packages/databricks-vscode/src/configuration/ConnectionManager.test.ts +++ b/packages/databricks-vscode/src/configuration/ConnectionManager.test.ts @@ -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; beforeEach(() => { disposables = []; - mockedCliWrapper = mock(CliWrapper); }); afterEach(() => { disposables.forEach((d) => d.dispose()); }); - it("should create an instance", async () => { - new ConnectionManager(instance(mockedCliWrapper)); - }); - // TODO // login // logout diff --git a/packages/databricks-vscode/src/configuration/ConnectionManager.ts b/packages/databricks-vscode/src/configuration/ConnectionManager.ts index d0e2e596e..2a15c3663 100644 --- a/packages/databricks-vscode/src/configuration/ConnectionManager.ts +++ b/packages/databricks-vscode/src/configuration/ConnectionManager.ts @@ -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"; @@ -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; @@ -218,7 +222,8 @@ export class ConnectionManager { if ( this.databricksWorkspace && - workspaceConfigs.enableFilesInWorkspace + (workspaceConfigs.enableFilesInWorkspace || + this.workspaceState.wsfsFeatureFlag) ) { await this.createRootDirectory( workspaceClient, diff --git a/packages/databricks-vscode/src/extension.ts b/packages/databricks-vscode/src/extension.ts index 0bd231a53..606ba211e 100644 --- a/packages/databricks-vscode/src/extension.ts +++ b/packages/databricks-vscode/src/extension.ts @@ -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( diff --git a/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_repo.e2e.ts b/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_repo.e2e.ts index 00e279c16..b49e77800 100644 --- a/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_repo.e2e.ts +++ b/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_repo.e2e.ts @@ -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); diff --git a/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_workspace.e2e.ts b/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_workspace.e2e.ts index d3310f752..03f1ed9f1 100644 --- a/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_workspace.e2e.ts +++ b/packages/databricks-vscode/src/test/e2e/run_job_on_cluster_with_workspace.e2e.ts @@ -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; @@ -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( diff --git a/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_repo.e2e.ts b/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_repo.e2e.ts index 288e2c0c3..270d363f7 100644 --- a/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_repo.e2e.ts +++ b/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_repo.e2e.ts @@ -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); diff --git a/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_workspace.e2e.ts b/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_workspace.e2e.ts index 3eb583f61..59ef11cbf 100644 --- a/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_workspace.e2e.ts +++ b/packages/databricks-vscode/src/test/e2e/run_on_cluster_with_workspace.e2e.ts @@ -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; @@ -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}); diff --git a/packages/databricks-vscode/src/test/e2e/utils.ts b/packages/databricks-vscode/src/test/e2e/utils.ts index ec8a32f68..0b1645005 100644 --- a/packages/databricks-vscode/src/test/e2e/utils.ts +++ b/packages/databricks-vscode/src/test/e2e/utils.ts @@ -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( diff --git a/packages/databricks-vscode/src/test/e2e/wdio.conf.ts b/packages/databricks-vscode/src/test/e2e/wdio.conf.ts index d972a118a..26e19cdfe 100644 --- a/packages/databricks-vscode/src/test/e2e/wdio.conf.ts +++ b/packages/databricks-vscode/src/test/e2e/wdio.conf.ts @@ -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"; @@ -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); @@ -545,6 +553,28 @@ async function createRepo(workspaceClient: WorkspaceClient): Promise { return repo.path; } +/** + * Create a workspace folder for the integration tests to use + */ +async function createWsFolder( + workspaceClient: WorkspaceClient +): Promise { + 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 diff --git a/packages/databricks-vscode/src/workspace-fs/WorkspaceFsAccessVerifier.ts b/packages/databricks-vscode/src/workspace-fs/WorkspaceFsAccessVerifier.ts index a4fc01f93..189ab2d27 100644 --- a/packages/databricks-vscode/src/workspace-fs/WorkspaceFsAccessVerifier.ts +++ b/packages/databricks-vscode/src/workspace-fs/WorkspaceFsAccessVerifier.ts @@ -139,6 +139,7 @@ export class WorkspaceFsAccessVerifier implements Disposable { } else { if ( workspaceConfigs.syncDestinationType === "workspace" || + !this.workspaceState.wsfsFeatureFlag || !(await this.isEnabledForWorkspace()) || this.workspaceState.skipSwitchToWorkspace ) {