torquespec 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/torque_spec/daemon.rb +1 -0
- data/lib/torquespec/daemon.rb +75 -0
- data/lib/torquespec/rspec.rb +46 -19
- data/lib/torquespec/torquespec.rb +7 -4
- data/lib/torquespec/version.rb +1 -1
- data/spec/hello_world_spec.rb +1 -1
- data/spec/remote_spec.rb +24 -0
- metadata +8 -4
@@ -0,0 +1 @@
|
|
1
|
+
require 'torquespec/daemon'
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'drb'
|
3
|
+
|
4
|
+
module TorqueSpec
|
5
|
+
class Daemon
|
6
|
+
|
7
|
+
def initialize(opts={})
|
8
|
+
puts "JC: create daemon opts=#{opts}"
|
9
|
+
@argv = opts['argv'].to_a
|
10
|
+
|
11
|
+
@options = RSpec::Core::ConfigurationOptions.new(@argv)
|
12
|
+
@options.parse_options
|
13
|
+
|
14
|
+
@configuration = RSpec::configuration
|
15
|
+
@world = RSpec::world
|
16
|
+
|
17
|
+
@options.configure(@configuration)
|
18
|
+
@configuration.load_spec_files
|
19
|
+
@configuration.configure_mock_framework
|
20
|
+
@configuration.configure_expectation_framework
|
21
|
+
end
|
22
|
+
|
23
|
+
def start
|
24
|
+
puts "JC: start daemon"
|
25
|
+
DRb.start_service("druby://127.0.0.1:#{TorqueSpec.drb_port}", self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def stop
|
29
|
+
puts "JC: stop daemon"
|
30
|
+
DRb.stop_service
|
31
|
+
end
|
32
|
+
|
33
|
+
def run(name, reporter)
|
34
|
+
puts "JC: run #{name}"
|
35
|
+
example_group = @world.example_groups.find { |g| g.name == name }
|
36
|
+
example_group.run( reporter )
|
37
|
+
end
|
38
|
+
|
39
|
+
# Intended to extend an RSpec::Core::ExampleGroup
|
40
|
+
module Client
|
41
|
+
# Delegate all examples (and nested groups) to remote daemon
|
42
|
+
def run_examples(reporter)
|
43
|
+
DRb.start_service("druby://127.0.0.1:0")
|
44
|
+
daemon = DRbObject.new_with_uri("druby://127.0.0.1:#{TorqueSpec.drb_port}")
|
45
|
+
begin
|
46
|
+
daemon.run( name, reporter )
|
47
|
+
rescue Exception
|
48
|
+
puts $!, $@
|
49
|
+
ensure
|
50
|
+
DRb.stop_service
|
51
|
+
end
|
52
|
+
end
|
53
|
+
# We have no nested groups locally, only remotely
|
54
|
+
def children
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# We don't actually serialize Proc objects, but we prevent a TypeError
|
62
|
+
# when an object containing a Proc is serialized, e.g. when an Example
|
63
|
+
# is passed to a remote Reporter. This works for us because the
|
64
|
+
# Reporter doesn't use the Example's Proc objects.
|
65
|
+
class Proc
|
66
|
+
def marshal_dump
|
67
|
+
end
|
68
|
+
def marshal_load *args
|
69
|
+
end
|
70
|
+
def _dump *args
|
71
|
+
end
|
72
|
+
def self._load *args
|
73
|
+
new {}
|
74
|
+
end
|
75
|
+
end
|
data/lib/torquespec/rspec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'torquespec/server'
|
2
|
-
|
3
1
|
begin
|
4
2
|
# RSpec v2
|
5
3
|
require 'rspec'
|
@@ -10,35 +8,64 @@ rescue Exception
|
|
10
8
|
TorqueSpec::Configurator = Spec::Runner
|
11
9
|
end
|
12
10
|
|
13
|
-
# Global configuration
|
14
11
|
TorqueSpec::Configurator.configure do |config|
|
15
|
-
|
16
12
|
# Add :deploy method to ExampleGroups
|
17
13
|
config.extend(TorqueSpec)
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
if ENV['TORQUEBOX_APP_NAME']
|
17
|
+
module TorqueSpec
|
18
|
+
def deploy(*descriptors)
|
19
|
+
end
|
22
20
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
else
|
22
|
+
require 'torquespec/server'
|
23
|
+
|
24
|
+
TorqueSpec::Configurator.configure do |config|
|
25
|
+
config.before(:suite) do
|
26
|
+
Thread.current[:app_server] = TorqueSpec::Server.new
|
27
|
+
Thread.current[:app_server].start(:wait => 120)
|
28
|
+
end
|
29
|
+
|
30
|
+
config.before(:all) do
|
31
|
+
if self.class.respond_to?( :deploy_paths )
|
32
|
+
self.class.deploy_paths.each do |path|
|
33
|
+
Thread.current[:app_server].deploy(path)
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
|
-
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
config.after(:all) do
|
39
|
+
if self.class.respond_to?( :deploy_paths )
|
40
|
+
self.class.deploy_paths.each do |path|
|
41
|
+
Thread.current[:app_server].undeploy(path)
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
45
|
+
|
46
|
+
config.after(:suite) do
|
47
|
+
Thread.current[:app_server].stop
|
48
|
+
end
|
38
49
|
end
|
50
|
+
end
|
39
51
|
|
40
|
-
|
41
|
-
|
52
|
+
require 'torquespec/daemon'
|
53
|
+
|
54
|
+
module TorqueSpec
|
55
|
+
module ObjectExtensions
|
56
|
+
def remote_describe(*args, &example_group_block)
|
57
|
+
group = describe(*args, &example_group_block)
|
58
|
+
ENV['TORQUEBOX_APP_NAME'] ? group : group.extend( TorqueSpec::Daemon::Client )
|
59
|
+
end
|
42
60
|
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class Object
|
64
|
+
include TorqueSpec::ObjectExtensions
|
65
|
+
end
|
43
66
|
|
67
|
+
module TorqueSpec
|
68
|
+
def self.rubylib
|
69
|
+
Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), "../../..", "*{spec,diff-lcs}*/lib"))).join(":")
|
70
|
+
end
|
44
71
|
end
|
@@ -3,19 +3,21 @@ require 'torquespec/deployment_descriptor'
|
|
3
3
|
module TorqueSpec
|
4
4
|
|
5
5
|
# Accepts any combination of hashes, filenames, or heredocs
|
6
|
-
def deploy(*descriptors)
|
6
|
+
def deploy(*descriptors, &block)
|
7
7
|
metaclass = class << self; self; end
|
8
8
|
metaclass.send(:define_method, :deploy_paths) do
|
9
|
+
return @deploy_paths if @deploy_paths
|
9
10
|
FileUtils.mkdir_p(TorqueSpec.knob_root) unless File.exist?(TorqueSpec.knob_root)
|
11
|
+
descriptors << block.call if block
|
10
12
|
i = descriptors.size > 1 ? 0 : nil
|
11
|
-
descriptors.map do |descriptor|
|
13
|
+
@deploy_paths = descriptors.map do |descriptor|
|
12
14
|
DeploymentDescriptor.new(descriptor, "#{self.display_name}#{i&&i-=1}").path
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
class << self
|
18
|
-
attr_accessor :knob_root, :jboss_home, :jvm_args, :max_heap, :lazy
|
20
|
+
attr_accessor :knob_root, :jboss_home, :jvm_args, :max_heap, :lazy, :drb_port
|
19
21
|
def configure
|
20
22
|
yield self
|
21
23
|
end
|
@@ -31,8 +33,9 @@ end
|
|
31
33
|
|
32
34
|
# Default TorqueSpec options
|
33
35
|
TorqueSpec.configure do |config|
|
36
|
+
config.drb_port = 7772
|
34
37
|
config.knob_root = ".torquespec"
|
35
38
|
config.jboss_home = ENV['JBOSS_HOME']
|
36
|
-
config.jvm_args = "-Xms64m -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -
|
39
|
+
config.jvm_args = "-Xms64m -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -Dgem.path=default"
|
37
40
|
end
|
38
41
|
|
data/lib/torquespec/version.rb
CHANGED
data/spec/hello_world_spec.rb
CHANGED
@@ -5,7 +5,7 @@ TorqueSpec.lazy = false
|
|
5
5
|
|
6
6
|
describe "simple knob deployment" do
|
7
7
|
|
8
|
-
deploy File.join( File.dirname(__FILE__), "../apps/simple.knob" )
|
8
|
+
deploy { File.join( File.dirname(__FILE__), "../apps/simple.knob" ) }
|
9
9
|
|
10
10
|
it "should greet the world" do
|
11
11
|
response = open("http://localhost:8080") {|f| f.read}
|
data/spec/remote_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'torquespec'
|
2
|
+
|
3
|
+
remote_describe "in-container tests" do
|
4
|
+
|
5
|
+
deploy <<-END.gsub(/^ {4}/,'')
|
6
|
+
application:
|
7
|
+
root: #{File.dirname(__FILE__)}/../apps/simple
|
8
|
+
services:
|
9
|
+
TorqueSpec::Daemon:
|
10
|
+
argv: #{ARGV.map{|x|File.expand_path(x)}.inspect}
|
11
|
+
environment:
|
12
|
+
RUBYLIB: #{TorqueSpec.rubylib}
|
13
|
+
END
|
14
|
+
|
15
|
+
it "should work" do
|
16
|
+
require 'torquebox/messaging/queue'
|
17
|
+
queue = TorqueBox::Messaging::Queue.start('/queues/foo', :jndi => "")
|
18
|
+
queue.publish('bar')
|
19
|
+
queue.receive.should == 'bar'
|
20
|
+
queue.stop
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torquespec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Crossley
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-05
|
19
|
+
date: 2011-06-05 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -63,15 +63,18 @@ files:
|
|
63
63
|
- apps/node-info.war
|
64
64
|
- apps/simple.knob
|
65
65
|
- apps/simple/config.ru
|
66
|
+
- lib/torque_spec/daemon.rb
|
66
67
|
- lib/torquespec.rb
|
67
68
|
- lib/torquespec/as6.rb
|
68
69
|
- lib/torquespec/as7.rb
|
70
|
+
- lib/torquespec/daemon.rb
|
69
71
|
- lib/torquespec/deployment_descriptor.rb
|
70
72
|
- lib/torquespec/rspec.rb
|
71
73
|
- lib/torquespec/server.rb
|
72
74
|
- lib/torquespec/torquespec.rb
|
73
75
|
- lib/torquespec/version.rb
|
74
76
|
- spec/hello_world_spec.rb
|
77
|
+
- spec/remote_spec.rb
|
75
78
|
- torquespec.gemspec
|
76
79
|
has_rdoc: true
|
77
80
|
homepage: http://github.com/torquebox/torquespec
|
@@ -109,3 +112,4 @@ specification_version: 3
|
|
109
112
|
summary: Deploy TorqueBox knobs to a running JBoss instance
|
110
113
|
test_files:
|
111
114
|
- spec/hello_world_spec.rb
|
115
|
+
- spec/remote_spec.rb
|