diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4d0aac5..cfcfa150 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,11 +48,12 @@ jobs: # Creates Compute Engine virtual machine instance w/ disks - name: Create instance run: | - gcloud compute instances create "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" \ + gcloud compute instances create-with-container "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" \ --boot-disk-size 100GB \ --boot-disk-type pd-ssd \ - --image-family cos-stable \ - --image-project cos-cloud \ + --container-image rust:buster \ + --container-mount-disk mount-path='/zebrad-cache',name=zebrad-cache-mainnet-sapling-activation \ + --create-disk name=zebrad-cache-mainnet-sapling-activation,image=zebrad-cache-062a5ae-mainnet-height-419200 \ --machine-type n2-standard-4 \ --service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \ --scopes cloud-platform \ @@ -62,9 +63,13 @@ jobs: # Build and run test container - name: Run all tests run: | - gcloud compute ssh "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" --zone "$ZONE" \ - --command "git clone -b $BRANCH_NAME https://github.com/ZcashFoundation/zebra.git; cd zebra/; docker build -f docker/Dockerfile.test -t zebrad-test .; docker run -i zebrad-test cargo test --workspace --no-fail-fast -- -Zunstable-options --include-ignored" - + gcloud compute ssh "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" --zone "$ZONE" --command \ + "git clone -b $BRANCH_NAME https://github.com/ZcashFoundation/zebra.git; + cd zebra/; + docker build -f docker/Dockerfile.test -t zebrad-test .; + docker run -i zebrad-test cargo test --workspace --no-fail-fast -- -Zunstable-options --include-ignored; + docker run -it --mount type=bind,source=/mnt/disks/gce-containers-mounts/gce-persistent-disks/zebrad-cache-mainnet-sapling-activation,target=/zebrad-cache zebrad-test:latest cargo test --verbose --features test_sync_to_sapling_mainnet --manifest-path zebrad/Cargo.toml sync_to_sapling_mainnet; + " # Clean up - name: Delete test instance # Always run even if the earlier step fails diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index e86c437c..0d18f4df 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -44,3 +44,9 @@ abscissa_core = { version = "0.5", features = ["testing"] } once_cell = "1.5" tempdir = "0.3.7" zebra-test = { path = "../zebra-test" } + +[features] +test_sync_to_sapling_mainnet = [] +test_sync_to_sapling_testnet = [] +test_sync_past_sapling_mainnet = [] +test_sync_past_sapling_testnet = [] diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index 789cc8c1..581f1b8a 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -13,9 +13,10 @@ #![warn(warnings, missing_docs, trivial_casts, unused_qualifications)] #![forbid(unsafe_code)] +#![allow(clippy::dead_code)] +#![allow(clippy::field_reassign_with_default)] #![allow(clippy::try_err)] #![allow(clippy::unknown_clippy_lints)] -#![allow(clippy::field_reassign_with_default)] use color_eyre::eyre::Result; use eyre::WrapErr; @@ -698,28 +699,27 @@ fn sync_past_sapling(network: Network) -> Result<()> { // drives populated by the first two tests, snapshot those drives, and then use // those to more quickly run the second two tests. -// Create a cached copy of the mainnet database up to the sapling activation -// height. -#[test] -#[ignore] -fn create_mainnet_cache() { +// Sync up to the sapling activation height on mainnet and stop. +#[cfg_attr(feature = "test_sync_to_sapling_mainnet", test)] +fn sync_to_sapling_mainnet() { zebra_test::init(); let network = Mainnet; create_cached_database(network).unwrap(); } -// Create a cached copy of the testnet database up to the sapling activation -// height. -#[test] -#[ignore] -fn create_testnet_cache() { +// Sync to the sapling activation height testnet and stop. +#[cfg_attr(feature = "test_sync_to_sapling_testnet", test)] +fn sync_to_sapling_testnet() { zebra_test::init(); let network = Testnet; create_cached_database(network).unwrap(); } /// Test syncing 1200 blocks (3 checkpoints) past the last checkpoint on mainnet. -#[test] -#[ignore] +/// +/// This assumes that the config'd state is already synced at or near Sapling +/// activation on mainnet. If the state has already synced past Sapling +/// activation by 1200 blocks, it will fail. +#[cfg_attr(feature = "test_sync_past_sapling_mainnet", test)] fn sync_past_sapling_mainnet() { zebra_test::init(); let network = Mainnet; @@ -727,8 +727,11 @@ fn sync_past_sapling_mainnet() { } /// Test syncing 1200 blocks (3 checkpoints) past the last checkpoint on testnet. -#[test] -#[ignore] +/// +/// This assumes that the config'd state is already synced at or near Sapling +/// activation on testnet. If the state has already synced past Sapling +/// activation by 1200 blocks, it will fail. +#[cfg_attr(feature = "test_sync_past_sapling_testnet", test)] fn sync_past_sapling_testnet() { zebra_test::init(); let network = Testnet;