[snowpatch] [PATCH] main: Run multiple branch tests in parallel
Andrew Donnellan
ajd at linux.ibm.com
Thu Jun 6 17:15:30 AEST 2019
Spawn multiple Jenkins tests for different branches in parallel for the
same patch.
This is very very simplistic but should significantly enhance Jenkins
utilisation.
Signed-off-by: Andrew Donnellan <ajd at linux.ibm.com>
---
src/main.rs | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 5ec0c37b2d7f..68ba9f9d5f47 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -208,6 +208,9 @@ fn test_patch(
push_opts.remote_callbacks(push_callbacks);
let mut successfully_applied = false;
+
+ let mut test_threads = vec![];
+
for branch_name in project.branches.clone() {
let tag = format!("{}_{}", tag, branch_name);
info!("Configuring local branch for {}.", tag);
@@ -297,18 +300,30 @@ fn test_patch(
&base,
hefty_tests,
)
- })
- .unwrap();
- results.append(&mut test.join().unwrap());
+ });
- // Delete the remote branch now it's not needed any more
- git::push_to_remote(&mut remote, &branch, true, &mut push_opts).unwrap();
+ match test {
+ Ok(thread) => test_threads.push((thread, branch)),
+ Err(e) => {
+ error!("Error spawning thread: {}", e);
+ git::push_to_remote(&mut remote, &branch, true, &mut push_opts).unwrap();
+ }
+ }
if !test_all_branches {
break;
}
}
+ // Wait for results
+ for (thread, branch) in test_threads {
+ results.append(&mut thread.join().unwrap());
+
+ // Delete the remote branch now it's not needed any more
+ git::push_to_remote(&mut remote, &branch, true, &mut push_opts).unwrap();
+ }
+
+
if !successfully_applied {
results.push(TestResult {
state: TestState::Fail,
--
2.20.1
More information about the snowpatch
mailing list