Skip to content

Commit

Permalink
Split expected pg_regress per version
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Nov 22, 2024
1 parent 1a8d0c5 commit d507308
Show file tree
Hide file tree
Showing 117 changed files with 11,503 additions and 454 deletions.
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ You can build a docker image with pg_tracing for a specific version.

```bash
make PG_VERSION=16 build-test-image
# Clean build
make DOCKER_BUILD_OPTS=--no-cache PG_VERSION=17 build-test-image
```

Once the docker image is built, you can launch it with:
Expand All @@ -87,6 +89,6 @@ If you have added additional tests, the expected outputs needs to be updated. If
# From local results
cp results/*out expected/

# From a running docker test container
docker cp 'pg_tracing_test:/usr/src/pg_tracing/results/.' expected
# Run tests in a docker container and update expected output locally
make PG_VERSION=15 update-regress-output
```
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ COPY --chown=postgres pg_tracing.conf ./pg_tracing.conf
# Tests
COPY --chown=postgres ./sql/ ./sql
COPY --chown=postgres ./t/ ./t
COPY --chown=postgres ./regress/ ./regress
COPY --chown=postgres ./expected/ ./expected

# Create empty results for mount bind
RUN mkdir results
RUN chown postgres:postgres results

RUN make -s clean
RUN sudo make -s install -j8

Expand Down
34 changes: 21 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,32 @@ OBJS = \
# Default version:
PG_VERSION ?= $(shell $(PG_CONFIG) --version | cut -d' ' -f2 | cut -d'.' -f1 | tr -d 'devel')

REGRESSCHECKS = setup utility select parameters insert trigger cursor json transaction
REGRESSCHECKS = setup utility select parameters insert trigger cursor json transaction planstate_projectset

ifeq ($(PG_VERSION),15)
REGRESSCHECKS += trigger_15
endif
REGRESSCHECKS_OPTS = --no-locale --encoding=UTF8 --temp-config pg_tracing.conf

# \bind is only available starting PG 16
ifeq ($(shell test $(PG_VERSION) -ge 16; echo $$?),0)
REGRESSCHECKS += extended trigger_16 parameters_16
REGRESSCHECKS += extended parameters_extended
# expecteddir is not supported by PG15, expected at the project root will only be used for PG 15 expected outputs
REGRESSCHECKS_OPTS += --expecteddir=regress/$(PG_VERSION)
endif

ifeq ($(shell test $(PG_VERSION) -lt 17; echo $$?),0)
REGRESSCHECKS += planstate_projectset
else
REGRESSCHECKS += planstate_projectset_17 nested_17
# infinity interval is only available starting PG 17
ifeq ($(shell test $(PG_VERSION) -ge 17; echo $$?),0)
REGRESSCHECKS += nested_17
endif

# PG 18 contains additional psql metacommand to test extended protocol
ifeq ($(shell test $(PG_VERSION) -ge 18; echo $$?),0)
REGRESSCHECKS += psql_extended psql_extended_tx
REGRESSCHECKS += psql_extended_18 psql_extended_tx_18
endif

REGRESSCHECKS += sample planstate planstate_bitmap planstate_hash \
planstate_subplans planstate_union \
parallel subxact full_buffer \
guc nested wal cleanup

REGRESSCHECKS_OPTS = --no-locale --encoding=UTF8 --temp-config pg_tracing.conf

PGXS := $(shell $(PG_CONFIG) --pgxs)

TAP_TESTS = 1
Expand Down Expand Up @@ -86,12 +84,22 @@ build-test-image: build-test-pg$(PG_VERSION) ;
.PHONY: $(BUILD_TEST_TARGETS)
$(BUILD_TEST_TARGETS):
docker build \
$(DOCKER_BUILD_OPTS) \
--build-arg PG_VERSION=$(PG_VERSION) \
-t $(TEST_CONTAINER_NAME):$(subst build-test-,,$@) .

.PHONY: run-test
run-test: build-test-pg$(PG_VERSION)
docker run \
--name $(TEST_CONTAINER_NAME) --rm \
-v ./results:/usr/src/pg_tracing/results\
$(TEST_CONTAINER_NAME):pg$(PG_VERSION) \
bash -c "PG_VERSION=$(PG_VERSION) make regresscheck_noinstall && make installcheck"
bash -c "make regresscheck_noinstall && make installcheck"

.PHONY: update-regress-output
update-regress-output: run-test
@if [ $(PG_VERSION) = "15" ]; then \
cp results/*.out expected/; \
else \
cp results/*.out regress/$(PG_VERSION)/expected; \
fi
44 changes: 22 additions & 22 deletions expected/guc.out
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ SELECT 3;
select trace_id, span_operation, parameters, lvl from peek_ordered_spans;
trace_id | span_operation | parameters | lvl
----------------------------------+------------------+------------+-----
00000000000000000000000000000004 | SELECT $1; | {1} | 0
00000000000000000000000000000004 | SELECT $1 | {1} | 0
00000000000000000000000000000004 | Planner | | 1
00000000000000000000000000000004 | ExecutorRun | | 1
00000000000000000000000000000004 | Result | | 2
00000000000000000000000000000004 | TransactionBlock | | 0
00000000000000000000000000000005 | SELECT $1; | {1} | 1
00000000000000000000000000000005 | SELECT $1 | {1} | 1
00000000000000000000000000000005 | Planner | | 2
00000000000000000000000000000005 | ExecutorRun | | 2
00000000000000000000000000000005 | Result | | 3
00000000000000000000000000000005 | COMMIT; | | 1
00000000000000000000000000000005 | ProcessUtility | | 2
fffffffffffffffffffffffffffffff5 | SELECT $1; | {2} | 0
fffffffffffffffffffffffffffffff5 | SELECT $1 | {2} | 0
fffffffffffffffffffffffffffffff5 | Planner | | 1
fffffffffffffffffffffffffffffff5 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff5 | Result | | 2
fffffffffffffffffffffffffffffff5 | SELECT $1; | {3} | 0
fffffffffffffffffffffffffffffff5 | SELECT $1 | {3} | 0
fffffffffffffffffffffffffffffff5 | Planner | | 1
fffffffffffffffffffffffffffffff5 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff5 | Result | | 2
Expand Down Expand Up @@ -84,24 +84,24 @@ SELECT 3;

-- Check mix SQLCommenter and GUC propagation
select trace_id, span_operation, parameters, lvl from peek_ordered_spans;
trace_id | span_operation | parameters | lvl
----------------------------------+--------------------+------------+-----
fffffffffffffffffffffffffffffff6 | SELECT $1; | {2} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
fffffffffffffffffffffffffffffff6 | SELECT $1, $2; | {1,1} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
fffffffffffffffffffffffffffffff6 | SELECT $1, $2, $3; | {1,2,3} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
fffffffffffffffffffffffffffffff6 | SELECT $1; | {3} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
trace_id | span_operation | parameters | lvl
----------------------------------+-------------------+------------+-----
fffffffffffffffffffffffffffffff6 | SELECT $1 | {2} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
fffffffffffffffffffffffffffffff6 | SELECT $1, $2 | {1,1} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
fffffffffffffffffffffffffffffff6 | SELECT $1, $2, $3 | {1,2,3} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
fffffffffffffffffffffffffffffff6 | SELECT $1 | {3} | 0
fffffffffffffffffffffffffffffff6 | Planner | | 1
fffffffffffffffffffffffffffffff6 | ExecutorRun | | 1
fffffffffffffffffffffffffffffff6 | Result | | 2
(16 rows)

CALL clean_spans();
Expand Down
20 changes: 10 additions & 10 deletions expected/insert.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ SELECT span_type, span_operation, lvl from peek_ordered_spans where trace_id='00
-- Simple insertion
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000002-01'*/ INSERT INTO pg_tracing_test_table_with_constraint VALUES(1, 'aaa');
SELECT span_type, span_operation from peek_ordered_spans where trace_id='00000000000000000000000000000002';
span_type | span_operation
-------------------+-------------------------------------------------------------------
Insert query | INSERT INTO pg_tracing_test_table_with_constraint VALUES($1, $2);
span_type | span_operation
-------------------+------------------------------------------------------------------
Insert query | INSERT INTO pg_tracing_test_table_with_constraint VALUES($1, $2)
Planner | Planner
ExecutorRun | ExecutorRun
Insert | Insert on pg_tracing_test_table_with_constraint
Expand All @@ -30,13 +30,13 @@ SELECT span_type, span_operation from peek_ordered_spans where trace_id='0000000
ERROR: duplicate key value violates unique constraint "pk_tracing_test"
DETAIL: Key (a)=(1) already exists.
SELECT span_type, span_operation, sql_error_code, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000003';
span_type | span_operation | sql_error_code | lvl
--------------+-------------------------------------------------------------------+----------------+-----
Insert query | INSERT INTO pg_tracing_test_table_with_constraint VALUES($1, $2); | 23505 | 0
Planner | Planner | 00000 | 1
ExecutorRun | ExecutorRun | 23505 | 1
Insert | Insert on pg_tracing_test_table_with_constraint | 23505 | 2
Result | Result | 23505 | 3
span_type | span_operation | sql_error_code | lvl
--------------+------------------------------------------------------------------+----------------+-----
Insert query | INSERT INTO pg_tracing_test_table_with_constraint VALUES($1, $2) | 23505 | 0
Planner | Planner | 00000 | 1
ExecutorRun | ExecutorRun | 23505 | 1
Insert | Insert on pg_tracing_test_table_with_constraint | 23505 | 2
Result | Result | 23505 | 3
(5 rows)

