Skip to content

Commit

Permalink
Include endpoint argument to all clients (#79)
Browse files Browse the repository at this point in the history
We have intermittent test failures with the AWS tests. This should hopefully fix them although ideally we should not be relying on sample to obtain a client as this is not very deterministic.

In order to reproduce this I ran the following under both the aws-2 and was-3 appraisal profiles

`bundle exec appraisal aws-2 bundle console`
```
Aws.config.update(stub_responses: true)
clients = Aws::Partitions.service_ids.keys.map {|service| Aws.const_get(service).const_get(:Client)}
clients.map do |c|
  begin
    c.new
  rescue => e
    @err = e
  ensure
    puts "#{@err} #{c}" if @err
    @err = nil
  end
end
```

`bundle exec appraisal aws-3 bundle console`
```
Aws.config.update(stub_responses: true)
clients = Aws::Partitions.service_ids.keys.map {|service| Aws.const_get(service).const_get(:Client)}
clients.map do |c|
  begin
    c.new
  rescue => e
    @err = e
  ensure
    puts "#{@err} #{c}" if @err
    @err = nil
  end
end
```

When running the code with `aws-2`, we get the following output, which looks suspiciously like the intermittent test failures that we see.

```
no member 'regional_endpoint' in struct Aws::CloudSearchDomain::Client
missing required option `:endpoint' Aws::IoTDataPlane::Client
```

I then altered the code to the following to see if we could provide the endpoint argument to all of the clients with no ill effect.

```
clients.map do |c|
  begin
    c.new(endpoint: "https://honeycomb.io")
  rescue => e
    @err = e
  ensure
    puts "#{@err} #{c}" if @err
    @err = nil
  end
end
```

This ran successfully on both `aws-2` and `aws-3` with no clients unable to be constructed.

cc: @ajvondrak
  • Loading branch information
martin308 authored Mar 10, 2020
1 parent 653e8fa commit 344928c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions spec/honeycomb/integrations/aws_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,30 @@ def version_of(service)
end

it "is enabled by default" do
aws = aws_clients.sample.new
aws = aws_clients.sample.new(endpoint: "https://honeycomb.io")
expect(aws.handlers).to include(
Honeycomb::Aws::SdkHandler,
Honeycomb::Aws::ApiHandler,
)
end

it "can be disabled" do
aws = aws_clients.sample.new(honeycomb: false)
aws = aws_clients.sample.new(endpoint: "https://honeycomb.io",
honeycomb: false)
expect(aws.handlers).not_to include(
Honeycomb::Aws::SdkHandler,
Honeycomb::Aws::ApiHandler,
)
end

it "uses the global Honeycomb client by default" do
aws = aws_clients.sample.new
aws = aws_clients.sample.new(endpoint: "https://honeycomb.io")
expect(aws.config.honeycomb_client).to be Honeycomb.client
end

it "can be configured with a different Honeycomb client" do
aws = aws_clients.sample.new(honeycomb_client: client)
aws = aws_clients.sample.new(endpoint: "https://honeycomb.io",
honeycomb_client: client)
expect(aws.config.honeycomb_client).to be client
end
end
Expand Down

0 comments on commit 344928c

Please sign in to comment.