mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-06 00:34:23 +01:00
Add --keep-files flag and force Drop of database in simulator to prevent issues with the Registry
This commit is contained in:
@@ -717,6 +717,7 @@ fn reopen_database(env: &mut SimulatorEnv) {
|
||||
}
|
||||
}
|
||||
SimulationType::Default | SimulationType::Doublecheck => {
|
||||
env.db = None;
|
||||
let db = match turso_core::Database::open_file(
|
||||
env.io.clone(),
|
||||
env.get_db_path().to_str().expect("path should be 'to_str'"),
|
||||
@@ -734,11 +735,12 @@ fn reopen_database(env: &mut SimulatorEnv) {
|
||||
}
|
||||
};
|
||||
|
||||
env.db = db;
|
||||
env.db = Some(db);
|
||||
|
||||
for _ in 0..num_conns {
|
||||
env.connections
|
||||
.push(SimConnection::LimboConnection(env.db.connect().unwrap()));
|
||||
env.connections.push(SimConnection::LimboConnection(
|
||||
env.db.as_ref().expect("db to be Some").connect().unwrap(),
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -136,7 +136,7 @@ fn testing_main(cli_opts: &SimulatorCLI) -> anyhow::Result<()> {
|
||||
println!("seed: {seed}");
|
||||
println!("path: {}", paths.base.display());
|
||||
|
||||
if result.is_ok() {
|
||||
if !cli_opts.keep_files && result.is_ok() {
|
||||
paths.delete_all_files();
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,12 @@ pub struct SimulatorCLI {
|
||||
pub experimental_mvcc: bool,
|
||||
#[clap(long, help = "Disable experimental indexing feature")]
|
||||
pub disable_experimental_indexes: bool,
|
||||
#[clap(
|
||||
long,
|
||||
help = "Keep all database and plan files",
|
||||
default_value_t = false
|
||||
)]
|
||||
pub keep_files: bool,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug, Clone, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Ord)]
|
||||
|
||||
@@ -62,7 +62,7 @@ pub(crate) struct SimulatorEnv {
|
||||
pub(crate) opts: SimulatorOpts,
|
||||
pub(crate) connections: Vec<SimConnection>,
|
||||
pub(crate) io: Arc<SimulatorIO>,
|
||||
pub(crate) db: Arc<Database>,
|
||||
pub(crate) db: Option<Arc<Database>>,
|
||||
pub(crate) rng: ChaCha8Rng,
|
||||
pub(crate) paths: Paths,
|
||||
pub(crate) type_: SimulationType,
|
||||
@@ -115,6 +115,7 @@ impl SimulatorEnv {
|
||||
if wal_path.exists() {
|
||||
std::fs::remove_file(&wal_path).unwrap();
|
||||
}
|
||||
self.db = None;
|
||||
|
||||
let db = match Database::open_file(
|
||||
io.clone(),
|
||||
@@ -129,7 +130,7 @@ impl SimulatorEnv {
|
||||
}
|
||||
};
|
||||
self.io = io;
|
||||
self.db = db;
|
||||
self.db = Some(db);
|
||||
}
|
||||
|
||||
pub(crate) fn get_db_path(&self) -> PathBuf {
|
||||
@@ -298,7 +299,7 @@ impl SimulatorEnv {
|
||||
paths,
|
||||
rng,
|
||||
io,
|
||||
db,
|
||||
db: Some(db),
|
||||
type_: simulation_type,
|
||||
phase: SimulationPhase::Test,
|
||||
}
|
||||
@@ -320,6 +321,8 @@ impl SimulatorEnv {
|
||||
SimulationType::Default | SimulationType::Doublecheck => {
|
||||
self.connections[connection_index] = SimConnection::LimboConnection(
|
||||
self.db
|
||||
.as_ref()
|
||||
.expect("db to be Some")
|
||||
.connect()
|
||||
.expect("Failed to connect to Limbo database"),
|
||||
);
|
||||
|
||||
@@ -123,8 +123,9 @@ fn execute_plan(
|
||||
|
||||
if let SimConnection::Disconnected = connection {
|
||||
tracing::debug!("connecting {}", connection_index);
|
||||
env.connections[connection_index] =
|
||||
SimConnection::LimboConnection(env.db.connect().unwrap());
|
||||
env.connections[connection_index] = SimConnection::LimboConnection(
|
||||
env.db.as_ref().expect("db to be Some").connect().unwrap(),
|
||||
);
|
||||
} else {
|
||||
tracing::debug!("connection {} already connected", connection_index);
|
||||
match execute_interaction(env, connection_index, interaction, &mut state.stack) {
|
||||
|
||||
@@ -98,8 +98,9 @@ fn execute_plan(
|
||||
|
||||
if let SimConnection::Disconnected = connection {
|
||||
tracing::debug!("connecting {}", connection_index);
|
||||
env.connections[connection_index] =
|
||||
SimConnection::LimboConnection(env.db.connect().unwrap());
|
||||
env.connections[connection_index] = SimConnection::LimboConnection(
|
||||
env.db.as_ref().expect("db to be Some").connect().unwrap(),
|
||||
);
|
||||
} else {
|
||||
match execute_interaction(env, connection_index, interaction, &mut state.stack) {
|
||||
Ok(next_execution) => {
|
||||
|
||||
Reference in New Issue
Block a user