beaker 3.7.0 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/acceptance/pre_suite/puppet_pkg/install.rb +5 -3
- data/acceptance/tests/puppet/with_puppet_running_on.rb +17 -21
- data/beaker.gemspec +2 -1
- data/bin/beaker +6 -2
- data/lib/beaker.rb +1 -1
- data/lib/beaker/cli.rb +4 -7
- data/lib/beaker/host_prebuilt_steps.rb +10 -1
- data/lib/beaker/shared.rb +1 -2
- data/lib/beaker/subcommand.rb +20 -0
- data/lib/beaker/subcommands/subcommand_util.rb +114 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/host_prebuilt_steps_spec.rb +12 -0
- data/spec/beaker/subcommand/subcommand_util_spec.rb +203 -0
- metadata +23 -8
- data/lib/beaker/shared/subcommands_util.rb +0 -37
- data/spec/beaker/shared/subcommands_util_spec.rb +0 -33
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2JkMGY5N2Y2NGU1YWU2NmZhZTJhZjdkNDkyMGZkODk2N2ExMGE2MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzY5ZGQ4NjQ4YzNlOWE0NDk5ZDRkMWMwMWU0ZGE0MzgwODYxZDFiZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDdmMjA2ZWFlZTkyMGI2YjMwZTIzM2ZhNGQwZWZiMzEwMGU0OGZkMDliNTJi
|
10
|
+
MTYyNGM0OGMxYjdkNDBkOTdmZmI4NWY0MzdhYTJkMDFlNzFlMDhlMDdkMDc0
|
11
|
+
NjczMjkyM2U2MzFhNTQ5NjdmMjc5M2NiMmE3MTBiMDc0OWM0YTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjgwMTliODVjYjFmYjk3M2MzMWFkYzhmMDRmYmFlMGExNWE3MDMwMTM3MmYy
|
14
|
+
MDQ5ZTcwYmY1ZWE2NzhkNjEzZDUxOGEzMTMzNjczYjIwNmY0YjM5ZDkyZDE2
|
15
|
+
ZjQ5N2VhN2ZjMmVkMGNjOWJiNTUxNmM5YjA4MzUzY2UzMDFmNTQ=
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# the version is required on windows
|
2
2
|
# all versions are required for osx
|
3
3
|
install_puppet({
|
4
|
-
:version => '
|
5
|
-
:
|
6
|
-
:hiera_version => '1.3.4',
|
4
|
+
:version => ENV['BEAKER_PUPPET_VERSION'] || '4.8.0',
|
5
|
+
:puppet_agent_version => ENV['BEAKER_PUPPET_AGENT_VERSION'] || '1.8.0'
|
7
6
|
})
|
7
|
+
|
8
|
+
on(master, puppet('resource user puppet ensure=present'))
|
9
|
+
on(master, puppet('resource group puppet ensure=present'))
|
@@ -1,30 +1,26 @@
|
|
1
|
-
test_name 'with_puppet_running_on' do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
assert_match(/running/,result,'did not find puppet service/master running')
|
1
|
+
test_name 'skip_test in with_puppet_running_on' do
|
2
|
+
assert_raises SkipTest do
|
3
|
+
with_puppet_running_on(master, {}) do
|
4
|
+
skip_test 'skip rest'
|
5
|
+
assert(false)
|
7
6
|
end
|
8
7
|
end
|
9
|
-
|
10
8
|
end
|
11
9
|
|
12
|
-
test_name '
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
test_name 'pending_test in with_puppet_running_on' do
|
11
|
+
assert_raises PendingTest do
|
12
|
+
with_puppet_running_on(master, {}) do
|
13
|
+
pending_test 'pending appendix prepended'
|
14
|
+
assert(false)
|
15
|
+
end
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
|
21
|
-
test_name '
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
test_name 'fail_test in with_puppet_running_on' do
|
20
|
+
assert_raises FailTest do
|
21
|
+
with_puppet_running_on(master, {}) do
|
22
|
+
fail_test 'fail_test message'
|
23
|
+
assert(false)
|
24
|
+
end
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
|
-
|
30
|
-
# TODO: no idea how to test fail_test in here
|
data/beaker.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency 'pry', '~> 0.10'
|
29
29
|
|
30
30
|
# Documentation dependencies
|
31
|
-
s.add_development_dependency 'yard'
|
31
|
+
s.add_development_dependency 'yard', '< 0.9.6'
|
32
32
|
|
33
33
|
# Run time dependencies
|
34
34
|
s.add_runtime_dependency 'minitest', '~> 5.4'
|
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_runtime_dependency 'rsync', '~> 1.0.9'
|
47
47
|
s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
|
48
48
|
s.add_runtime_dependency 'in-parallel', '~> 0.1'
|
49
|
+
s.add_runtime_dependency 'thor', '0.19.1'
|
49
50
|
|
50
51
|
# Run time dependencies that are Beaker libraries
|
51
52
|
s.add_runtime_dependency 'stringify-hash', '~> 0.0'
|
data/bin/beaker
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
require 'rubygems' unless defined?(Gem)
|
4
4
|
require 'beaker'
|
5
5
|
|
6
|
-
Beaker::
|
7
|
-
|
6
|
+
if Beaker::Subcommands::SubcommandUtil.execute_subcommand?(ARGV[0])
|
7
|
+
Beaker::Subcommand.start(ARGV)
|
8
|
+
else
|
9
|
+
Beaker::CLI.new.execute!
|
10
|
+
puts "Beaker completed successfully, thanks."
|
11
|
+
end
|
8
12
|
|
9
13
|
exit 0
|
data/lib/beaker.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems' unless defined?(Gem)
|
2
2
|
module Beaker
|
3
3
|
|
4
|
-
%w( version platform test_suite result command options network_manager cli perf logger_junit ).each do |lib|
|
4
|
+
%w( version platform test_suite result command options network_manager cli perf logger_junit subcommand ).each do |lib|
|
5
5
|
begin
|
6
6
|
require "beaker/#{lib}"
|
7
7
|
rescue LoadError
|
data/lib/beaker/cli.rb
CHANGED
@@ -27,19 +27,16 @@ module Beaker
|
|
27
27
|
@execute = false
|
28
28
|
return
|
29
29
|
end
|
30
|
+
|
30
31
|
if @options[:beaker_version_print]
|
31
32
|
@logger.notify(beaker_version_string)
|
32
33
|
@execute = false
|
33
34
|
return
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@logger.info("Beaker!")
|
40
|
-
@logger.info(beaker_version_string)
|
41
|
-
@logger.info(@options.dump)
|
42
|
-
end
|
37
|
+
@logger.info("Beaker!")
|
38
|
+
@logger.info(beaker_version_string)
|
39
|
+
@logger.info(@options.dump)
|
43
40
|
|
44
41
|
if @options[:parse_only]
|
45
42
|
@execute = false
|
@@ -336,7 +336,16 @@ module Beaker
|
|
336
336
|
host.exec(Command.new('cp -r .ssh /cygdrive/c/Users/Administrator/.'))
|
337
337
|
host.exec(Command.new('chown -R Administrator /cygdrive/c/Users/Administrator/.ssh'))
|
338
338
|
elsif host['platform'] =~ /windows/ and not host.is_cygwin?
|
339
|
-
|
339
|
+
# from https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true:
|
340
|
+
# /i : If Source is a directory or contains wildcards and Destination
|
341
|
+
# does not exist, xcopy assumes destination specifies a directory
|
342
|
+
# name and creates a new directory. Then, xcopy copies all specified
|
343
|
+
# files into the new directory. By default, xcopy prompts you to
|
344
|
+
# specify whether Destination is a file or a directory.
|
345
|
+
#
|
346
|
+
# /y : Suppresses prompting to confirm that you want to overwrite an
|
347
|
+
# existing destination file.
|
348
|
+
host.exec(Command.new("if exist .ssh (xcopy .ssh C:\\Users\\Administrator\\.ssh /s /e /y /i)"))
|
340
349
|
elsif host['platform'] =~ /osx/
|
341
350
|
host.exec(Command.new('sudo cp -r .ssh /var/root/.'), {:pty => true})
|
342
351
|
elsif host['platform'] =~ /freebsd/
|
data/lib/beaker/shared.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[ 'repetition', 'error_handler', 'host_manager', 'timed', 'semvar', 'options_resolver'
|
1
|
+
[ 'repetition', 'error_handler', 'host_manager', 'timed', 'semvar', 'options_resolver'].each do |lib|
|
2
2
|
require "beaker/shared/#{lib}"
|
3
3
|
end
|
4
4
|
module Beaker
|
@@ -9,7 +9,6 @@ module Beaker
|
|
9
9
|
include Beaker::Shared::Timed
|
10
10
|
include Beaker::Shared::Semvar
|
11
11
|
include Beaker::Shared::OptionsResolver
|
12
|
-
include Beaker::Shared::SubcommandsUtil
|
13
12
|
end
|
14
13
|
end
|
15
14
|
include Beaker::Shared
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "fileutils"
|
3
|
+
require "beaker/subcommands/subcommand_util"
|
4
|
+
|
5
|
+
module Beaker
|
6
|
+
class Subcommand < Thor
|
7
|
+
SubcommandUtil = Beaker::Subcommands::SubcommandUtil
|
8
|
+
|
9
|
+
desc "init", "Initialises the beaker test environment configuration"
|
10
|
+
option :hypervisor, :type => :string, :required => true
|
11
|
+
long_desc <<-LONGDESC
|
12
|
+
Initialises a beaker environment configuration
|
13
|
+
LONGDESC
|
14
|
+
def init()
|
15
|
+
SubcommandUtil.verify_init_args(options)
|
16
|
+
SubcommandUtil.require_tasks()
|
17
|
+
SubcommandUtil.init_hypervisor(options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Subcommands
|
5
|
+
# Methods used in execution of Subcommands
|
6
|
+
# - should we execute a subcommand?
|
7
|
+
# - reset ARGV
|
8
|
+
# - execute Beaker
|
9
|
+
# - update a rakefile to require beaker quickstart tasks
|
10
|
+
# - initialise a rake application
|
11
|
+
# - execute a rake task
|
12
|
+
# - execute the vagrant quickstart task
|
13
|
+
# - execute the vmpooler quickstart task
|
14
|
+
# - exit with a specific message
|
15
|
+
# - verify that the init subcommand has the correct arguments
|
16
|
+
# - execute the quick start task for the specified hypervisor
|
17
|
+
module SubcommandUtil
|
18
|
+
BEAKER_REQUIRE = "require 'beaker/tasks/quick_start'"
|
19
|
+
HYPERVISORS = ["vagrant", "vmpooler"]
|
20
|
+
|
21
|
+
# Check if the first argument to the beaker execution is a subcommand
|
22
|
+
# @return [Boolean] true if argv[0] is "help" or a method defined in the Subcommands class, false otherwise
|
23
|
+
def self.execute_subcommand?(arg0)
|
24
|
+
return false if arg0.nil?
|
25
|
+
(Beaker::Subcommand.instance_methods(false) << :help).include? arg0.to_sym
|
26
|
+
end
|
27
|
+
|
28
|
+
# Reset ARGV to contain the arguments determined by a specific subcommand
|
29
|
+
# @param [Array<String>] args the arguments determined by a specific subcommand
|
30
|
+
def self.reset_argv(args)
|
31
|
+
ARGV.clear
|
32
|
+
args.each do |arg|
|
33
|
+
ARGV << arg
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Update ARGV and call Beaker
|
38
|
+
# @param [Array<String>] args the arguments determined by a specific subcommand
|
39
|
+
def self.execute_beaker(*args)
|
40
|
+
reset_argv(args)
|
41
|
+
Beaker::CLI.new.execute!
|
42
|
+
end
|
43
|
+
|
44
|
+
# Determines what Rakefile to use
|
45
|
+
# @return [String] the name of the rakefile to use
|
46
|
+
def self.determine_rake_file()
|
47
|
+
rake_app.find_rakefile_location() ? rake_app.find_rakefile_location()[0] : "Rakefile"
|
48
|
+
end
|
49
|
+
|
50
|
+
# Check for the presence of a Rakefile containing the require of the
|
51
|
+
# quick start tasks
|
52
|
+
def self.require_tasks()
|
53
|
+
rake_file = determine_rake_file()
|
54
|
+
unless File.readlines(rake_file).grep(/#{BEAKER_REQUIRE}/).any?
|
55
|
+
File.open(rake_file, "a+") { |f| f.puts(BEAKER_REQUIRE) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initialises a rake application
|
60
|
+
# @return [Object] a rake application
|
61
|
+
def self.rake_app()
|
62
|
+
unless @rake_app
|
63
|
+
ARGV.clear
|
64
|
+
@rake_app = Rake.application
|
65
|
+
@rake_app.init
|
66
|
+
end
|
67
|
+
@rake_app
|
68
|
+
end
|
69
|
+
|
70
|
+
# Clear ARGV and execute a Rake task
|
71
|
+
# @param [String] task the rake task to execute
|
72
|
+
def self.execute_rake_task(task)
|
73
|
+
rake_app.load_rakefile()
|
74
|
+
rake_app.invoke_task(task)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Execute the quick start task for vagrant
|
78
|
+
def self.init_vagrant()
|
79
|
+
execute_rake_task("beaker_quickstart:gen_hosts[vagrant]")
|
80
|
+
end
|
81
|
+
|
82
|
+
# Execute the quick start task for vmpooler
|
83
|
+
def self.init_vmpooler()
|
84
|
+
execute_rake_task("beaker_quickstart:gen_hosts[vmpooler]")
|
85
|
+
end
|
86
|
+
|
87
|
+
# Print a message to the console and exit with 0
|
88
|
+
# @param [String] msg the message to print
|
89
|
+
def self.exit_with(msg)
|
90
|
+
puts msg
|
91
|
+
exit(0)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Verify that a valid hypervisor has been specified
|
95
|
+
# @param [Array<Object>] options the options we want to query
|
96
|
+
def self.verify_init_args(options)
|
97
|
+
unless HYPERVISORS.include?(options[:hypervisor])
|
98
|
+
exit_with("Invalid hypervisor. Currently supported hypervisors are: #{HYPERVISORS.join(', ')}")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Call the quick start task for the specified hypervisor
|
103
|
+
# @param [Array<Object>] options the options we want to query
|
104
|
+
def self.init_hypervisor(options)
|
105
|
+
case options[:hypervisor]
|
106
|
+
when "vagrant"
|
107
|
+
init_vagrant
|
108
|
+
when "vmpooler"
|
109
|
+
init_vmpooler
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/lib/beaker/version.rb
CHANGED
@@ -498,6 +498,18 @@ describe Beaker do
|
|
498
498
|
|
499
499
|
end
|
500
500
|
|
501
|
+
context "copy_ssh_to_root" do
|
502
|
+
subject { dummy_class.new }
|
503
|
+
|
504
|
+
it "can copy ssh to root in windows hosts with no cygwin" do
|
505
|
+
host = make_host( 'testhost', { :platform => 'windows', :is_cygwin => false })
|
506
|
+
expect( Beaker::Command ).to receive( :new ).with( "if exist .ssh (xcopy .ssh C:\\Users\\Administrator\\.ssh /s /e /y /i)" ).once
|
507
|
+
|
508
|
+
subject.copy_ssh_to_root(host, options)
|
509
|
+
end
|
510
|
+
|
511
|
+
end
|
512
|
+
|
501
513
|
context "package_proxy" do
|
502
514
|
|
503
515
|
subject { dummy_class.new }
|
@@ -0,0 +1,203 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Beaker
|
4
|
+
module Subcommands
|
5
|
+
describe SubcommandUtil do
|
6
|
+
|
7
|
+
let(:cli) {
|
8
|
+
double("cli")
|
9
|
+
}
|
10
|
+
|
11
|
+
let(:rake) {
|
12
|
+
double("rake")
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:file) {
|
16
|
+
double("file")
|
17
|
+
}
|
18
|
+
|
19
|
+
describe 'reset_argv' do
|
20
|
+
it "resets argv" do
|
21
|
+
args = ["test1", "test2"]
|
22
|
+
expect(ARGV).to receive(:clear).exactly(1).times
|
23
|
+
subject.reset_argv(args)
|
24
|
+
expect(ARGV[0]).to eq(args[0])
|
25
|
+
expect(ARGV[1]).to eq(args[1])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'execute_subcommand' do
|
30
|
+
it "determines if we should execute the init subcommand" do
|
31
|
+
expect(subject.execute_subcommand?("init")).to be == true
|
32
|
+
end
|
33
|
+
it "determines if we should execute the help subcommand" do
|
34
|
+
expect(subject.execute_subcommand?("help")).to be == true
|
35
|
+
end
|
36
|
+
it "determines that a subcommand should not be executed" do
|
37
|
+
expect(subject.execute_subcommand?("notasubcommand")).to be == false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'execute_beaker' do
|
42
|
+
it "executes beaker with arguments" do
|
43
|
+
allow(cli).to receive(:execute!).and_return(true)
|
44
|
+
allow(Beaker::CLI).to receive(:new).and_return(cli)
|
45
|
+
expect(subject).to receive(:reset_argv).exactly(1).times
|
46
|
+
expect(cli).to receive(:execute!).exactly(1).times
|
47
|
+
subject.execute_beaker(['args'])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'exit_with' do
|
52
|
+
it "the exit value should be false" do
|
53
|
+
expect(STDOUT).to receive(:puts).with("exiting").exactly(1).times
|
54
|
+
begin
|
55
|
+
subject.exit_with("exiting")
|
56
|
+
rescue SystemExit=>e
|
57
|
+
expect(e.status).to eq(0)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'init_vmpooler' do
|
63
|
+
it "executes the vmpooler quick task" do
|
64
|
+
expect(subject).to receive(:execute_rake_task).with("beaker_quickstart:gen_hosts[vmpooler]").exactly(1).times
|
65
|
+
subject.init_vmpooler
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'init_vagrant' do
|
70
|
+
it "executes the vmpooler quick task" do
|
71
|
+
expect(subject).to receive(:execute_rake_task).with("beaker_quickstart:gen_hosts[vagrant]").exactly(1).times
|
72
|
+
subject.init_vagrant
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'init_hypervisor' do
|
77
|
+
it "calls init_vagrant" do
|
78
|
+
options = {:hypervisor => "vagrant"}
|
79
|
+
expect(subject).to receive(:init_vagrant).with(no_args).exactly(1).times
|
80
|
+
expect(subject).to receive(:init_vmpooler).with(no_args).exactly(0).times
|
81
|
+
subject.init_hypervisor(options)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "calls init_vmpooler" do
|
85
|
+
options = {:hypervisor => "vmpooler"}
|
86
|
+
expect(subject).to receive(:init_vagrant).with(no_args).exactly(0).times
|
87
|
+
expect(subject).to receive(:init_vmpooler).with(no_args).exactly(1).times
|
88
|
+
subject.init_hypervisor(options)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "fails to call init for a hypervisor" do
|
92
|
+
options = {:hypervisor => "invalid"}
|
93
|
+
expect(subject).to receive(:init_vagrant).with(no_args).exactly(0).times
|
94
|
+
expect(subject).to receive(:init_vmpooler).with(no_args).exactly(0).times
|
95
|
+
subject.init_hypervisor(options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'execute_rake_task' do
|
100
|
+
|
101
|
+
it "executes the rake task" do
|
102
|
+
allow(Rake).to receive(:application).and_return(rake)
|
103
|
+
expect(ARGV).to receive(:clear).exactly(1).times
|
104
|
+
expect(rake).to receive(:init).and_return(true).exactly(1).times
|
105
|
+
expect(rake).to receive(:load_rakefile).and_return(true).exactly(1).times
|
106
|
+
expect(rake).to receive(:invoke_task).with("mytask").exactly(1).times
|
107
|
+
subject.execute_rake_task("mytask")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'verify_init_args' do
|
112
|
+
it "verfy the init args are valid for a vagrant run" do
|
113
|
+
options = {:hypervisor => "vagrant"}
|
114
|
+
expect(subject).to receive(:exit_with).exactly(0).times
|
115
|
+
subject.verify_init_args(options)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "verfy the init args are valid for a vmpooler run" do
|
119
|
+
options = {:hypervisor => "vmpooler"}
|
120
|
+
expect(subject).to receive(:exit_with).exactly(0).times
|
121
|
+
subject.verify_init_args(options)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "verify the init args are invalid for an init run" do
|
125
|
+
options = {}
|
126
|
+
expect(STDOUT).to receive(:puts).with("Invalid hypervisor. Currently supported hypervisors are: #{Beaker::Subcommands::SubcommandUtil::HYPERVISORS.join(', ')}").exactly(1).times
|
127
|
+
begin
|
128
|
+
subject.verify_init_args(options)
|
129
|
+
rescue SystemExit=>e
|
130
|
+
expect(e.status).to eq(0)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it "verify the init args are invalid for a vmpooler run" do
|
135
|
+
options = {:hypervisor => "thisshouldfail"}
|
136
|
+
expect(STDOUT).to receive(:puts).with("Invalid hypervisor. Currently supported hypervisors are: #{Beaker::Subcommands::SubcommandUtil::HYPERVISORS.join(', ')}").exactly(1).times
|
137
|
+
begin
|
138
|
+
subject.verify_init_args(options)
|
139
|
+
rescue SystemExit=>e
|
140
|
+
expect(e.status).to eq(0)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "determine_rake_file" do
|
146
|
+
|
147
|
+
it "uses Rakefile if no rakefile exists" do
|
148
|
+
allow(subject).to receive(:rake_app).and_return(rake)
|
149
|
+
allow(rake).to receive(:find_rakefile_location).and_return(nil)
|
150
|
+
expect subject.determine_rake_file == "Rakefile"
|
151
|
+
end
|
152
|
+
|
153
|
+
it "uses Rakefile if Rakefile exists" do
|
154
|
+
allow(subject).to receive(:rake_app).and_return(rake)
|
155
|
+
allow(rake).to receive(:find_rakefile_location).and_return("Rakefile")
|
156
|
+
expect subject.determine_rake_file == "Rakefile"
|
157
|
+
end
|
158
|
+
|
159
|
+
it "uses rakefile if rakefile exists" do
|
160
|
+
allow(subject).to receive(:rake_app).and_return(rake)
|
161
|
+
allow(rake).to receive(:find_rakefile_location).and_return("rakefile")
|
162
|
+
expect subject.determine_rake_file == "rakefile"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "uses Rakefile.rb if Rakefile.rb exists" do
|
166
|
+
allow(subject).to receive(:rake_app).and_return(rake)
|
167
|
+
allow(rake).to receive(:find_rakefile_location).and_return("Rakefile.rb")
|
168
|
+
expect subject.determine_rake_file == "Rakefile.rb"
|
169
|
+
end
|
170
|
+
|
171
|
+
it "uses rakefile.rb if rakefile.rb exists" do
|
172
|
+
allow(subject).to receive(:rake_app).and_return(rake)
|
173
|
+
allow(rake).to receive(:find_rakefile_location).and_return("rakefile.rb")
|
174
|
+
expect subject.determine_rake_file == "rakefile.rb"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "require_tasks" do
|
179
|
+
it "appends the require if it isn't contained in the Rakefile" do
|
180
|
+
allow(subject).to receive(:determine_rake_file).and_return("Rakefile")
|
181
|
+
allow(File).to receive(:readlines).with("Rakefile").and_return([""])
|
182
|
+
allow(File).to receive(:open).with("Rakefile", "a+").and_yield(file)
|
183
|
+
allow(File).to receive(:puts).with("require 'beaker/tasks/quick_start'").and_return(true)
|
184
|
+
expect(File).to receive(:open).with("Rakefile", "a+").and_yield(file).exactly(1).times
|
185
|
+
expect(file).to receive(:puts).with("require 'beaker/tasks/quick_start'").exactly(1).times
|
186
|
+
subject.require_tasks
|
187
|
+
end
|
188
|
+
|
189
|
+
it "does't append the require if it is contained in the Rakefile" do
|
190
|
+
allow(subject).to receive(:determine_rake_file).and_return("Rakefile")
|
191
|
+
allow(File).to receive(:readlines).with("Rakefile").and_return(["require 'beaker/tasks/quick_start'"])
|
192
|
+
allow(File).to receive(:open).with("Rakefile", "a+").and_yield(file)
|
193
|
+
allow(File).to receive(:puts).with("require 'beaker/tasks/quick_start'").and_return(true)
|
194
|
+
expect(File).to receive(:open).with("Rakefile", "a+").and_yield(file).exactly(0).times
|
195
|
+
expect(file).to receive(:puts).with("require 'beaker/tasks/quick_start'").exactly(0).times
|
196
|
+
subject.require_tasks
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppetlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: yard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - <
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.9.6
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - <
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.9.6
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - ~>
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0.1'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: thor
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - '='
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: 0.19.1
|
244
|
+
type: :runtime
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - '='
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: 0.19.1
|
237
251
|
- !ruby/object:Gem::Dependency
|
238
252
|
name: stringify-hash
|
239
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -675,9 +689,10 @@ files:
|
|
675
689
|
- lib/beaker/shared/options_resolver.rb
|
676
690
|
- lib/beaker/shared/repetition.rb
|
677
691
|
- lib/beaker/shared/semvar.rb
|
678
|
-
- lib/beaker/shared/subcommands_util.rb
|
679
692
|
- lib/beaker/shared/timed.rb
|
680
693
|
- lib/beaker/ssh_connection.rb
|
694
|
+
- lib/beaker/subcommand.rb
|
695
|
+
- lib/beaker/subcommands/subcommand_util.rb
|
681
696
|
- lib/beaker/tasks/quick_start.rb
|
682
697
|
- lib/beaker/tasks/rake_task.rb
|
683
698
|
- lib/beaker/tasks/test.rb
|
@@ -763,8 +778,8 @@ files:
|
|
763
778
|
- spec/beaker/shared/options_resolver_spec.rb
|
764
779
|
- spec/beaker/shared/repetition_spec.rb
|
765
780
|
- spec/beaker/shared/semvar_spec.rb
|
766
|
-
- spec/beaker/shared/subcommands_util_spec.rb
|
767
781
|
- spec/beaker/ssh_connection_spec.rb
|
782
|
+
- spec/beaker/subcommand/subcommand_util_spec.rb
|
768
783
|
- spec/beaker/test_case_spec.rb
|
769
784
|
- spec/beaker/test_suite_spec.rb
|
770
785
|
- spec/helpers.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module Shared
|
3
|
-
# Methods used in execution of Subcommands
|
4
|
-
# - should we write the config?
|
5
|
-
# - reset ARGV
|
6
|
-
# - execute Beaker
|
7
|
-
module SubcommandsUtil
|
8
|
-
CONFIG_PATH = ".beaker/config"
|
9
|
-
|
10
|
-
@@write_config = false
|
11
|
-
|
12
|
-
def self.write_config=( val )
|
13
|
-
@@write_config = val
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.write_config?
|
17
|
-
@@write_config
|
18
|
-
end
|
19
|
-
|
20
|
-
# Reset ARGV to contain the arguments determined by a specific subcommand
|
21
|
-
# @param [Array<String>] args the arguments determined by a specific subcommand
|
22
|
-
def reset_argv(args)
|
23
|
-
ARGV.clear
|
24
|
-
args.each do |arg|
|
25
|
-
ARGV << arg
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Update ARGV and call Beaker
|
30
|
-
# @param [Array<String>] args the arguments determined by a specific subcommand
|
31
|
-
def execute_beaker(*args)
|
32
|
-
reset_argv(args)
|
33
|
-
Beaker::CLI.new.execute!
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Beaker
|
4
|
-
module Shared
|
5
|
-
describe SubcommandsUtil do
|
6
|
-
|
7
|
-
let(:cli) {
|
8
|
-
double("cli")
|
9
|
-
}
|
10
|
-
|
11
|
-
describe 'reset_argv' do
|
12
|
-
it "resets argv" do
|
13
|
-
args = ["test1", "test2"]
|
14
|
-
expect(ARGV).to receive(:clear).exactly(1).times
|
15
|
-
subject.reset_argv(args)
|
16
|
-
expect(ARGV[0]).to eq(args[0])
|
17
|
-
expect(ARGV[1]).to eq(args[1])
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'execute_beaker' do
|
22
|
-
it "executes beaker with arguments" do
|
23
|
-
allow(cli).to receive(:execute!).and_return(true)
|
24
|
-
allow(Beaker::CLI).to receive(:new).and_return(cli)
|
25
|
-
expect(subject).to receive(:reset_argv).exactly(1).times
|
26
|
-
expect(cli).to receive(:execute!).exactly(1).times
|
27
|
-
subject.execute_beaker(['args'])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|