Improved tests and added CI config
+ Fixed long-standing issues with database tests. The DB is now guarded by a mutex to prevent tests running in parallel + Added .drone.yml to run tests on a PR and on a pushmain
parent
e1b362aa1c
commit
04d9c29458
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
kind: pipeline
|
||||
name: compliance
|
||||
type: docker
|
||||
trigger:
|
||||
event:
|
||||
- pull_request
|
||||
steps:
|
||||
- name: build
|
||||
pull: always
|
||||
image: rust:1.56.0
|
||||
commands:
|
||||
- rustup component add clippy
|
||||
- cargo build --verbose
|
||||
- cargo clippy --workspace --tests --all-targets --all-features
|
||||
- cargo test --workspace --no-fail-fast
|
||||
---
|
||||
kind: pipeline
|
||||
name: release
|
||||
type: docker
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
steps:
|
||||
- name: build
|
||||
pull: always
|
||||
image: rust:1.56.0
|
||||
commands:
|
||||
- rustup component add clippy
|
||||
- cargo build --verbose --release
|
||||
- cargo clippy --workspace --tests --all-targets --all-features
|
||||
- cargo test --workspace --no-fail-fast
|
|
@ -165,9 +165,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.3"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12"
|
||||
checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
|
@ -178,11 +178,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49"
|
||||
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"lazy_static",
|
||||
]
|
||||
|
@ -556,9 +555,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.88"
|
||||
version = "0.2.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a"
|
||||
checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
|
@ -568,9 +567,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
|||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.2"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312"
|
||||
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
@ -734,9 +733,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api",
|
||||
|
@ -745,9 +744,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
|
||||
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"instant",
|
||||
|
@ -932,9 +931,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.5"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
@ -1099,9 +1098,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
|||
|
||||
[[package]]
|
||||
name = "sled"
|
||||
version = "0.34.6"
|
||||
version = "0.34.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d0132f3e393bcb7390c60bb45769498cf4550bcb7a21d7f95c02b69f6362cdc"
|
||||
checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"crossbeam-epoch",
|
||||
|
|
|
@ -161,7 +161,7 @@ mod test {
|
|||
fn stress_test() {
|
||||
std::fs::remove_dir_all(PathBuf::from("test_db")).ok();
|
||||
println!("Shop Count,Item Count,Query Time,Query Time / Shop");
|
||||
for shop_count in (100..=1000).step_by(100) {
|
||||
for shop_count in (100..=500).step_by(100) {
|
||||
let query_dur = test_selling_lookup_speed(shop_count, 100, 10);
|
||||
|
||||
println!(
|
||||
|
|
|
@ -7,7 +7,7 @@ edition = "2018"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
sled = "0.34.6"
|
||||
sled = "0.34.7"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
geoffrey_models = { path = "../geoffrey_models" }
|
||||
|
|
|
@ -70,7 +70,9 @@ impl Database {
|
|||
where
|
||||
T: GeoffreyDatabaseModel,
|
||||
{
|
||||
Ok(self.db.open_tree(T::tree())?.clear()?)
|
||||
self.db.drop_tree(T::tree())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn filter<'a, T>(
|
||||
|
@ -116,10 +118,12 @@ mod tests {
|
|||
use geoffrey_models::GeoffreyDatabaseModel;
|
||||
use lazy_static::lazy_static;
|
||||
use std::path::Path;
|
||||
use std::sync::Mutex;
|
||||
use std::time::Instant;
|
||||
|
||||
lazy_static! {
|
||||
static ref DB: Database = Database::new(Path::new("../test_database")).unwrap();
|
||||
static ref LOCK: Mutex<()> = Mutex::default();
|
||||
}
|
||||
|
||||
fn cleanup() {
|
||||
|
@ -131,6 +135,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_insert() {
|
||||
let _lock = LOCK.lock().unwrap();
|
||||
cleanup();
|
||||
let player = Player::new("CoolZero123", UserID::DiscordUUID { discord_uuid: 0u64 });
|
||||
|
||||
|
@ -144,6 +149,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_unique_insert() {
|
||||
let _lock = LOCK.lock().unwrap();
|
||||
cleanup();
|
||||
let player1 = Player::new("CoolZero123", UserID::DiscordUUID { discord_uuid: 0u64 });
|
||||
let player2 = Player::new("CoolZero123", UserID::DiscordUUID { discord_uuid: 0u64 });
|
||||
|
@ -156,6 +162,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_get() {
|
||||
let _lock = LOCK.lock().unwrap();
|
||||
cleanup();
|
||||
let player = Player::new("CoolZero123", UserID::DiscordUUID { discord_uuid: 0u64 });
|
||||
|
||||
|
@ -169,6 +176,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_filter() {
|
||||
let _lock = LOCK.lock().unwrap();
|
||||
cleanup();
|
||||
let player = Player::new("CoolZero123", UserID::DiscordUUID { discord_uuid: 0u64 });
|
||||
let player = DB.insert::<Player>(player.clone()).unwrap();
|
||||
|
@ -198,6 +206,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_insert_speed() {
|
||||
let _lock = LOCK.lock().unwrap();
|
||||
cleanup();
|
||||
let insert_count = 1000;
|
||||
let timer = Instant::now();
|
||||
|
|
|
@ -57,7 +57,6 @@ impl GeoffreyDatabaseModel for Player {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::models::player::UserID::{DiscordUUID, MinecraftUUID};
|
||||
use crate::models::player::{Player, UserID};
|
||||
use crate::GeoffreyDatabaseModel;
|
||||
|
||||
|
|
Loading…
Reference in New Issue