Skip to content

Commit

Permalink
Update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasdel committed Aug 25, 2015
1 parent a26240f commit 22ed727
Show file tree
Hide file tree
Showing 107 changed files with 456 additions and 220 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:

integration: deps
go test ./internal/test/integration/... -tags=integration
gucumber
gucumber ./internal/features/smoke

lint: deps
@echo "golint ./..."
Expand Down
12 changes: 0 additions & 12 deletions internal/features/codecommit/client.feature

This file was deleted.

15 changes: 0 additions & 15 deletions internal/features/codedeploy/client.feature

This file was deleted.

12 changes: 0 additions & 12 deletions internal/features/codepipeline/client.feature

This file was deleted.

30 changes: 30 additions & 0 deletions internal/features/customizations/machinelearning/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//Package machinelearning provides gucumber integration tests suppport.
package machinelearning

import (
"github.com/aws/aws-sdk-go/internal/features/shared"
"github.com/aws/aws-sdk-go/service/machinelearning"
. "github.com/lsegal/gucumber"
)

var _ = shared.Imported

func init() {
Before("@machinelearning", func() {
World["client"] = machinelearning.New(nil)
})

When(`^I attempt to call the "(.+?)" API without the "(.+?)" parameter$`, func(s1 string, s2 string) {
// call(s1, nil, true)
T.Skip() // pending
})

When(`^I attempt to call the "(.+?)" API with "(.+?)" parameter$`, func(s1 string, s2 string) {
// call(s1, nil, true)
T.Skip() // pending
})

Then(`^the hostname should equal the "(.+?)" parameter$`, func(s1 string) {
T.Skip() // pending
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# language: en
@machinelearning
Feature: Amazon Machine Learning

I want to use Amazon Machine Learning


Scenario: Predict API endpoint
When I attempt to call the "Predict" API without the "PredictEndpoint" parameter
Then the request should fail

Scenario: Predict API endpoint
When I attempt to call the "Predict" API with "PredictEndpoint" parameter
Then the hostname should equal the "PredictEndpoint" parameter

Scenario: Predict API endpoint error handling
When I attempt to call the "Predict" API with JSON:
"""
{ "MLModelId": "fake-id", Record: {}, PredictEndpoint: "realtime.machinelearning.us-east-1.amazonaws.com" }
"""
Then the error code should be "PredictorNotMountedException"
16 changes: 0 additions & 16 deletions internal/features/emr/client.feature

This file was deleted.

16 changes: 0 additions & 16 deletions internal/features/lambda/client.feature

This file was deleted.

16 changes: 0 additions & 16 deletions internal/features/rds/client.feature

This file was deleted.

61 changes: 58 additions & 3 deletions internal/features/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
package shared

import (
"encoding/json"
"fmt"
"os"
"reflect"
"regexp"
"strconv"
"strings"

. "github.com/lsegal/gucumber"
"github.com/stretchr/testify/assert"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/aws/defaults"
. "github.com/lsegal/gucumber"
"github.com/stretchr/testify/assert"
)

// Imported is a marker to ensure that this package's init() function gets
Expand Down Expand Up @@ -46,7 +48,7 @@ func init() {

Then(`^the value at "(.+?)" should be a list$`, func(member string) {
vals := awsutil.ValuesAtAnyPath(World["response"], member)
assert.NotEmpty(T, vals)
assert.NotNil(T, vals)
})

Then(`^the response should contain a "(.+?)"$`, func(member string) {
Expand Down Expand Up @@ -89,6 +91,32 @@ func init() {
assert.True(T, found, fmt.Sprintf("no error messages matched: \"%s\"", err.Message()))
}
})

When(`^I call the "(.+?)" API with JSON:$`, func(s1 string, data string) {
callWithJSON(s1, data, false)
})

When(`^I attempt to call the "(.+?)" API with JSON:$`, func(s1 string, data string) {
callWithJSON(s1, data, true)
})

Then(`^the error code should be "(.+?)"$`, func(s1 string) {
err, ok := World["error"].(awserr.Error)
assert.True(T, ok, "no error returned")
assert.Equal(T, s1, err.Code())
})

And(`^the error message should contain:$`, func(data string) {
err, ok := World["error"].(awserr.Error)
assert.True(T, ok, "no error returned")
assert.Contains(T, err.Error(), data)
})

Then(`^the request should fail$`, func() {
err, ok := World["error"].(awserr.Error)
assert.True(T, ok, "no error returned")
assert.Error(T, err)
})
}

// findMethod finds the op operation on the v structure using a case-insensitive
Expand Down Expand Up @@ -162,3 +190,30 @@ func fillArgs(in reflect.Value, args [][]string) {
awsutil.SetValueAtAnyPath(in.Interface(), path, val)
}
}

func callWithJSON(op, j string, allowError bool) {
v := reflect.ValueOf(World["client"])
if m := findMethod(v, op); m != nil {
t := m.Type()
in := reflect.New(t.In(0).Elem())
fillJSON(in, j)

resps := m.Call([]reflect.Value{in})
World["response"] = resps[0].Interface()
World["error"] = resps[1].Interface()

if !allowError {
err, _ := World["error"].(error)
assert.NoError(T, err)
}
} else {
assert.Fail(T, "failed to find operation "+op)
}
}

func fillJSON(in reflect.Value, j string) {
d := json.NewDecoder(strings.NewReader(j))
if err := d.Decode(in.Interface()); err != nil {
panic(err)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@autoscaling @client
Feature: Auto Scaling

Scenario: Making a basic request
Scenario: Making a request
When I call the "DescribeScalingProcessTypes" API
Then the value at "Processes" should be a list

Scenario: Error handling
Scenario: Handing errors
When I attempt to call the "CreateLaunchConfiguration" API with:
| LaunchConfigurationName | |
| ImageId | ami-12345678 |
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@cloudformation @client
Feature: AWS CloudFormation

Scenario: Making a basic request
Scenario: Making a request
When I call the "ListStacks" API
Then the value at "StackSummaries" should be a list

Scenario: Error handling
Scenario: Handling errors
When I attempt to call the "CreateStack" API with:
| StackName | fakestack |
| TemplateURL | http://s3.amazonaws.com/foo/bar |
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@cloudhsm @client
Feature: Amazon CloudHSM

Scenario: Making a basic request
Scenario: Making a request
When I call the "ListHapgs" API
Then the value at "HapgList" should be a list

Scenario: Error handling
Scenario: Handling errors
When I attempt to call the "DescribeHapg" API with:
| HapgArn | bogus-arn |
Then I expect the response error code to be "ValidationException"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@cloudsearch @client
Feature: Amazon CloudSearch

Scenario: Making a basic request
Scenario: Making a request
When I call the "DescribeDomains" API
Then the response should contain a "DomainStatusList"

Scenario: Error handling
Scenario: Handling errors
When I attempt to call the "DescribeIndexFields" API with:
| DomainName | fakedomain |
Then I expect the response error code to be "ResourceNotFound"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@cloudtrail @client
Feature: AWS CloudTrail

Scenario: Making a basic request
Scenario: Making a request
When I call the "DescribeTrails" API
Then the response should contain a "trailList"

Scenario: Error handling
Scenario: Handling errors
When I attempt to call the "DeleteTrail" API with:
| Name | faketrail |
Then I expect the response error code to be "TrailNotFoundException"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# language: en
@cloudwatch @client
@cloudwatch @monitoring @client
Feature: Amazon CloudWatch

Scenario: Making a basic request
Scenario: Making a request
When I call the "ListMetrics" API with:
| Namespace | AWS/EC2 |
Then the value at "Metrics" should be a list

Scenario: Error handling
Scenario: Handling errors
When I attempt to call the "SetAlarmState" API with:
| AlarmName | abc |
| StateValue | mno |
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# language: en
@cloudwatchlogs @client
@cloudwatchlogs @logs
Feature: Amazon CloudWatch Logs

Scenario: Making a basic request
Scenario: Making a request
When I call the "DescribeLogGroups" API
Then the value at "LogGroups" should be a list
Then the value at "logGroups" should be a list

Scenario: Error handling
Scenario: Handling errors
When I attempt to call the "GetLogEvents" API with:
| LogGroupName | fakegroup |
| LogStreamName | fakestream |
| logGroupName | fakegroup |
| logStreamName | fakestream |
Then I expect the response error code to be "ResourceNotFoundException"
And I expect the response error message to include:
"""
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions internal/features/smoke/codecommit/codecommit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# language: en
@codecommit @client
Feature: Amazon CodeCommit

Scenario: Making a request
When I call the "ListRepositories" API
Then the value at "repositories" should be a list

Scenario: Handling errors
When I attempt to call the "ListBranches" API with:
| repositoryName | fake-repo |
Then I expect the response error code to be "RepositoryDoesNotExistException"
And I expect the response error message to include:
"""
fake-repo does not exist
"""
File renamed without changes.
16 changes: 16 additions & 0 deletions internal/features/smoke/codedeploy/codedeploy.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# language: en
@codedeploy @client
Feature: Amazon CodeDeploy

Scenario: Making a request
When I call the "ListApplications" API
Then the value at "applications" should be a list

Scenario: Handling errors
When I attempt to call the "GetDeployment" API with:
| deploymentId | d-USUAELQEX |
Then I expect the response error code to be "DeploymentDoesNotExistException"
And I expect the response error message to include:
"""
The deployment d-USUAELQEX could not be found
"""
File renamed without changes.
Loading

0 comments on commit 22ed727

Please sign in to comment.