Files
greptimedb/tests-integration
dennis zhuang 64943b35b6 feat(promql): read second, microsecond and nanosecond time indexes natively (#10671)
* feat(promql): read second, microsecond and nanosecond time indexes natively

The native route declined every selector over a time index that is not
in milliseconds. The existing plan wraps such a scan in a cast
projection, so the decline surfaced as selector_plan_is_not_a_table_scan,
and the region's raw series preflight refused the unit as well.

The raw series path now hands ticks over in the stored unit, and each
raw input of the native tree records that unit. Evaluation keeps the
existing plan's semantics: windows and lookbacks are decided on the
stored ticks, a kernel reads the time truncated toward zero to
milliseconds after the offset, and samples less than a millisecond
apart remain distinct samples. Since every bound is a whole
millisecond, deciding membership on ceil(tick) in milliseconds is
exact, so the evaluators keep a window time beside the payload only for
microsecond and nanosecond inputs. Scan filters are built in the
stored unit.

Histogram fields and range modifiers over a sub-millisecond time index
still decline. The append-mode decline is kept and renamed to
append_mode_table.

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

* fix(promql): decline a discovered selector over mixed time index units

Logical metrics on different physical tables can store their time
index in different units, while the union a nameless selector reads is
one native input bound to one unit. The union took the first source's
unit and read the other sources' ticks in it, so a series stored in
microseconds next to one in milliseconds dropped out of its windows.
Such a selector now declines.

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

* fix(promql): keep a window open until its last millisecond has been read

A sample finer than a millisecond is placed in the window ending at the
millisecond above it. A chunk that ends on such a sample has not read
the rest of that millisecond, so treating that millisecond as settled
closed the window before a later sample in the same millisecond arrived
in the next chunk. Settle only up to the millisecond the last sample lies
in, rounded down.

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

* fix(promql): select only an exact sample under a zero lookback

A zero lookback admits only a sample exactly at the instant. The window
time of a sample less than a millisecond before the instant rounds up to
the instant, so the native selection picked it where the existing route
returns nothing. Compare the stored tick with the instant when the
lookback is zero, on the grid and anchored paths.

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

* fix(promql): version the FusedSeries envelope for input time units

Move BoundInput::time_unit out of the positional tree encoding and append
the input leaves' units after the v1 payload as envelope v2. A v1 payload
from an older build still decodes, with millisecond inputs.

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

* test(promql): answer two selectors over different time units, and pin the mixed-unit decline reason

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

* test(promql): drop the retired series scan v2 switch from the mixed-unit case

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

* test(promql): expect the v2 FusedSeries envelope in the native prefix test

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

* test(promql): adapt the time-unit tests to upstream instant and discovery changes

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

* test(promql): name the mixed-unit discovery refusal as unsupported

A native input carries one time unit, so discovery across physical tables with different time index units is refused. Answering needs a per-source rescale that changes the RawSeriesSource wire format; tracked in #10767.

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

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-12-01 06:41:53 +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.