rspec-system 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +34 -0
- data/README.md +37 -1
- data/lib/rspec-system/node.rb +7 -2
- data/lib/rspec-system/node_set.rb +3 -3
- data/lib/rspec-system/node_set/base.rb +4 -2
- data/lib/rspec-system/node_set/vagrant.rb +11 -10
- data/lib/rspec-system/node_set/vsphere.rb +2 -1
- data/lib/rspec-system/prefab.rb +8 -1
- data/lib/rspec-system/spec_helper.rb +5 -1
- data/rspec-system.gemspec +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
1.4.0
|
2
|
+
=====
|
3
|
+
|
4
|
+
This release adds the ability to provide a custom prefabs.yml.
|
5
|
+
|
6
|
+
To define custom prefabs you can now place a `.prefabs.yml` file in your projects root directory.
|
7
|
+
|
8
|
+
---
|
9
|
+
'scientific-64-x64':
|
10
|
+
description: ""
|
11
|
+
facts:
|
12
|
+
kernelrelease: "2.6.32-358.el6.x86_64"
|
13
|
+
operatingsystem: Scientific
|
14
|
+
kernelmajversion: "2.6"
|
15
|
+
architecture: x86_64
|
16
|
+
facterversion: "1.7.0"
|
17
|
+
kernelversion: "2.6.32"
|
18
|
+
operatingsystemrelease: "6.4"
|
19
|
+
osfamily: RedHat
|
20
|
+
kernel: Linux
|
21
|
+
rubyversion: "1.8.7"
|
22
|
+
provider_specifics:
|
23
|
+
vagrant:
|
24
|
+
box: 'scientific-64-x64-vb4210-nocm'
|
25
|
+
box_url: 'http://example.com/path/to/scientific-64-x64-vb4210-nocm.box'
|
26
|
+
|
27
|
+
This also supports overriding the built-in prefabs as well, in case you wish to use your own image files - or use a cache host for example.
|
28
|
+
|
29
|
+
#### Detailed Changes
|
30
|
+
|
31
|
+
* Allow overriding prefabs including using boxes on local system (Trey Dockendorf)
|
32
|
+
|
33
|
+
-------------------------------
|
34
|
+
|
1
35
|
1.3.0
|
2
36
|
=====
|
3
37
|
|
data/README.md
CHANGED
@@ -86,7 +86,7 @@ The file must adhere to the Kwalify schema supplied in `resources/kwalify-schema
|
|
86
86
|
|
87
87
|
### Prefabs
|
88
88
|
|
89
|
-
Prefabs are 'pre-rolled' virtual images, for now its the only way to specify a template.
|
89
|
+
Prefabs are 'pre-rolled' virtual images, for now its the only way to specify a template.
|
90
90
|
|
91
91
|
The current built-in prefabs are defined in `resources/prefabs.yml`. The current set are based on boxes hosted on <http://puppet-vagrant-boxes.puppetlabs.com> as they have been built by myself and are generally trusted and have a reproducable build cycle (they aren't just 'golden images'). In the future I'll probably expand that list, but attempt to stick to boxes that we have control over.
|
92
92
|
|
@@ -96,6 +96,42 @@ For this reason there are various `provider_specific` settings that apply to dif
|
|
96
96
|
|
97
97
|
`facts` in the prefab are literally dumps of `facter -p` on the host stored in the prefab file so you can look them up without addressing the machine. These are accessed using the `system_node#facts` method on the helper results and can be used in conditional logic during test runs and setup tasks. Not all the facts are supplied, only the more interesting ones.
|
98
98
|
|
99
|
+
#### Custom Prefabs
|
100
|
+
|
101
|
+
To define custom prefabs place a `.prefabs.yml` file in your project's root directory.
|
102
|
+
|
103
|
+
---
|
104
|
+
'scientific-64-x64':
|
105
|
+
description: ""
|
106
|
+
facts:
|
107
|
+
kernelrelease: "2.6.32-358.el6.x86_64"
|
108
|
+
operatingsystem: Scientific
|
109
|
+
kernelmajversion: "2.6"
|
110
|
+
architecture: x86_64
|
111
|
+
facterversion: "1.7.0"
|
112
|
+
kernelversion: "2.6.32"
|
113
|
+
operatingsystemrelease: "6.4"
|
114
|
+
osfamily: RedHat
|
115
|
+
kernel: Linux
|
116
|
+
rubyversion: "1.8.7"
|
117
|
+
provider_specifics:
|
118
|
+
vagrant:
|
119
|
+
box: 'scientific-64-x64-vb4210-nocm'
|
120
|
+
box_url: 'http://example.com/path/to/scientific-64-x64-vb4210-nocm.box'
|
121
|
+
|
122
|
+
#### Overriding Prefabs
|
123
|
+
|
124
|
+
The custom prefab file, `.prefabs.yml` can also be used to override any of the built-in Prefabs.
|
125
|
+
|
126
|
+
For example, to use a different box for CentOS 6.4 x64, you can override the `box_url`. The example below overrides the URL to use the box with configuration management already installed.
|
127
|
+
|
128
|
+
---
|
129
|
+
'centos-64-x64':
|
130
|
+
provider_specifics:
|
131
|
+
vagrant:
|
132
|
+
box: 'centos-64-x64-vbox4210'
|
133
|
+
box_url: 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box'
|
134
|
+
|
99
135
|
### Running tests
|
100
136
|
|
101
137
|
There are two providers at the moment you can use to launch your nodes for testing:
|
data/lib/rspec-system/node.rb
CHANGED
@@ -7,10 +7,12 @@ module RSpecSystem
|
|
7
7
|
# @param nodeset [RSpecSystem::Node] nodeset that this node belongs to
|
8
8
|
# @param k [String] name of node
|
9
9
|
# @param v [Hash<String,String>] hash configuration as given from the nodeset yaml file
|
10
|
+
# @param custom_prefabs_path [String] path of custom prefabs yaml file
|
10
11
|
# @return [RSpecSystem::Node] returns a new node object
|
11
|
-
def self.node_from_yaml(nodeset, k, v)
|
12
|
+
def self.node_from_yaml(nodeset, k, v, custom_prefabs_path)
|
12
13
|
RSpecSystem::Node.new(
|
13
14
|
:nodeset => nodeset,
|
15
|
+
:custom_prefabs_path => custom_prefabs_path,
|
14
16
|
:name => k,
|
15
17
|
:prefab => v['prefab']
|
16
18
|
)
|
@@ -23,16 +25,19 @@ module RSpecSystem
|
|
23
25
|
# @option options [String] :prefab prefab setting. Mandatory.
|
24
26
|
# @option options [RSpecSystem::NodeSet] :nodeset the parent nodeset for
|
25
27
|
# this node. Mandatory.
|
28
|
+
# @option options [String] :custom_prefabs_path path of custom prefabs
|
29
|
+
# yaml file. Optional.
|
26
30
|
def initialize(options)
|
27
31
|
@name = options[:name]
|
28
32
|
prefab = options[:prefab]
|
29
33
|
@nodeset = options[:nodeset]
|
34
|
+
@custom_prefabs_path = options[:custom_prefabs_path]
|
30
35
|
|
31
36
|
if prefab.nil?
|
32
37
|
# TODO: do not support not prefabs yet
|
33
38
|
raise "No prefab defined, bailing"
|
34
39
|
else
|
35
|
-
@prefab = RSpecSystem::Prefab.prefab(prefab)
|
40
|
+
@prefab = RSpecSystem::Prefab.prefab(prefab, custom_prefabs_path)
|
36
41
|
@facts = @prefab.facts
|
37
42
|
@provider_specifics = @prefab.provider_specifics
|
38
43
|
end
|
@@ -5,12 +5,12 @@ module RSpecSystem
|
|
5
5
|
#
|
6
6
|
# @return [RSpecSystem::NodeSet::Base] returns an object based on the Base
|
7
7
|
# abstract class.
|
8
|
-
def self.create(setname, config, virtual_env, options)
|
8
|
+
def self.create(setname, config, virtual_env, custom_prefabs_path, options)
|
9
9
|
case(virtual_env)
|
10
10
|
when 'vagrant'
|
11
|
-
RSpecSystem::NodeSet::Vagrant.new(setname, config, options)
|
11
|
+
RSpecSystem::NodeSet::Vagrant.new(setname, config, custom_prefabs_path, options)
|
12
12
|
when 'vsphere'
|
13
|
-
RSpecSystem::NodeSet::Vsphere.new(setname, config, options)
|
13
|
+
RSpecSystem::NodeSet::Vsphere.new(setname, config, custom_prefabs_path, options)
|
14
14
|
else
|
15
15
|
raise "Unsupported virtual environment #{virtual_env}"
|
16
16
|
end
|
@@ -6,18 +6,20 @@ module RSpecSystem
|
|
6
6
|
class NodeSet::Base
|
7
7
|
attr_reader :config
|
8
8
|
attr_reader :setname
|
9
|
+
attr_reader :custom_prefabs_path
|
9
10
|
attr_reader :nodes
|
10
11
|
attr_reader :destroy
|
11
12
|
|
12
13
|
# Create new NodeSet, populating necessary data structures.
|
13
|
-
def initialize(setname, config, options)
|
14
|
+
def initialize(setname, config, custom_prefabs_path, options)
|
14
15
|
@setname = setname
|
15
16
|
@config = config
|
17
|
+
@custom_prefabs_path = custom_prefabs_path
|
16
18
|
@destroy = options[:destroy]
|
17
19
|
|
18
20
|
@nodes = {}
|
19
21
|
config['nodes'].each do |k,v|
|
20
|
-
@nodes[k] = RSpecSystem::Node.node_from_yaml(self, k, v)
|
22
|
+
@nodes[k] = RSpecSystem::Node.node_from_yaml(self, k, v, custom_prefabs_path)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -14,8 +14,9 @@ module RSpecSystem
|
|
14
14
|
#
|
15
15
|
# @param setname [String] name of the set to instantiate
|
16
16
|
# @param config [Hash] nodeset configuration hash
|
17
|
+
# @param custom_prefabs_path [String] path of custom prefabs yaml file
|
17
18
|
# @param options [Hash] options Hash
|
18
|
-
def initialize(setname, config, options)
|
19
|
+
def initialize(setname, config, custom_prefabs_path, options)
|
19
20
|
super
|
20
21
|
@vagrant_path = File.expand_path(File.join(RSpec.configuration.system_tmp, 'vagrant_projects', setname))
|
21
22
|
end
|
@@ -134,16 +135,16 @@ module RSpecSystem
|
|
134
135
|
|
135
136
|
ps = v.provider_specifics['vagrant']
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
v.vm.
|
140
|
-
v.vm.
|
141
|
-
v.vm.
|
142
|
-
|
143
|
-
|
144
|
-
|
138
|
+
node_config = " c.vm.define '#{k}' do |v|\n"
|
139
|
+
node_config << " v.vm.host_name = '#{k}'\n"
|
140
|
+
node_config << " v.vm.box = '#{ps['box']}'\n"
|
141
|
+
node_config << " v.vm.box_url = '#{ps['box_url']}'\n" unless ps['box_url'].nil?
|
142
|
+
node_config << " v.vm.base_mac = '#{randmac}'\n"
|
143
|
+
node_config << " end\n"
|
144
|
+
|
145
|
+
f.write(node_config)
|
145
146
|
end
|
146
|
-
f.write(
|
147
|
+
f.write("end\n")
|
147
148
|
end
|
148
149
|
log.debug "[Vagrant#create_vagrantfile] Finished creating vagrant file"
|
149
150
|
nil
|
@@ -15,8 +15,9 @@ module RSpecSystem
|
|
15
15
|
#
|
16
16
|
# @param setname [String] name of the set to instantiate
|
17
17
|
# @param config [Hash] nodeset configuration hash
|
18
|
+
# @param custom_prefabs_path [String] path of custom prefabs yaml file
|
18
19
|
# @param options [Hash] options Hash
|
19
|
-
def initialize(setname, config, options)
|
20
|
+
def initialize(setname, config, custom_prefabs_path, options)
|
20
21
|
super
|
21
22
|
@vim = RbVmomi::VIM.connect(
|
22
23
|
:host => ENV["RSPEC_VSPHERE_HOST"],
|
data/lib/rspec-system/prefab.rb
CHANGED
@@ -7,8 +7,15 @@ module RSpecSystem
|
|
7
7
|
attr_reader :provider_specifics
|
8
8
|
|
9
9
|
# Return prefab object based on name
|
10
|
-
def self.prefab(name)
|
10
|
+
def self.prefab(name, custom_prefabs_path)
|
11
|
+
if File.exists?(custom_prefabs_path)
|
12
|
+
custom_prefabs = YAML.load_file(custom_prefabs_path)
|
13
|
+
else
|
14
|
+
custom_prefabs = {}
|
15
|
+
end
|
16
|
+
|
11
17
|
prefabs = YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'resources', 'prefabs.yml'))
|
18
|
+
prefabs.merge!(custom_prefabs)
|
12
19
|
raise "No such prefab" unless pf = prefabs[name]
|
13
20
|
|
14
21
|
RSpecSystem::Prefab.new(
|
@@ -22,6 +22,10 @@ RSpec.configure do |c|
|
|
22
22
|
Pathname.new(File.join(File.basename(__FILE__), '..', '.nodeset.yml'))
|
23
23
|
end
|
24
24
|
|
25
|
+
def custom_prefabs_path
|
26
|
+
File.expand_path(File.join(File.basename(__FILE__), '..', '.prefabs.yml'))
|
27
|
+
end
|
28
|
+
|
25
29
|
def rspec_system_config
|
26
30
|
YAML.load_file('.nodeset.yml')
|
27
31
|
end
|
@@ -42,7 +46,7 @@ RSpec.configure do |c|
|
|
42
46
|
config = rspec_system_config['sets'][setname]
|
43
47
|
options = {}
|
44
48
|
options[:destroy] = rspec_destroy
|
45
|
-
RSpecSystem::NodeSet.create(setname, config, rspec_virtual_env, options)
|
49
|
+
RSpecSystem::NodeSet.create(setname, config, rspec_virtual_env, custom_prefabs_path, options)
|
46
50
|
end
|
47
51
|
|
48
52
|
def start_nodes
|
data/rspec-system.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|