Skip to content

Commit

Permalink
test: add e2e extended mode test (risingwavelabs#8710)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZENOTME authored Mar 23, 2023
1 parent 7bac239 commit 9d64e50
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 28 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ members = [
"src/stream",
"src/test_runner",
"src/tests/compaction_test",
"src/tests/e2e_extended_mode",
"src/tests/regress",
"src/tests/simulation",
"src/tests/sqlsmith",
Expand Down
3 changes: 2 additions & 1 deletion ci/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ cargo build \
-p risingwave_compaction_test \
-p risingwave_backup_cmd \
-p risingwave_java_binding \
-p risingwave_e2e_extended_mode_test \
--features "static-link static-log-level" --profile "$profile"

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

echo "--- Show link info"
ldd target/"$target"/risingwave
Expand Down
8 changes: 7 additions & 1 deletion ci/scripts/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ mkdir -p target/debug
buildkite-agent artifact download risingwave-"$profile" target/debug/
buildkite-agent artifact download risedev-dev-"$profile" target/debug/
buildkite-agent artifact download "e2e_test/generated/*" ./
buildkite-agent artifact download risingwave_e2e_extended_mode_test-"$profile" target/debug/
mv target/debug/risingwave-"$profile" target/debug/risingwave
mv target/debug/risedev-dev-"$profile" target/debug/risedev-dev
mv target/debug/risingwave_e2e_extended_mode_test-"$profile" target/debug/risingwave_e2e_extended_mode_test

echo "--- Adjust permission"
chmod +x ./target/debug/risingwave
chmod +x ./target/debug/risedev-dev
chmod +x ./target/debug/risingwave_e2e_extended_mode_test

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

echo "--- Kill cluster"
cargo make ci-kill
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
# The basic.slt is to cover the path of pgwire.
#
# There are two kinds of statement, they run different path of pgwire:
# 1. un-query statement: SET,CREATE,INSERT,FLUSH,EXPLAIN,DROP..
# 2. query statement: SELECT,WITH,VALUES,SHOW,DESCRIBE..
#
# We also need to test different type in extended query mode:
# smallint,int,bigint
# real,double precision,numeric
# time,date,timestamp

# Test different statements(DDL,DQL,DML) in extended mode.

statement ok
SET RW_IMPLICIT_FLUSH TO true;
Expand Down Expand Up @@ -78,18 +68,3 @@ with t as (select generate_series(1,3,1)) select * from t;
1
2
3

query III
select 42::smallint, 42::int, 42::bigint;
----
42 42 42

query III
select 42::real,42::double precision,42::decimal;
----
42 42 42

query TTT
select '20:55:12'::time,'2022-07-12'::date,'2022-07-12 20:55:12'::timestamp;
----
20:55:12 2022-07-12 2022-07-12 20:55:12
28 changes: 28 additions & 0 deletions e2e_test/extended_mode/type.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Test binary format of different type. (sqllogitest return binary format in extended mode)

statement ok
SET RW_IMPLICIT_FLUSH TO true;

# RisingWave can't support list and struct now so we skip them.
# include ../batch/types/array.slt.part
# include ../batch/types/struct.slt.part
# include ../batch/types/list.slt.part

# Sqllogitest can't support binary format bytea type so we skip it.
# include ../batch/types/bytea.slt.part

# Can't support inf,-inf binary format now so we skip it.
# include ../batch/types/decimal.slt.part

# Sqllogitest can't support binary format jsonb type so we skip it.
# include ../batch/types/jsonb_ord.slt.part
# include ../batch/types/jsonb.slt.part

include ../batch/types/boolean.slt.part
include ../batch/types/cast.slt.part
include ../batch/types/date.slt
include ../batch/types/intercal.slt.part
include ../batch/types/number_arithmetic.slt.part
include ../batch/types/temporal_arithmetic.slt.part
include ../batch/types/time.slt.part
include ../batch/types/timestamptz_utc.slt.part
29 changes: 29 additions & 0 deletions src/tests/e2e_extended_mode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "risingwave_e2e_extended_mode_test"
version = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
keywords = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[package.metadata.cargo-machete]
ignored = ["workspace-hack"]

[package.metadata.cargo-udeps.ignore]
normal = ["workspace-hack"]

[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
chrono = { version = "0.4", features = ['serde'] }
clap = { version = "4", features = ["derive"] }
pg_interval = "0.4"
rust_decimal ={ version = "1.25", features = ["db-postgres","db-tokio-postgres"] }
tokio = { version = "1", features = ["rt", "macros","rt-multi-thread"] }
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"] }
tracing = "0.1"
tracing-subscriber = "0.3.16"

[[bin]]
name = "risingwave_e2e_extended_mode_test"
path = "src/main.rs"
21 changes: 21 additions & 0 deletions src/tests/e2e_extended_mode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This is a program used for e2e test in extended mode.

## What is difference between it and extended_mode/*.slt in e2e_test

For e2e test in extended query mode, there are two thing we can't test in sqllogitest
1. bind parameter
2. max row number
See [detail](https://www.postgresql.org/docs/15/protocol-flow.html#PROTOCOL-FLOW-PIPELINING:~:text=Once%20a%20portal,count%20is%20ignored)

So before sqllogictest supporting these, we test these function in this program.

In the future, we may merge it to e2e_text/extended_query

# How to run

```shell
RUST_BACKTRACE=1 target/debug/risingwave_e2e_extended_mode_test --host 127.0.0.1 \
-p 4566 \
-u root \
--database dev \
```
48 changes: 48 additions & 0 deletions src/tests/e2e_extended_mode/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2023 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

mod opts;
mod test;

use std::process::exit;

use clap::Parser;
use tracing::{error, info};

use crate::opts::Opts;
use crate::test::TestSuite;

#[tokio::main(flavor = "multi_thread", worker_threads = 5)]
async fn main() {
exit(run_test().await)
}

async fn run_test() -> i32 {
let opts = Opts::parse();

tracing_subscriber::fmt::init();

let test_suite = TestSuite::new(opts);

match test_suite.test().await {
Ok(_) => {
info!("Risingwave e2e extended mode test completed successfully!");
0
}
Err(e) => {
error!("Risingwave e2e extended mode test failed: {:?}. Please ensure that your psql version is larger than 14.1", e);
1
}
}
}
33 changes: 33 additions & 0 deletions src/tests/e2e_extended_mode/src/opts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2023 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use clap::{Parser, ValueHint};

#[derive(Parser, Debug, Clone)]
pub struct Opts {
/// Database name used to connect to pg.
#[clap(name = "DB", long = "database", default_value = "dev")]
pub pg_db_name: String,
/// Username used to connect to postgresql.
#[clap(name = "PG_USERNAME", short = 'u', long = "user", default_value="postgres", value_hint=ValueHint::Username)]
pub pg_user_name: String,
/// Postgresql server address to test against.
#[clap(name = "PG_SERVER_ADDRESS", long = "host", default_value = "localhost")]
pub pg_server_host: String,
/// Postgresql server port to test against.
#[clap(name = "PG_SERVER_PORT", short = 'p', long = "port")]
pub pg_server_port: u16,
#[clap(name = "PG_PASSWARD", long = "password", default_value = "")]
pub pg_password: String,
}
Loading

0 comments on commit 9d64e50

Please sign in to comment.