Ensure that python dependencies are installed during upgrade (#1390)

## Changes
The installer.Upgrade() processing did not install Python dependencies.
This resulted in errors such as:

```
ModuleNotFoundError: No module named 'databricks.labs.blueprint'
```

Any new dependencies are now installed during the upgrade process.

Resolves: databrickslabs/ucx#1276

## Tests

The TestUpgraderWorksForReleases test now checks to see if the upgrade
process resulted in the dependencies being installed.

---------

Signed-off-by: Jim.Idle <jimi@idle.ws>
This commit is contained in:
Jim Idle 2024-04-24 11:34:09 -06:00 committed by GitHub
parent 1c02224902
commit 4c71f8cac4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View File

@ -136,6 +136,10 @@ func (i *installer) Upgrade(ctx context.Context) error {
if err != nil {
return fmt.Errorf("installer: %w", err)
}
err = i.installPythonDependencies(ctx, ".")
if err != nil {
return fmt.Errorf("python dependencies: %w", err)
}
return nil
}

View File

@ -403,6 +403,12 @@ func TestUpgraderWorksForReleases(t *testing.T) {
newHome := copyTestdata(t, "testdata/installed-in-home")
ctx = env.WithUserHomeDir(ctx, newHome)
// Install stubs for the python calls we need to ensure were run in the
// upgrade process.
ctx, stub := process.WithStub(ctx)
stub.WithStderrFor(`python[\S]+ -m pip install .`, "[mock pip install]")
stub.WithStdoutFor(`python[\S]+ install.py`, "setting up important infrastructure")
py, _ := python.DetectExecutable(ctx)
py, _ = filepath.Abs(py)
ctx = env.Set(ctx, "PYTHON_BIN", py)
@ -420,4 +426,17 @@ func TestUpgraderWorksForReleases(t *testing.T) {
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "upgrade", "blueprint")
r.RunAndExpectOutput("setting up important infrastructure")
// Check if the stub was called with the 'python -m pip install' command
pi := false
for _, call := range stub.Commands() {
if strings.HasSuffix(call, "-m pip install .") {
pi = true
break
}
}
if !pi {
t.Logf(`Expected stub command 'python[\S]+ -m pip install .' not found`)
t.FailNow()
}
}