From 6f20e88b4ad49732edbc27fa8e5a2c9bd7b6deb3 Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Tue, 21 Jan 2025 18:16:06 +0100 Subject: [PATCH] Added annotations to output --- .../variables/var_file_overrides/output.txt | 11 ++++++++++ .../variables/var_file_overrides/script | 22 +++++++++---------- acceptance/script.prepare | 5 +++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/acceptance/bundle/variables/var_file_overrides/output.txt b/acceptance/bundle/variables/var_file_overrides/output.txt index f5b9d20b1..cc5c98485 100644 --- a/acceptance/bundle/variables/var_file_overrides/output.txt +++ b/acceptance/bundle/variables/var_file_overrides/output.txt @@ -1,4 +1,5 @@ +=== variable file >>> $CLI bundle validate -o json --var-file=var_files/normal.json { "job_cluster_key": "mlops_stacks-cluster", @@ -8,6 +9,7 @@ } } +=== default variable file (see .databricks/*) >>> $CLI bundle validate -o json --target with-default-variable-file { "job_cluster_key": "mlops_stacks-cluster-2", @@ -17,6 +19,7 @@ } } +=== variable file and variable flag >>> $CLI bundle validate -o json --var-file=var_files/normal.json --var=cluster_key=mlops_stacks-cluster-overriden { "job_cluster_key": "mlops_stacks-cluster-overriden", @@ -26,6 +29,7 @@ } } +=== variable file and environment variable >>> BUNDLE_VAR_cluster_key=incorrectly-overriden $CLI bundle validate -o json --var-file=var_files/normal.json { "job_cluster_key": "mlops_stacks-cluster", @@ -35,6 +39,7 @@ } } +=== file not found >>> errcode $CLI bundle validate -o json --var-file=var_files/not_found.json Error: failed to read variables file: open var_files/not_found.json: @@ -48,6 +53,7 @@ Exit code: 1 } } +=== file cannot be parsed >>> errcode $CLI bundle validate -o json --var-file=var_files/invalid_json.json Error: failed to parse variables file: error decoding JSON at :0:0: invalid character 'o' in literal false (expecting 'a') @@ -61,6 +67,7 @@ Exit code: 1 } } +=== file has wrong structure >>> errcode $CLI bundle validate -o json --var-file=var_files/wrong_file_structure.json Error: failed to parse variables file: var_files/wrong_file_structure.json:1:1: expected a map, found a sequence in var_files/wrong_file_structure.json:1:1 @@ -78,6 +85,7 @@ Exit code: 1 } } +=== file has variable name that is not defined >>> errcode $CLI bundle validate -o json --var-file=var_files/undeclared.json Error: variable undeclared_var has not been defined @@ -91,6 +99,7 @@ Exit code: 1 } } +=== file has variable name that is complex but default is string >>> errcode $CLI bundle validate -o json --var-file=var_files/complex_to_string.json Error: expected a map to index "variables.cluster.value.node_type_id", found string @@ -104,6 +113,7 @@ Exit code: 1 } } +=== file has variable name that is string but default is complex >>> errcode $CLI bundle validate -o json --var-file=var_files/string_to_complex.json Error: failed to assign map[node_type_id:Standard_DS3_v2] to cluster_key: variable type is not complex @@ -117,6 +127,7 @@ Exit code: 1 } } +=== variable is required but it's not provided in the file >>> errcode $CLI bundle validate -o json --target without-defaults --var-file=var_files/without_required.json Error: no value assigned to required variable cluster. Assignment can be done using "--var" or "--var-file", by setting the BUNDLE_VAR_cluster environment variable, or in .databricks/bundle//vars.json file diff --git a/acceptance/bundle/variables/var_file_overrides/script b/acceptance/bundle/variables/var_file_overrides/script index 9dab54bda..8f1f6700e 100644 --- a/acceptance/bundle/variables/var_file_overrides/script +++ b/acceptance/bundle/variables/var_file_overrides/script @@ -1,35 +1,35 @@ cluster_expr=".resources.jobs.job1.job_clusters[0]" -# variable file +title "variable file" trace $CLI bundle validate -o json --var-file=var_files/normal.json | jq $cluster_expr -# default variable file (see .databricks/*) +title "default variable file (see .databricks/*)" trace $CLI bundle validate -o json --target with-default-variable-file | jq $cluster_expr -# variable file and variable flag +title "variable file and variable flag" trace $CLI bundle validate -o json --var-file=var_files/normal.json --var="cluster_key=mlops_stacks-cluster-overriden" | jq $cluster_expr -# variable file and environment variable +title "variable file and environment variable" trace BUNDLE_VAR_cluster_key=incorrectly-overriden $CLI bundle validate -o json --var-file=var_files/normal.json | jq $cluster_expr -# file not found +title "file not found" trace errcode $CLI bundle validate -o json --var-file=var_files/not_found.json 2> >(sed 's/\(Error: failed to read variables file: open var_files\/not_found.json:\).*/\1/' >&2) > tmp.txt jq "$cluster_expr" tmp.txt -# file cannot be parsed +title "file cannot be parsed" trace errcode $CLI bundle validate -o json --var-file=var_files/invalid_json.json | jq $cluster_expr -# file has wrong structure +title "file has wrong structure" trace errcode $CLI bundle validate -o json --var-file=var_files/wrong_file_structure.json | jq $cluster_expr -# file has variable name that is not defined +title "file has variable name that is not defined" trace errcode $CLI bundle validate -o json --var-file=var_files/undeclared.json | jq $cluster_expr -# file has variable name that is complex but default is string +title "file has variable name that is complex but default is string" trace errcode $CLI bundle validate -o json --var-file=var_files/complex_to_string.json | jq $cluster_expr -# file has variable name that is string but default is complex +title "file has variable name that is string but default is complex" trace errcode $CLI bundle validate -o json --var-file=var_files/string_to_complex.json | jq $cluster_expr -# variable is required but it's not provided in the file +title "variable is required but it's not provided in the file" trace errcode $CLI bundle validate -o json --target without-defaults --var-file=var_files/without_required.json | jq $cluster_expr diff --git a/acceptance/script.prepare b/acceptance/script.prepare index 61061b59e..4932e45f5 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -40,3 +40,8 @@ git-repo-init() { git add databricks.yml git commit -qm 'Add databricks.yml' } + +title() { + local label="$1" + printf "\n=== %s" "$label" +}