Skip to content

Commit

Permalink
Make the smoke tests less dependent on account state (and make accoun…
Browse files Browse the repository at this point in the history
…t state-related failures count as a skip instead of a fail)
  • Loading branch information
jeskew committed Jul 20, 2015
1 parent 9db359f commit b2c6dc0
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 15 deletions.
8 changes: 4 additions & 4 deletions features/smoke/codedeploy/codedeploy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Feature: Amazon CodeDeploy
Then the value at "applications" should be a list

Scenario: Handling errors
When I attempt to call the "GetApplication" API with:
| applicationName | bogus-app |
Then I expect the response error code to be "ApplicationDoesNotExistException"
When I attempt to call the "GetDeployment" API with:
| deploymentId | bogus-deployment |
Then I expect the response error code to be "InvalidDeploymentIdException"
And I expect the response error message to include:
"""
No application found for name: bogus-app
Specified DeploymentId is not in the valid format: bogus-deployment
"""
14 changes: 6 additions & 8 deletions features/smoke/emr/emr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
Feature: Amazon EMR

Scenario: Making a request
When I call the "DescribeJobFlows" API
Then the value at "JobFlows" should be a list
When I call the "ListClusters" API
Then the value at "Clusters" should be a list

Scenario: Handling errors
When I attempt to call the "DescribeJobFlows" API with JSON:
"""
{"JobFlowIds": ["fake_job_flow"]}
"""
Then I expect the response error code to be "ValidationException"
When I attempt to call the "DescribeCluster" API with:
| ClusterId | fake_cluster |
Then I expect the response error code to be "InvalidRequestException"
And I expect the response error message to include:
"""
Specified job flow ID not valid
Cluster id 'fake_cluster' is not valid.
"""
91 changes: 88 additions & 3 deletions tests/Integ/SmokeContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace Aws\Test\Integ;

use Aws;
Expand All @@ -9,6 +8,8 @@
use Aws\Sdk;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Hook\Scope\AfterFeatureScope;
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
Expand All @@ -23,12 +24,15 @@ class SmokeContext extends PHPUnit_Framework_Assert implements
use IntegUtils;

protected static $configOverrides = [
'ElasticFileSystem' => [
'DeviceFarm' => [
'region' => 'us-west-2',
],
'DeviceFarm' => [
'ElasticFileSystem' => [
'region' => 'us-west-2',
],
'Support' => [
'profile' => 'shared-integ',
],
];

/**
Expand Down Expand Up @@ -72,6 +76,87 @@ public static function prepare()
Env::cleanCompileDir();
}

/**
* @BeforeFeature @efs
*
* Ensure that the testing credentials have access to the EFS preview;
* skip entire feature otherwise.
*
* @param BeforeFeatureScope $scope
*/
public static function setUpEfs(BeforeFeatureScope $scope)
{
try {
self::getSdk(self::$configOverrides)
->createEfs()
->describeFileSystems();
} catch (\Exception $e) {
// If the test failed because the account has no access to EFS,
// throw the exception to cause the feature to be skipped.
if ($e instanceof AwsException &&
'AccessDeniedException' === $e->getAwsErrorCode()
) {
throw $e;
}
}
}

/**
* @BeforeFeature @sqs
*
* @param BeforeFeatureScope $scope
*/
public static function setUpSqs(BeforeFeatureScope $scope)
{
self::getSdk(self::$configOverrides)
->createSqs()
->createQueue([
'QueueName' => self::getResourcePrefix() . 'testing-queue',
]);
}

/**
* @AfterFeature @sqs
*
* @param AfterFeatureScope $scope
*/
public static function tearDownSqs(AfterFeatureScope $scope)
{
$sqs = self::getSdk(self::$configOverrides)
->createSqs();

$sqs->deleteQueue([
'QueueUrl' => $sqs->getQueueUrl([
'QueueName' => self::getResourcePrefix() . 'testing-queue',
])['QueueUrl']
]);
}

/**
* @BeforeFeature @support
*
* Ensure that the testing credentials have a support subscription;
* skip entire feature otherwise.
*
* @param BeforeFeatureScope $scope
*/
public static function setUpSupport(BeforeFeatureScope $scope)
{
try {
self::getSdk(self::$configOverrides)
->createSupport()
->describeServices();
} catch (\Exception $e) {
// If the test failed because the account has no support subscription,
// throw the exception to cause the feature to be skipped.
if ($e instanceof AwsException &&
'SubscriptionRequiredException' === $e->getAwsErrorCode()
) {
throw $e;
}
}
}

/**
* @BeforeScenario
*
Expand Down

0 comments on commit b2c6dc0

Please sign in to comment.