-- Trigger an error while calling pg_tracing_peek_spans which resets tracing, nothing should be generated
Expand Down
38 changes: 20 additions & 18 deletions expected/json.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
SELECT trace_id, name, kind, lvl FROM peek_ordered_json_spans;
trace_id | name | kind | lvl
----------------------------------+-------------+------+-----
00000000000000000000000000000001 | SELECT $1; | 2 | 1
00000000000000000000000000000001 | SELECT $1 | 2 | 1
00000000000000000000000000000001 | Planner | 2 | 2
00000000000000000000000000000001 | ExecutorRun | 2 | 2
00000000000000000000000000000001 | Result | 2 | 3
00000000000000000000000000000002 | SELECT $1, +| 2 | 1
| $2; | |
00000000000000000000000000000002 | SELECT +| 2 | 1
| $1, +| |
| $2 | |
00000000000000000000000000000002 | Planner | 2 | 2
00000000000000000000000000000002 | ExecutorRun | 2 | 2
00000000000000000000000000000002 | Result | 2 | 3
Expand All @@ -32,12 +33,13 @@ SELECT trace_id, name, kind, lvl FROM peek_ordered_json_spans;
SELECT trace_id, name, plan_startup_cost, plan_total_cost, plan_rows, plan_width, parameters, lvl FROM peek_ordered_json_spans;
trace_id | name | plan_startup_cost | plan_total_cost | plan_rows | plan_width | parameters | lvl
----------------------------------+-------------+-------------------+-----------------+-----------+------------+------------+-----
00000000000000000000000000000001 | SELECT $1; | | | | | {1} | 1
00000000000000000000000000000001 | SELECT $1 | | | | | {1} | 1
00000000000000000000000000000001 | Planner | | | | | | 2
00000000000000000000000000000001 | ExecutorRun | | | | | | 2
00000000000000000000000000000001 | Result | | 0.01 | 1 | 4 | | 3
00000000000000000000000000000002 | SELECT $1, +| | | | | {1,2} | 1
| $2; | | | | | |
00000000000000000000000000000002 | SELECT +| | | | | {1,2} | 1
| $1, +| | | | | |
| $2 | | | | | |
00000000000000000000000000000002 | Planner | | | | | | 2
00000000000000000000000000000002 | ExecutorRun | | | | | | 2
00000000000000000000000000000002 | Result | | 0.01 | 1 | 8 | | 3
Expand All @@ -51,12 +53,12 @@ ERROR: canceling statement due to statement timeout
-- Check json generated spans with sql error code
set statement_timeout TO DEFAULT;
SELECT trace_id, name, sql_error_code, status_code, status_message, lvl FROM peek_ordered_json_spans;
trace_id | name | sql_error_code | status_code | status_message | lvl
----------------------------------+-----------------------------+----------------+-------------+-------------------+-----
00000000000000000000000000000001 | select * from pg_sleep($1); | 57014 | 2 | "SQLError: 57014" | 1
00000000000000000000000000000001 | Planner | | 1 | | 2
00000000000000000000000000000001 | ExecutorRun | 57014 | 2 | "SQLError: 57014" | 2
00000000000000000000000000000001 | FunctionScan on pg_sleep | 57014 | 2 | "SQLError: 57014" | 3
trace_id | name | sql_error_code | status_code | status_message | lvl
----------------------------------+----------------------------+----------------+-------------+-------------------+-----
00000000000000000000000000000001 | select * from pg_sleep($1) | 57014 | 2 | "SQLError: 57014" | 1
00000000000000000000000000000001 | Planner | | 1 | | 2
00000000000000000000000000000001 | ExecutorRun | 57014 | 2 | "SQLError: 57014" | 2
00000000000000000000000000000001 | FunctionScan on pg_sleep | 57014 | 2 | "SQLError: 57014" | 3
(4 rows)

