GithubHelp home page GithubHelp logo

fnaranjo-vmw / disaster-recovery-acceptance-tests Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sap-contributions/disaster-recovery-acceptance-tests

0.0 0.0 0.0 13.28 MB

Acceptance tests for disaster recovery of Cloud Foundry

License: Apache License 2.0

Shell 13.57% Go 86.21% HTML 0.21%

disaster-recovery-acceptance-tests's Introduction

disaster-recovery-acceptance-tests (DRATs)

Tests if Cloud Foundry (CF) can be backed up and restored. The tests will back up from and restore to CF_DEPLOYMENT_NAME. Specifically, DRATs adds state to a Cloud Foundry deployment by testing backup and restore during a CF operation such as pushing an app. DRATs backs up the deployment, restores from the backup, and asserts that the state is present after restore.

Prerequisites

  1. Install go
  2. Install ginkgo

Running DRATs with Environment Variables

  1. Spin up a Cloud Foundry deployment**.
  2. Run DRATs against it using one of the following:

**Cloud Foundry on BOSH Lite is supported.

Test Structure

The system tests do the following:

  1. Calls CheckDeployment(common.Config) on all provided TestCases (to e.g. check if errand-pushed apps are present).
  2. Sets up a temporary local working directory for storing the backup artifact, and CF_HOME directories for all the test cases.
  3. Calls BeforeBackup(common.Config) on all provided TestCases (to e.g. push unique apps to the environment to be backed up).
  4. Backs up the CF_DEPLOYMENT_NAME Cloud Foundry deployment.
  5. Calls AfterBackup(common.Config) on all provided TestCases.
  6. Restores to the CF_DEPLOYMENT_NAME Cloud Foundry deployment.
  7. Calls AfterRestore(common.Config) on all provided TestCases (to e.g. check the apps pushed are present in the restored environment).
  8. Calls Cleanup(common.Config) on all provided TestCases (to e.g. clean up the apps from the backup environment). It will do this even if an error or failure occurred in a previous step
  9. Cleans up the temporary directories created in the setup
  10. If an error occurred during a bbr backup command, DRATs runs bbr backup-cleanup to remove temporary bbr artifacts from your deployment (which would otherwise cause subsequent DRATs runs to fail)

Extending DRATs

DRATs runs a collection of test cases against a Cloud Foundry deployment.

Test cases should be used for checking that CF components' data has been backed up and restored correctly – e.g. if your release backs up a table in a database, that the table can be altered and is then restored to its original state.

Backup and restore of apps is covered by the existing CAPI test case. No new test cases are needed for this – unless you're writing CAPI backup and restore scripts, app backup and restore can be assumed to work.

To add extra test cases, create a new TestCase that follows the TestCase interface.

The methods that need to be implemented are:

  • CheckDeployment(common.Config) runs first to ensure that the test case could possibly succeed in the deployment DRATs is running against. E.g. An errand-based test case could never succeed in a deployment where the errand has never been run.
  • BeforeBackup(common.Config) runs before the backup is taken, and should create state in the Cloud Foundry deployment to be backed up.
  • AfterBackup(common.Config) runs after the backup is complete but before the restore is started. If were monitoring e.g. app uptime during the backup you could use this step to stop monitoring knowing that backup definitely finished.
  • AfterRestore(common.Config) runs after the restore is complete, and should assert that the state in the restored Cloud Foundry deployment matches that created in BeforeBackup(common.Config).
  • Cleanup(common.Config) should clean up the state created in the Cloud Foundry deployment to be backed up.

common.Config contains the config for the BOSH Director and for the CF deployments to backup and restore.

  1. Create a new TestCase in test_cases
  2. In testcases/testcase_helper.go, initialise the TestCase and add it to the slice returned by OpenSourceTestCases()

Running DRATs in your CI

We provide tasks to run DRATs with your CI:

Both DRATs tasks establish an SSH tunnel using sshuttle so that they can run from outside the network. Note the tasks will need to be run from a privileged container. You can also find our pipeline definition here

Debugging your DRATs run

DRATs runs multiple interwoven test cases (for app uptime and each of the components under test) so it can be a little tricky to work out what's gone wrong when there's an error or failure. Here are some tips on investigating DRATs failures - please PR in additions to this doc if you think of more tips that might help other teams!

  1. The bbr backup-cleanup command runs if the test run errored during the bbr backup step. If you see an error in the backup-cleanup step, it's likely that a similar problem happened in the backup step which caused the original failure - scroll up to see.
  2. The easiest way to see where the failure / error happened is to look for the nearest STEP statement in the logs

disaster-recovery-acceptance-tests's People

Contributors

aaronshurley avatar alamages avatar bruce-ricard avatar chunyilyu avatar cryogenics-ci avatar davewalter avatar dependabot[bot] avatar dlresende avatar edwardecook avatar eujungkim avatar fhanik avatar flangewad avatar fnaranjo-vmw avatar gcapizzi avatar gmrodgers avatar henryaj avatar jimbo459 avatar jrussett avatar matt-royal avatar mdelillo avatar mirahimage avatar mrbuk avatar neil-hickey avatar rosenhouse avatar sethboyles avatar staylor14 avatar terminatingcode avatar tinygrasshopper avatar tophat8855 avatar utako avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.