From 8f7bcb540aec1c7083b86d38d2e1e5a0f84a3de6 Mon Sep 17 00:00:00 2001 From: Bill Guowei Yang Date: Thu, 1 Oct 2026 10:27:37 -0400 Subject: [PATCH] fix(scenario): read Trino endpoint from status.connection #1246 removed cell.coordinator_url from GET /api/v1/orgs/:id/trino; pooled cells advertise their client endpoint (the Gateway) as status.connection instead. The scenario perf step still required the removed field, so the nightly posthog_frozen_perf run failed at perf_queries with "has no coordinator URL" even though the stack was healthy. Build the Trino server URL from status.connection host/port, the same source tests/mw-dev/e2e/trino.sh already uses. Co-Authored-By: Claude Opus 5.5 --- tests/mw-dev/README.md | 7 ++++--- tests/mw-dev/scenario/perf/adapter_test.go | 16 +++++++--------- tests/mw-dev/scenario/perf/steps.go | 10 +++++++--- tests/mw-dev/scenario/provision/client.go | 15 +++++++++++---- tests/mw-dev/scenario/provision/client_test.go | 4 ++++ 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/tests/mw-dev/README.md b/tests/mw-dev/README.md index 6c85bbef3..94ed9cd6e 100644 --- a/tests/mw-dev/README.md +++ b/tests/mw-dev/README.md @@ -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://:` 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: diff --git a/tests/mw-dev/scenario/perf/adapter_test.go b/tests/mw-dev/scenario/perf/adapter_test.go index 3f28e9deb..6fe3e7cc5 100644 --- a/tests/mw-dev/scenario/perf/adapter_test.go +++ b/tests/mw-dev/scenario/perf/adapter_test.go @@ -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{} diff --git a/tests/mw-dev/scenario/perf/steps.go b/tests/mw-dev/scenario/perf/steps.go index f1cd56521..790bc6f36 100644 --- a/tests/mw-dev/scenario/perf/steps.go +++ b/tests/mw-dev/scenario/perf/steps.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "net" "path/filepath" "strconv" "strings" @@ -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, diff --git a/tests/mw-dev/scenario/provision/client.go b/tests/mw-dev/scenario/provision/client.go index 7f922e441..c6f50ae79 100644 --- a/tests/mw-dev/scenario/provision/client.go +++ b/tests/mw-dev/scenario/provision/client.go @@ -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 { @@ -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 { diff --git a/tests/mw-dev/scenario/provision/client_test.go b/tests/mw-dev/scenario/provision/client_test.go index 4568257b9..80d5b6460 100644 --- a/tests/mw-dev/scenario/provision/client_test.go +++ b/tests/mw-dev/scenario/provision/client_test.go @@ -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"}, }, }) })) @@ -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) {