beaker-hostgenerator 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +4 -0
- data/HISTORY.md +233 -2
- data/README.md +50 -11
- data/beaker-hostgenerator.gemspec +2 -2
- data/lib/beaker-hostgenerator.rb +0 -1
- data/lib/beaker-hostgenerator/cli.rb +38 -26
- data/lib/beaker-hostgenerator/data.rb +960 -35
- data/lib/beaker-hostgenerator/generator.rb +57 -97
- data/lib/beaker-hostgenerator/hypervisor.rb +97 -0
- data/lib/beaker-hostgenerator/hypervisor/none.rb +17 -0
- data/lib/beaker-hostgenerator/hypervisor/vmpooler.rb +32 -0
- data/lib/beaker-hostgenerator/parser.rb +199 -0
- data/lib/beaker-hostgenerator/roles.rb +21 -14
- data/lib/beaker-hostgenerator/util.rb +10 -29
- data/lib/beaker-hostgenerator/version.rb +1 -1
- data/spec/beaker-hostgenerator/generator_spec.rb +73 -109
- data/spec/beaker-hostgenerator/parser_spec.rb +84 -0
- data/test/fixtures/default/cisconx-64a +1 -1
- data/test/fixtures/default/windows10ent-32d +22 -0
- data/test/fixtures/default/windows10ent-64f +22 -0
- data/test/fixtures/default/windows10pro-64m +22 -0
- data/test/fixtures/default/windows2003-6432d +22 -0
- data/test/fixtures/default/windows2003-64c +22 -0
- data/test/fixtures/default/windows2003r2-32f +22 -0
- data/test/fixtures/default/windows2003r2-6432aulcdfm +27 -0
- data/test/fixtures/default/windows2003r2-64m +22 -0
- data/test/fixtures/default/windows2008-6432u +22 -0
- data/test/fixtures/default/windows2008-64a +21 -0
- data/test/fixtures/default/windows2008r2-6432c +22 -0
- data/test/fixtures/default/windows2008r2-64l +22 -0
- data/test/fixtures/default/windows2012-6432f +22 -0
- data/test/fixtures/default/windows2012-64d +22 -0
- data/test/fixtures/default/windows2012r2-6432aulcdfm +27 -0
- data/test/fixtures/default/windows2012r2-64m +22 -0
- data/test/fixtures/default/windows7-64a +21 -0
- data/test/fixtures/default/windows8-64u +22 -0
- data/test/fixtures/default/windows81-64l +22 -0
- data/test/fixtures/default/windowsvista-64c +22 -0
- data/test/fixtures/multiplatform/arista4-32a-windows10pro-64-arista4-32aulcdfm +47 -0
- data/test/fixtures/multiplatform/centos4-32u-windows10ent-64-centos4-32m +43 -0
- data/test/fixtures/multiplatform/centos4-64l-windows10ent-32-centos4-64f +43 -0
- data/test/fixtures/multiplatform/centos5-32c-windowsvista-64-centos5-32d +43 -0
- data/test/fixtures/multiplatform/centos5-64d-windows81-64-centos5-64c +43 -0
- data/test/fixtures/multiplatform/centos6-32f-windows8-64-centos6-32l +43 -0
- data/test/fixtures/multiplatform/centos6-64m-windows7-64-centos6-64u +43 -0
- data/test/fixtures/multiplatform/centos7-64aulcdfm-windows2012r2-6432-centos7-64a +47 -0
- data/test/fixtures/multiplatform/cisconx-64a-windows2012r2-64-cisconx-64aulcdfm +53 -0
- data/test/fixtures/multiplatform/ciscoxr-64u-windows2012-6432-ciscoxr-64m +43 -0
- data/test/fixtures/multiplatform/cumulus25-64l-windows2012-64-cumulus25-64f +43 -0
- data/test/fixtures/multiplatform/debian6-32c-windows2008r2-6432-debian6-32d +43 -0
- data/test/fixtures/multiplatform/debian6-64d-windows2008r2-64-debian6-64c +43 -0
- data/test/fixtures/multiplatform/debian7-32f-windows2008-6432-debian7-32l +43 -0
- data/test/fixtures/multiplatform/debian7-64m-windows2008-64-debian7-64u +43 -0
- data/test/fixtures/multiplatform/debian8-32aulcdfm-windows2003r2-6432-debian8-32a +47 -0
- data/test/fixtures/multiplatform/debian8-64a-windows2003r2-64-debian8-64aulcdfm +47 -0
- data/test/fixtures/multiplatform/debian9-32u-windows2003r2-32-debian9-32m +43 -0
- data/test/fixtures/multiplatform/debian9-64l-windows2003-6432-debian9-64f +43 -0
- data/test/fixtures/multiplatform/fedora14-32l-solaris11-64-fedora14-32f +42 -0
- data/test/fixtures/multiplatform/fedora19-32c-solaris11-32-fedora19-32d +42 -0
- data/test/fixtures/multiplatform/fedora19-64d-solaris10-64-fedora19-64c +42 -0
- data/test/fixtures/multiplatform/fedora20-32f-solaris10-32-fedora20-32l +42 -0
- data/test/fixtures/multiplatform/fedora20-64m-sles12-64-fedora20-64u +42 -0
- data/test/fixtures/multiplatform/fedora21-32aulcdfm-sles11-64-fedora21-32a +46 -0
- data/test/fixtures/multiplatform/fedora21-64a-sles11-32-fedora21-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/fedora22-32u-sles10-64-fedora22-32m +42 -0
- data/test/fixtures/multiplatform/fedora22-64l-sles10-32-fedora22-64f +42 -0
- data/test/fixtures/multiplatform/fedora23-32c-scientific7-64-fedora23-32d +42 -0
- data/test/fixtures/multiplatform/fedora23-64d-scientific6-64-fedora23-64c +42 -0
- data/test/fixtures/multiplatform/opensuse11-32f-scientific6-32-opensuse11-32l +42 -0
- data/test/fixtures/multiplatform/opensuse11-64m-scientific5-64-opensuse11-64u +42 -0
- data/test/fixtures/multiplatform/oracle5-32c-windows2003-64-oracle5-32d +43 -0
- data/test/fixtures/multiplatform/oracle5-64d-ubuntu1604-64-oracle5-64c +42 -0
- data/test/fixtures/multiplatform/oracle6-32f-ubuntu1604-32-oracle6-32l +42 -0
- data/test/fixtures/multiplatform/oracle6-64m-ubuntu1510-64-oracle6-64u +42 -0
- data/test/fixtures/multiplatform/oracle7-64aulcdfm-ubuntu1510-32-oracle7-64a +46 -0
- data/test/fixtures/multiplatform/osx1010-64u-ubuntu1504-32-osx1010-64m +42 -0
- data/test/fixtures/multiplatform/osx1011-64l-ubuntu1404-64-osx1011-64f +42 -0
- data/test/fixtures/multiplatform/osx109-64a-ubuntu1504-64-osx109-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/redhat4-32c-ubuntu1404-32-redhat4-32d +42 -0
- data/test/fixtures/multiplatform/redhat4-64d-ubuntu1204-64-redhat4-64c +42 -0
- data/test/fixtures/multiplatform/redhat5-32f-ubuntu1204-32-redhat5-32l +42 -0
- data/test/fixtures/multiplatform/redhat5-64m-ubuntu1004-64-redhat5-64u +42 -0
- data/test/fixtures/multiplatform/redhat6-32aulcdfm-ubuntu1004-32-redhat6-32a +46 -0
- data/test/fixtures/multiplatform/redhat6-64a-solaris112-64-redhat6-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/redhat7-64u-solaris112-32-redhat7-64m +42 -0
- data/test/fixtures/multiplatform/scientific5-32aulcdfm-scientific5-32-scientific5-32a +46 -0
- data/test/fixtures/multiplatform/scientific5-64a-opensuse11-64-scientific5-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/scientific6-32u-opensuse11-32-scientific6-32m +42 -0
- data/test/fixtures/multiplatform/scientific6-64l-fedora23-64-scientific6-64f +42 -0
- data/test/fixtures/multiplatform/scientific7-64c-fedora23-32-scientific7-64d +42 -0
- data/test/fixtures/multiplatform/sles10-32d-fedora22-64-sles10-32c +42 -0
- data/test/fixtures/multiplatform/sles10-64f-fedora22-32-sles10-64l +42 -0
- data/test/fixtures/multiplatform/sles11-32m-fedora21-64-sles11-32u +42 -0
- data/test/fixtures/multiplatform/sles11-64aulcdfm-fedora21-32-sles11-64a +46 -0
- data/test/fixtures/multiplatform/sles12-64a-fedora20-64-sles12-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/solaris10-32u-fedora20-32-solaris10-32m +42 -0
- data/test/fixtures/multiplatform/solaris10-64l-fedora19-64-solaris10-64f +42 -0
- data/test/fixtures/multiplatform/solaris11-32c-fedora19-32-solaris11-32d +42 -0
- data/test/fixtures/multiplatform/solaris11-64d-fedora14-32-solaris11-64c +42 -0
- data/test/fixtures/multiplatform/solaris112-32f-redhat7-64-solaris112-32l +42 -0
- data/test/fixtures/multiplatform/solaris112-64m-redhat6-64-solaris112-64u +42 -0
- data/test/fixtures/multiplatform/ubuntu1004-32aulcdfm-redhat6-32-ubuntu1004-32a +46 -0
- data/test/fixtures/multiplatform/ubuntu1004-64a-redhat5-64-ubuntu1004-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/ubuntu1204-32u-redhat5-32-ubuntu1204-32m +42 -0
- data/test/fixtures/multiplatform/ubuntu1204-64l-redhat4-64-ubuntu1204-64f +42 -0
- data/test/fixtures/multiplatform/ubuntu1404-32c-redhat4-32-ubuntu1404-32d +42 -0
- data/test/fixtures/multiplatform/ubuntu1404-64d-osx1011-64-ubuntu1404-64c +42 -0
- data/test/fixtures/multiplatform/ubuntu1504-32f-osx1010-64-ubuntu1504-32l +42 -0
- data/test/fixtures/multiplatform/ubuntu1504-64m-osx109-64-ubuntu1504-64u +42 -0
- data/test/fixtures/multiplatform/ubuntu1510-32aulcdfm-oracle7-64-ubuntu1510-32a +46 -0
- data/test/fixtures/multiplatform/ubuntu1510-64a-oracle6-64-ubuntu1510-64aulcdfm +46 -0
- data/test/fixtures/multiplatform/ubuntu1604-32u-oracle6-32-ubuntu1604-32m +42 -0
- data/test/fixtures/multiplatform/ubuntu1604-64l-oracle5-64-ubuntu1604-64f +42 -0
- data/test/fixtures/multiplatform/windows10ent-32d-centos4-64-windows10ent-32c +44 -0
- data/test/fixtures/multiplatform/windows10ent-64f-centos4-32-windows10ent-64l +44 -0
- data/test/fixtures/multiplatform/windows10pro-64m-arista4-32-windows10pro-64u +44 -0
- data/test/fixtures/multiplatform/windows2003-6432d-debian9-64-windows2003-6432c +44 -0
- data/test/fixtures/multiplatform/windows2003-64c-oracle5-32-windows2003-64d +44 -0
- data/test/fixtures/multiplatform/windows2003r2-32f-debian9-32-windows2003r2-32l +44 -0
- data/test/fixtures/multiplatform/windows2003r2-6432aulcdfm-debian8-32-windows2003r2-6432a +48 -0
- data/test/fixtures/multiplatform/windows2003r2-64m-debian8-64-windows2003r2-64u +44 -0
- data/test/fixtures/multiplatform/windows2008-6432u-debian7-32-windows2008-6432m +44 -0
- data/test/fixtures/multiplatform/windows2008-64a-debian7-64-windows2008-64aulcdfm +48 -0
- data/test/fixtures/multiplatform/windows2008r2-6432c-debian6-32-windows2008r2-6432d +44 -0
- data/test/fixtures/multiplatform/windows2008r2-64l-debian6-64-windows2008r2-64f +44 -0
- data/test/fixtures/multiplatform/windows2012-6432f-ciscoxr-64-windows2012-6432l +44 -0
- data/test/fixtures/multiplatform/windows2012-64d-cumulus25-64-windows2012-64c +44 -0
- data/test/fixtures/multiplatform/windows2012r2-6432aulcdfm-centos7-64-windows2012r2-6432a +48 -0
- data/test/fixtures/multiplatform/windows2012r2-64m-cisconx-64-windows2012r2-64u +47 -0
- data/test/fixtures/multiplatform/windows7-64a-centos6-64-windows7-64aulcdfm +48 -0
- data/test/fixtures/multiplatform/windows8-64u-centos6-32-windows8-64m +44 -0
- data/test/fixtures/multiplatform/windows81-64l-centos5-64-windows81-64f +44 -0
- data/test/fixtures/multiplatform/windowsvista-64c-centos5-32-windowsvista-64d +44 -0
- data/test/fixtures/osinfo-version-0/cisconx-64a +1 -1
- data/test/fixtures/osinfo-version-0/windows10ent-32d +22 -0
- data/test/fixtures/osinfo-version-0/windows10ent-64f +22 -0
- data/test/fixtures/osinfo-version-0/windows10pro-64m +22 -0
- data/test/fixtures/osinfo-version-0/windows2003-6432d +22 -0
- data/test/fixtures/osinfo-version-0/windows2003-64c +22 -0
- data/test/fixtures/osinfo-version-0/windows2003r2-32f +22 -0
- data/test/fixtures/osinfo-version-0/windows2003r2-6432aulcdfm +27 -0
- data/test/fixtures/osinfo-version-0/windows2003r2-64m +22 -0
- data/test/fixtures/osinfo-version-0/windows2008-6432u +22 -0
- data/test/fixtures/osinfo-version-0/windows2008-64a +21 -0
- data/test/fixtures/osinfo-version-0/windows2008r2-6432c +22 -0
- data/test/fixtures/osinfo-version-0/windows2008r2-64l +22 -0
- data/test/fixtures/osinfo-version-0/windows2012-6432f +22 -0
- data/test/fixtures/osinfo-version-0/windows2012-64d +22 -0
- data/test/fixtures/osinfo-version-0/windows2012r2-6432aulcdfm +27 -0
- data/test/fixtures/osinfo-version-0/windows2012r2-64m +22 -0
- data/test/fixtures/osinfo-version-0/windows7-64a +21 -0
- data/test/fixtures/osinfo-version-0/windows8-64u +22 -0
- data/test/fixtures/osinfo-version-0/windows81-64l +22 -0
- data/test/fixtures/osinfo-version-0/windowsvista-64c +22 -0
- data/test/fixtures/osinfo-version-1/cisconx-64a +1 -1
- data/test/fixtures/osinfo-version-1/windows10ent-32d +22 -0
- data/test/fixtures/osinfo-version-1/windows10ent-64f +22 -0
- data/test/fixtures/osinfo-version-1/windows10pro-64m +22 -0
- data/test/fixtures/osinfo-version-1/windows2003-6432d +22 -0
- data/test/fixtures/osinfo-version-1/windows2003-64c +22 -0
- data/test/fixtures/osinfo-version-1/windows2003r2-32f +22 -0
- data/test/fixtures/osinfo-version-1/windows2003r2-6432aulcdfm +27 -0
- data/test/fixtures/osinfo-version-1/windows2003r2-64m +22 -0
- data/test/fixtures/osinfo-version-1/windows2008-6432u +22 -0
- data/test/fixtures/osinfo-version-1/windows2008-64a +21 -0
- data/test/fixtures/osinfo-version-1/windows2008r2-6432c +22 -0
- data/test/fixtures/osinfo-version-1/windows2008r2-64l +22 -0
- data/test/fixtures/osinfo-version-1/windows2012-6432f +22 -0
- data/test/fixtures/osinfo-version-1/windows2012-64d +22 -0
- data/test/fixtures/osinfo-version-1/windows2012r2-6432aulcdfm +27 -0
- data/test/fixtures/osinfo-version-1/windows2012r2-64m +22 -0
- data/test/fixtures/osinfo-version-1/windows7-64a +21 -0
- data/test/fixtures/osinfo-version-1/windows8-64u +22 -0
- data/test/fixtures/osinfo-version-1/windows81-64l +22 -0
- data/test/fixtures/osinfo-version-1/windowsvista-64c +22 -0
- data/test/fixtures/per-host-settings/arbitrary-settings.yaml +57 -0
- data/test/fixtures/per-host-settings/every-hypervisor.yaml +30 -0
- data/test/fixtures/per-host-settings/malformed-input.yaml +5 -0
- data/test/test_stdout.rb +2 -2
- data/test/util/generator_helpers.rb +12 -4
- metadata +167 -6
- data/lib/beaker-hostgenerator/data/vmpooler.rb +0 -467
- data/lib/beaker-hostgenerator/generator/vmpooler.rb +0 -59
- data/test/test_util.rb +0 -26
@@ -1,22 +1,29 @@
|
|
1
|
-
require 'beaker-hostgenerator/data'
|
2
|
-
require 'beaker-hostgenerator/data/vmpooler'
|
3
|
-
require 'deep_merge'
|
4
|
-
|
5
1
|
module BeakerHostGenerator
|
6
|
-
|
2
|
+
module Roles
|
7
3
|
|
8
|
-
|
9
|
-
|
4
|
+
ROLES = {
|
5
|
+
'a' => 'agent',
|
6
|
+
'u' => 'ca',
|
7
|
+
'l' => 'classifier',
|
8
|
+
'c' => 'dashboard',
|
9
|
+
'd' => 'database',
|
10
|
+
'f' => 'frictionless',
|
11
|
+
'm' => 'master',
|
12
|
+
}
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
'
|
14
|
-
'
|
15
|
-
|
16
|
-
'environmentpath' => '/etc/puppetlabs/puppet/environments',
|
17
|
-
}
|
14
|
+
ROLE_CONFIG = {
|
15
|
+
'compile_master' => {
|
16
|
+
'main' => {
|
17
|
+
'dns_alt_names' => 'puppet',
|
18
|
+
'environmentpath' => '/etc/puppetlabs/puppet/environments',
|
18
19
|
}
|
19
20
|
}
|
21
|
+
}
|
22
|
+
|
23
|
+
module_function
|
24
|
+
|
25
|
+
def get_role_config(role)
|
26
|
+
ROLE_CONFIG[role] || {}
|
20
27
|
end
|
21
28
|
end
|
22
29
|
end
|
@@ -1,36 +1,25 @@
|
|
1
1
|
require 'beaker-hostgenerator/data'
|
2
|
-
require 'beaker-hostgenerator/
|
2
|
+
require 'beaker-hostgenerator/roles'
|
3
|
+
require 'beaker-hostgenerator/hypervisor/vmpooler'
|
3
4
|
require 'deep_merge'
|
4
5
|
|
5
6
|
module BeakerHostGenerator
|
6
7
|
module Utils
|
7
|
-
|
8
|
-
include BeakerHostGenerator::Data::Vmpooler
|
8
|
+
module_function
|
9
9
|
|
10
10
|
def pe_dir(version, family)
|
11
|
-
|
12
|
-
# released version. Use the archive path. Otherwise, we want to use
|
13
|
-
# the development build path.
|
14
|
-
if version && family
|
15
|
-
if version == family
|
16
|
-
return "http://enterprise.delivery.puppetlabs.net/archives/releases/#{family}/"
|
17
|
-
else
|
18
|
-
return "http://enterprise.delivery.puppetlabs.net/#{family}/ci-ready"
|
19
|
-
end
|
20
|
-
end
|
11
|
+
BeakerHostGenerator::Data.pe_dir(version, family)
|
21
12
|
end
|
22
13
|
|
23
14
|
def fixup_node(cfg)
|
24
|
-
|
25
|
-
if cfg['platform'] =~ /el-4/ and pe_version =~ /2\.8/
|
26
|
-
cfg['pe_ver'] = "2.0.3"
|
27
|
-
end
|
15
|
+
BeakerHostGenerator::Data.fixup_node(cfg)
|
28
16
|
end
|
29
17
|
|
30
18
|
def dump_hosts(hosts, path)
|
19
|
+
vmpooler_hypervisor = BeakerHostGenerator::Hypervisor::Vmpooler.new
|
31
20
|
config = {}
|
32
|
-
config.deep_merge! BASE_CONFIG
|
33
|
-
config.deep_merge!
|
21
|
+
config.deep_merge! BeakerHostGenerator::Data.BASE_CONFIG
|
22
|
+
config['CONFIG'].deep_merge! vmpooler_hypervisor.global_config()
|
34
23
|
|
35
24
|
hosts.each do |host|
|
36
25
|
config['HOSTS'][host.node_name] = {
|
@@ -46,19 +35,11 @@ module BeakerHostGenerator
|
|
46
35
|
end
|
47
36
|
|
48
37
|
def get_platforms(hypervisor_type='vmpooler', bhg_version=0)
|
49
|
-
|
50
|
-
when /vmpooler/
|
51
|
-
osinfo = BeakerHostGenerator::Data::Vmpooler.get_osinfo(bhg_version)
|
52
|
-
else
|
53
|
-
raise "Invalid hypervisor #{hypervisor_type}"
|
54
|
-
end
|
55
|
-
return osinfo
|
38
|
+
BeakerHostGenerator::Data.get_platforms(bhg_version)
|
56
39
|
end
|
57
40
|
|
58
41
|
def get_roles
|
59
|
-
|
42
|
+
BeakerHostGenerator::Roles.ROLES
|
60
43
|
end
|
61
|
-
|
62
|
-
module_function :get_roles, :get_platforms, :dump_hosts, :fixup_node, :pe_dir
|
63
44
|
end
|
64
45
|
end
|
@@ -6,125 +6,89 @@ require 'beaker-hostgenerator'
|
|
6
6
|
require 'util/generator_helpers'
|
7
7
|
|
8
8
|
module BeakerHostGenerator
|
9
|
-
|
10
|
-
|
11
|
-
{
|
12
|
-
list_platforms_and_roles: false,
|
13
|
-
disable_default_role: false,
|
14
|
-
disable_role_config: false,
|
15
|
-
hypervisor: 'vmpooler',
|
16
|
-
}
|
17
|
-
}
|
18
|
-
let(:generator) { BeakerHostGenerator::Generator.new(options) }
|
9
|
+
describe Generator do
|
10
|
+
let(:generator) { BeakerHostGenerator::Generator.new }
|
19
11
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
12
|
+
describe 'get_host_roles' do
|
13
|
+
it 'Expands default roles and merges in arbitrary roles' do
|
14
|
+
{
|
15
|
+
{
|
16
|
+
"roles" => "aulcdfm",
|
17
|
+
"arbitrary_roles" => [],
|
18
|
+
} => [
|
19
|
+
'agent',
|
20
|
+
'ca',
|
21
|
+
'classifier',
|
22
|
+
'dashboard',
|
23
|
+
'database',
|
24
|
+
'frictionless',
|
25
|
+
'master',
|
26
|
+
],
|
27
|
+
{
|
28
|
+
"roles" => "a",
|
29
|
+
"arbitrary_roles" => ["meow","hello","compile_master"],
|
30
|
+
} => [
|
31
|
+
'agent',
|
32
|
+
'meow',
|
33
|
+
'hello',
|
34
|
+
'compile_master',
|
35
|
+
],
|
36
|
+
{
|
37
|
+
"roles" => "",
|
38
|
+
"arbitrary_roles" => ["compile_master"],
|
39
|
+
} => [
|
40
|
+
'compile_master'
|
41
|
+
],
|
42
|
+
{
|
43
|
+
"roles" => "",
|
44
|
+
"arbitrary_roles" => [],
|
45
|
+
} => [],
|
46
|
+
}.each do |node_info, roles|
|
47
|
+
expect( generator.get_host_roles(node_info) ).to eq( roles )
|
58
48
|
end
|
49
|
+
end
|
50
|
+
end
|
59
51
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
node_info = generator.__parse_node_info_token("64")
|
69
|
-
expect( node_info ).to eq({
|
70
|
-
"roles" => "",
|
71
|
-
"arbitrary_roles" => [],
|
72
|
-
"bits" => "64",
|
73
|
-
})
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'Supports the use of arbitrary roles.' do
|
77
|
-
node_info = generator.__parse_node_info_token("64compile_master,ca,blah.mad")
|
78
|
-
expect( node_info ).to eq({
|
79
|
-
"roles" => "mad",
|
80
|
-
"arbitrary_roles" => ["compile_master", "ca", "blah"],
|
81
|
-
"bits" => "64",
|
82
|
-
})
|
83
|
-
end
|
52
|
+
shared_examples "fixtures" do |fixture_hash|
|
53
|
+
arguments = fixture_hash["arguments_string"]
|
54
|
+
it "beaker-hostgenerator #{arguments}" do
|
55
|
+
arguments = arguments.split
|
56
|
+
STDERR.reopen("stderr.txt", "w")
|
57
|
+
fixture_hash['environment_variables'].each do |key, value|
|
58
|
+
ENV[key] = value
|
59
|
+
end
|
84
60
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
"roles" => "",
|
94
|
-
"arbitrary_roles" => ["compile_master", "ca", "blah"],
|
95
|
-
"bits" => "64",
|
96
|
-
})
|
97
|
-
end
|
61
|
+
cli = BeakerHostGenerator::CLI.new(arguments)
|
62
|
+
if fixture_hash['expected_exception']
|
63
|
+
# Turn fully-qualified classname string into actual Class object.
|
64
|
+
# We have to manually descend into each Module that makes up the
|
65
|
+
# fully-qualified path to the error class.
|
66
|
+
qualified_classname = fixture_hash['expected_exception'].split('::')
|
67
|
+
expected_class = qualified_classname.reduce(Object) do |accum, e|
|
68
|
+
accum.const_get(e)
|
98
69
|
end
|
70
|
+
expect { cli.execute }.to raise_error(expected_class)
|
71
|
+
else
|
72
|
+
test_hash = YAML.load(cli.execute)
|
73
|
+
expect(test_hash).to eq(fixture_hash['expected_hash'])
|
99
74
|
end
|
100
75
|
|
101
|
-
|
102
|
-
|
103
|
-
it "beaker-hostgenerator #{arguments}" do
|
104
|
-
arguments = arguments.split
|
105
|
-
STDERR.reopen("stderr.txt", "w")
|
106
|
-
fixture_hash['environment_variables'].each do |key, value|
|
107
|
-
ENV[key] = value
|
108
|
-
end
|
109
|
-
cli = BeakerHostGenerator::CLI.new(arguments)
|
110
|
-
test_hash = YAML.load(cli.execute)
|
111
|
-
fixture_hash['environment_variables'].each_key do |key|
|
112
|
-
ENV[key] = nil
|
113
|
-
end
|
114
|
-
expect(test_hash).to eq(fixture_hash["expected_hash"])
|
115
|
-
end
|
76
|
+
fixture_hash['environment_variables'].each_key do |key|
|
77
|
+
ENV[key] = nil
|
116
78
|
end
|
79
|
+
end
|
80
|
+
end
|
117
81
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
124
|
-
include_examples "fixtures", YAML.load_file(f)
|
125
|
-
end
|
82
|
+
context "Fixtures" do
|
83
|
+
Find.find 'test/fixtures' do |f|
|
84
|
+
context "#{f}" do
|
85
|
+
if File.directory?(f)
|
86
|
+
next
|
126
87
|
end
|
88
|
+
include_examples "fixtures", YAML.load_file(f)
|
127
89
|
end
|
128
|
-
|
129
90
|
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
130
94
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'beaker-hostgenerator/parser'
|
2
|
+
|
3
|
+
module BeakerHostGenerator
|
4
|
+
describe Parser do
|
5
|
+
include BeakerHostGenerator::Parser
|
6
|
+
|
7
|
+
describe 'parse_node_info_token' do
|
8
|
+
|
9
|
+
it 'Raises InvalidNodeSpecError for invalid tokens.' do
|
10
|
+
expect { parse_node_info_token("64compile_master") }.
|
11
|
+
to raise_error(BeakerHostGenerator::Exceptions::InvalidNodeSpecError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'Supports no roles in the spec.' do
|
15
|
+
expect( parse_node_info_token("64") ).
|
16
|
+
to eq({
|
17
|
+
"roles" => "",
|
18
|
+
"arbitrary_roles" => [],
|
19
|
+
"bits" => "64",
|
20
|
+
"host_settings" => {}
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'Supports the use of arbitrary roles.' do
|
25
|
+
expect( parse_node_info_token("64compile_master,ca,blah.mad") ).
|
26
|
+
to eq({
|
27
|
+
"roles" => "mad",
|
28
|
+
"arbitrary_roles" => ["compile_master", "ca", "blah"],
|
29
|
+
"bits" => "64",
|
30
|
+
"host_settings" => {}
|
31
|
+
})
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'When using arbitrary roles' do
|
35
|
+
|
36
|
+
it 'Fails without a role-type delimiter (a period)' do
|
37
|
+
expect { parse_node_info_token("64compile_master,ca,blah") }.
|
38
|
+
to raise_error(BeakerHostGenerator::Exceptions::InvalidNodeSpecError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'It supports no static roles.' do
|
42
|
+
expect( parse_node_info_token("64compile_master,ca,blah.") ).
|
43
|
+
to eq({
|
44
|
+
"roles" => "",
|
45
|
+
"arbitrary_roles" => ["compile_master", "ca", "blah"],
|
46
|
+
"bits" => "64",
|
47
|
+
"host_settings" => {}
|
48
|
+
})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'When using arbitrary host settings' do
|
53
|
+
it 'Supports arbitrary whitespace' do
|
54
|
+
expect( parse_node_info_token("64{ k1=v1, k2=v2, k3 = v3 , k4 =v4 }") ).
|
55
|
+
to eq({
|
56
|
+
"roles" => "",
|
57
|
+
"arbitrary_roles" => [],
|
58
|
+
"bits" => "64",
|
59
|
+
"host_settings" => {
|
60
|
+
"k1" => "v1",
|
61
|
+
"k2" => "v2",
|
62
|
+
"k3" => "v3",
|
63
|
+
"k4" => "v4"
|
64
|
+
}
|
65
|
+
})
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'Raises InvalidNodeSpecError for malformed key-value pairs' do
|
69
|
+
expect { parse_node_info_token("64{foo=bar=baz}") }.
|
70
|
+
to raise_error(BeakerHostGenerator::Exceptions::InvalidNodeSpecError)
|
71
|
+
|
72
|
+
expect { parse_node_info_token("64{foo=}") }.
|
73
|
+
to raise_error(BeakerHostGenerator::Exceptions::InvalidNodeSpecError)
|
74
|
+
|
75
|
+
expect { parse_node_info_token("64{=bar}") }.
|
76
|
+
to raise_error(BeakerHostGenerator::Exceptions::InvalidNodeSpecError)
|
77
|
+
|
78
|
+
expect { parse_node_info_token("64{=}") }.
|
79
|
+
to raise_error(BeakerHostGenerator::Exceptions::InvalidNodeSpecError)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
arguments_string: windows10ent-32d
|
3
|
+
environment_variables: {}
|
4
|
+
expected_hash:
|
5
|
+
HOSTS:
|
6
|
+
windows10ent-32-1:
|
7
|
+
pe_dir:
|
8
|
+
pe_ver:
|
9
|
+
pe_upgrade_dir:
|
10
|
+
pe_upgrade_ver:
|
11
|
+
hypervisor: vmpooler
|
12
|
+
platform: windows-10ent-32
|
13
|
+
ruby_arch: x86
|
14
|
+
template: win-10-ent-i386
|
15
|
+
roles:
|
16
|
+
- agent
|
17
|
+
- database
|
18
|
+
CONFIG:
|
19
|
+
nfs_server: none
|
20
|
+
consoleport: 443
|
21
|
+
pooling_api: http://vmpooler.delivery.puppetlabs.net/
|
22
|
+
expected_exception:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
arguments_string: windows10ent-64f
|
3
|
+
environment_variables: {}
|
4
|
+
expected_hash:
|
5
|
+
HOSTS:
|
6
|
+
windows10ent-64-1:
|
7
|
+
pe_dir:
|
8
|
+
pe_ver:
|
9
|
+
pe_upgrade_dir:
|
10
|
+
pe_upgrade_ver:
|
11
|
+
hypervisor: vmpooler
|
12
|
+
platform: windows-10ent-64
|
13
|
+
ruby_arch: x64
|
14
|
+
template: win-10-ent-x86_64
|
15
|
+
roles:
|
16
|
+
- agent
|
17
|
+
- frictionless
|
18
|
+
CONFIG:
|
19
|
+
nfs_server: none
|
20
|
+
consoleport: 443
|
21
|
+
pooling_api: http://vmpooler.delivery.puppetlabs.net/
|
22
|
+
expected_exception:
|