@@ -4,7 +4,6 @@ import type {Options} from "@wdio/types";
44
55// eslint-disable-next-line @typescript-eslint/no-var-requires
66const video = require ( "wdio-video-reporter" ) ;
7-
87import path from "node:path" ;
98import assert from "assert" ;
109import fs from "fs/promises" ;
@@ -120,7 +119,7 @@ export const config: Options.Testrunner = {
120119 // Define all options that are relevant for the WebdriverIO instance here
121120 //
122121 // Level of logging verbosity: trace | debug | info | warn | error | silent
123- logLevel : "info " ,
122+ logLevel : "debug " ,
124123
125124 outputDir : "logs" ,
126125
@@ -217,33 +216,37 @@ export const config: Options.Testrunner = {
217216 * @param {Array.<Object> } capabilities list of capabilities details
218217 */
219218 onPrepare : async function ( ) {
220- assert (
221- process . env [ "DATABRICKS_HOST" ] ,
222- "Environment variable DATABRICKS_HOST must be set"
223- ) ;
224- assert (
225- process . env [ "DATABRICKS_TOKEN" ] ,
226- "Environment variable DATABRICKS_TOKEN must be set"
227- ) ;
228- assert (
229- process . env [ "TEST_DEFAULT_CLUSTER_ID" ] ,
230- "Environment variable TEST_DEFAULT_CLUSTER_ID must be set"
231- ) ;
232-
233- await fs . rm ( WORKSPACE_PATH , { recursive : true , force : true } ) ;
234- await fs . mkdir ( WORKSPACE_PATH ) ;
235-
236- const apiClient = getApiClient (
237- process . env [ "DATABRICKS_HOST" ] ,
238- process . env [ "DATABRICKS_TOKEN" ]
239- ) ;
240- const repoPath = await createRepo ( apiClient ) ;
241- const configFile = await writeDatabricksConfig ( ) ;
242- await startCluster ( apiClient , process . env [ "TEST_DEFAULT_CLUSTER_ID" ] ) ;
243-
244- process . env . DATABRICKS_CONFIG_FILE = configFile ;
245- process . env . WORKSPACE_PATH = WORKSPACE_PATH ;
246- process . env . TEST_REPO_PATH = repoPath ;
219+ try {
220+ assert (
221+ process . env [ "DATABRICKS_TOKEN" ] ,
222+ "Environment variable DATABRICKS_TOKEN must be set"
223+ ) ;
224+ assert (
225+ process . env [ "TEST_DEFAULT_CLUSTER_ID" ] ,
226+ "Environment variable TEST_DEFAULT_CLUSTER_ID must be set"
227+ ) ;
228+
229+ await fs . rm ( WORKSPACE_PATH , { recursive : true , force : true } ) ;
230+ await fs . mkdir ( WORKSPACE_PATH ) ;
231+
232+ const apiClient = getApiClient (
233+ getHost ( ) ,
234+ process . env [ "DATABRICKS_TOKEN" ]
235+ ) ;
236+ const repoPath = await createRepo ( apiClient ) ;
237+ const configFile = await writeDatabricksConfig ( ) ;
238+ await startCluster (
239+ apiClient ,
240+ process . env [ "TEST_DEFAULT_CLUSTER_ID" ]
241+ ) ;
242+
243+ process . env . DATABRICKS_CONFIG_FILE = configFile ;
244+ process . env . WORKSPACE_PATH = WORKSPACE_PATH ;
245+ process . env . TEST_REPO_PATH = repoPath ;
246+ } catch ( e ) {
247+ console . error ( e ) ;
248+ process . exit ( 1 ) ;
249+ }
247250 } ,
248251
249252 /**
@@ -386,7 +389,7 @@ export const config: Options.Testrunner = {
386389 * @param {Array.<Object> } capabilities list of capabilities details
387390 * @param {<Object> } results object containing test results
388391 */
389- // onComplete: function(exitCode, config, capabilities, results) {
392+ // onComplete: function (exitCode, config, capabilities, results) {
390393 // },
391394
392395 /**
@@ -399,10 +402,6 @@ export const config: Options.Testrunner = {
399402} ;
400403
401404async function writeDatabricksConfig ( ) {
402- assert (
403- process . env [ "DATABRICKS_HOST" ] ,
404- "Environment variable DATABRICKS_HOST must be set"
405- ) ;
406405 assert (
407406 process . env [ "DATABRICKS_TOKEN" ] ,
408407 "Environment variable DATABRICKS_TOKEN must be set"
@@ -413,14 +412,10 @@ async function writeDatabricksConfig() {
413412 ) ;
414413
415414 const configFile = path . join ( WORKSPACE_PATH , ".databrickscfg" ) ;
416- let host = process . env [ "DATABRICKS_HOST" ] ;
417- if ( ! host . startsWith ( "http" ) ) {
418- host = `https://${ host } ` ;
419- }
420415 await fs . writeFile (
421416 configFile ,
422417 `[DEFAULT]
423- host = ${ host }
418+ host = ${ getHost ( ) }
424419token = ${ process . env [ "DATABRICKS_TOKEN" ] } `
425420 ) ;
426421
@@ -470,3 +465,17 @@ async function startCluster(apiClient: ApiClient, clusterId: string) {
470465 ) ;
471466 console . log ( `Cluster started` ) ;
472467}
468+
469+ function getHost ( ) {
470+ assert (
471+ process . env [ "DATABRICKS_HOST" ] ,
472+ "Environment variable DATABRICKS_HOST must be set"
473+ ) ;
474+
475+ let host = process . env [ "DATABRICKS_HOST" ] ;
476+ if ( ! host . startsWith ( "http" ) ) {
477+ host = `https://${ host } ` ;
478+ }
479+
480+ return host ;
481+ }
0 commit comments