Skip to content

Commit

Permalink
test(taos): check count
Browse files Browse the repository at this point in the history
  • Loading branch information
qevolg committed Dec 18, 2024
1 parent 5bb19bb commit 50a03a1
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 12 deletions.
23 changes: 22 additions & 1 deletion taos/benches/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use chrono::Local;
use flume::{Receiver, Sender};
use rand::Rng;
use taos::{AsyncQueryable, AsyncTBuilder, TaosBuilder};
use taos::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -49,6 +49,8 @@ async fn main() -> anyhow::Result<()> {

consume_sqls(db, receivers).await;

check_count(&taos, subtable_cnt * record_cnt).await?;

Ok(())
}

Expand Down Expand Up @@ -182,3 +184,22 @@ async fn consume_sqls(db: &str, mut receivers: Vec<Receiver<String>>) {

println!("Consuming sqls end, elapsed = {:?}\n", start.elapsed());
}

async fn check_count(taos: &Taos, cnt: usize) -> anyhow::Result<()> {
#[derive(Debug, serde::Deserialize)]
struct Record {
cnt: usize,
}

let res: Vec<Record> = taos
.query("select count(*) as cnt from s0")
.await?
.deserialize()
.try_collect()
.await?;

assert_eq!(res.len(), 1);
assert_eq!(res[0].cnt, cnt);

Ok(())
}
23 changes: 22 additions & 1 deletion taos/benches/sql_interlace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use chrono::Local;
use rand::Rng;
use taos::{AsyncQueryable, AsyncTBuilder, TaosBuilder};
use taos::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -39,6 +39,8 @@ async fn main() -> anyhow::Result<()> {

consume_sqls(db, sqls).await;

check_count(&taos, subtable_cnt * record_cnt).await?;

Ok(())
}

Expand Down Expand Up @@ -188,3 +190,22 @@ async fn consume_sqls(db: &str, sqls: Vec<String>) {

println!("Consuming data end, elapsed = {:?}\n", start.elapsed());
}

async fn check_count(taos: &Taos, cnt: usize) -> anyhow::Result<()> {
#[derive(Debug, serde::Deserialize)]
struct Record {
cnt: usize,
}

let res: Vec<Record> = taos
.query("select count(*) as cnt from s0")
.await?
.deserialize()
.try_collect()
.await?;

assert_eq!(res.len(), 1);
assert_eq!(res[0].cnt, cnt);

Ok(())
}
23 changes: 22 additions & 1 deletion taos/benches/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use chrono::Local;
use flume::{Receiver, Sender};
use rand::Rng;
use taos::{AsyncBindable, AsyncQueryable, AsyncTBuilder, ColumnView, Stmt, TaosBuilder};
use taos::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -49,6 +49,8 @@ async fn main() -> anyhow::Result<()> {

consume_data(db, receivers).await;

check_count(&taos, subtable_cnt * record_cnt).await?;

Ok(())
}

Expand Down Expand Up @@ -212,3 +214,22 @@ async fn consume_data(db: &str, mut receivers: Vec<Receiver<Vec<(String, Vec<Col

println!("Consuming data end, elapsed = {:?}\n", start.elapsed());
}

async fn check_count(taos: &Taos, cnt: usize) -> anyhow::Result<()> {
#[derive(Debug, serde::Deserialize)]
struct Record {
cnt: usize,
}

let res: Vec<Record> = taos
.query("select count(*) as cnt from s0")
.await?
.deserialize()
.try_collect()
.await?;

assert_eq!(res.len(), 1);
assert_eq!(res[0].cnt, cnt);

Ok(())
}
26 changes: 22 additions & 4 deletions taos/benches/stmt2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use chrono::Local;
use flume::{Receiver, Sender};
use rand::Rng;
use taos::{
AsyncQueryable, AsyncTBuilder, ColumnView, Stmt2, Stmt2AsyncBindable, Stmt2BindData,
TaosBuilder,
};
use taos::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -52,6 +49,8 @@ async fn main() -> anyhow::Result<()> {

consume_data(db, receivers).await;

check_count(&taos, subtable_cnt * record_cnt).await?;

Ok(())
}

Expand Down Expand Up @@ -212,3 +211,22 @@ async fn consume_data(db: &str, mut receivers: Vec<Receiver<Vec<Stmt2BindData>>>

println!("Consuming data end, elapsed = {:?}\n", start.elapsed());
}

async fn check_count(taos: &Taos, cnt: usize) -> anyhow::Result<()> {
#[derive(Debug, serde::Deserialize)]
struct Record {
cnt: usize,
}

let res: Vec<Record> = taos
.query("select count(*) as cnt from s0")
.await?
.deserialize()
.try_collect()
.await?;

assert_eq!(res.len(), 1);
assert_eq!(res[0].cnt, cnt);

Ok(())
}
26 changes: 22 additions & 4 deletions taos/benches/stmt2_interlace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use std::{
use chrono::Local;
use flume::{Receiver, Sender};
use rand::Rng;
use taos::{
AsyncQueryable, AsyncTBuilder, ColumnView, Stmt2, Stmt2AsyncBindable, Stmt2BindData,
TaosBuilder,
};
use taos::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -55,6 +52,8 @@ async fn main() -> anyhow::Result<()> {

consume_data(db, receivers).await;

check_count(&taos, subtable_cnt * record_cnt).await?;

Ok(())
}

Expand Down Expand Up @@ -203,3 +202,22 @@ async fn consume_data(db: &str, mut receivers: Vec<Receiver<Vec<Stmt2BindData>>>

println!("Consuming data end, elapsed = {:?}\n", start.elapsed());
}

async fn check_count(taos: &Taos, cnt: usize) -> anyhow::Result<()> {
#[derive(Debug, serde::Deserialize)]
struct Record {
cnt: usize,
}

let res: Vec<Record> = taos
.query("select count(*) as cnt from s0")
.await?
.deserialize()
.try_collect()
.await?;

assert_eq!(res.len(), 1);
assert_eq!(res[0].cnt, cnt);

Ok(())
}
23 changes: 22 additions & 1 deletion taos/benches/stmt_interlace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use chrono::Local;
use flume::{Receiver, Sender};
use rand::Rng;
use taos::{AsyncBindable, AsyncQueryable, AsyncTBuilder, ColumnView, Stmt, TaosBuilder};
use taos::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -52,6 +52,8 @@ async fn main() -> anyhow::Result<()> {

consume_data(db, receivers).await;

check_count(&taos, subtable_cnt * record_cnt).await?;

Ok(())
}

Expand Down Expand Up @@ -203,3 +205,22 @@ async fn consume_data(db: &str, mut receivers: Vec<Receiver<Vec<(String, Vec<Col

println!("Consuming data end, elapsed = {:?}\n", start.elapsed());
}

async fn check_count(taos: &Taos, cnt: usize) -> anyhow::Result<()> {
#[derive(Debug, serde::Deserialize)]
struct Record {
cnt: usize,
}

let res: Vec<Record> = taos
.query("select count(*) as cnt from s0")
.await?
.deserialize()
.try_collect()
.await?;

assert_eq!(res.len(), 1);
assert_eq!(res[0].cnt, cnt);

Ok(())
}

0 comments on commit 50a03a1

Please sign in to comment.