Skip to content

Commit

Permalink
Fix test connector acquire
Browse files Browse the repository at this point in the history
  • Loading branch information
begelundmuller committed Dec 12, 2024
1 parent aca2be3 commit 2e07547
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions runtime/drivers/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ func (d driver) Open(instanceID string, config map[string]any, st *storage.Clien
if err != nil {
return nil, err
}
} else {
return nil, errors.New("no clickhouse connection configured: 'dsn', 'host' or 'managed: true' must be set")
}

db := sqlx.NewDb(otelsql.OpenDB(clickhouse.Connector(opts)), "clickhouse")
Expand Down
1 change: 1 addition & 0 deletions runtime/metricsview/executor_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ select parseDateTimeBestEffort('2024-01-05T00:00:00Z') as time, 'DK' as country,
`,
},
})
testruntime.RequireReconcileState(t, rt, instanceID, 2, 0, 0)

// Test cases of metrics view YAML partials defining dimensions and measures.
cases := []struct {
Expand Down
2 changes: 2 additions & 0 deletions runtime/testruntime/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package testruntime
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
goruntime "runtime"
Expand Down Expand Up @@ -64,6 +65,7 @@ var Connectors = map[string]ConnectorAcquireFunc{
require.NoError(t, err)

t.Cleanup(func() {
log.Printf("TERMINATING")
err := clickHouseContainer.Terminate(ctx)
require.NoError(t, err)
})
Expand Down
9 changes: 7 additions & 2 deletions runtime/testruntime/testruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ func NewInstanceWithOptions(t TestingT, opts InstanceOptions) (*runtime.Runtime,
vars["rill.stage_changes"] = strconv.FormatBool(opts.StageChanges)

for _, conn := range opts.TestConnectors {
connVars := Connectors[conn](t)
maps.Copy(vars, connVars)
acquire, ok := Connectors[conn]
require.True(t, ok, "unknown test connector %q", conn)
cfg := acquire(t)
for k, v := range cfg {
k = fmt.Sprintf("connector.%s.%s", conn, k)
vars[k] = v
}
}

tmpDir := t.TempDir()
Expand Down

0 comments on commit 2e07547

Please sign in to comment.