Skip to content

Commit

Permalink
fix: save old bin dir
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Dec 9, 2024
1 parent cf41ab1 commit 6675f0f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/runner/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ pub struct Env {
bins_dir: Arc<Mutex<Option<PathBuf>>>,
/// Pull different versions of GreptimeDB on need.
pull_version_on_need: bool,
/// old bins dir, useful when switching versions
old_bins_dir: Arc<Mutex<Option<PathBuf>>>,
}

#[async_trait]
Expand Down Expand Up @@ -112,6 +114,7 @@ impl Env {
wal,
pull_version_on_need,
bins_dir: Arc::new(Mutex::new(bins_dir)),
old_bins_dir: Arc::new(Mutex::new(None)),
}
}

Expand Down Expand Up @@ -700,9 +703,13 @@ impl Database for GreptimeDB {
if ctx.context.contains_key("restart") && self.env.server_addrs.server_addr.is_none() {
self.env.restart_server(self).await;
} else if let Some(version) = ctx.context.get("version") {
if self.env.old_bins_dir.lock().unwrap().is_none() {
// save old bins dir
*self.env.old_bins_dir.lock().unwrap() = self.env.bins_dir.lock().unwrap().clone();
}
if version == "latest" {
// use default latest by building db now
*self.env.bins_dir.lock().unwrap() = Some(util::get_binary_dir("debug"));
*self.env.bins_dir.lock().unwrap() = self.env.old_bins_dir.lock().unwrap().clone();
} else {
// use version in dir files
maybe_pull_binary(version, self.env.pull_version_on_need).await;
Expand Down

0 comments on commit 6675f0f

Please sign in to comment.