Compare commits

...

40 commits
1.0.0 ... main

Author SHA1 Message Date
Michael Hashizume
f055e1202b
Merge pull request #36 from mhashizume/PA-6510/main/beaker-6
Add support for Beaker 6
2024-05-28 11:33:55 -07:00
Michael Hashizume
c027b1bcef Add support for Beaker 6 2024-05-28 10:59:04 -07:00
Aria Li (she/her)
c309bf02ce
Merge pull request #34 from mhashizume/PUP-11786/main/beaker-bump
(PUP-11786) Beaker 5 compatibility
2024-02-14 17:20:09 -08:00
Michael Hashizume
4f5ee09807 (PUP-11786) Beaker 5 compatibility
Vox Pupuli has released Beaker 5, which drops older (< 2.7) Ruby
compatibility and adds compatibility for Ruby 3.2

This commit adds testing for Ruby 3.2, sets the dependency on
Beaker to ~> 5.0, replaces the File#exists? method that's been
deprecated since Ruby 2.7 and removed in 3.2, and updates the
dependency on FakeFS to the same version that Beaker uses (FakeFS
~> 2.4).
2023-03-27 13:59:30 -07:00
Jake Spain
278515e460
Merge pull request #31 from puppetlabs/add_mend
(RE-15111) Add mend scanning. Update test and release actions
2023-02-10 16:49:12 -05:00
Jake Spain
6acbc08aba
Add mend scanning. Update test and release actions 2023-02-10 16:46:25 -05:00
Jake Spain
d8ea6a2e4c
Merge pull request #29 from puppetlabs/codeowners
Update code owners to RE
2023-01-20 13:27:12 -05:00
5be58b1e82
Update code owners to RE 2023-01-20 13:03:59 -05:00
Samuel
5d04a41003
Merge pull request #23 from puppetlabs/snyk_scan
(DIO-3134) Scan repo with Snyk
2022-05-04 14:38:30 -05:00
suckatrash
596e0d83f9
(DIO-3134) Scan repo with Snyk 2022-05-02 13:49:25 -07:00
e012919f08
Update CODEOWNERS 2022-02-16 09:36:17 -05:00
Jenkins
639255b4de (GEM) update beaker-vmpooler version to 1.4.0 2021-06-15 18:44:52 +00:00
1da71ab4dc
Merge pull request #18 from nmburgan/maint/master/use_ssl_with_https_uri
(maint) Use SSL when pooler_api URL is HTTPS
2021-06-15 14:42:48 -04:00
Nick Burgan-Illig
49f57963bc (maint) Use SSL when pooler_api URL is HTTPS
Since vmpooler supports HTTPS and in some environments, only HTTPS is allowed, this sets Net::HTTP to use SSL when the URI is HTTPS.
2021-06-15 16:09:19 +00:00
bd4ae1ee8e
Merge pull request #21 from puppetlabs/dependabot/bundler/rake-tw-13.0
Update rake requirement from ~> 10.1 to ~> 13.0
2021-06-15 10:28:50 -04:00
dependabot[bot]
252e92ab4f
Update rake requirement from ~> 10.1 to ~> 13.0
Updates the requirements on [rake](https://github.com/ruby/rake) to permit the latest version.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/rake-10.1.0...v13.0.3)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-15 14:27:24 +00:00
f6bf085eab
Merge pull request #19 from puppetlabs/gh-actions
Add some GH-based testing
2021-06-15 10:26:45 -04:00
ef72c2399a
Add some GH-based testing 2021-06-15 10:24:28 -04:00
Belén
0c4dc910d3
(MAINT) Add CODEOWNERS file 2019-08-26 09:50:16 -07:00
Michelle Schuknecht
79d0880c5b (MAINT) Add CODEOWNERS file 2019-08-26 06:30:15 -07:00
Jenkins
d54e825506 (GEM) update beaker-vmpooler version to 1.3.3 2019-04-30 16:59:45 +00:00
kirby@puppetlabs.com
4063b01ba0 Revert "Fix the API URL for adding disks"
This reverts commit 64c827fab0.
2019-04-30 09:49:19 -07:00
Jenkins
a504de0ae4 (GEM) update beaker-vmpooler version to 1.3.2 2019-04-22 16:40:14 +00:00
mattkirby
b463b50cbe
Merge pull request #15 from jwjs36987/fix_disk_url
(maint) Fix the API URL for adding disks
2019-04-22 09:29:17 -07:00
Jack Stone
64c827fab0 Fix the API URL for adding disks
The pooling_api variable already contains /api/v1 so remove this from
the disk API URL so we don't end up with it twice
2019-04-15 10:51:06 +01:00
Jenkins
15acdf0d7f (GEM) update beaker-vmpooler version to 1.3.1 2018-11-26 18:20:45 +00:00
Spencer McElmurry
d1ad5bb083
Merge pull request #13 from DavidS/randomized-backoff
(maint) random backoff strategy
2018-11-26 13:06:25 -05:00
David Schmitt
5317f2c1db (maint) random backoff strategy
The retry logic for VMPooler has two issues. 1) Waiting longer than
VMPooler takes to refill the pool to retry introduces excessive delays,
and 2) waiting for a deterministic amount of time means that processes
started at the same time stay in sync causing peak loads.

