Chef exec rspec trying to make HTTP connection?

I’m very confused as to what rspec is trying to do here with the simple default spec in place indicating that things should just converge successfully. If I use strace, I see rspec trying to talk to our enterprise http_proxy for something.

% chef exec rspec
F

Failures:

  1) our-certs::default When all attributes are default, on an unspecified platform converges successfully
     Failure/Error: expect { chef_run }.to_not raise_error
       expected no Exception, got #<Net::HTTPFatalError: 504 "Gateway Timeout"> with backtrace:
         # ./spec/unit/recipes/default_spec.rb:7:in `block (3 levels) in <top (required)>'
         # ./spec/unit/recipes/default_spec.rb:11:in `block (4 levels) in <top (required)>'
         # ./spec/unit/recipes/default_spec.rb:11:in `block (3 levels) in <top (required)>'
     # ./spec/unit/recipes/default_spec.rb:11:in `block (3 levels) in <top (required)>'

Finished in 0.45415 seconds (files took 7.19 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/unit/recipes/default_spec.rb:10 # our-certs::default When all attributes are default, on an unspecified platform converges successfully

Howdy! Do you have something in your Chef recipe that makes an internet connection? That’s the most logical first place I would look. I suppose it’s also possible that ChefSpec is trying to talk to Chef Zero over HTTP using your proxy if you’re using ChefSpec::ServerRunner, though I’ve never seen that happen before (and I could be totally wrong on that second point).

1 Like

Thanks Martin. Turns out the latter answer was exactly the problem. Unsetting my proxy environment variables got me past that exception.

As for the first idea, even if my recipe did make http connections, like with remote_file, I would not expect ChefSpec to be converging them and making http requests.

Ah! Excellent. I would think there’s no point in ChefSpec configuring Chef-Zero to obey the proxy, since it’s always running locally. But I guess it does obey proxy settings…

I was thinking more like some pure Ruby or if you had ChefSpec configured to step into a particular resource/provider.

In any case, glad it’s solved! :slight_smile: