Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create immutable file to test snapshot creation #265

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mithril-test-lab/mithril-end-to-end/src/end_to_end_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ impl Spec {
let aggregator_endpoint = self.infrastructure.aggregator().endpoint();

wait_for_pending_certificate(&aggregator_endpoint).await?;
let _ = self.infrastructure.add_immutable();

let digest = assert_node_producing_snapshot(&aggregator_endpoint).await?;
let certificate_hash =
assert_signer_is_signing_snapshot(&aggregator_endpoint, &digest).await?;
Expand Down Expand Up @@ -82,7 +84,7 @@ async fn wait_for_pending_certificate(aggregator_endpoint: &str) -> Result<(), S
async fn assert_node_producing_snapshot(aggregator_endpoint: &str) -> Result<String, String> {
let url = format!("{}/snapshots", aggregator_endpoint);

match attempt!(10, Duration::from_millis(1000), {
match attempt!(20, Duration::from_millis(1500), {
match reqwest::get(url.clone()).await {
Ok(response) => match response.status() {
StatusCode::OK => match response.json::<Vec<Snapshot>>().await.as_deref() {
Expand Down
2 changes: 1 addition & 1 deletion mithril-test-lab/mithril-end-to-end/src/mithril/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Client {
self.command.dump_logs_to_stdout().await?;

Err(match status.code() {
Some(c) => format!("mithril-signer exited with code: {}", c),
Some(c) => format!("mithril-client exited with code: {}", c),
None => "mithril-client was terminated with a signal".to_string(),
})
}
Expand Down
20 changes: 20 additions & 0 deletions mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};
pub struct MithrilInfrastructure {
work_dir: PathBuf,
bin_dir: PathBuf,
db_dir: PathBuf,
aggregator: Aggregator,
signer: Signer,
}
Expand All @@ -25,6 +26,7 @@ impl MithrilInfrastructure {
Ok(Self {
work_dir: work_dir.to_path_buf(),
bin_dir: bin_dir.to_path_buf(),
db_dir: db_dir.to_path_buf(),
aggregator,
signer,
})
Expand All @@ -49,4 +51,22 @@ impl MithrilInfrastructure {
pub fn build_client(&self) -> Result<Client, String> {
Client::new(self.aggregator.endpoint(), &self.work_dir, &self.bin_dir)
}

pub fn add_immutable(&self) -> Result<(), Box<dyn std::error::Error>> {
let db_path = self.db_dir.join("immutable");
let glob_expr = format!("{}/*.chunk", db_path.to_string_lossy());

let mut filelist = glob::glob(&glob_expr)?
.map(|f| {
str::parse::<usize>(f.unwrap().file_stem().unwrap().to_str().unwrap()).unwrap()
})
.collect::<Vec<usize>>();
filelist.sort();
let new_number = filelist.pop().unwrap() + 1;

std::fs::File::create(db_path.join(format!("{:05}.chunk", new_number)))?;
std::fs::File::create(db_path.join(format!("{:05}.primary", new_number)))?;
std::fs::File::create(db_path.join(format!("{:05}.secondary", new_number)))?;
Ok(())
}
}