Skip to content

Commit

Permalink
refactor(sqlsmith): refactor sqlsmith using http client (#16890)
Browse files Browse the repository at this point in the history
* refactor(sqlsmith): refactor sqlsmith using http client

* fix

* rewrite HttpClient
  • Loading branch information
b41sh authored Nov 23, 2024
1 parent a2ce45c commit 221018b
Show file tree
Hide file tree
Showing 10 changed files with 580 additions and 329 deletions.
148 changes: 11 additions & 137 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,6 @@ tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json", "valuable"] }

# Databend Integration Test
databend-client = { version = "0.22" }
databend-driver = { version = "0.22" }
databend-driver-core = { version = "0.22" }
msql-srv = "0.11.0"
mysql_common = "0.32.4"
quickcheck = "1.0"
Expand Down
18 changes: 10 additions & 8 deletions src/query/expression/src/row/row_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ impl RowConverter {

fn support_data_type(d: &DataType) -> bool {
match d {
DataType::Array(_)
| DataType::EmptyArray
| DataType::EmptyMap
| DataType::Map(_)
| DataType::Bitmap
| DataType::Tuple(_)
| DataType::Generic(_) => false,
DataType::Null
| DataType::Boolean
| DataType::Number(_)
| DataType::Decimal(_)
| DataType::Timestamp
| DataType::Date
| DataType::Binary
| DataType::String
| DataType::Variant => true,
DataType::Nullable(inner) => Self::support_data_type(inner.as_ref()),
_ => true,
_ => false,
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/tests/sqlsmith/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ edition = { workspace = true }
[dependencies]
chrono-tz = { workspace = true }
clap = { workspace = true }
databend-client = { workspace = true }
cookie = { workspace = true }
databend-common-ast = { workspace = true }
databend-common-exception = { workspace = true }
databend-common-expression = { workspace = true }
databend-common-formats = { workspace = true }
databend-common-functions = { workspace = true }
databend-common-io = { workspace = true }
databend-common-sql = { workspace = true }
databend-driver = { workspace = true }
databend-driver-core = { workspace = true }
ethnum = { workspace = true }
itertools = { workspace = true }
jiff = { workspace = true }
jsonb = { workspace = true }
rand = { workspace = true }
reqwest = { workspace = true, features = ["cookies"] }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
tokio-stream = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
url = { workspace = true }

[[bin]]
name = "databend-sqlsmith"
Expand Down
32 changes: 23 additions & 9 deletions src/tests/sqlsmith/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// limitations under the License.

use clap::Parser;
use databend_common_exception::Result;
use databend_sqlsmith::Runner;
use tracing::metadata::LevelFilter;
use tracing_subscriber::EnvFilter;

#[derive(Clone, Debug, PartialEq, Eq, Parser)]
#[clap(about, author)]
Expand All @@ -27,7 +30,7 @@ pub struct Args {
port: u16,

/// The test database.
#[clap(long, default_value = "default")]
#[clap(long, default_value = "sqlsmith_test")]
db: String,

/// The username.
Expand All @@ -48,15 +51,26 @@ pub struct Args {
}

#[tokio::main(flavor = "multi_thread", worker_threads = 5)]
async fn main() {
tracing_subscriber::fmt::init();
async fn main() -> Result<()> {
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.parse("")
.unwrap();
tracing_subscriber::fmt().with_env_filter(filter).init();

let args = Args::parse();
let host = format!("http://{}:{}", args.host, args.port);
let mut runner = Runner::try_new(
host,
args.user.clone(),
args.pass.clone(),
args.db.clone(),
args.count,
None,
args.timeout,
)
.await?;
runner.run().await?;

let dsn = format!(
"databend://{}:{}@{}:{}/{}?sslmode=disable",
args.user, args.pass, args.host, args.port, args.db
);
let runner = Runner::new(dsn, args.count, None, args.timeout);
runner.run().await;
Ok(())
}
Loading

0 comments on commit 221018b

Please sign in to comment.