diff --git a/example.pantheon.yml b/example.pantheon.yml index 6430992..ec980c0 100644 --- a/example.pantheon.yml +++ b/example.pantheon.yml @@ -27,7 +27,7 @@ workflows: description: post to slack after the database clones script: private/scripts/slack_after_db_clone.php - # Code Deploys: Notify, Sanitize (if on test), post to new relic, update db, and notify completion + # Code Deploys: Notify, Sanitize (if on test), post to new relic, testd, update db, and notify completion deploy: before: - type: webphp @@ -49,6 +49,9 @@ workflows: - type: webphp description: do a visual regression test with Backtrac.io script: private/scripts/backtrac_visualregression.php + - type: webphp + description: do a performance test with Load Impact + script: private/scripts/loadimpact.php - type: webphp description: post to slack after each deploy script: private/scripts/slack_after_deploy.php diff --git a/loadimpact/README.md b/loadimpact/README.md new file mode 100644 index 0000000..e4c0285 --- /dev/null +++ b/loadimpact/README.md @@ -0,0 +1,37 @@ +# Performance Testing via Load Impact # + +This example will show you how to integrate [Load Impact](https://loadimpact.com/)'s performance testing into your deployment workflow. + +This will allow you to do a performance scan of your testing environment after your code deployments. + +## Instructions ## + +In order to get up and running, you first need to setup a Load Impact project: + +1. Either login to your account or register for a new one at [https://loadimpact.com/](https://loadimpact.com/). +2. Generate an API Key on your Load Impact account page: [https://app.loadimpact.com/integrations/api-token](https://app.loadimpact.com/integrations/api-token). +3. Setup a Load Impact test for your site. + +Then you need to add the relevant code to your Pantheon project: + +1. Add the example `loadimpact.php` script to the 'private/scripts/' directory of your code repository. +2. Modify the `loadimpact.php` script to include your API key and your Project URL. +3. Add a Quicksilver operation to your `pantheon.yml` to fire the script after a deploy to test. +4. Test a deploy out! + +Optionally, you may want to use the `terminus workflows watch` command to get immediate debugging feedback. + +### Example `pantheon.yml` ### + +Here's an example of what your `pantheon.yml` would look like if this were the only Quicksilver operation you wanted to use: + +```yaml +api_version: 1 + +workflows: + deploy: + after: + - type: webphp + description: do a performance test with Load Impact + script: private/scripts/loadimpact.php +``` diff --git a/loadimpact/loadimpact.php b/loadimpact/loadimpact.php new file mode 100644 index 0000000..b05570a --- /dev/null +++ b/loadimpact/loadimpact.php @@ -0,0 +1,52 @@ + 'https://api.loadimpact.com/v2/test-configs/' . $test_id . '/start', + CURLOPT_USERPWD => $api_key . ':', + CURLOPT_HTTPAUTH => CURLAUTH_BASIC, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POST => 1, + ); + curl_setopt_array($curl, $curl_options); + $curl_response = json_decode(curl_exec($curl)); + curl_close($curl); + + if (isset($curl_response->id)) { + // Let's run a V3 Call to Get Public URL + $curl = curl_init(); + $curl_options = array( + CURLOPT_URL => 'https://api.loadimpact.com/v3/test-runs/' . $curl_response->id . '/generate_public_url', + CURLOPT_USERPWD => $api_key_v3 . ':', + CURLOPT_HTTPAUTH => CURLAUTH_BASIC, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POST => 1, + ); + curl_setopt_array($curl, $curl_options); + $curl_response = json_decode(curl_exec($curl)); + curl_close($curl); + + echo 'Test results: ' . $curl_response->test_run->public_url . "\n"; + } + else { + echo 'There has been an error: ' . ucwords($curl_response->message) . "\n"; + } +}