tlb-cucumber 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +31 -51
- data/{lib → cucumber/lib}/tlb/cucumber/lib/configuration_inflection.rb +2 -1
- data/{lib → cucumber/lib}/tlb/cucumber/lib/run_data_formatter.rb +1 -1
- data/{lib → cucumber/lib}/tlb/cucumber/lib/test_splitter.rb +1 -1
- data/{lib → cucumber/lib}/tlb/cucumber/rake/cucumber_task.rb +0 -1
- metadata +67 -102
- data/.emacs_project.template +0 -21
- data/.gitignore +0 -8
- data/.gitmodules +0 -3
- data/Rakefile +0 -27
- data/gem_common.rb +0 -64
- data/lib/tasks/tlb.rake +0 -12
- data/lib/tlb.rb +0 -238
- data/lib/tlb/run_data.rb +0 -55
- data/lib/tlb/util.rb +0 -11
- data/spike/Rakefile +0 -12
- data/spike/features/step_definitions/addition.rb +0 -18
- data/spike/features/step_definitions/answer.rb +0 -13
- data/spike/features/step_definitions/sub.rb +0 -18
- data/spike/features/sub.feature +0 -6
- data/spike/features/sum.feature +0 -6
- data/spike/features/the_answer.feature +0 -6
- data/test.sh +0 -42
- data/tlb-cucumber.gemspec +0 -9
- data/tlb-rspec2.gemspec +0 -10
- data/tlb-testunit.gemspec +0 -8
data/README.markdown
CHANGED
@@ -1,66 +1,46 @@
|
|
1
|
-
## Using
|
1
|
+
## Using tlb.rb:
|
2
2
|
|
3
|
-
|
3
|
+
__tlb.rb__ uses [tlb](https://github.com/test-load-balancer/tlb "TLB") under the hood. It runs a sub-process which talks to the actual tlb-server(or equivallent) to balance and post run-feedback.
|
4
4
|
Balancer process is actually an HTTP server which listen to a certain TCP port so tlb-ruby library can talk to it.
|
5
5
|
This is controlled by an environment variable named *'TLB_BALANCER_PORT'*, which can be set to any port number(integer between 1024 to 65535) that is guaranteed to remain un-bound while the build runs.
|
6
6
|
|
7
|
-
In addition to this extra environment variable, the usual TLB environment variable setup is required(so the balancer knows things like what partitioning algorithm to use or
|
7
|
+
In addition to this extra environment variable, the usual TLB environment variable setup is required(so the balancer knows things like what partitioning algorithm to use or the type of server it has to talk to etc).
|
8
8
|
Detailed documentation of TLB environment variable configuration is available at [http://test-load-balancer.github.com](http://test-load-balancer.github.com "Tlb Documentation")
|
9
9
|
|
10
|
-
|
10
|
+
__tlb.rb__ supports RSpec(1.x and 2.x), Cucumber and Test::Unit, which are the most widely used testing frameworks in the Ruby world.
|
11
11
|
|
12
|
-
|
12
|
+
__tlb.rb__ is fully compatible with both Ruby 1.9 and 1.8 across __MRI__ and __JRuby__. However, 1.9 support will be available only version 0.3.2 onwards.
|
13
13
|
|
14
|
-
|
14
|
+
We test __tlb.rb__ on MRI and JRuby, however it should work with other flavours of Ruby(like REE) as well.
|
15
15
|
|
16
|
-
|
17
|
-
__RSpec-1.x__:
|
18
|
-
require 'rubygems'
|
19
|
-
gem 'tlb-rspec1'
|
20
|
-
require 'tlb/spec_task'
|
21
|
-
|
22
|
-
Tlb::SpecTask.new(:balanced_specs) do |t|
|
23
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
-
t.spec_opts << "--format progress"
|
25
|
-
end
|
26
|
-
|
27
|
-
load 'tasks/tlb.rake'
|
28
|
-
desc "run specs load-balanced(based on environment variables)"
|
29
|
-
task :bal => ['tlb:start', :balanced_specs]
|
16
|
+
## Getting tlb.rb:
|
30
17
|
|
31
|
-
|
32
|
-
|
33
|
-
gem 'tlb-rspec2'
|
34
|
-
require 'tlb/rspec/spec_task'
|
35
|
-
|
36
|
-
Tlb::RSpec::SpecTask.new(:run_balanced) do |t|
|
37
|
-
t.pattern = 'spec/**/*_spec.rb'
|
38
|
-
end
|
39
|
-
|
40
|
-
load 'tasks/tlb.rake'
|
41
|
-
desc "run specs load-balanced(based on environment variables)"
|
42
|
-
task :bal => ['tlb:start', :run_balanced]
|
18
|
+
__RSpec2__ support(both __1.9__ and __1.8__):
|
19
|
+
$ gem install tlb-rspec2
|
43
20
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
21
|
+
__Cucumber__ support(both __1.9__ and __1.8__):
|
22
|
+
$ gem install tlb-cucumber
|
23
|
+
|
24
|
+
__RSpec1__ support(both __1.9__ and __1.8__):
|
25
|
+
$ gem install tlb-rspec1
|
26
|
+
|
27
|
+
__Test::Unit__ support on Ruby __1.9__:(available 0.3.2 onwards)
|
28
|
+
$ gem install tlb-testunit19
|
29
|
+
|
30
|
+
__Test::Unit__ support on Ruby __1.8__:(available 0.3.2 onwards)
|
31
|
+
$ gem install tlb-testunit18
|
55
32
|
|
56
|
-
|
33
|
+
If a version older than 0.3.2, please use
|
34
|
+
$ gem install tlb-testunit
|
35
|
+
for Test::Unit support.
|
57
36
|
|
58
|
-
|
59
|
-
|
60
|
-
|
37
|
+
## Setting it up for your project
|
38
|
+
|
39
|
+
Please refer documentation on [http://test-load-balancer.github.com/](http://test-load-balancer.github.com/ "TLB Website") for detailed setup instructions.
|
40
|
+
|
41
|
+
Documentation also explains TLB concepts and customization options in fair amount of detail. We highly recomend going through the TLB documentation.
|
42
|
+
|
43
|
+
## Want a feature? Found a bug?
|
61
44
|
|
62
|
-
|
63
|
-
The branch '__master__' supports __Test::Unit__ and __RSpec-2.x__. If you use __RSpec-1__(i.e. __1.3.x__ etc), please use the branch named '__rspec-1__'.
|
64
|
-
Having said that, we encourage end-users to use the released gem versions insteed of using upstream snapshot. Detailed documentation for every released version is available at http://test-load-balancer.github.com.
|
65
|
-
Please post any issues on our [Issue Tracker](http://code.google.com/p/tlb/issues/list "Issue Tracker").
|
45
|
+
Post it at [Issue Tracker](http://code.google.com/p/tlb/issues/list "Issue Tracker").
|
66
46
|
|
metadata
CHANGED
@@ -1,67 +1,53 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlb-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 1
|
9
|
-
version: 0.3.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
|
-
|
13
|
-
|
8
|
+
- Janmejay Singh
|
9
|
+
- Pavan KS
|
14
10
|
autorequire:
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
13
|
|
18
|
-
date: 2011-05-
|
19
|
-
default_executable:
|
14
|
+
date: 2011-05-27 00:00:00 Z
|
20
15
|
dependencies:
|
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
|
-
segments:
|
55
|
-
- 0
|
56
|
-
- 10
|
57
|
-
- 2
|
58
|
-
version: 0.10.2
|
59
|
-
type: :runtime
|
60
|
-
version_requirements: *id003
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rake
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tlb-core
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - "="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.3.2
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: cucumber
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.10.2
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
61
49
|
description: |
|
62
|
-
TLB
|
63
|
-
TLB.rb test suite is not bundled, please check http://github.com/test-load-balancer/tlb.rb for tests.
|
64
|
-
Detailed documentation is available at http://test-load-balancer.github.com.
|
50
|
+
TLB-Ruby component that provides support for load balancing tests written using cucumber. This library consumes APIs provided by tlb-core.
|
65
51
|
|
66
52
|
email: singh.janmejay@gmail.com;itspanzi@gmail.com
|
67
53
|
executables: []
|
@@ -69,80 +55,59 @@ executables: []
|
|
69
55
|
extensions: []
|
70
56
|
|
71
57
|
extra_rdoc_files:
|
72
|
-
|
58
|
+
- README.markdown
|
73
59
|
files:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
- gem_common.rb
|
80
|
-
- lib/tasks/tlb.rake
|
81
|
-
- lib/tlb.rb
|
82
|
-
- lib/tlb/cucumber/lib/configuration_inflection.rb
|
83
|
-
- lib/tlb/cucumber/lib/run_data_formatter.rb
|
84
|
-
- lib/tlb/cucumber/lib/test_splitter.rb
|
85
|
-
- lib/tlb/cucumber/rake/cucumber_task.rb
|
86
|
-
- lib/tlb/run_data.rb
|
87
|
-
- lib/tlb/util.rb
|
88
|
-
- spike/Rakefile
|
89
|
-
- spike/features/step_definitions/addition.rb
|
90
|
-
- spike/features/step_definitions/answer.rb
|
91
|
-
- spike/features/step_definitions/sub.rb
|
92
|
-
- spike/features/sub.feature
|
93
|
-
- spike/features/sum.feature
|
94
|
-
- spike/features/the_answer.feature
|
95
|
-
- test.sh
|
96
|
-
- tlb-cucumber.gemspec
|
97
|
-
- tlb-rspec2.gemspec
|
98
|
-
- tlb-testunit.gemspec
|
99
|
-
- tlb-alien-g0.3.0-4-g1077d1b.jar
|
100
|
-
has_rdoc: true
|
60
|
+
- cucumber/lib/tlb/cucumber/lib/configuration_inflection.rb
|
61
|
+
- cucumber/lib/tlb/cucumber/lib/run_data_formatter.rb
|
62
|
+
- cucumber/lib/tlb/cucumber/lib/test_splitter.rb
|
63
|
+
- cucumber/lib/tlb/cucumber/rake/cucumber_task.rb
|
64
|
+
- README.markdown
|
101
65
|
homepage: http://github.com/test-load-balancer/tlb.rb
|
102
66
|
licenses: []
|
103
67
|
|
104
68
|
post_install_message: |
|
69
|
+
=========================================================================
|
70
|
+
Documentation: Detailed configuration documentation can be found at http://test-load-balancer.github.com. Documentation section in this website hosts documentation for every public release.
|
71
|
+
|
105
72
|
-------------------------------------------------------------------------
|
106
|
-
TLB
|
73
|
+
TLB Setup: You'll need a TLB-Server in your network that is reachable over the network from the machines you use to execute your project's test-suite. Please refer the TLB documentation for details.
|
107
74
|
|
108
75
|
-------------------------------------------------------------------------
|
109
|
-
|
110
|
-
|
111
|
-
We recommend playing with the configuration-variable values being set in the shell-script(s) to understand the effect different values have on load-balancing/reordering behavior.
|
76
|
+
Example(s): We maintain a directory of tlb-enabled dummy projects written in different languages using different testing and build frameworks to help new TLB users get started and provide users a working project to refer to while hooking up TLB on their project(s).
|
77
|
+
Each of these projects have a shell script(named run_balanced.sh) that is meant to demonstrate a typical tlb-enabled build(by starting a local tlb server, and executing two partitions that run dummy tests locally). This script also starts its own server(so you do not need to worry about the TLB server for trying it out).
|
78
|
+
We recommend playing with the configuration-variable values being set in the shell-script(s) to understand the effect different values have on load-balancing/reordering behavior.
|
112
79
|
|
113
|
-
Examples archive is released along-with TLB
|
80
|
+
Examples archive is released along-with TLB and is available for download at http://code.google.com/p/tlb/downloads/list.
|
114
81
|
|
115
82
|
To execute the example project, drop into the example project directory(examples/rspec2_example for instance) and invoke the './run_balanced.sh'.
|
116
83
|
|
117
84
|
-------------------------------------------------------------------------
|
118
|
-
|
85
|
+
Issue Tracker: http://code.google.com/p/tlb/issues/list
|
119
86
|
|
120
|
-
|
87
|
+
=========================================================================
|
121
88
|
|
122
89
|
rdoc_options:
|
123
|
-
|
90
|
+
- --charset=UTF-8
|
124
91
|
require_paths:
|
125
|
-
|
92
|
+
- cucumber/lib
|
126
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
127
95
|
requirements:
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
- 0
|
132
|
-
version: "0"
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "0"
|
133
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
134
101
|
requirements:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
- 0
|
139
|
-
version: "0"
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
140
105
|
requirements: []
|
141
106
|
|
142
107
|
rubyforge_project: tlb-rb
|
143
|
-
rubygems_version: 1.3
|
108
|
+
rubygems_version: 1.8.3
|
144
109
|
signing_key:
|
145
110
|
specification_version: 3
|
146
|
-
summary: tlb-cucumber-0.3.
|
111
|
+
summary: tlb-cucumber-0.3.2
|
147
112
|
test_files: []
|
148
113
|
|
data/.emacs_project.template
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
;; copy me as .emacs_project in project root if using .emacs.d = git://github.com/janmejay/emacs.git
|
2
|
-
;; after copying it across, modify the file to make it relevant to local rvm setup
|
3
|
-
(setq rspec-executable "rspec")
|
4
|
-
(setq rb_platform "jruby")
|
5
|
-
(setq rb_platform "mri")
|
6
|
-
|
7
|
-
(unless (getenv "ORIG_PATH")
|
8
|
-
(setenv "ORIG_PATH" (getenv "PATH")))
|
9
|
-
|
10
|
-
(defun add-gem-bin (gem-bin)
|
11
|
-
(setenv "PATH" (concat gem-bin ":" (getenv "ORIG_PATH"))))
|
12
|
-
|
13
|
-
(if (equal rb_platform "jruby")
|
14
|
-
(progn
|
15
|
-
(setenv "GEM_HOME" "/home/janmejay/.rvm/gems/jruby-1.5.6@tlb")
|
16
|
-
(setenv "GEM_PATH" "/home/janmejay/.rvm/gems/jruby-1.5.6@tlb:/home/janmejay/.rvm/gems/jruby-1.5.6@global")
|
17
|
-
(add-gem-bin "/home/janmejay/.rvm/gems/jruby-1.5.6@tlb/bin"))
|
18
|
-
(progn
|
19
|
-
(setenv "GEM_HOME" "/home/janmejay/.rvm/gems/ruby-1.8.7-p334@tlb")
|
20
|
-
(setenv "GEM_PATH" "/home/janmejay/.rvm/gems/ruby-1.8.7-p334@tlb:/home/janmejay/.rvm/gems/ruby-1.8.7-p334@global")
|
21
|
-
(add-gem-bin "/home/janmejay/.rvm/gems/ruby-1.8.7-p334@tlb/bin")))
|
data/.gitignore
DELETED
data/.gitmodules
DELETED
data/Rakefile
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rspec/core/rake_task'
|
2
|
-
require 'rake/testtask'
|
3
|
-
|
4
|
-
task :test => ['test:rspec', 'test:test_unit']
|
5
|
-
|
6
|
-
namespace :test do
|
7
|
-
RSpec::Core::RakeTask.new(:rspec) do |t|
|
8
|
-
t.pattern = 'tests/**/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
Rake::TestTask.new(:test_unit) do |t|
|
12
|
-
t.test_files = FileList['tests/**/*_test.rb']
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
task :build_tlb do
|
17
|
-
[Dir.glob("tlb-alien*.jar"), Dir.glob("tlb-server*.jar")].flatten.each { |jar| FileUtils.rm(jar) }
|
18
|
-
sh '(cd tlb && ant clean package -Doffline=t)'
|
19
|
-
Dir.glob('tlb/target/tlb-alien*').each { |file| FileUtils.copy(file, ".") }
|
20
|
-
Dir.glob('tlb/target/tlb-server*').each { |file| FileUtils.copy(file, "tests/") }
|
21
|
-
end
|
22
|
-
|
23
|
-
task :package do
|
24
|
-
`gem build tlb-rspec2.gemspec`
|
25
|
-
`gem build tlb-testunit.gemspec`
|
26
|
-
`gem build tlb-cucumber.gemspec`
|
27
|
-
end
|
data/gem_common.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
BASE_DIR = File.dirname(__FILE__)
|
2
|
-
LIB_TLB = File.join(BASE_DIR, "lib", "tlb")
|
3
|
-
TEST_DIR = File.join(BASE_DIR, "tests")
|
4
|
-
TAG_VERSION = `git describe --abbrev=0`.gsub(/^v/, '')
|
5
|
-
CODE_VERSION = `git describe --always`
|
6
|
-
AUTHORS = ["Janmejay Singh", "Pavan KS"]
|
7
|
-
EMAIL = "singh.janmejay@gmail.com;itspanzi@gmail.com"
|
8
|
-
HOME_PAGE = "http://github.com/test-load-balancer/tlb.rb"
|
9
|
-
SUMMARY = "#{$name}-#{CODE_VERSION}"
|
10
|
-
DESC = <<END
|
11
|
-
TLB ruby implementation base, which provides support for load balancing tests written in #{$framework}.
|
12
|
-
TLB.rb test suite is not bundled, please check http://github.com/test-load-balancer/tlb.rb for tests.
|
13
|
-
Detailed documentation is available at http://test-load-balancer.github.com.
|
14
|
-
END
|
15
|
-
POST_INSTALL_MESSAGE = <<END
|
16
|
-
-------------------------------------------------------------------------
|
17
|
-
TLB Documentation: Detailed configuration documentation can be found at http://test-load-balancer.github.com. Documentation section in this website hosts documentation for every public release.
|
18
|
-
|
19
|
-
-------------------------------------------------------------------------
|
20
|
-
TLB Example(s): We maintain a directory of tlb-enabled dummy projects written in different languages using different testing and build frameworks to help new TLB users get started and provide people a working project to refer to while hooking up TLB on their project(s). Each of these projects have a shell script(named run_balanced.sh) that is meant to demonstrate a typical tlb-enabled build(by starting a local tlb server, and executing two partitions that run dummy tests locally).
|
21
|
-
For demonstration purpose, aforementioned shell script executes partitions in the example-project one after another(serially). However, partitions will be executed parallely on different machines in a real-world setup(hence cutting the build time).
|
22
|
-
We recommend playing with the configuration-variable values being set in the shell-script(s) to understand the effect different values have on load-balancing/reordering behavior. You may want to check http://test-load-balancer.github.com, which links to 'detailed documentation' that covers each configuration variable and explains its purpose, effect and implication.
|
23
|
-
|
24
|
-
Examples archive is released along-with TLB, and is available for download at http://code.google.com/p/tlb/downloads/list.
|
25
|
-
|
26
|
-
To execute the example project, drop into the example project directory(examples/rspec2_example for instance) and invoke the './run_balanced.sh'.
|
27
|
-
|
28
|
-
-------------------------------------------------------------------------
|
29
|
-
TLB Issue Tracker: Please report/port bugs/enhancements/feature-requests on http://code.google.com/p/tlb/issues/list. Github, Rubyforge or any other issue trackers are not monitored or updated.
|
30
|
-
|
31
|
-
-------------------------------------------------------------------------
|
32
|
-
END
|
33
|
-
RUBYFORGE_PROJECT = "tlb-rb"
|
34
|
-
RUBYGEMS_VERSION = "1.3.7"
|
35
|
-
|
36
|
-
def files *exclude_dirs
|
37
|
-
files = `git ls-files`.split("\n")
|
38
|
-
files += Dir.glob(File.join(File.dirname(__FILE__), "*.jar")).map { |path| File.basename(path) }
|
39
|
-
exclude_dirs.inject(files) { |files, dir| files - `git ls-files #{dir}`.split("\n") }
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
def configure_tlb s
|
44
|
-
s.name = $name
|
45
|
-
s.version = TAG_VERSION
|
46
|
-
s.platform = Gem::Platform::RUBY
|
47
|
-
s.authors = AUTHORS
|
48
|
-
s.email = EMAIL
|
49
|
-
s.homepage = HOME_PAGE
|
50
|
-
s.summary = SUMMARY
|
51
|
-
s.description = DESC
|
52
|
-
|
53
|
-
s.rubyforge_project = RUBYFORGE_PROJECT
|
54
|
-
s.rubygems_version = RUBYGEMS_VERSION
|
55
|
-
|
56
|
-
s.post_install_message = POST_INSTALL_MESSAGE
|
57
|
-
|
58
|
-
s.extra_rdoc_files = [ "README.markdown" ]
|
59
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
60
|
-
s.require_path = "lib"
|
61
|
-
|
62
|
-
s.add_runtime_dependency 'open4', '>= 1.0.1'
|
63
|
-
s.add_runtime_dependency 'rake'
|
64
|
-
end
|
data/lib/tasks/tlb.rake
DELETED
data/lib/tlb.rb
DELETED
@@ -1,238 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'open4'
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
TLB_RB_LIB = File.expand_path(File.dirname(__FILE__))
|
6
|
-
unless $LOAD_PATH.include? TLB_RB_LIB
|
7
|
-
$LOAD_PATH << TLB_RB_LIB
|
8
|
-
end
|
9
|
-
|
10
|
-
module Tlb
|
11
|
-
TLB_OUT_FILE = 'TLB_OUT_FILE'
|
12
|
-
TLB_ERR_FILE = 'TLB_ERR_FILE'
|
13
|
-
TLB_APP = 'TLB_APP'
|
14
|
-
|
15
|
-
module Balancer
|
16
|
-
TLB_BALANCER_PORT = 'TLB_BALANCER_PORT'
|
17
|
-
BALANCE_PATH = '/balance'
|
18
|
-
SUITE_TIME_REPORTING_PATH = '/suite_time'
|
19
|
-
SUITE_RESULT_REPORTING_PATH = '/suite_result'
|
20
|
-
|
21
|
-
def self.host
|
22
|
-
'localhost'
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.port
|
26
|
-
ENV[TLB_BALANCER_PORT] || '8019'
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.send path, data
|
30
|
-
Net::HTTP.start(host, port) do |h|
|
31
|
-
res = h.post(path, data)
|
32
|
-
res.value
|
33
|
-
res.body
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.get path
|
38
|
-
Net::HTTP.get_response(host, path, port).body
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.running?
|
42
|
-
get("/control/status") == "RUNNING"
|
43
|
-
rescue
|
44
|
-
false
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.terminate
|
48
|
-
get("/control/suicide")
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.wait_for_start
|
52
|
-
loop do
|
53
|
-
begin
|
54
|
-
break if running?
|
55
|
-
rescue
|
56
|
-
#ignore
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
module RSpec
|
63
|
-
end
|
64
|
-
|
65
|
-
module TestUnit
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.relative_file_path file_name
|
69
|
-
abs_file_name = File.expand_path(file_name)
|
70
|
-
rel_file_name = abs_file_name.sub(/^#{Dir.pwd}/, '.')
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.relative_file_paths file_names
|
74
|
-
file_names.map { |file_name| relative_file_path(file_name) }
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.balance_and_order file_set
|
78
|
-
ensure_server_running
|
79
|
-
Balancer.send(Balancer::BALANCE_PATH, file_set.join("\n")).split("\n")
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.suite_result suite_name, result
|
83
|
-
ensure_server_running
|
84
|
-
Balancer.send(Balancer::SUITE_RESULT_REPORTING_PATH, "#{suite_name}: #{result}")
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.suite_time suite_name, mills
|
88
|
-
ensure_server_running
|
89
|
-
Balancer.send(Balancer::SUITE_TIME_REPORTING_PATH, "#{suite_name}: #{mills}")
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.fail_as_balancer_is_not_running
|
93
|
-
raise "Balancer server must be started before tests are run."
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.ensure_server_running
|
97
|
-
server_running? || fail_as_balancer_is_not_running
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.server_running?
|
101
|
-
Balancer.running?
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.root_dir
|
105
|
-
File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
106
|
-
end
|
107
|
-
|
108
|
-
def self.tlb_jar
|
109
|
-
File.expand_path(Dir.glob(File.join(root_dir, "tlb-alien*")).first)
|
110
|
-
end
|
111
|
-
|
112
|
-
def self.server_command
|
113
|
-
"java -jar #{tlb_jar}"
|
114
|
-
end
|
115
|
-
|
116
|
-
def self.can_fork?
|
117
|
-
RUBY_PLATFORM != 'java'
|
118
|
-
end
|
119
|
-
|
120
|
-
class BalancerProcess
|
121
|
-
class StreamPumper
|
122
|
-
def initialize stream, file
|
123
|
-
@stream, @file = stream, file
|
124
|
-
@thd = Thread.new { pump }
|
125
|
-
end
|
126
|
-
|
127
|
-
def pump
|
128
|
-
loop do
|
129
|
-
data_available? && flush_stream
|
130
|
-
Thread.current[:stop_pumping] && break
|
131
|
-
sleep 0.1
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def flush_stream
|
136
|
-
File.open(ENV[@file], 'a') do |h|
|
137
|
-
h.write(read)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def stop_pumping!
|
142
|
-
@thd[:stop_pumping] = true
|
143
|
-
@thd.join
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def initialize server_command
|
148
|
-
pumper_type, out, err = start(server_command)
|
149
|
-
@out_pumper = pumper_type.new(out, TLB_OUT_FILE)
|
150
|
-
@err_pumper = pumper_type.new(err, TLB_ERR_FILE)
|
151
|
-
end
|
152
|
-
|
153
|
-
def stop_pumping
|
154
|
-
@out_pumper.stop_pumping!
|
155
|
-
@err_pumper.stop_pumping!
|
156
|
-
end
|
157
|
-
|
158
|
-
def die
|
159
|
-
Balancer.terminate
|
160
|
-
stop_pumping
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
class ForkBalancerProcess < BalancerProcess
|
165
|
-
def start server_command
|
166
|
-
@pid, input, out, err = Open4.popen4(server_command)
|
167
|
-
unless (out)
|
168
|
-
raise "out was nil"
|
169
|
-
end
|
170
|
-
return Class.new(StreamPumper) do
|
171
|
-
def data_available?
|
172
|
-
not @stream.eof?
|
173
|
-
end
|
174
|
-
|
175
|
-
def read
|
176
|
-
@stream.read
|
177
|
-
end
|
178
|
-
end, out, err
|
179
|
-
end
|
180
|
-
|
181
|
-
def die
|
182
|
-
super
|
183
|
-
@pid = nil
|
184
|
-
Process.wait
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
class JavaBalancerProcess < BalancerProcess
|
189
|
-
def start server_command
|
190
|
-
require 'java'
|
191
|
-
pb = java.lang.ProcessBuilder.new(server_command.split)
|
192
|
-
ENV.each do |key, val|
|
193
|
-
pb.environment[key] = val
|
194
|
-
end
|
195
|
-
@process = pb.start()
|
196
|
-
return Class.new(StreamPumper) do
|
197
|
-
def data_available?
|
198
|
-
@stream.ready
|
199
|
-
end
|
200
|
-
|
201
|
-
def read
|
202
|
-
@stream.read_line
|
203
|
-
end
|
204
|
-
|
205
|
-
def stop_pumping!
|
206
|
-
super
|
207
|
-
@stream.close
|
208
|
-
end
|
209
|
-
end, buf_reader(@process.input_stream), buf_reader(@process.error_stream)
|
210
|
-
end
|
211
|
-
|
212
|
-
def buf_reader stream
|
213
|
-
java.io.BufferedReader.new(java.io.InputStreamReader.new(stream))
|
214
|
-
end
|
215
|
-
|
216
|
-
def die
|
217
|
-
super
|
218
|
-
@process.destroy
|
219
|
-
@process.waitFor
|
220
|
-
@process = nil
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
def self.balancer_process_type
|
225
|
-
can_fork? ? ForkBalancerProcess : JavaBalancerProcess
|
226
|
-
end
|
227
|
-
|
228
|
-
def self.start_server
|
229
|
-
ENV[TLB_APP] = 'tlb.balancer.BalancerInitializer'
|
230
|
-
bal_klass = balancer_process_type
|
231
|
-
@balancer_process = bal_klass.new(server_command)
|
232
|
-
Balancer.wait_for_start
|
233
|
-
end
|
234
|
-
|
235
|
-
def self.stop_server
|
236
|
-
@balancer_process.die
|
237
|
-
end
|
238
|
-
end
|
data/lib/tlb/run_data.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'tlb'))
|
2
|
-
|
3
|
-
module Tlb::RunData
|
4
|
-
class Suite < Struct.new(:identity, :start_time, :end_time, :failed)
|
5
|
-
MILLS_PER_SEC = 1000
|
6
|
-
|
7
|
-
def initialize(identity, start_time)
|
8
|
-
super(identity, start_time, start_time, false)
|
9
|
-
end
|
10
|
-
|
11
|
-
def run_time
|
12
|
-
((end_time - start_time)*MILLS_PER_SEC).to_i
|
13
|
-
end
|
14
|
-
|
15
|
-
def for_id? new_identity
|
16
|
-
identity == new_identity
|
17
|
-
end
|
18
|
-
|
19
|
-
def report_to_tlb
|
20
|
-
Tlb.suite_time(identity, run_time)
|
21
|
-
Tlb.suite_result(identity, failed)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def suite_started identity
|
26
|
-
unless (suites.last && suites.last.for_id?(identity))
|
27
|
-
suites << Tlb::RunData::Suite.new(identity, Time.now)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def update_suite_data identity
|
32
|
-
if (suite = suites.last) #stupid framework :: retarded fix (this is necessary since rspec-1[don't know if rspec-2 is as stupid too] creates example_proxies for every example it runs, as though its an independent spec-group)
|
33
|
-
suite.end_time = Time.now
|
34
|
-
block_given? && yield(suite)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def update_suite_failed identity
|
39
|
-
update_suite_data(identity) do |suite|
|
40
|
-
suite.failed = true
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def report_all_suite_data
|
45
|
-
suites.each do |suite_time|
|
46
|
-
suite_time.report_to_tlb
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def suites
|
53
|
-
@suites ||= []
|
54
|
-
end
|
55
|
-
end
|
data/lib/tlb/util.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'tlb'))
|
2
|
-
|
3
|
-
module Tlb::Util
|
4
|
-
def self.quote_path *fragments
|
5
|
-
single_quote(File.expand_path(File.join(*fragments)))
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.single_quote arg
|
9
|
-
"'#{arg.gsub(/'/, "\\'")}'"
|
10
|
-
end
|
11
|
-
end
|
data/spike/Rakefile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'cucumber'
|
3
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'tlb'))
|
4
|
-
require 'tlb/cucumber/rake/cucumber_task'
|
5
|
-
|
6
|
-
Tlb::Cucumber::Rake::CucumberTask.new(:cucumber_tests)
|
7
|
-
|
8
|
-
load 'tasks/tlb.rake'
|
9
|
-
desc "Run Cucumber features in a load-balanced fashion (based on environment variables)"
|
10
|
-
task :bal => ['tlb:start', :cucumber_tests]
|
11
|
-
|
12
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require ('test/unit/assertions')
|
2
|
-
|
3
|
-
World(Test::Unit::Assertions)
|
4
|
-
|
5
|
-
Given /There are two numbers (\d+) and (\d+)/ do |one, two|
|
6
|
-
instance_variable_set("@first", one)
|
7
|
-
instance_variable_set("@second", two)
|
8
|
-
end
|
9
|
-
|
10
|
-
When /I add them together/ do
|
11
|
-
one = instance_variable_get("@first")
|
12
|
-
two = instance_variable_get("@second")
|
13
|
-
instance_variable_set("@sum", one.to_i + two.to_i)
|
14
|
-
end
|
15
|
-
|
16
|
-
Then /I should get (\d+)/ do |expected_sum|
|
17
|
-
assert_equal expected_sum.to_i, instance_variable_get("@sum")
|
18
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require ('test/unit/assertions')
|
2
|
-
|
3
|
-
World(Test::Unit::Assertions)
|
4
|
-
|
5
|
-
Given /I am wondering what the hell is the answer/ do
|
6
|
-
end
|
7
|
-
|
8
|
-
When /I ask Deep thought/ do
|
9
|
-
end
|
10
|
-
|
11
|
-
Then /Deep Thought should say "(\d+)"/ do |answer|
|
12
|
-
assert_equal 42, answer.to_i
|
13
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require ('test/unit/assertions')
|
2
|
-
|
3
|
-
World(Test::Unit::Assertions)
|
4
|
-
|
5
|
-
Given /There are two numbers for subtraction (\d+) and (\d+)/ do |one, two|
|
6
|
-
instance_variable_set("@first", one)
|
7
|
-
instance_variable_set("@second", two)
|
8
|
-
end
|
9
|
-
|
10
|
-
When /I subtract second from the first/ do
|
11
|
-
one = instance_variable_get("@first")
|
12
|
-
two = instance_variable_get("@second")
|
13
|
-
instance_variable_set("@diff", one.to_i - two.to_i)
|
14
|
-
end
|
15
|
-
|
16
|
-
Then /I should get the difference (\d+)/ do |expected_difference|
|
17
|
-
assert_equal expected_difference.to_i, instance_variable_get("@diff")
|
18
|
-
end
|
data/spike/features/sub.feature
DELETED
data/spike/features/sum.feature
DELETED
data/test.sh
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# this is a smart hack strictly meant for developer convinience, not for CI. -janmejay
|
4
|
-
|
5
|
-
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
6
|
-
|
7
|
-
sep() {
|
8
|
-
in_red "-----------------------------------------------------------------"
|
9
|
-
echo
|
10
|
-
}
|
11
|
-
|
12
|
-
function in_red {
|
13
|
-
tput sgr0
|
14
|
-
tput setaf 1;
|
15
|
-
tput setab 7;
|
16
|
-
echo -n $1;
|
17
|
-
tput sgr0
|
18
|
-
}
|
19
|
-
|
20
|
-
function show_running_with {
|
21
|
-
echo -e "\n"
|
22
|
-
sep
|
23
|
-
in_red "|"
|
24
|
-
echo -n " "
|
25
|
-
tput setaf 4
|
26
|
-
echo -n "Running tests with: "
|
27
|
-
tput bold;
|
28
|
-
tput setaf 0
|
29
|
-
ruby --version
|
30
|
-
sep
|
31
|
-
echo
|
32
|
-
}
|
33
|
-
|
34
|
-
run_tests_with() {
|
35
|
-
rvm use $1
|
36
|
-
show_running_with
|
37
|
-
rake test
|
38
|
-
}
|
39
|
-
|
40
|
-
run_tests_with ruby-1.8.7-p334@tlb
|
41
|
-
|
42
|
-
run_tests_with jruby-1.5.6@tlb
|
data/tlb-cucumber.gemspec
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
$name="tlb-cucumber"
|
2
|
-
$framework='cucumber'
|
3
|
-
require File.join(File.dirname(__FILE__), 'gem_common')
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
configure_tlb(s)
|
7
|
-
s.files = files('tests', File.join('lib', 'tlb', 'rspec'), File.join('lib', 'tlb', 'test_unit'))
|
8
|
-
s.add_runtime_dependency 'cucumber', '>= 0.10.2'
|
9
|
-
end
|
data/tlb-rspec2.gemspec
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
$name="tlb-rspec2"
|
2
|
-
$framework='rspec-2.x'
|
3
|
-
require File.join(File.dirname(__FILE__), 'gem_common')
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
configure_tlb(s)
|
7
|
-
s.files = files('tests', File.join('lib', 'tlb', 'test_unit'), File.join('lib', 'tlb', 'cucumber'))
|
8
|
-
s.add_runtime_dependency 'rspec', '>= 2.3.0'
|
9
|
-
end
|
10
|
-
|
data/tlb-testunit.gemspec
DELETED