Make bind/schema acceptance test run locally (#2463)

## Changes
<!-- Brief summary of your changes that is easy to understand -->
1. Change the cloud acceptance test for `bind/schema` to run locally
2. Add debug lines to the mock server
3. Change `fake_workspace` to create directories for imported files

## Why
<!-- Why are these changes needed? Provide the context that the reviewer
might be missing.
For example, were there any decisions behind the change that are not
reflected in the code itself? -->
1. Local version of the test run can indicate breaking changes faster
than the cloud version and it can be run locally without any predefined
environment variables

## Tests
<!-- How have you tested the changes? -->
1. Ran both acloud and local versions of test, both succeeded

<!-- If your PR needs to be included in the release notes for next
release,
add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
This commit is contained in:
Anton Nekipelov 2025-03-11 13:25:32 +01:00 committed by GitHub
parent 6f9ddf4b20
commit e2a5953568
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 5 deletions

View File

@ -223,7 +223,9 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
if !isTruePtr(config.Cloud) && cloudEnv != "" {
t.Skipf("Disabled via Cloud setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
} else {
}
if cloudEnv != "" {
if isTruePtr(config.RequiresUnityCatalog) && os.Getenv("TEST_METASTORE_ID") == "" {
t.Skipf("Skipping on non-UC workspaces")
}
@ -361,6 +363,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
absDir, err := filepath.Abs(dir)
require.NoError(t, err)
cmd.Env = append(cmd.Env, "TESTDIR="+absDir)
cmd.Env = append(cmd.Env, "CLOUD_ENV="+cloudEnv)
// Write combined output to a file
out, err := os.Create(filepath.Join(tmpDir, "output.txt"))

View File

@ -3,8 +3,7 @@
=== Substitute variables in the template:
=== Create a pre-defined schema: {
"full_name": "main.test-schema-[UUID]",
"catalog_name": "main",
"comment": null
"catalog_name": "main"
}
=== Bind schema: Updating deployment state...

View File

@ -2,12 +2,16 @@ title "Bind schema test: "
title "Substitute variables in the template: "
export BUNDLE_NAME_SUFFIX=$(uuid)
export SCHEMA_NAME="test-schema-$(uuid)"
if [ -z "$CLOUD_ENV" ]; then
export SCHEMA_NAME="test-schema-6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
fi
envsubst < databricks.yml > out.yml && mv out.yml databricks.yml
title "Create a pre-defined schema: "
CATALOG_NAME=main
$CLI schemas create ${SCHEMA_NAME} ${CATALOG_NAME} | jq '{full_name, catalog_name, comment}'
$CLI schemas create ${SCHEMA_NAME} ${CATALOG_NAME} | jq '{full_name, catalog_name}'
cleanupRemoveSchema() {
title "Test cleanup: "

View File

@ -1,3 +1,30 @@
Local = false
Local = true
Cloud = true
RequiresUnityCatalog = true
[[Server]]
Pattern = "POST /api/2.1/unity-catalog/schemas"
Response.Body = '''
{
"name":"test-schema-6260d50f-e8ff-4905-8f28-812345678903",
"catalog_name":"main",
"full_name":"main.test-schema-6260d50f-e8ff-4905-8f28-812345678903"
}
'''
[[Server]]
Pattern = "GET /api/2.1/unity-catalog/schemas/{schema_fullname}"
Response.Body = '''
{
"name":"test-schema-6260d50f-e8ff-4905-8f28-812345678903",
"catalog_name":"main",
"full_name":"main.test-schema-6260d50f-e8ff-4905-8f28-812345678903",
"comment": "This schema was created from DABs"
}
'''
[[Server]]
Pattern = "PATCH /api/2.1/unity-catalog/schemas/{schema_fullname}"
[[Server]]
Pattern = "DELETE /api/2.1/unity-catalog/schemas/{schema_fullname}"