forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rs
More file actions
90 lines (76 loc) · 2.43 KB
/
Copy pathmain.rs
File metadata and controls
90 lines (76 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2021 Datafuse 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;
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)]
pub struct Args {
/// The database host.
#[clap(long, default_value = "localhost")]
host: String,
/// The database http port.
#[clap(long, default_value = "8000")]
port: u16,
/// The test database.
#[clap(long, default_value = "sqlsmith_test")]
db: String,
/// The username.
#[clap(long, default_value = "root")]
user: String,
/// The password.
#[clap(long, default_value = "")]
pass: String,
/// The number of test cases to generate.
#[clap(long, default_value = "500")]
count: usize,
/// The number of timeout seconds of one query.
#[clap(long, default_value = "5")]
timeout: u64,
/// The fuzz query test file path.
#[clap(long, default_value = "")]
fuzz_path: String,
/// The log path to write executed SQLs..
#[clap(long, default_value = ".databend/sqlsmithlog")]
log_path: String,
}
#[tokio::main(flavor = "multi_thread", worker_threads = 5)]
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.log_path.clone(),
args.count,
None,
args.timeout,
)
.await?;
if !args.fuzz_path.is_empty() {
runner.run_fuzz(&args.fuzz_path).await?;
} else {
runner.run().await?;
}
Ok(())
}