@@ -31,12 +31,18 @@ func init() {
3131 }
3232}
3333
34+ // testEnvironmentType returns the value of the TEST_ENVIRONMENT_TYPE
35+ // environment variable, which controls integration test filtering.
36+ func testEnvironmentType () string {
37+ return os .Getenv ("TEST_ENVIRONMENT_TYPE" )
38+ }
39+
3440// prelude for all workspace-level tests
3541func workspaceTest (t * testing.T ) (context.Context , * databricks.WorkspaceClient ) {
3642 loadDebugEnvIfRunsFromIDE (t , "workspace" )
3743 t .Log (GetEnvOrSkipTest (t , "CLOUD_ENV" ))
38- if os . Getenv ( "DATABRICKS_ACCOUNT_ID" ) != "" {
39- skipf (t )("Skipping workspace test on account level" )
44+ if envType := testEnvironmentType (); envType != "" && envType != "WORKSPACE" && envType != "UC_WORKSPACE " {
45+ skipf (t )("Skipping workspace test: TEST_ENVIRONMENT_TYPE=%s" , envType )
4046 }
4147 t .Parallel ()
4248 ctx := context .Background ()
@@ -46,8 +52,8 @@ func workspaceTest(t *testing.T) (context.Context, *databricks.WorkspaceClient)
4652// prelude for all workspace-level UC tests
4753func ucwsTest (t * testing.T ) (context.Context , * databricks.WorkspaceClient ) {
4854 loadDebugEnvIfRunsFromIDE (t , "ucws" )
49- if os . Getenv ( "DATABRICKS_ACCOUNT_ID" ) != "" {
50- skipf (t )("Skipping workspace test on account level" )
55+ if envType := testEnvironmentType (); envType != "" && envType != "UC_WORKSPACE " {
56+ skipf (t )("Skipping UC workspace test: TEST_ENVIRONMENT_TYPE=%s" , envType )
5157 }
5258 GetEnvOrSkipTest (t , "TEST_METASTORE_ID" )
5359 t .Parallel ()
@@ -91,6 +97,9 @@ func unifiedHostAccountTest(t *testing.T) (context.Context, *databricks.AccountC
9197// prelude for all account-level tests
9298func accountTest (t * testing.T ) (context.Context , * databricks.AccountClient ) {
9399 loadDebugEnvIfRunsFromIDE (t , "account" )
100+ if envType := testEnvironmentType (); envType != "" && envType != "ACCOUNT" && envType != "UC_ACCOUNT" {
101+ skipf (t )("Skipping account test: TEST_ENVIRONMENT_TYPE=%s" , envType )
102+ }
94103 cfg := & config.Config {
95104 AccountID : GetEnvOrSkipTest (t , "DATABRICKS_ACCOUNT_ID" ),
96105 // Large timeout to support API calls that take long.
@@ -102,9 +111,6 @@ func accountTest(t *testing.T) (context.Context, *databricks.AccountClient) {
102111 if err != nil {
103112 skipf (t )("error: %s" , err )
104113 }
105- if cfg .HostType () == config .WorkspaceHost {
106- skipf (t )("Not in account env: %s/%s" , cfg .AccountID , cfg .Host )
107- }
108114 t .Log (GetEnvOrSkipTest (t , "CLOUD_ENV" ))
109115 t .Parallel ()
110116 ctx := context .Background ()
@@ -115,16 +121,16 @@ func accountTest(t *testing.T) (context.Context, *databricks.AccountClient) {
115121// prelude for all UC account-level tests
116122func ucacctTest (t * testing.T ) (context.Context , * databricks.AccountClient ) {
117123 loadDebugEnvIfRunsFromIDE (t , "ucacct" )
124+ if envType := testEnvironmentType (); envType != "" && envType != "UC_ACCOUNT" {
125+ skipf (t )("Skipping UC account test: TEST_ENVIRONMENT_TYPE=%s" , envType )
126+ }
118127 cfg := & config.Config {
119128 AccountID : GetEnvOrSkipTest (t , "DATABRICKS_ACCOUNT_ID" ),
120129 }
121130 err := cfg .EnsureResolved ()
122131 if err != nil {
123132 skipf (t )("error: %s" , err )
124133 }
125- if cfg .HostType () == config .WorkspaceHost {
126- skipf (t )("Not in account env: %s/%s" , cfg .AccountID , cfg .Host )
127- }
128134 t .Log (GetEnvOrSkipTest (t , "CLOUD_ENV" ))
129135 t .Parallel ()
130136 ctx := context .Background ()
0 commit comments