CALL clean_spans();
Expand All @@ -75,10 +77,10 @@ SELECT trace_id, name,
startup > 0 as has_startup,
lvl FROM peek_ordered_json_spans
WHERE name LIKE 'INSERT%';
trace_id | name | subxact_count | has_shared_hit | has_wal_records | has_wal_bytes | has_startup | lvl
----------------------------------+------------------------------------------------------------------+---------------+----------------+-----------------+---------------+-------------+-----
00000000000000000000000000000001 | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3); | | t | t | t | | 2
00000000000000000000000000000001 | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3); | 1 | t | t | t | | 2
trace_id | name | subxact_count | has_shared_hit | has_wal_records | has_wal_bytes | has_startup | lvl
----------------------------------+-----------------------------------------------------------------+---------------+----------------+-----------------+---------------+-------------+-----
00000000000000000000000000000001 | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3) | | t | t | t | | 2
00000000000000000000000000000001 | INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3) | 1 | t | t | t | | 2
(2 rows)

CALL clean_spans();
Expand All @@ -92,7 +94,7 @@ CALL clean_spans();
SELECT trace_id, name, parameters, deparse_info, lvl FROM peek_ordered_json_spans;
trace_id | name | parameters | deparse_info | lvl
----------------------------------+-----------------------------------------------------+------------+---------------------+-----
00000000000000000000000000000001 | SELECT * FROM pg_tracing_test WHERE a=$1; | {1} | | 1
00000000000000000000000000000001 | SELECT * FROM pg_tracing_test WHERE a=$1 | {1} | | 1
00000000000000000000000000000001 | Planner | | | 2
00000000000000000000000000000001 | ExecutorRun | | | 2
00000000000000000000000000000001 | IndexScan using pg_tracing_index on pg_tracing_test | | Index Cond: (a = 1) | 3
Expand All @@ -109,7 +111,7 @@ CALL clean_spans();
SELECT trace_id, name, service_name FROM peek_ordered_json_spans;
trace_id | name | service_name
----------------------------------+-----------------------------------------------------+---------------------
00000000000000000000000000000001 | SELECT * FROM pg_tracing_test WHERE a=$1; | "PostgreSQL_Server"
00000000000000000000000000000001 | SELECT * FROM pg_tracing_test WHERE a=$1 | "PostgreSQL_Server"
00000000000000000000000000000001 | Planner | "PostgreSQL_Server"
00000000000000000000000000000001 | ExecutorRun | "PostgreSQL_Server"
00000000000000000000000000000001 | IndexScan using pg_tracing_index on pg_tracing_test | "PostgreSQL_Server"
Expand Down
Loading

0 comments on commit d507308

Please sign in to comment.