2023-09-07 14:08:16 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/databricks/cli/internal"
|
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) {
|
2023-09-07 14:08:16 +00:00
|
|
|
env := internal.GetEnvOrSkipTest(t, "CLOUD_ENV")
|
|
|
|
t.Log(env)
|
|
|
|
|
|
|
|
var nodeTypeId string
|
|
|
|
if env == "gcp" {
|
|
|
|
nodeTypeId = "n1-standard-4"
|
|
|
|
} else if env == "aws" {
|
|
|
|
nodeTypeId = "i3.xlarge"
|
|
|
|
} else {
|
|
|
|
nodeTypeId = "Standard_DS4_v2"
|
|
|
|
}
|
|
|
|
|
|
|
|
bundleRoot, err := initTestTemplate(t, "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)
|
|
|
|
|
|
|
|
err = deployBundle(t, bundleRoot)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
destroyBundle(t, bundleRoot)
|
|
|
|
})
|
|
|
|
|
|
|
|
out, err := runResource(t, bundleRoot, "some_other_job")
|
|
|
|
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
|
|
|
|
|
|
|
out, err = runResourceWithParams(t, bundleRoot, "some_other_job", "--python-params=param1,param2")
|
|
|
|
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) {
|
2023-10-20 15:03:29 +00:00
|
|
|
runPythonWheelTest(t, "13.2.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
|
|
|
}
|