Skip to content

Commit

Permalink
add a simple compatibility test
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-cai-timeplus committed Dec 13, 2023
1 parent 59358da commit 0863b10
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 23 deletions.
19 changes: 15 additions & 4 deletions tests/stream/test_compatibility/basic_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
docker-compose -f test_compatibility/docker-compose.yaml up -d
CUR_DIR="$GITHUB_WORKSPACE/tests/stream/test_compatibility"
docker-compose -f "$CUR_DIR/configs/docker-compose.yaml" up -d
sleep 5
docker exec proton-server proton client -nm -q "select x from example where _tp_time > earliest_ts() limit 3;"
docker exec proton-server proton client -nm -q "select x from example_external limit 3 settings seek_to='earliest';"
docker-compose -f test_compatibility/docker-compose.yaml down
sqls=$(cat $CUR_DIR/basic_tests.sql | tr "\n" " " | sed 's/ \+/ /g')
IFS=";
"
for sql in $sqls
do
if [ ${#sql} -gt 1 ]
then
echo "> [$sql]"
timeout --foreground 30s docker exec proton-server proton client -nm -q "$sql"
sleep 2
fi
done
docker-compose -f "$CUR_DIR/configs/docker-compose.yaml" down -v
11 changes: 11 additions & 0 deletions tests/stream/test_compatibility/basic_tests.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
select 'test 1';
insert into test_1_s (* except _tp_time)
values
(7, 1.1, 'g7', 47), (8, 2.1, 'h8', 48), (9, 3.1, 'i9', 49);
select (* except _tp_time) from table(test_1_mv);
select (* except _tp_time) from test_1_mv where _tp_time > earliest_ts() limit 9;

select 'test 2';
insert into test_2_mv(* except _tp_time) values (0, 6.1);
select (* except _tp_time) from table(test_2_mv);
select (* except _tp_time) from test_2_mv where _tp_time > earliest_ts() limit 1;
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ services:
- $GITHUB_WORKSPACE/data/proton-redp/datas:/var/lib/proton
- $GITHUB_WORKSPACE/data/proton-redp/log:/var/log/proton-server
ports:
- "13218:3218" # HTTP Streaming
- "18123:8123" # HTTP Snapshot
- "18463:8463" # TCP Streaming
- "15432:5432" # Postgres Snapshot
- "17587:7587" # TCP Snapshot
- "3218:3218" # HTTP Streaming
- "8123:8123" # HTTP Snapshot
- "8463:8463" # TCP Streaming
- "5432:5432" # Postgres Snapshot
- "7587:7587" # TCP Snapshot
deploy:
replicas: 1
restart_policy:
Expand Down
8 changes: 1 addition & 7 deletions tests/stream/test_compatibility/extra_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
docker-compose -f test_compatibility/docker-compose.yaml up -d
sleep 5
docker exec proton-server proton client -nm -q "insert into example (x) values (4)(5)(6);"
docker exec proton-server proton client -nm -q "select x from example where _tp_time > earliest_ts() limit 6;"
docker exec proton-server proton client -nm -q "insert into example_external (x) values (8)(10)(12);"
docker exec proton-server proton client -nm -q "select x from example_external limit 6 settings seek_to='earliest';"
docker-compose -f test_compatibility/docker-compose.yaml down
CUR_DIR="$GITHUB_WORKSPACE/tests/stream/test_compatibility"
22 changes: 15 additions & 7 deletions tests/stream/test_compatibility/prepare_data.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
docker-compose -f test_compatibility/docker-compose.yaml up -d
CUR_DIR="$GITHUB_WORKSPACE/tests/stream/test_compatibility"
echo $CUR_DIR
docker-compose -f "$CUR_DIR/configs/docker-compose.yaml" up -d
sleep 5
docker exec proton-server proton client -nm -q "create stream example(x int);"
docker exec proton-server proton client -nm -q "insert into example (x) values (1)(2)(3);"
docker exec redpanda rpk topic create example_topic
docker exec proton-server proton client -nm -q "create external stream example_external (x int) settings type='kafka', brokers='stream-store:9092',topic='example_topic',data_format = 'JSONEachRow';"
docker exec proton-server proton client -nm -q "insert into example_external (x) values (2)(4)(6);"
docker-compose -f test_compatibility/docker-compose.yaml down
sqls=$(cat $CUR_DIR/prepare_data.sql | tr "\n" " " | sed 's/ \+/ /g')
IFS=";"
for sql in $sqls
do
if [ ${#sql} -gt 1 ]
then
echo "> [$sql]"
timeout --foreground 30s docker exec proton-server proton client -n -q "$sql;"
sleep 2
fi
done
docker-compose -f "$CUR_DIR/configs/docker-compose.yaml" down -v
37 changes: 37 additions & 0 deletions tests/stream/test_compatibility/prepare_data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
select 'test 1: a mv on stream, and then alter the stream add column';
create stream test_1_s (
col1 int,
col2 float,
col3 string
);
create materialized view test_1_mv as (
select
col1, col2, col3
from
test_1_s
);
insert into test_1_s (* except _tp_time)
values
(1, 1.1, 'a1'), (2, 2.1, 'b2'), (3, 3.1, 'c3');

alter stream test_1_s add column col4 uint64;

insert into test_1_s (* except _tp_time)
values
(4, 4.1, 'd4', 44), (5, 5.1, 'e5', 45), (6, 6.1, 'f6', 46);

select 'test 2 a mv on stream global aggregation';
create stream test_2_s (
col1 int,
col2 float64
);
create materialized view test_2_mv as(
select
min(col2) as min_col2,
max(col2) as max_col2,
count(col2) as cnt_col2
from test_2_s
);
insert into test_2_s (* except _tp_time)
values
(1, 1.1), (2, 2.1), (3, 3.1), (4, 4.1), (5, 5.1), (6, 6.1), (3, 3.1), (4, 4.1);

0 comments on commit 0863b10

Please sign in to comment.