bosh-disaster-recovery-acceptance-tests (B-DRATs)
Tests a given BOSH director can be backed up and restored using bbr
.
The test runner provides hooks around bbr director backup
and bbr director restore
.
Dependencies
- Install Golang
- Install
ginkgo
CLI - Install
dep
dependency management tool - Download
bbr
CLI
Running B-DRATs in your pipelines
We encourage you to use our run-b-drats
CI task to run B-DRATS in your Concourse pipeline.
Please refer to our b-drats pipeline definition for a working example.
Running B-DRATs locally
- Clone this repo
$ go get github.com/cloudfoundry-incubator/bosh-disaster-recovery-acceptance-tests $ cd $GOPATH/src/github.com/cloudfoundry-incubator/bosh-disaster-recovery-acceptance-tests
- Create an
integration-config.json
file, for example:{ "bosh_host": "director-address", "bosh_ssh_username": "ssh-username", "bosh_ssh_private_key": "bosh-ssh-private-key", "bosh_client": "bosh-client-name", "bosh_client_secret": "bosh-client-secret", "bosh_ca_cert": "bosh-ca-cert", "credhub_client":"credhub-client", "credhub_client_secret":"credhub-client-secret", "credhub_ca_cert":"credhub-ca-cert", "timeout_in_minutes": 30, "stemcell_src": "stemcell-path.tgz", "include_credhub_testcase": true, "include_deployment_testcase": true, "include_truncate_db_blobstore_testcase": true }
- Export
INTEGRATION_CONFIG_PATH
to be path tointegration-config.json
file you just created. - Export
BBR_BINARY_PATH
to the path to the BBR binary. - Run acceptance tests
$ ./scripts/_run_acceptance_tests.sh
Integration Config Variables
bosh_host
- the BOSH director hostnamebosh_ssh_username
- the BOSH director VM SSH usernamebosh_ssh_private_key
- the BOSH director VM SSH private keybosh_client
- the BOSH director API clientbosh_client_secret
- the BOSH director API client secretbosh_ca_cert
- the BOSH director API CA certificatecredhub_client
- the UAA client that is used to authenticate with CredHubcredhub_client_secret
- the UAA secret that is used to authenticate with CredHubcredhub_ca_cert
- the mTLS certificate that is used to communicate with CredHubtimeout_in_minutes
- default ginkgoEventually
timeout in minutes, defaults to30
stemcell_src
- absolute path to stemcell tarballinclude_<testcase-name>
- flag for whether to run a given testcase, if omitted defaults tofalse
deployment_vm_type
- cloud config vm_type to be passed into config, if omitted defaults todefault
(used by example deployment_testcase)deployment_network
- cloud config network to be passed into config, if omitted defaults todefault
(used by example deployment_testcase)deployment_az
- cloud config az to be passed into config, if omitted defaults toz1
(used by example deployment_testcase)
Contributing to B-DRATs
B-DRATS runs a collection of test cases against a bosh director.
Test cases should be used for checking that BOSH director components' data has been backed up and restored correctly. For example, if your release backs up a database during bbr director backup
, and the database is altered after taking the backup. Then after a successful bbr director restore
, the content of the database will be restored to its original state.
To add extra test cases, create a new test case that implements the TestCase
interface.
The methods that need to be implemented are:
Name() string
- should return name of the test case.BeforeBackup(Config)
- runs before the backup is taken, and should create state in the BOSH director to be backed up.AfterBackup(Config)
- runs after the backup is complete but before the restore is started.AfterRestore(Config)
- runs after the restore is complete, and should assert that the state in the restored BOSH director matches that created inBeforeBackup(Config)
.Cleanup(Config)
- should clean up the state created in the BOSH director through the test.
Config
contains the config for the BOSH Director and for the CF deployments to backup and restore.
Creating a new test case
- Create a new test case in the testcases package.
- Add the newly created test case to
[]runner.TestCase
inacceptance_test.go
.