Skip to content

Commit 9d64e50

Browse files
authored
test: add e2e extended mode test (risingwavelabs#8710)
1 parent 7bac239 commit 9d64e50

File tree

12 files changed

+525
-28
lines changed

12 files changed

+525
-28
lines changed

Cargo.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ members = [
3232
"src/stream",
3333
"src/test_runner",
3434
"src/tests/compaction_test",
35+
"src/tests/e2e_extended_mode",
3536
"src/tests/regress",
3637
"src/tests/simulation",
3738
"src/tests/sqlsmith",

ci/scripts/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ cargo build \
4343
-p risingwave_compaction_test \
4444
-p risingwave_backup_cmd \
4545
-p risingwave_java_binding \
46+
-p risingwave_e2e_extended_mode_test \
4647
--features "static-link static-log-level" --profile "$profile"
4748

4849
# the file name suffix of artifact for risingwave_java_binding is so only for linux. It is dylib for MacOS
49-
artifacts=(risingwave sqlsmith compaction-test backup-restore risingwave_regress_test risedev-dev delete-range-test librisingwave_java_binding.so)
50+
artifacts=(risingwave sqlsmith compaction-test backup-restore risingwave_regress_test risingwave_e2e_extended_mode_test risedev-dev delete-range-test librisingwave_java_binding.so)
5051

5152
echo "--- Show link info"
5253
ldd target/"$target"/risingwave

ci/scripts/run-e2e-test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ mkdir -p target/debug
2424
buildkite-agent artifact download risingwave-"$profile" target/debug/
2525
buildkite-agent artifact download risedev-dev-"$profile" target/debug/
2626
buildkite-agent artifact download "e2e_test/generated/*" ./
27+
buildkite-agent artifact download risingwave_e2e_extended_mode_test-"$profile" target/debug/
2728
mv target/debug/risingwave-"$profile" target/debug/risingwave
2829
mv target/debug/risedev-dev-"$profile" target/debug/risedev-dev
30+
mv target/debug/risingwave_e2e_extended_mode_test-"$profile" target/debug/risingwave_e2e_extended_mode_test
2931

3032
echo "--- Adjust permission"
3133
chmod +x ./target/debug/risingwave
3234
chmod +x ./target/debug/risedev-dev
35+
chmod +x ./target/debug/risingwave_e2e_extended_mode_test
3336

3437
echo "--- Generate RiseDev CI config"
3538
cp ci/risedev-components.ci.env risedev-components.user.env
@@ -75,7 +78,10 @@ cargo make ci-kill
7578
echo "--- e2e, ci-3cn-1fe, extended query"
7679
RUST_LOG="info,risingwave_stream=info,risingwave_batch=info,risingwave_storage=info" \
7780
cargo make ci-start ci-3cn-1fe
78-
sqllogictest -p 4566 -d dev -e postgres-extended './e2e_test/extended_query/**/*.slt'
81+
sqllogictest -p 4566 -d dev -e postgres-extended './e2e_test/extended_mode/**/*.slt'
82+
RUST_BACKTRACE=1 target/debug/risingwave_e2e_extended_mode_test --host 127.0.0.1 \
83+
-p 4566 \
84+
-u root
7985

8086
echo "--- Kill cluster"
8187
cargo make ci-kill

e2e_test/extended_query/basic.slt renamed to e2e_test/extended_mode/basic.slt

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
# The basic.slt is to cover the path of pgwire.
2-
#
3-
# There are two kinds of statement, they run different path of pgwire:
4-
# 1. un-query statement: SET,CREATE,INSERT,FLUSH,EXPLAIN,DROP..
5-
# 2. query statement: SELECT,WITH,VALUES,SHOW,DESCRIBE..
6-
#
7-
# We also need to test different type in extended query mode:
8-
# smallint,int,bigint
9-
# real,double precision,numeric
10-
# time,date,timestamp
11-
1+
# Test different statements(DDL,DQL,DML) in extended mode.
122

133
statement ok
144
SET RW_IMPLICIT_FLUSH TO true;
@@ -78,18 +68,3 @@ with t as (select generate_series(1,3,1)) select * from t;
7868
1
7969
2
8070
3
81-
82-
query III
83-
select 42::smallint, 42::int, 42::bigint;
84-
----
85-
42 42 42
86-
87-
query III
88-
select 42::real,42::double precision,42::decimal;
89-
----
90-
42 42 42
91-
92-
query TTT
93-
select '20:55:12'::time,'2022-07-12'::date,'2022-07-12 20:55:12'::timestamp;
94-
----
95-
20:55:12 2022-07-12 2022-07-12 20:55:12

e2e_test/extended_mode/type.slt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Test binary format of different type. (sqllogitest return binary format in extended mode)
2+
3+
statement ok
4+
SET RW_IMPLICIT_FLUSH TO true;
5+
6+
# RisingWave can't support list and struct now so we skip them.
7+
# include ../batch/types/array.slt.part
8+
# include ../batch/types/struct.slt.part
9+
# include ../batch/types/list.slt.part
10+
11+
# Sqllogitest can't support binary format bytea type so we skip it.
12+
# include ../batch/types/bytea.slt.part
13+
14+
# Can't support inf,-inf binary format now so we skip it.
15+
# include ../batch/types/decimal.slt.part
16+
17+
# Sqllogitest can't support binary format jsonb type so we skip it.
18+
# include ../batch/types/jsonb_ord.slt.part
19+
# include ../batch/types/jsonb.slt.part
20+
21+
include ../batch/types/boolean.slt.part
22+
include ../batch/types/cast.slt.part
23+
include ../batch/types/date.slt
24+
include ../batch/types/intercal.slt.part
25+
include ../batch/types/number_arithmetic.slt.part
26+
include ../batch/types/temporal_arithmetic.slt.part
27+
include ../batch/types/time.slt.part
28+
include ../batch/types/timestamptz_utc.slt.part
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "risingwave_e2e_extended_mode_test"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
homepage = { workspace = true }
6+
keywords = { workspace = true }
7+
license = { workspace = true }
8+
repository = { workspace = true }
9+
10+
[package.metadata.cargo-machete]
11+
ignored = ["workspace-hack"]
12+
13+
[package.metadata.cargo-udeps.ignore]
14+
normal = ["workspace-hack"]
15+
16+
[dependencies]
17+
anyhow = { version = "1", features = ["backtrace"] }
18+
chrono = { version = "0.4", features = ['serde'] }
19+
clap = { version = "4", features = ["derive"] }
20+
pg_interval = "0.4"
21+
rust_decimal ={ version = "1.25", features = ["db-postgres","db-tokio-postgres"] }
22+
tokio = { version = "1", features = ["rt", "macros","rt-multi-thread"] }
23+
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"] }
24+
tracing = "0.1"
25+
tracing-subscriber = "0.3.16"
26+
27+
[[bin]]
28+
name = "risingwave_e2e_extended_mode_test"
29+
path = "src/main.rs"

src/tests/e2e_extended_mode/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This is a program used for e2e test in extended mode.
2+
3+
## What is difference between it and extended_mode/*.slt in e2e_test
4+
5+
For e2e test in extended query mode, there are two thing we can't test in sqllogitest
6+
1. bind parameter
7+
2. max row number
8+
See [detail](https://www.postgresql.org/docs/15/protocol-flow.html#PROTOCOL-FLOW-PIPELINING:~:text=Once%20a%20portal,count%20is%20ignored)
9+
10+
So before sqllogictest supporting these, we test these function in this program.
11+
12+
In the future, we may merge it to e2e_text/extended_query
13+
14+
# How to run
15+
16+
```shell
17+
RUST_BACKTRACE=1 target/debug/risingwave_e2e_extended_mode_test --host 127.0.0.1 \
18+
-p 4566 \
19+
-u root \
20+
--database dev \
21+
```
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2023 RisingWave Labs
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
mod opts;
16+
mod test;
17+
18+
use std::process::exit;
19+
20+
use clap::Parser;
21+
use tracing::{error, info};
22+
23+
use crate::opts::Opts;
24+
use crate::test::TestSuite;
25+
26+
#[tokio::main(flavor = "multi_thread", worker_threads = 5)]
27+
async fn main() {
28+
exit(run_test().await)
29+
}
30+
31+
async fn run_test() -> i32 {
32+
let opts = Opts::parse();
33+
34+
tracing_subscriber::fmt::init();
35+
36+
let test_suite = TestSuite::new(opts);
37+
38+
match test_suite.test().await {
39+
Ok(_) => {
40+
info!("Risingwave e2e extended mode test completed successfully!");
41+
0
42+
}
43+
Err(e) => {
44+
error!("Risingwave e2e extended mode test failed: {:?}. Please ensure that your psql version is larger than 14.1", e);
45+
1
46+
}
47+
}
48+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2023 RisingWave Labs
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use clap::{Parser, ValueHint};
16+
17+
#[derive(Parser, Debug, Clone)]
18+
pub struct Opts {
19+
/// Database name used to connect to pg.
20+
#[clap(name = "DB", long = "database", default_value = "dev")]
21+
pub pg_db_name: String,
22+
/// Username used to connect to postgresql.
23+
#[clap(name = "PG_USERNAME", short = 'u', long = "user", default_value="postgres", value_hint=ValueHint::Username)]
24+
pub pg_user_name: String,
25+
/// Postgresql server address to test against.
26+
#[clap(name = "PG_SERVER_ADDRESS", long = "host", default_value = "localhost")]
27+
pub pg_server_host: String,
28+
/// Postgresql server port to test against.
29+
#[clap(name = "PG_SERVER_PORT", short = 'p', long = "port")]
30+
pub pg_server_port: u16,
31+
#[clap(name = "PG_PASSWARD", long = "password", default_value = "")]
32+
pub pg_password: String,
33+
}

0 commit comments

Comments
 (0)