Having trouble with chefspec on EC2 error - Net::OpenTimeout execution expired

Hi, and thanks in advance for the help!

I am attempting to run chefspec against my cookbook using an EC2 instance (Ubuntu 16.04) and I am coming up against a strange issue affecting every test case for every recipe. I have scoured the internet and can’t come up with a solution.

Here is a single recipe:

## BASHRC Work
# copy the bashrc proxy file
cookbook_file '/tmp/bashrc_proxy.txt' do
  source 'bashrc_proxy.txt'
  action :create
end

# copy the contents of bashrc_proxy.txt to the end of bashrc
execute 'bashrc insert' do
  command 'cat /tmp/bashrc_proxy.txt >> /etc/bashrc'
  # only if it's not mounted already
  not_if "grep -qs 'function proxy_on' /etc/bashrc"
end

The spec file is:

require 'spec_helper'

describe 'my_cb::bashrc' do
  before do
    # Fauxhai.mock(platform: 'redhat', version: '7.4')
    # Stub all the commands we use
    stub_command("grep -qs 'function proxy_on' /etc/bashrc").and_return('')
  end

  context 'When all attributes are default, on RHEL' do
    let(:chef_run) do
      runner = ChefSpec::ServerRunner.new(platform: 'redhat', version: '7.4')
      runner.converge(described_recipe)
    end

    it 'converges successfully' do
      expect { chef_run }.to_not raise_error
    end

    it 'copies /tmp/bashrc_proxy.txt' do
      expect(chef_run).to create_cookbook_file('/tmp/bashrc_proxy.txt')
    end
  end
end

spec_helper just has:

require 'chefspec'
require 'chefspec/policyfile'

RSpec.configure do |config|
  config.color = true               # Use color in STDOUT
  config.formatter = :documentation # Use the specified formatter
  config.log_level = :error         # Avoid deprecation notice SPAM
end

And the error I am getting is:

# chef exec rspec spec/unit/recipes/bashrc_spec.rb

my_cb::bashrc
  When all attributes are default, on RHEL
    converges successfully (FAILED - 1)
    copies /tmp/bashrc_proxy.txt (FAILED - 2)

Failures:

  1) my_cb::bashrc When all attributes are default, on RHEL converges successfully
     Failure/Error: expect { chef_run }.to_not raise_error

       expected no Exception, got #<Net::OpenTimeout: execution expired> with backtrace:
         # ./spec/unit/recipes/bashrc_spec.rb:19:in `block (3 levels) in <top (required)>'
         # ./spec/unit/recipes/bashrc_spec.rb:23:in `block (4 levels) in <top (required)>'
         # ./spec/unit/recipes/bashrc_spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./spec/unit/recipes/bashrc_spec.rb:23:in `block (3 levels) in <top (required)>'

  2) my_cb::bashrc When all attributes are default, on RHEL copies /tmp/bashrc_proxy.txt
     Failure/Error: runner.converge(described_recipe)

     Net::OpenTimeout:
       execution expired
     # ./spec/unit/recipes/bashrc_spec.rb:19:in `block (3 levels) in <top (required)>'
     # ./spec/unit/recipes/bashrc_spec.rb:27:in `block (3 levels) in <top (required)>'

Finished in 2 minutes 1.4 seconds (files took 2.73 seconds to load)
2 examples, 2 failures

Failed examples:

rspec ./spec/unit/recipes/bashrc_spec.rb:22 # my_cb::bashrc When all attributes are default, on RHEL converges successfully
rspec ./spec/unit/recipes/bashrc_spec.rb:26 # my_cb::bashrc When all attributes are default, on RHEL copies /tmp/bashrc_proxy.txt

thanks for any help!