From e3601b6c8e9d71f7ed06560bda199d3c6edfec65 Mon Sep 17 00:00:00 2001 From: Simon B Date: Wed, 21 Mar 2018 17:05:07 +0100 Subject: [PATCH] Travis cleaner caching (#833) * speed up Travis startup - keep all test tempdata in target/tmp - purge before saving target/* to S3 cache * allow 4 minutes for cache up/download from Travis' S3 cache stores --- .travis.yml | 9 +++++++-- grin/tests/framework/mod.rs | 6 +++--- grin/tests/simulnet.rs | 8 ++++---- store/tests/pmmr.rs | 2 +- util/tests/zip.rs | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 225411cf..3f82b5a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,10 @@ language: rust -cache: cargo +cache: + cargo: true + timeout: + 240 # =4 min (default 120). ~6 GB cache up/down from S3 needs time. +before_cache: + - rm -rf target/tmp dist: trusty sudo: false rust: @@ -17,7 +22,7 @@ addons: - libdw-dev - cmake - gcc - - binutils-dev + - binutils-dev env: global: - RUST_BACKTRACE="1" diff --git a/grin/tests/framework/mod.rs b/grin/tests/framework/mod.rs index 3d2b80d3..6034959c 100644 --- a/grin/tests/framework/mod.rs +++ b/grin/tests/framework/mod.rs @@ -34,7 +34,7 @@ use wallet::WalletConfig; /// Just removes all results from previous runs pub fn clean_all_output(test_name_dir: &str) { - let target_dir = format!("target/{}", test_name_dir); + let target_dir = format!("target/tmp/{}", test_name_dir); let result = fs::remove_dir_all(target_dir); if let Err(e) = result { println!("{}", e); @@ -156,10 +156,10 @@ pub struct LocalServerContainer { impl LocalServerContainer { /// Create a new local server container with defaults, with the given name /// all related files will be created in the directory - /// target/test_servers/{name} + /// target/tmp/test_servers/{name} pub fn new(config: LocalServerContainerConfig) -> Result { - let working_dir = format!("target/test_servers/{}", config.name); + let working_dir = format!("target/tmp/test_servers/{}", config.name); let mut wallet_config = WalletConfig::default(); wallet_config.api_listen_port = format!("{}", config.wallet_port); diff --git a/grin/tests/simulnet.rs b/grin/tests/simulnet.rs index ed267ac3..8ba0f21b 100644 --- a/grin/tests/simulnet.rs +++ b/grin/tests/simulnet.rs @@ -190,7 +190,7 @@ fn a_simulate_block_propagation() { for n in 0..5 { let s = grin::Server::new(grin::ServerConfig { api_http_addr: format!("127.0.0.1:{}", 19000 + n), - db_root: format!("target/{}/grin-prop-{}", test_name_dir, n), + db_root: format!("target/tmp/{}/grin-prop-{}", test_name_dir, n), p2p_config: p2p::P2PConfig { port: 18000 + n, ..p2p::P2PConfig::default() @@ -300,8 +300,8 @@ fn simulate_fast_sync_double() { s2.stop(); } // locks files don't seem to be cleaned properly until process exit - std::fs::remove_file("target/grin-double-fast2/grin-sync-1001/chain/LOCK"); - std::fs::remove_file("target/grin-double-fast2/grin-sync-1001/peers/LOCK"); + std::fs::remove_file("target/tmp/grin-double-fast2/grin-sync-1001/chain/LOCK"); + std::fs::remove_file("target/tmp/grin-double-fast2/grin-sync-1001/peers/LOCK"); thread::sleep(time::Duration::from_secs(20)); let mut conf = config(1001, "grin-double-fast2"); @@ -316,7 +316,7 @@ fn simulate_fast_sync_double() { fn config(n: u16, test_name_dir: &str) -> grin::ServerConfig { grin::ServerConfig { api_http_addr: format!("127.0.0.1:{}", 19000 + n), - db_root: format!("target/{}/grin-sync-{}", test_name_dir, n), + db_root: format!("target/tmp/{}/grin-sync-{}", test_name_dir, n), p2p_config: p2p::P2PConfig { port: 11000 + n, ..p2p::P2PConfig::default() diff --git a/store/tests/pmmr.rs b/store/tests/pmmr.rs index 9c23d940..14c6b234 100644 --- a/store/tests/pmmr.rs +++ b/store/tests/pmmr.rs @@ -555,7 +555,7 @@ fn pmmr_compact_horizon() { fn setup(tag: &str) -> (String, Vec) { let _ = env_logger::init(); let t = time::get_time(); - let data_dir = format!("./target/{}.{}-{}", t.sec, t.nsec, tag); + let data_dir = format!("./target/tmp/{}.{}-{}", t.sec, t.nsec, tag); fs::create_dir_all(data_dir.clone()).unwrap(); let mut elems = vec![]; diff --git a/util/tests/zip.rs b/util/tests/zip.rs index bade93d4..81a76034 100644 --- a/util/tests/zip.rs +++ b/util/tests/zip.rs @@ -21,8 +21,8 @@ use util::zip; #[test] fn zip_unzip() { - let root = Path::new("./target"); - let zip_name = "./target/zipped.zip"; + let root = Path::new("./target/tmp"); + let zip_name = "./target/tmp/zipped.zip"; fs::create_dir_all(root.join("./to_zip/sub")).unwrap(); write_files(&root).unwrap();