Guidelines for AI coding agents working with SQL integration tests. For detailed documentation, see
test/README.md.
The test/ directory contains SQL integration tests using the SQL-tester framework. These tests verify end-to-end functionality by executing SQL statements against a running StarRocks cluster.
Read handbook/index.md first and use handbook/domains/sql-integration.md for suite selection, validation commands, and current harness gaps.
# Python 3.8+
python3 --version
# Install dependencies
pip3 install -r test/requirements.txtcd test
# Run all tests (validate mode)
python3 run.py -v
# Run tests in specific directory
python3 run.py -d sql/test_select -v
# Run specific test file
python3 run.py -d sql/test_select/R/test_basic -v
# List tests without running
python3 run.py -l
# Record mode (generate expected results)
python3 run.py -d sql/test_select -rEdit test/conf/sr.conf with your cluster info:
[mysql-client]
host = 127.0.0.1
port = 9030
user = root
password =
http_port = 8030
[replace]
url = http://${mysql-client:host}:${mysql-client:http_port}Location: test/sql/*/T/
-- name: test_basic_select
create database test_db_${uuid0};
use test_db_${uuid0};
create table t1 (c1 int, c2 string) distributed by hash(c1);
insert into t1 values (1, 'a'), (2, 'b');
select * from t1 order by c1;
drop database test_db_${uuid0};Location: test/sql/*/R/
-- name: test_basic_select
create database test_db_${uuid0};
use test_db_${uuid0};
create table t1 (c1 int, c2 string) distributed by hash(c1);
insert into t1 values (1, 'a'), (2, 'b');
select * from t1 order by c1;
-- result:
1 a
2 b
-- !result
drop database test_db_${uuid0};-- UUID for unique names
create database db_${uuid0};
-- Config variables from sr.conf
shell: curl ${url}/api/health-- Exact match
select 1;
-- result:
1
-- !result
-- Regex match
select version();
-- result:
[REGEX].*StarRocks.*
-- !result
-- Order-sensitive
[ORDER]select * from t1 order by c1;
-- result:
1
2
3
-- !result-- Skip result check for this statement
[UC]show backends;shell: echo "hello"
-- result:
0
hello
-- !result-- Call Python helper functions
function: wait_load_finish("label")-- Run only in shared-nothing mode
-- name: test_native @native
-- Run only in shared-data mode
-- name: test_cloud @cloud-
Create T file in appropriate directory:
test/sql/test_feature/T/test_my_feature -
Write test cases:
-- name: test_my_feature_basic create database test_db_${uuid0}; use test_db_${uuid0}; -- Your test SQL here drop database test_db_${uuid0};
-
Generate R file:
python3 run.py -d sql/test_feature/T/test_my_feature -r
-
Verify:
python3 run.py -d sql/test_feature/R/test_my_feature -v
| Parameter | Description |
|---|---|
-v |
Validate mode (check results) |
-r |
Record mode (generate results) |
-d PATH |
Specify test path |
-c N |
Concurrency (default: 8) |
-t N |
Timeout in seconds (default: 600) |
-l |
List tests only |
--file_filter REGEX |
Filter files by name |
--case_filter REGEX |
Filter cases by name |
- Use unique names: Always use
${uuid0}for database/table names - Clean up: Drop created objects at the end
- Order results: Use
[ORDER]tag when order matters - Minimal tests: Test one thing per case
- Descriptive names: Name cases clearly
Check the actual vs expected output in the test log.
Verify test/conf/sr.conf has correct cluster info.
Increase timeout with -t parameter.
Full documentation: test/README.md