2023-09-07 14:08:16 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/databricks/cli/internal"
|
2024-02-07 11:18:56 +00:00
|
|
|
"github.com/databricks/cli/internal/acc"
|
|
|
|
"github.com/databricks/cli/libs/env"
|
2023-09-07 20:02:26 +00:00
|
|
|
"github.com/google/uuid"
|
2023-09-07 14:08:16 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2023-10-20 15:03:29 +00:00
|
|
|
func runPythonWheelTest(t *testing.T, sparkVersion string, pythonWheelWrapper bool) {
|
2024-02-07 11:18:56 +00:00
|
|
|
ctx, _ := acc.WorkspaceTest(t)
|
|
|
|
|
|
|
|
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
|
|
|
|
bundleRoot, err := initTestTemplate(t, ctx, "python_wheel_task", map[string]any{
|
2023-09-26 14:32:20 +00:00
|
|
|
"node_type_id": nodeTypeId,
|
|
|
|
"unique_id": uuid.New().String(),
|
2023-10-20 15:03:29 +00:00
|
|
|
"spark_version": sparkVersion,
|
2023-09-26 14:32:20 +00:00
|
|
|
"python_wheel_wrapper": pythonWheelWrapper,
|
2023-09-07 14:08:16 +00:00
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-07 11:18:56 +00:00
|
|
|
err = deployBundle(t, ctx, bundleRoot)
|
2023-09-07 14:08:16 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
t.Cleanup(func() {
|
2024-02-07 11:18:56 +00:00
|
|
|
destroyBundle(t, ctx, bundleRoot)
|
2023-09-07 14:08:16 +00:00
|
|
|
})
|
|
|
|
|
2024-02-07 11:18:56 +00:00
|
|
|
out, err := runResource(t, ctx, bundleRoot, "some_other_job")
|
2023-09-07 14:08:16 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Contains(t, out, "Hello from my func")
|
|
|
|
require.Contains(t, out, "Got arguments:")
|
2023-09-26 14:32:20 +00:00
|
|
|
require.Contains(t, out, "['my_test_code', 'one', 'two']")
|
2023-12-01 10:35:20 +00:00
|
|
|
|
2024-02-07 11:18:56 +00:00
|
|
|
out, err = runResourceWithParams(t, ctx, bundleRoot, "some_other_job", "--python-params=param1,param2")
|
2023-12-01 10:35:20 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Contains(t, out, "Hello from my func")
|
|
|
|
require.Contains(t, out, "Got arguments:")
|
|
|
|
require.Contains(t, out, "['my_test_code', 'param1', 'param2']")
|
2023-09-26 14:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccPythonWheelTaskDeployAndRunWithoutWrapper(t *testing.T) {
|
2024-04-19 11:31:54 +00:00
|
|
|
// This is the first DBR version where we can install Python wheels from the Workspace File System.
|
|
|
|
runPythonWheelTest(t, "13.3.x-snapshot-scala2.12", false)
|
2023-09-26 14:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAccPythonWheelTaskDeployAndRunWithWrapper(t *testing.T) {
|
2023-10-20 15:03:29 +00:00
|
|
|
runPythonWheelTest(t, "12.2.x-scala2.12", true)
|
2023-09-07 14:08:16 +00:00
|
|
|
}
|