Files
greptimedb/tests-integration
dennis zhuang 15ca57ca20 fix(promql): publish legacy columns for native TQL in CTEs and flows (#10666)
* fix(promql): keep the native name column out of TQL CTEs and flows

The native rows layout always appends a per-row `__name__` column. The
Prometheus HTTP response reads it, but two SQL-visible consumers took it
as part of the statement's columns:

- A hybrid CTE published it after the existing planner's columns, so
  `WITH t (ts, val) AS (TQL EVAL ... metric)` failed with a column count
  mismatch on the native route.
- A TQL flow matched it against the sink table and failed with "found 4
  flow output columns and 3 sink table columns".

A CTE now publishes exactly the existing planner's columns over the
native plan. A TQL flow plans its query with the native route off, like
CREATE VIEW does, because its output columns are the sink table's schema
and the native route also names value columns differently.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(flow): plan TQL flows on the native route with the existing columns

The previous commit kept a TQL flow's sink schema stable by forcing the
existing PromQL planner. Plan it like a TQL CTE instead: run natively and
publish the existing planner's columns over the native plan.

`LogicalPlanner::plan_relation` plans a statement whose columns are read
by SQL. The CTE path and `sql_to_df_plan` both use it.

The standalone test harness now starts the flow consistency check task,
which `ADMIN FLUSH_FLOW` syncs with, so the flow test can run the flow
and compare the sink table and rows with the existing route's.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(promql): pair per-series columns by role when a TQL CTE or flow runs natively

publish_legacy_schema paired the columns it could not match by name by
type alone, so a series with two string labels left both label columns
ambiguous and the statement fell back to the existing plan. Per-series
outputs such as rate(), topk(), offset binaries and label_replace() over
a table with more than one tag never ran natively in a CTE or a flow.

Pair the time index by its marker, labels by name, and the remaining
value columns in order, with the same casts as before.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test: start the flow check task only in the flow test

The standalone harness started the flow consistent-check task for every
instance. The task runs on the global runtime and holds the flow engine,
and nothing stopped it, so it outlived the instance and each rebuild
started another one. The harness now exposes the flow engine, and the
flow test that needs ADMIN FLUSH_FLOW starts the task and stops it.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(promql): check a two-field TQL CTE keeps each value column

The native route pairs value columns with the existing ones by position.
Two fields with different values make a swapped pair visible.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* style: format the two-field CTE test

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(flow): key a TQL sink table on every label of the answer

The sink table of a TQL flow took its primary key from the innermost
aggregate when the plan had one. In `m / scalar(sum(m))` that aggregate
groups by time alone, so the labels of `m` were created as DOUBLE fields,
written as NULL, and every series collapsed into one row per timestamp.
The native route has no such aggregate and keyed on the labels, so the
two routes created different sinks for the same flow.

Every string column of a PromQL answer is a label of its output series,
so the sink now keys on all of them on both routes.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(flow): keep writing a TQL sink that has the native __name__ column

Before TQL flows were planned with `plan_relation`, a native TQL flow
auto-created its sink from the native plan's own columns: the value named
by that route, the labels, and `__name__` as a primary key column. The
relation plan publishes neither, so such a flow failed sink validation
and stopped writing.

When the sink has a `__name__` column, plan the statement with `plan`,
which is what these flows ran before. They keep writing the same columns
and the same `__name__` values: the metric name for a selector, NULL
where PromQL drops the name.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-27 12:13:15 +00:00
..

Setup tests for multiple storage backend

To run the integration test, please copy .env.example to .env in the project root folder and change the values on need.

Take s3 for example. You need to set your S3 bucket, access key id and secret key:

# Settings for s3 test
GT_S3_BUCKET=S3 bucket
GT_S3_REGION=S3 region
GT_S3_ACCESS_KEY_ID=S3 access key id
GT_S3_ACCESS_KEY=S3 secret access key

Run

Execute the following command in the project root folder:

cargo test integration

Test s3 storage:

cargo test s3

Test oss storage:

cargo test oss

Test azblob storage:

cargo test azblob

Setup tests with Kafka wal

To run the integration test, please copy .env.example to .env in the project root folder and change the values on need.

GT_KAFKA_ENDPOINTS = localhost:9092

Setup kafka standalone

cd tests-integration/fixtures

docker compose -f docker-compose.yml up kafka

Setup tests with etcd TLS

This guide explains how to set up and test TLS-enabled etcd connections in GreptimeDB integration tests.

Quick Start

TLS certificates are already at tests-integration/fixtures/etcd-tls-certs/.

  1. Start TLS-enabled etcd:

    cd tests-integration/fixtures
    docker compose up etcd-tls -d
    
  2. Start all services (including etcd-tls):

    cd tests-integration/fixtures
    docker compose up -d --wait
    

Certificate Details

The checked-in certificates include:

  • ca.crt - Certificate Authority certificate
  • server.crt / server-key.pem - Server certificate for etcd-tls service
  • client.crt / client-key.pem - Client certificate for connecting to etcd-tls

The server certificate includes SANs for localhost, etcd-tls, 127.0.0.1, and ::1.

Regenerating Certificates (Optional)

If you need to regenerate the etcd certificates:

# Regenerate certificates (overwrites existing ones)
./scripts/generate-etcd-tls-certs.sh

# Or generate in custom location
./scripts/generate-etcd-tls-certs.sh /path/to/cert/directory

If you need to regenerate the mysql and postgres certificates:

# Regenerate certificates (overwrites existing ones)
./scripts/generate_certs.sh

# Or generate in custom location
./scripts/generate_certs.sh /path/to/cert/directory

Note: The checked-in certificates are for testing purposes only and should never be used in production.