Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation checks if either configs ("enableProjectTypeInWorkspace", "enableWorkspaceFilesystem") are 'false' and makes them 'true' for valid installation #831

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/databricks/labs/ucx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def folder(self):

def run(self):
logger.info(f"Installing UCX v{PRODUCT_INFO.version()}")
self._enable_files_in_repos()
pritishpai marked this conversation as resolved.
Show resolved Hide resolved
pritishpai marked this conversation as resolved.
Show resolved Hide resolved
Threads.strict(
"installing components",
[
Expand Down Expand Up @@ -962,6 +963,21 @@ def validate_and_run(self, step: str):
if not self.validate_step(step):
self.run_workflow(step)

def _enable_files_in_repos(self):
# check if "enableProjectTypeInWorkspace" and "enableWorkspaceFilesystem" are set to false
project_type = self._ws.workspace_conf.get_status("enableProjectTypeInWorkspace")
pritishpai marked this conversation as resolved.
Show resolved Hide resolved
workspace_file_system = self._ws.workspace_conf.get_status("enableWorkspaceFilesystem")

logger.debug("Checking Files In Repos configuration")

if project_type["enableProjectTypeInWorkspace"] == "false":
logger.debug("enableProjectTypeInWorkspace is False, enabling the config")
self._ws.workspace_conf.set_status("enableProjectTypeInWorkspace")

if workspace_file_system["enableWorkspaceFilesystem"] == "false":
logger.debug("enableWorkspaceFilesystem is False, enabling the config")
self._ws.workspace_conf.set_status("enableWorkspaceFilesystem")
pritishpai marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
logger = get_logger(__file__)
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,12 @@ def test_uninstallation(ws, sql_backend, new_installation):
ws.jobs.get(job_id=assessment_job_id)
with pytest.raises(NotFound):
sql_backend.execute(f"show tables from hive_metastore.{install.config.inventory_database}")


def test_files_in_repos_enablement(new_installation):
pritishpai marked this conversation as resolved.
Show resolved Hide resolved
try:
install = new_installation()
install.uninstall()
except NotFound as e:
raise AssertionError() from e
assert True
33 changes: 33 additions & 0 deletions tests/unit/test_install.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import random
from datetime import timedelta
from unittest.mock import MagicMock, create_autospec

Expand Down Expand Up @@ -93,6 +94,14 @@ def ws():
return ws


def mock_get_status(*args, **kwargs):
random_return_value = random.choice(["true", "false"])
if args[0] == 'enableProjectTypeInWorkspace':
return {"enableProjectTypeInWorkspace": random_return_value}
elif args[0] == 'enableWorkspaceFilesystem':
return {"enableWorkspaceFilesystem": random_return_value}


def created_job(ws: MagicMock, name: str):
for call in ws.jobs.method_calls:
if call.kwargs['name'] == name:
Expand Down Expand Up @@ -1045,3 +1054,27 @@ def test_repair_run_result_state(ws, caplog, mock_installation_with_jobs, any_pr

workspace_installation.repair_run("assessment")
assert "Please try after sometime" in caplog.text


def test_enable_files_in_repos(ws, mock_installation, any_prompt, mocker):
sql_backend = MockBackend(
fails_on_first={'CREATE TABLE': '[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column, variable is incorrect'}
)
wheels = create_autospec(WheelsV2)

ws.workspace_conf.get_status = mocker.patch(
"databricks.sdk.service.settings.WorkspaceConfAPI.get_status", side_effect=mock_get_status
)

workspace_installation = WorkspaceInstallation(
WorkspaceConfig(inventory_database='ucx'),
mock_installation,
sql_backend,
wheels,
ws,
any_prompt,
timedelta(seconds=1),
)

workspace_installation._enable_files_in_repos()
assert True
Loading