mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-18 15:44:20 +01:00
remove dead code in sim
This commit is contained in:
@@ -63,11 +63,6 @@ impl InteractionPlan {
|
||||
Self { plan, mvcc, len }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plan(&self) -> &[Interactions] {
|
||||
&self.plan
|
||||
}
|
||||
|
||||
/// Length of interactions that are not transaction statements
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
@@ -629,14 +624,6 @@ impl InteractionsType {
|
||||
}
|
||||
|
||||
impl Interactions {
|
||||
pub(crate) fn name(&self) -> Option<&str> {
|
||||
match &self.interactions {
|
||||
InteractionsType::Property(property) => Some(property.name()),
|
||||
InteractionsType::Query(_) => None,
|
||||
InteractionsType::Fault(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn interactions(&self) -> Vec<Interaction> {
|
||||
match &self.interactions {
|
||||
InteractionsType::Property(property) => property.interactions(self.connection_index),
|
||||
@@ -726,17 +713,6 @@ pub(crate) struct InteractionStats {
|
||||
pub(crate) rollback_count: u32,
|
||||
}
|
||||
|
||||
impl InteractionStats {
|
||||
pub fn total_writes(&self) -> u32 {
|
||||
self.insert_count
|
||||
+ self.delete_count
|
||||
+ self.update_count
|
||||
+ self.create_count
|
||||
+ self.create_index_count
|
||||
+ self.drop_count
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for InteractionStats {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
@@ -758,10 +734,6 @@ impl Display for InteractionStats {
|
||||
|
||||
type AssertionFunc = dyn Fn(&Vec<ResultSet>, &mut SimulatorEnv) -> Result<Result<(), String>>;
|
||||
|
||||
enum AssertionAST {
|
||||
Pick(),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Assertion {
|
||||
pub func: Rc<AssertionFunc>,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use rand::distr::{Distribution, weighted::WeightedIndex};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sql_generation::{
|
||||
generation::{Arbitrary, ArbitraryFrom, GenerationContext, Opts, pick, pick_index},
|
||||
generation::{Arbitrary, ArbitraryFrom, GenerationContext, pick, pick_index},
|
||||
model::{
|
||||
query::{
|
||||
Create, Delete, Drop, Insert, Select,
|
||||
@@ -17,7 +17,7 @@ use sql_generation::{
|
||||
transaction::{Begin, Commit, Rollback},
|
||||
update::Update,
|
||||
},
|
||||
table::{SimValue, Table},
|
||||
table::SimValue,
|
||||
},
|
||||
};
|
||||
use strum::IntoEnumIterator;
|
||||
@@ -27,40 +27,15 @@ use turso_parser::ast::{self, Distinctness};
|
||||
use crate::{
|
||||
common::print_diff,
|
||||
generation::{
|
||||
Shadow as _, WeightedDistribution,
|
||||
plan::InteractionType,
|
||||
query::{QueryDistribution, possible_queries},
|
||||
Shadow as _, WeightedDistribution, plan::InteractionType, query::QueryDistribution,
|
||||
},
|
||||
model::{Query, QueryCapabilities, QueryDiscriminants},
|
||||
profiles::query::QueryProfile,
|
||||
runner::env::{ShadowTablesMut, SimulatorEnv},
|
||||
runner::env::SimulatorEnv,
|
||||
};
|
||||
|
||||
use super::plan::{Assertion, Interaction, InteractionStats, ResultSet};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
struct PropertyGenContext<'a> {
|
||||
tables: &'a Vec<sql_generation::model::table::Table>,
|
||||
opts: &'a sql_generation::generation::Opts,
|
||||
}
|
||||
|
||||
impl<'a> PropertyGenContext<'a> {
|
||||
#[inline]
|
||||
fn new(tables: &'a Vec<Table>, opts: &'a Opts) -> Self {
|
||||
Self { tables, opts }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> GenerationContext for PropertyGenContext<'a> {
|
||||
fn tables(&self) -> &Vec<sql_generation::model::table::Table> {
|
||||
self.tables
|
||||
}
|
||||
|
||||
fn opts(&self) -> &sql_generation::generation::Opts {
|
||||
self.opts
|
||||
}
|
||||
}
|
||||
|
||||
/// Properties are representations of executable specifications
|
||||
/// about the database behavior.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, strum::EnumDiscriminants)]
|
||||
@@ -1925,11 +1900,6 @@ impl PropertyDiscriminants {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn possiple_properties(tables: &[Table]) -> Vec<PropertyDiscriminants> {
|
||||
let queries = possible_queries(tables);
|
||||
PropertyDiscriminants::can_generate(queries)
|
||||
}
|
||||
|
||||
pub(super) struct PropertyDistribution<'a> {
|
||||
properties: Vec<PropertyDiscriminants>,
|
||||
weights: WeightedIndex<u32>,
|
||||
@@ -1995,49 +1965,6 @@ impl<'a> ArbitraryFrom<&PropertyDistribution<'a>> for Property {
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_queries<R: rand::Rng + ?Sized, F>(
|
||||
rng: &mut R,
|
||||
ctx: &impl GenerationContext,
|
||||
amount: usize,
|
||||
init_queries: &[&Query],
|
||||
func: F,
|
||||
) -> Vec<Query>
|
||||
where
|
||||
F: Fn(&mut R, PropertyGenContext) -> Option<Query>,
|
||||
{
|
||||
// Create random queries respecting the constraints
|
||||
let mut queries = Vec::new();
|
||||
|
||||
let range = 0..amount;
|
||||
if !range.is_empty() {
|
||||
let mut tmp_tables = ctx.tables().clone();
|
||||
|
||||
for query in init_queries {
|
||||
tmp_shadow(&mut tmp_tables, query);
|
||||
}
|
||||
|
||||
for _ in range {
|
||||
let tmp_ctx = PropertyGenContext::new(&tmp_tables, ctx.opts());
|
||||
|
||||
let Some(query) = func(rng, tmp_ctx) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
tmp_shadow(&mut tmp_tables, &query);
|
||||
|
||||
queries.push(query);
|
||||
}
|
||||
}
|
||||
queries
|
||||
}
|
||||
|
||||
fn tmp_shadow(tmp_tables: &mut Vec<Table>, query: &Query) {
|
||||
let mut tx_tables = None;
|
||||
let mut tmp_shadow_tables = ShadowTablesMut::new(tmp_tables, &mut tx_tables);
|
||||
|
||||
let _ = query.shadow(&mut tmp_shadow_tables);
|
||||
}
|
||||
|
||||
fn print_row(row: &[SimValue]) -> String {
|
||||
row.iter()
|
||||
.map(|v| match &v.0 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![allow(clippy::arc_with_non_send_sync, dead_code)]
|
||||
#![allow(clippy::arc_with_non_send_sync)]
|
||||
use anyhow::anyhow;
|
||||
use clap::Parser;
|
||||
use generation::plan::{InteractionPlan, InteractionPlanState};
|
||||
@@ -421,6 +421,7 @@ enum SandboxedResult {
|
||||
error: String,
|
||||
last_execution: Execution,
|
||||
},
|
||||
#[expect(dead_code)]
|
||||
FoundBug {
|
||||
error: String,
|
||||
history: ExecutionHistory,
|
||||
|
||||
@@ -204,16 +204,6 @@ impl QueryDiscriminants {
|
||||
QueryDiscriminants::Drop,
|
||||
QueryDiscriminants::CreateIndex,
|
||||
];
|
||||
|
||||
#[inline]
|
||||
pub fn is_transaction(&self) -> bool {
|
||||
matches!(self, Self::Begin | Self::Commit | Self::Rollback)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_ddl(&self) -> bool {
|
||||
matches!(self, Self::Create | Self::CreateIndex | Self::Drop)
|
||||
}
|
||||
}
|
||||
|
||||
impl Shadow for Create {
|
||||
|
||||
@@ -49,6 +49,7 @@ pub(crate) struct BugRun {
|
||||
}
|
||||
|
||||
impl Bug {
|
||||
#[expect(dead_code)]
|
||||
/// Check if the bug is loaded.
|
||||
pub(crate) fn is_loaded(&self) -> bool {
|
||||
match self {
|
||||
@@ -130,6 +131,7 @@ impl BugBase {
|
||||
Err(anyhow!("failed to create bug base"))
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
/// Load the bug base from one of the potential paths.
|
||||
pub(crate) fn interactive_load() -> anyhow::Result<Self> {
|
||||
let potential_paths = vec![
|
||||
@@ -338,6 +340,7 @@ impl BugBase {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub(crate) fn mark_successful_run(
|
||||
&mut self,
|
||||
seed: u64,
|
||||
@@ -434,6 +437,7 @@ impl BugBase {
|
||||
}
|
||||
|
||||
impl BugBase {
|
||||
#[expect(dead_code)]
|
||||
/// Get the path to the bug base directory.
|
||||
pub(crate) fn path(&self) -> &PathBuf {
|
||||
&self.path
|
||||
|
||||
@@ -83,18 +83,6 @@ impl<'a, 'b> ShadowTablesMut<'a>
|
||||
where
|
||||
'a: 'b,
|
||||
{
|
||||
/// Creation of [ShadowTablesMut] outside of [SimulatorEnv] should be done sparingly and carefully.
|
||||
/// Should only need to call this function if we need to do shadowing in a temporary model table
|
||||
pub fn new(
|
||||
commited_tables: &'a mut Vec<Table>,
|
||||
transaction_tables: &'a mut Option<TransactionTables>,
|
||||
) -> Self {
|
||||
ShadowTablesMut {
|
||||
commited_tables,
|
||||
transaction_tables,
|
||||
}
|
||||
}
|
||||
|
||||
fn tables(&'a self) -> &'a Vec<Table> {
|
||||
self.transaction_tables
|
||||
.as_ref()
|
||||
@@ -312,7 +300,6 @@ impl SimulatorEnv {
|
||||
seed,
|
||||
ticks: rng
|
||||
.random_range(cli_opts.minimum_tests as usize..=cli_opts.maximum_tests as usize),
|
||||
max_tables: rng.random_range(0..128),
|
||||
disable_select_optimizer: cli_opts.disable_select_optimizer,
|
||||
disable_insert_values_select: cli_opts.disable_insert_values_select,
|
||||
disable_double_create_failure: cli_opts.disable_double_create_failure,
|
||||
@@ -528,14 +515,6 @@ impl SimulatorEnv {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ConnectionTrait
|
||||
where
|
||||
Self: std::marker::Sized + Clone,
|
||||
{
|
||||
fn is_connected(&self) -> bool;
|
||||
fn disconnect(&mut self);
|
||||
}
|
||||
|
||||
pub(crate) enum SimConnection {
|
||||
LimboConnection(Arc<turso_core::Connection>),
|
||||
SQLiteConnection(rusqlite::Connection),
|
||||
@@ -584,7 +563,6 @@ impl Display for SimConnection {
|
||||
pub(crate) struct SimulatorOpts {
|
||||
pub(crate) seed: u64,
|
||||
pub(crate) ticks: usize,
|
||||
pub(crate) max_tables: usize,
|
||||
|
||||
pub(crate) disable_select_optimizer: bool,
|
||||
pub(crate) disable_insert_values_select: bool,
|
||||
|
||||
@@ -46,6 +46,7 @@ impl ExecutionHistory {
|
||||
}
|
||||
|
||||
pub struct ExecutionResult {
|
||||
#[expect(dead_code)]
|
||||
pub history: ExecutionHistory,
|
||||
pub error: Option<LimboError>,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
@@ -121,7 +121,7 @@ pub struct MemorySimIO {
|
||||
timeouts: CallbackQueue,
|
||||
pub files: RefCell<IndexMap<Fd, Arc<MemorySimFile>>>,
|
||||
pub rng: RefCell<ChaCha8Rng>,
|
||||
pub nr_run_once_faults: Cell<usize>,
|
||||
#[expect(dead_code)]
|
||||
pub page_size: usize,
|
||||
seed: u64,
|
||||
latency_probability: u8,
|
||||
@@ -141,13 +141,11 @@ impl MemorySimIO {
|
||||
) -> Self {
|
||||
let files = RefCell::new(IndexMap::new());
|
||||
let rng = RefCell::new(ChaCha8Rng::seed_from_u64(seed));
|
||||
let nr_run_once_faults = Cell::new(0);
|
||||
Self {
|
||||
callbacks: Arc::new(Mutex::new(Vec::new())),
|
||||
timeouts: Arc::new(Mutex::new(Vec::new())),
|
||||
files,
|
||||
rng,
|
||||
nr_run_once_faults,
|
||||
page_size,
|
||||
seed,
|
||||
latency_probability,
|
||||
|
||||
@@ -5,7 +5,7 @@ pub mod differential;
|
||||
pub mod doublecheck;
|
||||
pub mod env;
|
||||
pub mod execution;
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
pub mod file;
|
||||
pub mod io;
|
||||
pub mod memory;
|
||||
|
||||
Reference in New Issue
Block a user