This change caps the wait time at 15 seconds plus a random wait time,
addressing both issues.
2018-11-26 09:48:48 +00:00
Kevin Imber
02684546cb
Merge pull request #12 from Dakta/BKR-1509
(BKR-1509) Hypervisor usage instructions for Beaker 4.0
2018-08-03 15:07:21 -07:00
Dakota Schneider
7a4909805a (BKR-1509) Hypervisor usage instructions for Beaker 4.0 2018-08-03 12:17:32 -07:00
Jenkins
b0bc656187 (GEM) update beaker-vmpooler version to 1.3.0 2018-07-16 20:10:55 +00:00
Dakota Schneider
c0938fe1c8 (BKR-1481) Rewrite beaker-vmpooler to use shared .fog parsing (#11)
* (BKR-1481) Rewrite beaker-vmpooler to use shared .fog parsing

* (BKR-1481) Rename Fog Credential Method

* (BKR-1481) Cleanup spec tests

Spec tests don't need to replicate spec tests of core functionality.
2018-07-16 13:09:51 -07:00
Dakota Schneider
b8804eb5f1 (MAINT) Drop MockVsphereHelper (#10)
* (MAINT) Update specs to remove VsphereHelper

VsphereHelper is no longer relevant since vmpooler doesn't use vSphere/vCloud any more.

* (MAINT) Drop conflicting, unused dependency on beaker-abs

* (MAINT) Conditionally pin fakefs '< 0.14.0' for Ruby < '2.3.0'

* (MAINT) Remove more VsphereHelper references

And minor whitespace cleanup

* (MAINT) Drop unused beaker-abs dependency

Could have sworn I fixed that... maybe in a different branch?
2018-07-02 08:57:30 -07:00
mchllweeks
4cc317c488
Merge pull request #9 from kevpl/maint_connections_symbol
(MAINT) fix connection preferences
2018-03-12 10:18:35 -07:00
kevpl
b1f30c268f
(MAINT) fix connection preferences
Previously, beaker-vmpooler defined its
connection preferences as string options, but
beaker provides defaults as symbols. This ends
with beaker saying that it doesn't support methods
that it does due to the mismatch. This will get
rid of those messages, as the provided methods
will be symbols, matching what beaker expects
2018-03-09 15:00:54 -08:00
Jenkins CI
3ac63b61da (GEM) update beaker-vmpooler version to 1.2.0 2018-01-04 14:44:48 -08:00
Kevin Imber
f6c0f255b1
Merge pull request #8 from puppetlabs/maint/fix-rake-for-abs
(maint) Add option for BEAKER_HOSTS file to be pre-generated in acceptance tests
2018-01-04 14:43:02 -08:00
Spencer McElmurry
ddae40bade (maint) Add option for BEAKER_HOSTS file to be pregenerated in acceptance tests
Before, the host configuration was hard-coded. Added an option
to specify an ENV var in order to use a different string or a
pregenerated hostfile.

This also allows us to use abs in production, so that has been added
to the Gemfile
2017-11-28 08:41:42 -08:00
Jenkins CI
8fd2538382 (GEM) update beaker-vmpooler version to 1.1.0 2017-08-14 14:02:31 -07:00
Rishi Javia
6872c1d2b8 (BKR-1155) Override beaker's default ssh connection preference
[skip ci]
2017-08-14 14:01:17 -07:00
12 changed files with 189 additions and 135 deletions

7
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10

39
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: Release
on: workflow_dispatch
jobs:
release:
runs-on: ubuntu-latest
if: github.repository == 'puppetlabs/beaker-vmpooler'
steps:
- uses: actions/checkout@v3
- name: Get Version
id: gv
run: |
version=$(grep VERSION lib/beaker-vmpooler/version.rb |rev |cut -d "'" -f2 |rev)
echo "version=$version" >> $GITHUB_OUTPUT
echo "Found version $version from lib/beaker-vmpooler/version.rb"
- name: Tag Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.gv.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
generateReleaseNotes: true
- name: Install Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
- name: Build gem
run: gem build *.gemspec
- name: Publish gem
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push *.gem
env:
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'

39
.github/workflows/security.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: Security
on:
workflow_dispatch:
push:
branches:
- main
jobs:
scan:
name: Mend Scanning
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
# setup a package lock if one doesn't exist, otherwise do nothing
- name: check lock
run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock'
# install java
- uses: actions/setup-java@v3
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
# download mend
- name: download_mend
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar
- name: run mend
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: RE
WS_PROJECTNAME: ${{ github.event.repository.name }}

26
.github/workflows/testing.yml vendored Normal file
View file

@ -0,0 +1,26 @@
name: Testing
on:
pull_request:
branches:
- main
jobs:
spec_tests:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run spec tests
run: bundle exec rake test

2
CODEOWNERS Normal file
View file

@ -0,0 +1,2 @@
* @puppetlabs/release-engineering

11
Gemfile
View file

@ -1,8 +1,6 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
gemspec
gemspec :development_group => :acceptance_testing
def location_for(place, fake_version = nil)
if place =~ /^(git:[^#]*)#(.*)/
@ -14,14 +12,13 @@ def location_for(place, fake_version = nil)
end
end
# We don't put beaker in as a test dependency because we
# don't want to create a transitive dependency
group :acceptance_testing do
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.0')
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 5.0', '< 7')
gem "beaker-abs"
end
if File.exists? "#{__FILE__}.local"
if File.exist? "#{__FILE__}.local"
eval(File.read("#{__FILE__}.local"), binding)
end

View file

@ -3,8 +3,27 @@
Beaker library to use vmpooler hypervisor
# How to use this wizardry
This is a gem that allows you to use hosts with [vmpooler](vmpooler.md) hypervisor with [beaker](https://github.com/puppetlabs/beaker). This gem is already included as [beaker dependency](https://github.com/puppetlabs/beaker/blob/master/beaker.gemspec#L59) for you, so you don't need to do anything special to use this gem's functionality with beaker.
This is a gem that allows you to use hosts with [vmpooler](vmpooler.md) hypervisor with [beaker](https://github.com/puppetlabs/beaker).
Beaker will automatically load the appropriate hypervisors for any given hosts file, so as long as your project dependencies are satisfied there's nothing else to do. No need to `require` this library in your tests.
## With Beaker 3.x
This library is included as a dependency of Beaker 3.x versions, so there's nothing to do.
## With Beaker 4.x
As of Beaker 4.0, all hypervisor and DSL extension libraries have been removed and are no longer dependencies. In order to use a specific hypervisor or DSL extension library in your project, you will need to include them alongside Beaker in your Gemfile or project.gemspec. E.g.
~~~ruby
# Gemfile
gem 'beaker', '~>4.0'
gem 'beaker-vmpooler'
# project.gemspec
s.add_runtime_dependency 'beaker', '~>4.0'
s.add_runtime_dependency 'beaker-vmpooler'
~~~
# Spec tests

View file

@ -20,11 +20,12 @@ Runs the base beaker acceptance test using the hypervisor library
beaker_gem_spec = Gem::Specification.find_by_name('beaker')
beaker_gem_dir = beaker_gem_spec.gem_dir
beaker_test_base_dir = File.join(beaker_gem_dir, 'acceptance/tests/base')
beaker_hosts = ENV['BEAKER_HOSTS'] || 'redhat7-64af-64default.mdcal'
load_path_option = File.join(beaker_gem_dir, 'acceptance/lib')
sh("beaker",
"--tests", beaker_test_base_dir,
"--log-level", "verbose",
"--hosts", "redhat7-64af-redhat7-64default.mdcal",
"--hosts", beaker_hosts,
"--load-path", load_path_option,
"--keyfile", ENV['KEY'] || "#{ENV['HOME']}/.ssh/id_rsa-acceptance")
end

View file

@ -20,8 +20,8 @@ Gem::Specification.new do |s|
# Testing dependencies
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'rspec-its'
s.add_development_dependency 'fakefs', '~> 0.6'
s.add_development_dependency 'rake', '~> 10.1'
s.add_development_dependency 'fakefs', '~> 2.4'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'pry', '~> 0.10'

View file

@ -1,3 +1,3 @@
module BeakerVmpooler
VERSION = '1.0.0'
VERSION = '1.4.0'
end

View file

@ -27,33 +27,21 @@ module Beaker
def load_credentials(dot_fog = '.fog')
creds = {}
if fog = read_fog_file(dot_fog)
if fog[:default] && fog[:default][:vmpooler_token]
creds[:vmpooler_token] = fog[:default][:vmpooler_token]
begin
fog = get_fog_credentials(dot_fog)
if fog[:vmpooler_token]
creds[:vmpooler_token] = fog[:vmpooler_token]
else
@logger.warn "Credentials file (#{dot_fog}) is missing a :default section with a :vmpooler_token value; proceeding without authentication"
@logger.warn "vmpooler_token not found in credentials file (#{dot_fog})\nProceeding without authentication"
end
else
@logger.warn "Credentials file (#{dot_fog}) is empty; proceeding without authentication"
rescue ArgumentError => e
@logger.warn "Invalid credentials file:\n(#{e.class}) #{e.message}\nProceeding without authentication"
end
creds
rescue TypeError, Psych::SyntaxError => e
@logger.warn "#{e.class}: Credentials file (#{dot_fog}) has invalid syntax; proceeding without authentication"
creds
rescue Errno::ENOENT
@logger.warn "Credentials file (#{dot_fog}) not found; proceeding without authentication"
creds
end
def read_fog_file(dot_fog = '.fog')
YAML.load_file(dot_fog)
end
def connection_preference
['vmhostname', 'ip', 'hostname']
def connection_preference(host)
[:vmhostname, :ip, :hostname]
end
def check_url url
@ -126,6 +114,7 @@ module Beaker
uri = URI.parse(@options['pooling_api'] + '/vm/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.instance_of?(URI::HTTPS)
request = Net::HTTP::Post.new(uri.request_uri)
if @credentials[:vmpooler_token]
@ -181,7 +170,7 @@ module Beaker
@logger.debug("Retrying provision for vmpooler host after waiting #{wait} second(s)")
sleep wait
waited += wait
last_wait, wait = wait, last_wait + wait
last_wait, wait = wait, [last_wait + wait, 15].min + rand(5)
retry
end
report_and_raise(@logger, e, 'Vmpooler.provision')
@ -197,6 +186,7 @@ module Beaker
uri = URI.parse(@options[:pooling_api] + '/vm/' + h['vmhostname'].split('.')[0])
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.instance_of?(URI::HTTPS)
request = Net::HTTP::Put.new(uri.request_uri)
# merge pre-defined tags with host tags
@ -262,6 +252,7 @@ module Beaker
uri = URI.parse(get_template_url(@options['pooling_api'], name))
http = Net::HTTP.new( uri.host, uri.port )
http.use_ssl = uri.instance_of?(URI::HTTPS)
request = Net::HTTP::Delete.new(uri.request_uri)
if @credentials[:vmpooler_token]
@ -289,6 +280,7 @@ module Beaker
uri = URI.parse(@options[:pooling_api] + '/api/v1/vm/' + hostname + '/disk/' + disk_size.to_s)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.instance_of?(URI::HTTPS)
request = Net::HTTP::Post.new(uri.request_uri)
request['X-AUTH-TOKEN'] = @credentials[:vmpooler_token]
@ -321,6 +313,7 @@ module Beaker
uri = URI.parse(@options[:pooling_api] + '/vm/' + hostname)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.instance_of?(URI::HTTPS)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)

View file

@ -4,11 +4,8 @@ module Beaker
describe Vmpooler do
before :each do
vms = make_hosts()
MockVsphereHelper.set_config( fog_file_contents )
MockVsphereHelper.set_vms( vms )
stub_const( "VsphereHelper", MockVsphereHelper )
stub_const( "Net", MockNet )
allow_any_instance_of(MockNet::HTTP).to receive(:use_ssl=)
allow( JSON ).to receive( :parse ) do |arg|
arg
end
@ -147,20 +144,15 @@ module Beaker
describe "#cleanup" do
it "cleans up hosts in the pool" do
MockVsphereHelper.powerOn
mock_http = MockNet::HTTP.new( "host", "port" )
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
allow( vmpooler ).to receive( :require ).and_return( true )
allow( vmpooler ).to receive( :sleep ).and_return( true )
vmpooler.provision
vmpooler.cleanup
vm_count = vmpooler.instance_variable_get( :@hosts ).count
hosts = vmpooler.instance_variable_get( :@hosts )
hosts.each do | host |
name = host.name
vm = MockVsphereHelper.find_vm( name )
expect( vm.runtime.powerState ).to be === "poweredOn" #handed back to the pool, stays on
end
expect( Net::HTTP ).to receive( :new ).exactly( vm_count ).times.and_return( mock_http )
expect( mock_http ).to receive( :request ).exactly( vm_count ).times
expect( Net::HTTP::Delete ).to receive( :new ).exactly( vm_count ).times
expect{ vmpooler.cleanup }.to_not raise_error
end
end
end
@ -168,10 +160,6 @@ module Beaker
describe Vmpooler do
before :each do
vms = make_hosts()
MockVsphereHelper.set_config( fog_file_contents )
MockVsphereHelper.set_vms( vms )
stub_const( "VsphereHelper", MockVsphereHelper )
stub_const( "Net", MockNet )
allow( JSON ).to receive( :parse ) do |arg|
arg
@ -181,96 +169,39 @@ module Beaker
describe "#load_credentials" do
it 'continues without credentials when fog file is missing' do
allow_any_instance_of( Beaker::Vmpooler ).to \
receive(:read_fog_file).and_raise(Errno::ENOENT.new)
it 'loads credentials from a fog file' do
credentials = { :vmpooler_token => "example_token" }
make_opts = { :dot_fog => '.fog' }
expect_any_instance_of( Beaker::Vmpooler ).to receive( :get_fog_credentials ).and_return(credentials)
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == credentials
end
it 'continues without credentials when there are problems loading the fog file' do
logger = double( 'logger' )
make_opts = { :logger => logger, :dot_fog => '.fog' }
expect_any_instance_of( Beaker::Vmpooler ).to receive( :get_fog_credentials ).and_raise( ArgumentError, 'something went wrong' )
expect( logger ).to receive( :warn ).with( /Invalid credentials file.*something went wrong.*Proceeding without authentication/m )
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == {}
end
it 'continues without credentials when fog file is empty' do
allow_any_instance_of( Beaker::Vmpooler ).to \
receive(:read_fog_file).and_return(false)
it 'continues without credentials when fog file has no vmpooler_token' do
logger = double( 'logger' )
make_opts = { :logger => logger, :dot_fog => '.fog' }
expect_any_instance_of( Beaker::Vmpooler ).to receive( :get_fog_credentials ).and_return( {} )
expect( logger ).to receive( :warn ).with( /vmpooler_token not found in credentials file.*Proceeding without authentication/m )
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == {}
end
it 'continues without credentials when fog file contains no :default section' do
data = { :some => { :other => :data } }
allow_any_instance_of( Beaker::Vmpooler ).to \
receive(:read_fog_file).and_return(data)
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == { }
end
it 'continues without credentials when fog file :default section has no :vmpooler_token' do
data = { :default => { :something_else => "TOKEN" } }
allow_any_instance_of( Beaker::Vmpooler ).to \
receive(:read_fog_file).and_return(data)
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == { }
end
it 'continues without credentials when there are formatting errors in the fog file' do
data = { "'default'" => { :vmpooler_token => "b2wl8prqe6ddoii70md" } }
allow_any_instance_of( Beaker::Vmpooler ).to \
receive(:read_fog_file).and_return(data)
logger = double('logger')
expect(logger).to receive(:warn).with(/is missing a :default section with a :vmpooler_token value/)
make_opts = {:logger => logger}
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == { }
end
it 'throws a TypeError and continues without credentials when there are syntax errors in the fog file' do
data = "'default'\n :vmpooler_token: z2wl8prqe0ddoii70ad"
allow( File ).to receive( :open ).and_yield( StringIO.new(data) )
logger = double('logger')
expect(logger).to receive(:warn).with(/TypeError: .* has invalid syntax/)
make_opts = {:logger => logger}
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == { }
end
it 'throws a Psych::SyntaxError and continues without credentials when there are syntax errors in the fog file' do
data = ";default;\n :vmpooler_token: z2wl8prqe0ddoii707d"
allow( File ).to receive( :open ).and_yield( StringIO.new(data) )
logger = double('logger')
expect(logger).to receive(:warn).with(/Psych::SyntaxError: .* invalid syntax/)
make_opts = {:logger => logger}
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == { }
end
it 'stores vmpooler token when found in fog file' do
data = { :default => { :vmpooler_token => "TOKEN" } }
allow_any_instance_of( Beaker::Vmpooler ).to \
receive(:read_fog_file).and_return(data)
vmpooler = Beaker::Vmpooler.new( make_hosts, make_opts )
expect( vmpooler.credentials ).to be == { :vmpooler_token => "TOKEN" }
end
end
end
end