Skip to content

Commit 438b341

Browse files
authored
feat: Parameterize location and improve error messaging (#289)
1 parent 9dcdd07 commit 438b341

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

test/integration/data_warehouse/data_warehouse_test.go

+7-14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"log"
2020
"os"
2121
"reflect"
22+
"strings"
2223
"testing"
2324
"time"
2425

@@ -45,14 +46,15 @@ func TestDataWarehouse(t *testing.T) {
4546
projectID := dwh.GetTFSetupStringOutput("project_id")
4647
bucket := dwh.GetStringOutput("raw_bucket")
4748
workflow := "initial-workflow"
49+
location := "asia-southeast1"
4850

49-
// Assert that the bucket is in asia-southeast1
51+
// Assert that the bucket is in location defined above
5052
bucketOP := gcloud.Runf(t, "storage buckets describe gs://%s --project %s", bucket, projectID)
51-
assert.Equal("ASIA-SOUTHEAST1", bucketOP.Get("location").String(), "Bucket should be in asia-southeast1")
53+
assert.Equal("ASIA-SOUTHEAST1", bucketOP.Get("location").String(), "Bucket should be in %[1]s \n", strings.ToUpper(location))
5254

5355
// Assert that Workflow ran successfully
5456
verifyWorkflows := func() (bool, error) {
55-
workflowState := gcloud.Runf(t, "workflows executions list %s --project %s --location=asia-southeast1 --limit=1", workflow, projectID).Array()
57+
workflowState := gcloud.Runf(t, "workflows executions list %s --project %s --location=%s --limit=1", workflow, projectID, location).Array()
5658
state := workflowState[0].Get("state").String()
5759
assert.NotEqual(t, state, "FAILED")
5860
if state == "SUCCEEDED" {
@@ -92,21 +94,16 @@ func TestDataWarehouse(t *testing.T) {
9294
for _, table := range tables {
9395
query := fmt.Sprintf(query_template, projectID, table)
9496
op := bq.Runf(t, "--project_id=%[1]s --headless=true query --nouse_legacy_sql %[2]s", projectID, query)
95-
fmt.Print(op)
9697

9798
count := op.Get("0.count_rows").Int()
98-
fmt.Printf("Table has %d rows \n", count)
9999
count_kind := reflect.TypeOf(count).Kind()
100-
fmt.Printf("count has type %s \n", count_kind)
101100
test_result := assert.Greater(count, int64(0))
102101
if test_result == true {
103-
fmt.Printf("Table `%s` has %d rows. Test passed! \n", table, count)
104102
} else {
105-
fmt.Printf("Some kind of error occurred while running the count query for the %s table. We think it has %d rows. Test failed. \n", table, count)
103+
fmt.Printf("Some kind of error occurred while running the count query for the %[1]s table. We think it has %[2]d rows. Test failed. Here's some additional details: \n Query results. If this number is greater than 0, then there is probably an issue in the comparison: %[3]s \n Variable type for the count. This should be INT64: %[4]s \n ", table, count, op, count_kind)
106104
}
107105
}
108106
}
109-
110107
test_tables()
111108

112109
// Assert BigQuery connection to Vertex GenAI was successfully created and works as expected
@@ -118,17 +115,13 @@ func TestDataWarehouse(t *testing.T) {
118115

119116
llm_count := llm_op.Get("0.count_rows").Int()
120117
count_llm_kind := reflect.TypeOf(llm_count).Kind()
121-
fmt.Printf("llm_count has type %s", count_llm_kind)
122118
llm_test_result := assert.Greater(llm_count, int64(0))
123119
if llm_test_result == true {
124-
fmt.Printf("LLM table has %d rows. Test passed! \n", llm_count)
125120
} else {
126-
fmt.Printf("Some kind of error occurred while running the count query for the LLM table. We think it has %d rows. Test failed. \n", llm_count)
121+
fmt.Printf("Some kind of error occurred while running the llm_count query. We think it has %[1]d rows. Here's some additional details: \n Query results. If this number is greater than 0, then there is probably an issue in the comparison: %[2]s \n Variable type for the count. This should be INT64: %[3]s \n ", llm_count, llm_op, count_llm_kind)
127122
}
128123
}
129-
130124
test_llms()
131125
})
132126
dwh.Test()
133127
}
134-

0 commit comments

Comments
 (0)