Giter Site home page Giter Site logo

chunyilyu / disaster-recovery-acceptance-tests Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudfoundry/disaster-recovery-acceptance-tests

0.0 2.0 0.0 162 KB

Acceptance tests for disaster recovery of Cloud Foundry

License: Apache License 2.0

Go 86.51% Shell 13.12% HTML 0.37%

disaster-recovery-acceptance-tests's Introduction

disaster-recovery-acceptance-tests (DRATS)

Tests if Cloud Foundry can be backed up and restored. The tests will back up from and restore to CF_DEPLOYMENT_NAME.

Running DRATS

  1. Spin up a Cloud Foundry deployment.
  2. Run scripts/run_acceptance_tests_local.sh with the following environment variables set:
    • CF_DEPLOYMENT_NAME - name of the Cloud Foundry deployment to backup and restore
    • CF_API_URL - Cloud Foundry api url
    • CF_ADMIN_USERNAME - Cloud Foundry api admin user
    • CF_ADMIN_PASSWORD - Cloud Foundry api admin password
    • BOSH_ENVIRONMENT - URL of BOSH Director which has deployed the above Cloud Foundries
    • BOSH_CLIENT - BOSH Director username
    • BOSH_CLIENT_SECRET - BOSH Director password
    • BOSH_CA_CERT - BOSH Director's CA cert content
    • BOSH_GW_HOST - Gateway host to use for BOSH SSH connection
    • BOSH_GW_USER - Gateway user to use for BOSH SSH connection
    • BOSH_GW_PRIVATE_KEY_CONTENTS - Private key to use for BOSH SSH connection
    • BBR_BUILD_PATH - path to BBR binary
    • DEFAULT_TIMEOUT_MINS - timeout for commands run in the test. Defaults to 15 minutes.
  3. The following environment variables are optional and could be set depending on test configuration:
    • SSH_DESTINATION_CIDR - Default to "10.0.0.0/8"; change if your cf-deployment is deployed in a different internal network range
    • NFS_SERVICE_NAME - Environment variable required to run NFS test case
    • NFS_PLAN_NAME - Environment variable required to run NFS test case
    • NFS_BROKER_USER - Environment variable required to run NFS test case
    • NFS_BROKER_PASSWORD - Environment variable required to run NFS test case
    • NFS_BROKER_URL - Environment variable required to run NFS test case

Focusing/Skipping a test suite

Run DRATS as usual but set the environment variable FOCUSED_SUITE_NAME and/or SKIP_SUITE_NAME to a regex matching the name(s) of test suites. Only those suites that either match FOCUSED_SUITE_NAME or don't match SKIP_SUITE_NAME will be run. Leaving either of these unset is supported.

If these variables are not set, all test suites returned by testcases.OpenSourceTestCases() will be run.

Test Structure

The system tests do the following:

  1. Calls BeforeBackup(common.Config) on all provided TestCases (to e.g. push unique apps to the environment to be backed up).
  2. Backs up the CF_DEPLOYMENT_NAME Cloud Foundry deployment.
  3. Calls AfterBackup(common.Config) on all provided TestCases.
  4. Restores to the CF_DEPLOYMENT_NAME Cloud Foundry deployment.
  5. Calls AfterRestore(common.Config) on all provided TestCases (to e.g. check the apps pushed are present in the restored environment).
  6. Calls Cleanup(common.Config) on all provided TestCases (to e.g. clean up the apps from the backup environment).

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 BeforeBackup(common.Config), AfterBackup(common.Config), AfterRestore(common.Config) and Cleanup(common.Config).

  • 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 have shared a task to run DRATS with your CI. The task establishes an SSH tunnel using sshuttle so that it can run from outside the network. Note that this task needs a privileged container.

disaster-recovery-acceptance-tests's People

Contributors

aaronshurley avatar angelachin avatar charleshansen avatar christopherclark avatar chunyilyu avatar dennisdenuto avatar edwardecook avatar fhanik avatar flangewad avatar gcapizzi avatar henryaj avatar joachimvaldez avatar matt-royal avatar mrbuk avatar rosenhouse avatar selzoc avatar tinygrasshopper avatar utako avatar

Watchers

 avatar  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.