rspec-system 0.3.2 → 0.3.3
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/.travis.yml +1 -1
- data/README.md +52 -2
- data/lib/rspec-system/node_set/vagrant.rb +4 -4
- data/rspec-system.gemspec +1 -1
- data/spec/system/{basic_spec.rb → system_rcp_spec.rb} +1 -8
- data/spec/system/system_run_spec.rb +38 -0
- metadata +6 -4
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -115,6 +115,22 @@ In Jenkins you should be able to use RSPEC\_SET in a test matrix, thus obtaining
|
|
115
115
|
|
116
116
|
### Plugins to rspec-system
|
117
117
|
|
118
|
+
Right now we have two types of plugins, the framework is in a state of flux as to how one writes these things but here we go.
|
119
|
+
|
120
|
+
#### Helper libraries
|
121
|
+
|
122
|
+
Libraries that provide test helpers, and setup helpers for testing development on the software in question.
|
123
|
+
|
124
|
+
* rspec-system-puppet <http://rubygems.org/gems/rspec-system-puppet>
|
125
|
+
|
126
|
+
#### Node providers
|
127
|
+
|
128
|
+
A node provider should provide the ability to launch nodes (or if they are already launched provide information to get to them), run commands on nodes, transfer files and shutdown nodes.
|
129
|
+
|
130
|
+
That is, abstractions around other virtualisation, cloud or system tools. Right now we only have one of these for Vagrant using VirtualBox specifically and its in core.
|
131
|
+
|
132
|
+
#### The Future of Plugins
|
133
|
+
|
118
134
|
I want to start an eco-system of plugins for rspec-system, but do it in a sane way. Right now I see the following potential plugin types, if you think you can help please do:
|
119
135
|
|
120
136
|
* node providers - that is, abstractions around other virtualisation, cloud or system tools. Right now a NodeSet is tied to a virtual type, but I think this isn't granual enough. Some ideas for future providers are:
|
@@ -124,10 +140,44 @@ I want to start an eco-system of plugins for rspec-system, but do it in a sane w
|
|
124
140
|
* manual - not everything has to be 'launched' I can see a need for defining a static configuration for older machines that can't be poked and peeked. Of course, we might need to add cleanup tasks for this case.
|
125
141
|
* helper libraries - libraries that provide test helpers, and setup helpers for testing development on the software in question.
|
126
142
|
* distro - helpers that wrap common linux distro tasks, like package installation.
|
127
|
-
* puppet - helpers around installing different versions of puppet, PE as well - firing up masters. Perfect for testing modules I think. Puppet could be used a provisioner for setting up tests, as using shell commands for this purpose is a bit rough, not very idepotent and is re-inventing the wheel.
|
128
143
|
* mcollective - for launching the basics, activemq, broker clusters. Useful for testing mcollective agents.
|
129
144
|
* puppetdb - helpers for setting up puppetdb, probably using the modules we already have.
|
130
145
|
* other config management tools - for the purposes of testing modules against them, or using them for test setup provisioners like I've mentioned before with Puppet.
|
131
146
|
* others I'm sure ...
|
132
147
|
|
133
|
-
These could be shipped as external gems, and plugged in to the rspec-system framework somehow.
|
148
|
+
These could be shipped as external gems, and plugged in to the rspec-system framework somehow. Ideas on how to do this properly are very welcome, if you bring code as well :-).
|
149
|
+
|
150
|
+
### CI Integration
|
151
|
+
|
152
|
+
So currently I've only integrated this with Jenkins. If you have luck doing it on other CI platforms, feel free to add to this documentation.
|
153
|
+
|
154
|
+
#### Jenkins
|
155
|
+
|
156
|
+
My setup was:
|
157
|
+
|
158
|
+
* Single box - 32GB of RAM and 8 cpus
|
159
|
+
* Debian 7
|
160
|
+
* Jenkins 1.510 (installed via packages from the jenkins repos)
|
161
|
+
* Vagrant 1.1.5 (installed via packages from the vagrant site)
|
162
|
+
* VirtualBox 4.2.10 (installed via packages from virtualbox)
|
163
|
+
* RVM with Ruby 2.0.0
|
164
|
+
|
165
|
+
The setup for a job is basically:
|
166
|
+
|
167
|
+
* Setup your slave box to only have 1 executor (there is some bug here, something to do with vagrant not liking multiple projects)
|
168
|
+
* Create new matrix build
|
169
|
+
* Specify VCS settings etc. as per normal
|
170
|
+
* Create a user defined axis called 'RSPEC_SET' and add your nodesets in there: fedora-18-x64, centos-64-x64 etc.
|
171
|
+
* Use touchstone with a filter of RSPEC_SET=='centos-64-x64' so you don't chew up cycles running a whole batch of broken builds
|
172
|
+
* Create an execute shell job like so:
|
173
|
+
|
174
|
+
#!/bin/bash
|
175
|
+
set +e
|
176
|
+
|
177
|
+
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
178
|
+
rvm use ruby-2.0.0@some_unique_name_here --create
|
179
|
+
|
180
|
+
bundle update
|
181
|
+
rake spec:system
|
182
|
+
|
183
|
+
I went quite complex and had Github pull request integration working with this, and quite a few other nice features. If you need help setting it up get in touch.
|
@@ -53,10 +53,10 @@ module RSpecSystem
|
|
53
53
|
|
54
54
|
r = nil
|
55
55
|
Dir.chdir(@vagrant_path) do
|
56
|
-
|
57
|
-
log.debug("[vagrant#run] Running command: #{
|
58
|
-
r = systemu
|
59
|
-
log.debug("[Vagrant#run] Finished running command: #{
|
56
|
+
ex = "vagrant ssh #{dest} --command \"cd /tmp && sudo sh -c '#{cmd}'\""
|
57
|
+
log.debug("[vagrant#run] Running command: #{ex}")
|
58
|
+
r = systemu ex
|
59
|
+
log.debug("[Vagrant#run] Finished running command: #{ex}.")
|
60
60
|
end
|
61
61
|
|
62
62
|
{
|
data/rspec-system.gemspec
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
require 'spec_helper_system'
|
2
2
|
|
3
|
-
describe "
|
4
|
-
it "check system_run works" do
|
5
|
-
system_run("cat /etc/hosts") do |r|
|
6
|
-
r[:exit_code].should == 0
|
7
|
-
r[:stdout].should =~ /localhost/
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
3
|
+
describe "system_rcp:" do
|
11
4
|
it 'check system_rcp works' do
|
12
5
|
system_rcp(
|
13
6
|
:sp => fixture_root + 'example_dir',
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper_system'
|
2
|
+
|
3
|
+
describe "system_run:" do
|
4
|
+
it "cat /etc/hosts" do
|
5
|
+
system_run("cat /etc/hosts") do |r|
|
6
|
+
r[:exit_code].should == 0
|
7
|
+
r[:stdout].should =~ /localhost/
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'piping should be preserved' do
|
12
|
+
system_run('rm -f /tmp/foo')
|
13
|
+
system_run('echo "foo" > /tmp/foo') do |r|
|
14
|
+
r[:stderr].should == ''
|
15
|
+
r[:exit_code].should == 0
|
16
|
+
end
|
17
|
+
|
18
|
+
system_run('cat /tmp/foo') do |r|
|
19
|
+
r[:stdout].should =~ /foo/
|
20
|
+
r[:exit_code].should == 0
|
21
|
+
end
|
22
|
+
system_run('rm -f /tmp/foo')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'escape single quotes properly' do
|
26
|
+
system_run('rm -f /tmp/foo')
|
27
|
+
system_run("echo 'foo' > /tmp/foo") do |r|
|
28
|
+
r[:stderr].should == ''
|
29
|
+
r[:exit_code].should == 0
|
30
|
+
end
|
31
|
+
|
32
|
+
system_run('cat /tmp/foo') do |r|
|
33
|
+
r[:stdout].should =~ /foo/
|
34
|
+
r[:exit_code].should == 0
|
35
|
+
end
|
36
|
+
system_run('rm -f /tmp/foo')
|
37
|
+
end
|
38
|
+
end
|
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: 0.3.
|
4
|
+
version: 0.3.3
|
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-04-
|
12
|
+
date: 2013-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -103,7 +103,8 @@ files:
|
|
103
103
|
- spec/fixtures/nodeset_example2.yml
|
104
104
|
- spec/spec_helper.rb
|
105
105
|
- spec/spec_helper_system.rb
|
106
|
-
- spec/system/
|
106
|
+
- spec/system/system_rcp_spec.rb
|
107
|
+
- spec/system/system_run_spec.rb
|
107
108
|
- spec/unit/kwalify-schemas/nodeset_schema_spec.rb
|
108
109
|
- spec/unit/kwalify-schemas/prefabs_schema_spec.rb
|
109
110
|
homepage: https://github.com/kbarber/rspec-system
|
@@ -132,7 +133,8 @@ signing_key:
|
|
132
133
|
specification_version: 3
|
133
134
|
summary: System testing with rspec
|
134
135
|
test_files:
|
135
|
-
- spec/system/
|
136
|
+
- spec/system/system_rcp_spec.rb
|
137
|
+
- spec/system/system_run_spec.rb
|
136
138
|
- spec/unit/kwalify-schemas/nodeset_schema_spec.rb
|
137
139
|
- spec/unit/kwalify-schemas/prefabs_schema_spec.rb
|
138
140
|
has_rdoc:
|