Skip to content

Commit cfcd7ce

Browse files
authored
[Tests] another attempt to stabilize tests (#1199)
* moving custom_errors_found up * removing json logger settings from cmd, since it's in config * changed log success entry line, changing is up verification since rest bootstrap is longer
1 parent ddf9b70 commit cfcd7ce

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

jormungandr-integration-tests/src/common/jormungandr/commands.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ use std::fs::File;
44
use std::path::PathBuf;
55
use std::process::{Command, Stdio};
66

7-
fn set_json_logger(command: &mut Command) {
8-
command.arg("--log-format").arg("json");
9-
}
10-
117
pub fn get_start_jormungandr_as_leader_node_command(
128
config_path: &PathBuf,
139
genesis_block_path: &PathBuf,
1410
secret_path: &PathBuf,
1511
log_file_path: &PathBuf,
1612
) -> Command {
1713
let mut command = Command::new(configuration::get_jormungandr_app().as_os_str());
18-
set_json_logger(&mut command);
1914
command
2015
.arg("--secret")
2116
.arg(secret_path.as_os_str())
@@ -34,7 +29,6 @@ pub fn get_start_jormungandr_as_passive_node_command(
3429
log_file_path: &PathBuf,
3530
) -> Command {
3631
let mut command = Command::new(configuration::get_jormungandr_app().as_os_str());
37-
set_json_logger(&mut command);
3832
command
3933
.arg("--config")
4034
.arg(config_path.as_os_str())

jormungandr-integration-tests/src/common/jormungandr/configuration_builder.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::common::{
22
configuration::{
33
genesis_model::{Fund, GenesisYaml, Initial, LinearFees},
44
jormungandr_config::JormungandrConfig,
5-
node_config_model::{Log, NodeConfig, TrustedPeer},
5+
node_config_model::{Log, LogEntry, NodeConfig, TrustedPeer},
66
secret_model::SecretModel,
77
},
88
file_utils, jcli_wrapper,
@@ -45,7 +45,10 @@ impl ConfigurationBuilder {
4545
slots_per_epoch: None,
4646
slot_duration: None,
4747
epoch_stability_depth: None,
48-
log: None,
48+
log: Some(Log(vec![LogEntry {
49+
level: Some("info".to_string()),
50+
format: Some("json".to_string()),
51+
}])),
4952
linear_fees: LinearFees {
5053
constant: 0,
5154
coefficient: 0,

jormungandr-integration-tests/src/common/jormungandr/starter.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub enum Role {
4545
}
4646

4747
pub trait StartupVerification {
48-
fn stop(&self) -> bool;
49-
fn success(&self) -> bool;
48+
fn if_stopped(&self) -> bool;
49+
fn if_succeed(&self) -> bool;
5050
}
5151

5252
#[derive(Clone, Debug)]
@@ -61,12 +61,12 @@ impl RestStartupVerification {
6161
}
6262

6363
impl StartupVerification for RestStartupVerification {
64-
fn stop(&self) -> bool {
64+
fn if_stopped(&self) -> bool {
6565
let logger = JormungandrLogger::new(self.config.log_file_path.clone());
6666
logger.contains_error().unwrap_or_else(|_| false)
6767
}
6868

69-
fn success(&self) -> bool {
69+
fn if_succeed(&self) -> bool {
7070
let output = process_utils::run_process_and_get_output(
7171
jcli_commands::get_rest_stats_command(&self.config.get_node_address()),
7272
);
@@ -100,15 +100,15 @@ impl LogStartupVerification {
100100
}
101101

102102
impl StartupVerification for LogStartupVerification {
103-
fn stop(&self) -> bool {
103+
fn if_stopped(&self) -> bool {
104104
let logger = JormungandrLogger::new(self.config.log_file_path.clone());
105105
logger.contains_error().unwrap_or_else(|_| false)
106106
}
107107

108-
fn success(&self) -> bool {
108+
fn if_succeed(&self) -> bool {
109109
let logger = JormungandrLogger::new(self.config.log_file_path.clone());
110110
logger
111-
.message_logged_multiple_times("initial bootstrap completed", 2)
111+
.contains_message("genesis block fetched")
112112
.unwrap_or_else(|_| false)
113113
}
114114
}
@@ -212,23 +212,25 @@ impl Starter {
212212
process_assert::assert_process_failed_and_matches_message(command, &expected_msg);
213213
}
214214

215-
fn success(&self) -> bool {
215+
fn if_succeed(&self) -> bool {
216216
match self.verification_mode {
217217
StartupVerificationMode::Rest => {
218-
RestStartupVerification::new(self.config.clone()).success()
218+
RestStartupVerification::new(self.config.clone()).if_succeed()
219219
}
220220
StartupVerificationMode::Log => {
221-
LogStartupVerification::new(self.config.clone()).success()
221+
LogStartupVerification::new(self.config.clone()).if_succeed()
222222
}
223223
}
224224
}
225225

226-
fn stop(&self) -> bool {
226+
fn if_stopped(&self) -> bool {
227227
match self.verification_mode {
228228
StartupVerificationMode::Rest => {
229-
RestStartupVerification::new(self.config.clone()).stop()
229+
RestStartupVerification::new(self.config.clone()).if_stopped()
230+
}
231+
StartupVerificationMode::Log => {
232+
LogStartupVerification::new(self.config.clone()).if_stopped()
230233
}
231-
StartupVerificationMode::Log => LogStartupVerification::new(self.config.clone()).stop(),
232234
}
233235
}
234236

@@ -254,19 +256,21 @@ impl Starter {
254256
log_content: file_utils::read_file(&self.config.log_file_path),
255257
});
256258
}
257-
if self.success() {
259+
if self.if_succeed() {
260+
println!("jormungandr is up");
258261
return Ok(JormungandrProcess::from_config(
259262
process,
260263
self.config.clone(),
261264
));
262265
}
263-
if self.stop() {
266+
self.custom_errors_found()?;
267+
if self.if_stopped() {
268+
println!("attempt stopped due to error signal recieved");
264269
logger.print_raw_log();
265270
return Err(StartupError::ErrorInLogsFound {
266271
log_content: file_utils::read_file(&self.config.log_file_path),
267272
});
268273
}
269-
self.custom_errors_found()?;
270274
process_utils::sleep(self.sleep);
271275
}
272276
}

jormungandr-integration-tests/src/networking/testnet.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn e2e_stake_pool() {
9494
.config(testnet_config.make_config())
9595
.timeout(Duration::from_secs(1000))
9696
.passive()
97-
.verify_by(StartupVerificationMode::Log)
97+
.verify_by(StartupVerificationMode::Rest)
9898
.start()
9999
.unwrap();
100100

@@ -106,7 +106,6 @@ pub fn e2e_stake_pool() {
106106
//register stake pool
107107
let stake_pool_id = create_new_stake_pool(
108108
&mut actor_account,
109-
"1234",
110109
&block0_hash,
111110
&jormungandr.rest_address(),
112111
&long_wait,

0 commit comments

Comments
 (0)