Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/mw-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ cell or its observer credentials.
A `perf_queries` step targeting Trino consumes that stored readiness state. It
uses `status.principal` as the Trino username (not `root`), `status.catalog` as
the catalog, the provision response's root password, and schema `posthog` by
default. The coordinator URL comes from `cell.coordinator_url`. Isolated cells
must mount their per-run CA and set `trino_ca_cert_file`; the driver requires
verified HTTPS and never disables certificate verification.
default. The server URL is `https://<host>:<port>` from `status.connection`,
the cell's advertised client endpoint (the Gateway for a pooled cell). Isolated
cells must mount their per-run CA and set `trino_ca_cert_file`; the driver
requires verified HTTPS and never disables certificate verification.

Optional perf-step settings are:

Expand Down
16 changes: 7 additions & 9 deletions tests/mw-dev/scenario/perf/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,16 @@ func TestExecutorBuildsTrinoDriverFromReadinessState(t *testing.T) {
Password: "root-password",
})
provisionState.StoreTrinoStatus("scenario-org", provision.TrinoStatus{
Cell: provision.TrinoCell{
ID: "legacy",
CoordinatorURL: "https://trino.example.test:8443",
},
Cell: provision.TrinoCell{ID: "legacy"},
Enabled: true,
Available: true,
Status: &provision.TrinoOrgStatus{
Org: "scenario-org",
Principal: "org_database",
Catalog: "org_catalog",
Cell: "legacy",
State: provision.WarehouseStateReady,
Org: "scenario-org",
Principal: "org_database",
Catalog: "org_catalog",
Cell: "legacy",
State: provision.WarehouseStateReady,
Connection: &provision.TrinoConnection{Host: "trino.example.test", Port: 8443},
},
})
factory := &fakeDriverFactory{}
Expand Down
10 changes: 7 additions & 3 deletions tests/mw-dev/scenario/perf/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -510,14 +511,17 @@ func (e *Executor) trinoConnection(spec stepSpec) (trinodriver.ConnectionConfig,
status.Cell.ID == "" || status.Status.Cell != status.Cell.ID {
return trinodriver.ConnectionConfig{}, classified(ErrorClassConfig, fmt.Errorf("trino readiness state for org %q is incomplete; run wait_trino_ready before perf_queries", spec.OrgID))
}
if status.Cell.CoordinatorURL == "" {
return trinodriver.ConnectionConfig{}, classified(ErrorClassConfig, fmt.Errorf("trino readiness state for org %q has no coordinator URL", spec.OrgID))
// The cell's advertised client endpoint, the same one tenants are told to
// dial. Pooled cells have no fixed coordinator to connect to directly.
connection := status.Status.Connection
if connection == nil || connection.Host == "" || connection.Port <= 0 {
return trinodriver.ConnectionConfig{}, classified(ErrorClassConfig, fmt.Errorf("trino readiness state for org %q has no advertised client connection (status.connection)", spec.OrgID))
}
if status.Status.Principal == "" || status.Status.Catalog == "" {
return trinodriver.ConnectionConfig{}, classified(ErrorClassConfig, fmt.Errorf("trino readiness state for org %q has no principal or catalog", spec.OrgID))
}
return trinodriver.ConnectionConfig{
ServerURL: status.Cell.CoordinatorURL,
ServerURL: "https://" + net.JoinHostPort(connection.Host, strconv.Itoa(connection.Port)),
CatalogStoreCellID: e.trinoCatalogStoreCellID,
HoglakeCatalog: spec.TrinoHoglakeCatalog,
Username: status.Status.Principal,
Expand Down
15 changes: 11 additions & 4 deletions tests/mw-dev/scenario/provision/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ type TrinoStatus struct {
}

type TrinoCell struct {
ID string `json:"id"`
CoordinatorURL string `json:"coordinator_url,omitempty"`
ID string `json:"id"`
}

type TrinoOrgStatus struct {
Expand All @@ -90,8 +89,16 @@ type TrinoOrgStatus struct {
StatusMessage string `json:"status_message,omitempty"`
ReadyAt *time.Time `json:"ready_at,omitempty"`
FailedAt *time.Time `json:"failed_at,omitempty"`
RunningQueries int `json:"running_queries"`
QueuedQueries int `json:"queued_queries"`
// Connection is the cell's advertised client endpoint. The admin API
// includes it only once the org is ready on a reachable cell.
Connection *TrinoConnection `json:"connection,omitempty"`
RunningQueries int `json:"running_queries"`
QueuedQueries int `json:"queued_queries"`
}

type TrinoConnection struct {
Host string `json:"host"`
Port int `json:"port"`
}

type ConnectionDetails struct {
Expand Down
4 changes: 4 additions & 0 deletions tests/mw-dev/scenario/provision/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func TestClientTrinoStatusUsesOrgDetailEndpoint(t *testing.T) {
"tier": "free",
"cell": "cell-001",
"state": "ready",
"connection": map[string]any{"host": "duckgres-trino-gateway.ns.svc", "port": 8443, "username": "scenario-db"},
},
})
}))
Expand All @@ -250,6 +251,9 @@ func TestClientTrinoStatusUsesOrgDetailEndpoint(t *testing.T) {
if status.Status.Principal != "scenario-db" || status.Status.Catalog != "org_scenario_db" {
t.Fatalf("Trino identity = %+v, want scenario-db/org_scenario_db", status.Status)
}
if got := status.Status.Connection; got == nil || got.Host != "duckgres-trino-gateway.ns.svc" || got.Port != 8443 {
t.Fatalf("Trino connection = %+v, want advertised gateway endpoint", got)
}
}

func TestClientWaitTrinoReadyPollsUntilEnabledAvailableAndReady(t *testing.T) {
Expand Down
Loading