Skip to content

Commit 9b5e5d8

Browse files
committed
3-level logs worked: cargo test --test 02_commit_and_undelegate test_committing_and_undelegating_one_account --profile test -- --nocapture --exact
1 parent 7b23df7 commit 9b5e5d8

File tree

4 files changed

+151
-148
lines changed

4 files changed

+151
-148
lines changed

test-integration/test-runner/bin/run_tests.rs

Lines changed: 95 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ use test_runner::{
2222

2323
pub fn main() {
2424
let config = TestConfigViaEnvVars::default();
25+
if config.selected_tests.len() != 0 {
26+
println!("config: {:#?}", config);
27+
// return;
28+
}
29+
2530
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
2631
let Ok((security_output, scenarios_output)) =
2732
run_schedule_commit_tests(&manifest_dir, &config)
@@ -30,72 +35,72 @@ pub fn main() {
3035
return;
3136
};
3237

33-
let Ok(issues_frequent_commits_output) =
34-
run_issues_frequent_commmits_tests(&manifest_dir, &config)
35-
else {
36-
return;
37-
};
38-
39-
let Ok(cloning_output) = run_cloning_tests(&manifest_dir, &config) else {
40-
return;
41-
};
42-
43-
let Ok(restore_ledger_output) =
44-
run_restore_ledger_tests(&manifest_dir, &config)
45-
else {
46-
return;
47-
};
48-
49-
let Ok(magicblock_api_output) =
50-
run_magicblock_api_tests(&manifest_dir, &config)
51-
else {
52-
return;
53-
};
54-
55-
let Ok((table_mania_output, committor_output)) =
56-
run_table_mania_and_committor_tests(&manifest_dir, &config)
57-
else {
58-
return;
59-
};
60-
61-
let Ok(magicblock_pubsub_output) =
62-
run_magicblock_pubsub_tests(&manifest_dir, &config)
63-
else {
64-
return;
65-
};
66-
67-
let Ok(config_output) = run_config_tests(&manifest_dir, &config) else {
68-
return;
69-
};
70-
71-
let Ok(schedule_intents_output) =
72-
run_schedule_intents_tests(&manifest_dir, &config)
73-
else {
74-
return;
75-
};
76-
77-
let Ok(task_scheduler_output) =
78-
run_task_scheduler_tests(&manifest_dir, &config)
79-
else {
80-
return;
81-
};
82-
83-
// Assert that all tests passed
38+
// let Ok(issues_frequent_commits_output) =
39+
// run_issues_frequent_commmits_tests(&manifest_dir, &config)
40+
// else {
41+
// return;
42+
// };
43+
44+
// let Ok(cloning_output) = run_cloning_tests(&manifest_dir, &config) else {
45+
// return;
46+
// };
47+
48+
// let Ok(restore_ledger_output) =
49+
// run_restore_ledger_tests(&manifest_dir, &config)
50+
// else {
51+
// return;
52+
// };
53+
54+
// let Ok(magicblock_api_output) =
55+
// run_magicblock_api_tests(&manifest_dir, &config)
56+
// else {
57+
// return;
58+
// };
59+
60+
// let Ok((table_mania_output, committor_output)) =
61+
// run_table_mania_and_committor_tests(&manifest_dir, &config)
62+
// else {
63+
// return;
64+
// };
65+
66+
// let Ok(magicblock_pubsub_output) =
67+
// run_magicblock_pubsub_tests(&manifest_dir, &config)
68+
// else {
69+
// return;
70+
// };
71+
72+
// let Ok(config_output) = run_config_tests(&manifest_dir, &config) else {
73+
// return;
74+
// };
75+
76+
// let Ok(schedule_intents_output) =
77+
// run_schedule_intents_tests(&manifest_dir, &config)
78+
// else {
79+
// return;
80+
// };
81+
82+
// let Ok(task_scheduler_output) =
83+
// run_task_scheduler_tests(&manifest_dir, &config)
84+
// else {
85+
// return;
86+
// };
87+
88+
// // Assert that all tests passed
8489
assert_cargo_tests_passed(security_output, "security");
8590
assert_cargo_tests_passed(scenarios_output, "scenarios");
86-
assert_cargo_tests_passed(cloning_output, "cloning");
87-
assert_cargo_tests_passed(
88-
issues_frequent_commits_output,
89-
"issues_frequent_commits",
90-
);
91-
assert_cargo_tests_passed(restore_ledger_output, "restore_ledger");
92-
assert_cargo_tests_passed(magicblock_api_output, "magicblock_api");
93-
assert_cargo_tests_passed(table_mania_output, "table_mania");
94-
assert_cargo_tests_passed(committor_output, "committor");
95-
assert_cargo_tests_passed(magicblock_pubsub_output, "magicblock_pubsub");
96-
assert_cargo_tests_passed(config_output, "config");
97-
assert_cargo_tests_passed(schedule_intents_output, "schedule_intents");
98-
assert_cargo_tests_passed(task_scheduler_output, "task_scheduler");
91+
// assert_cargo_tests_passed(cloning_output, "cloning");
92+
// assert_cargo_tests_passed(
93+
// issues_frequent_commits_output,
94+
// "issues_frequent_commits",
95+
// );
96+
// assert_cargo_tests_passed(restore_ledger_output, "restore_ledger");
97+
// assert_cargo_tests_passed(magicblock_api_output, "magicblock_api");
98+
// assert_cargo_tests_passed(table_mania_output, "table_mania");
99+
// assert_cargo_tests_passed(committor_output, "committor");
100+
// assert_cargo_tests_passed(magicblock_pubsub_output, "magicblock_pubsub");
101+
// assert_cargo_tests_passed(config_output, "config");
102+
// assert_cargo_tests_passed(schedule_intents_output, "schedule_intents");
103+
// assert_cargo_tests_passed(task_scheduler_output, "task_scheduler");
99104
}
100105

101106
fn success_output() -> Output {
@@ -298,22 +303,22 @@ fn run_schedule_commit_tests(
298303
);
299304
let mut ephem_validator = start_ephem_validator();
300305

301-
eprintln!("======== RUNNING SECURITY TESTS ========");
302-
let test_security_dir =
303-
format!("{}/../{}", manifest_dir, "schedulecommit/test-security");
304-
eprintln!("Running security tests in {}", test_security_dir);
305-
let test_security_output =
306-
match run_test(test_security_dir, Default::default()) {
307-
Ok(output) => output,
308-
Err(err) => {
309-
eprintln!("Failed to run security: {:?}", err);
310-
cleanup_validators(
311-
&mut ephem_validator,
312-
&mut devnet_validator,
313-
);
314-
return Err(err.into());
315-
}
316-
};
306+
// eprintln!("======== RUNNING SECURITY TESTS ========");
307+
// let test_security_dir =
308+
// format!("{}/../{}", manifest_dir, "schedulecommit/test-security");
309+
// eprintln!("Running security tests in {}", test_security_dir);
310+
// let test_security_output =
311+
// match run_test(test_security_dir, Default::default()) {
312+
// Ok(output) => output,
313+
// Err(err) => {
314+
// eprintln!("Failed to run security: {:?}", err);
315+
// cleanup_validators(
316+
// &mut ephem_validator,
317+
// &mut devnet_validator,
318+
// );
319+
// return Err(err.into());
320+
// }
321+
// };
317322

318323
eprintln!("======== RUNNING SCENARIOS TESTS ========");
319324
let test_scenarios_dir =
@@ -332,7 +337,8 @@ fn run_schedule_commit_tests(
332337
};
333338

334339
cleanup_validators(&mut ephem_validator, &mut devnet_validator);
335-
Ok((test_security_output, test_scenarios_output))
340+
//Ok((test_security_output, test_scenarios_output))
341+
Ok((test_scenarios_output.clone(), test_scenarios_output))
336342
} else {
337343
let devnet_validator =
338344
config.setup_devnet(TEST_NAME).then(start_devnet_validator);
@@ -761,11 +767,11 @@ fn run_test(
761767
config: RunTestConfig,
762768
) -> io::Result<process::Output> {
763769
let mut cmd = process::Command::new("cargo");
764-
cmd.env(
765-
"RUST_LOG",
766-
std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()),
767-
)
768-
.arg("test");
770+
// cmd.env(
771+
// "RUST_LOG",
772+
// std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string()),
773+
// )
774+
cmd.arg("test");
769775
if let Some(package) = config.package {
770776
cmd.arg("-p").arg(package);
771777
}
@@ -774,6 +780,9 @@ fn run_test(
774780
}
775781
cmd.arg("--").arg("--test-threads=1").arg("--nocapture");
776782
cmd.current_dir(manifest_dir.clone());
783+
784+
println!("run_test CMD: {:#?}", cmd);
785+
777786
Teepee::new(cmd).output()
778787
}
779788

test-integration/test-runner/src/env_config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[derive(Debug)]
12
enum ValidatorSetup {
23
Devnet,
34
Ephem,
@@ -26,9 +27,10 @@ impl From<&str> for ValidatorSetup {
2627
}
2728
}
2829

30+
#[derive(Debug)]
2931
pub struct TestConfigViaEnvVars {
3032
validators_only: Option<ValidatorSetup>,
31-
selected_tests: Vec<String>,
33+
pub selected_tests: Vec<String>,
3234
skipped_tests: Vec<String>,
3335
}
3436

test-integration/test-tools/src/integration_test_context.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub struct IntegrationTestContext {
6060

6161
impl IntegrationTestContext {
6262
pub fn try_new_ephem_only() -> Result<Self> {
63+
println!(" == try_new_ephem_only ==");
6364
let commitment = CommitmentConfig::confirmed();
6465
let ephem_client = RpcClient::new_with_commitment(
6566
Self::url_ephem().to_string(),
@@ -78,6 +79,7 @@ impl IntegrationTestContext {
7879
}
7980

8081
pub fn try_new_chain_only() -> Result<Self> {
82+
println!(" == try_new_chain_only ==");
8183
let commitment = CommitmentConfig::confirmed();
8284
let chain_client = RpcClient::new_with_commitment(
8385
Self::url_chain().to_string(),
@@ -95,6 +97,7 @@ impl IntegrationTestContext {
9597
}
9698

9799
pub fn try_new() -> Result<Self> {
100+
println!(" == try_new ==");
98101
let commitment = CommitmentConfig::confirmed();
99102

100103
let chain_client = RpcClient::new_with_commitment(
@@ -136,15 +139,21 @@ impl IntegrationTestContext {
136139
rpc_client: Option<&RpcClient>,
137140
label: &str,
138141
) -> Option<Vec<String>> {
139-
let rpc_client = rpc_client.or(self.chain_client.as_ref())?;
142+
let rpc_client =
143+
rpc_client.expect("rpc_client for [{}] does not exist");
140144

141145
// Try this up to 50 times since devnet here returns the version response instead of
142146
// the EncodedConfirmedTransactionWithStatusMeta at times
143-
for idx in 1..=100 {
147+
for idx in 1..=50 {
144148
let status = match rpc_client.get_transaction_with_config(
145149
&sig,
146150
RpcTransactionConfig {
147151
commitment: Some(self.commitment),
152+
max_supported_transaction_version: if label == "chain" {
153+
Some(0)
154+
} else {
155+
None
156+
},
148157
..Default::default()
149158
},
150159
) {
@@ -156,32 +165,25 @@ impl IntegrationTestContext {
156165
label, err
157166
);
158167
}
159-
// println!(
160-
// "Failed to fetch transaction from {}: SLEEP for 400ms",
161-
// label
162-
// );
163168
sleep(Duration::from_millis(400));
164169
continue;
165170
}
166171
};
167-
println!("RETURN LOGS");
168-
return Option::<Vec<String>>::from(
169-
status
170-
.transaction
171-
.meta
172-
.as_ref()
173-
.with_context(|| {
174-
format!(
175-
"No transaction meta found for signature {:?}: {:?}",
176-
sig, status
177-
)
178-
})
179-
.unwrap()
180-
.log_messages
181-
.clone(),
182-
);
172+
return status
173+
.transaction
174+
.meta
175+
.as_ref()
176+
.with_context(|| {
177+
format!(
178+
"No transaction meta found for signature {:?}: {:?}",
179+
sig, status
180+
)
181+
})
182+
.unwrap()
183+
.log_messages
184+
.clone()
185+
.into();
183186
}
184-
println!("RETURN NONE");
185187
None
186188
}
187189

0 commit comments

Comments
 (0)