tlb-rspec1 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 CHANGED
@@ -1,66 +1,46 @@
1
- ## Using tlb_rb:
1
+ ## Using tlb.rb:
2
2
 
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.
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 what server to talk to).
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
- As of now, tlb.rb supports RSpec(1.x and 2.x) and Test::Unit, which are the two most widely used testing frameworks in Ruby. We plan to add support for other ruby-testing-frameworks soon.
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
- ## Setting it up for your project
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
- Please refer the [sample_projects](http://github.com/test-load-balancer/sample_projects "Tlb setup examples") to see the details of how to set it up.
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
- Usually, something equivallent of this in one of your Rake files should suffice:
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
- __RSpec-2.x__:
32
- require 'rubygems'
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
- __Test::Unit__:
45
- require 'rake'
46
- require 'rubygems'
47
- gem 'tlb-testunit'
48
- require 'tlb/test_unit/test_task'
49
-
50
- Tlb::TestUnit::TestTask.new(:test_balanced) do |t|
51
- t.libs << "test"
52
- t.test_files = FileList['test/**/*_test.rb']
53
- t.verbose = true
54
- end
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
- load 'tasks/tlb.rake'
33
+ If a version older than 0.3.2, please use
34
+ $ gem install tlb-testunit
35
+ for Test::Unit support.
57
36
 
58
- task :bal => ['tlb:start', :test_balanced]
59
-
60
- Where __bal__ is the task you invoke at the top-level(invoked externally).
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
- ## RSpec source-control and release-version/environment compatibility
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
 
@@ -1,5 +1,6 @@
1
1
  require 'spec/runner/formatter/silent_formatter'
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'tlb'))
2
+ require 'rubygems'
3
+ require 'tlb'
3
4
 
4
5
  class Tlb::SpecFormatter < Spec::Runner::Formatter::SilentFormatter
5
6
  class Suite < Struct.new(:file_name, :start_time, :end_time, :failed)
@@ -1,5 +1,5 @@
1
1
  require 'spec/rake/spectask'
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'tlb'))
2
+ require 'tlb'
3
3
  require 'tlb/util'
4
4
 
5
5
  class Tlb::SpecTask < Spec::Rake::SpecTask
metadata CHANGED
@@ -1,74 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tlb-rspec1
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
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
- - Janmejay Singh
13
- - Pavan KS
8
+ - Janmejay Singh
9
+ - Pavan KS
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
13
 
18
- date: 2011-05-11 00:00:00 +05:30
19
- default_executable:
14
+ date: 2011-05-27 00:00:00 Z
20
15
  dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: open4
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 1
30
- - 0
31
- - 1
32
- version: 1.0.1
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rake
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 0
44
- version: "0"
45
- type: :runtime
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- prerelease: false
50
- requirement: &id003 !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 1
56
- - 3
57
- - 0
58
- version: 1.3.0
59
- - - <
60
- - !ruby/object:Gem::Version
61
- segments:
62
- - 2
63
- - 0
64
- - 0
65
- version: 2.0.0
66
- type: :runtime
67
- 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: rspec
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.3.0
47
+ - - <
48
+ - !ruby/object:Gem::Version
49
+ version: 2.0.0
50
+ type: :runtime
51
+ version_requirements: *id003
68
52
  description: |
69
- TLB ruby implementation base, which provides support for load balancing tests written in rspec-1.x.
70
- TLB.rb test suite is not bundled, please check http://github.com/test-load-balancer/tlb.rb for tests.
71
- Detailed documentation is available at http://test-load-balancer.github.com.
53
+ TLB-Ruby component that provides support for load balancing tests written using rspec-1.x. This library consumes APIs provided by tlb-core.
72
54
 
73
55
  email: singh.janmejay@gmail.com;itspanzi@gmail.com
74
56
  executables: []
@@ -76,68 +58,57 @@ executables: []
76
58
  extensions: []
77
59
 
78
60
  extra_rdoc_files:
79
- - README.markdown
61
+ - README.markdown
80
62
  files:
81
- - .emacs_project
82
- - .gitignore
83
- - .gitmodules
84
- - README.markdown
85
- - Rakefile
86
- - gem_common.rb
87
- - lib/tasks/tlb.rake
88
- - lib/tlb.rb
89
- - lib/tlb/spec_formatter.rb
90
- - lib/tlb/spec_task.rb
91
- - lib/tlb/util.rb
92
- - test.sh
93
- - tlb-rspec1.gemspec
94
- - tlb-alien-g0.3.0-4-g1077d1b.jar
95
- has_rdoc: true
63
+ - rspec1/lib/tlb/spec/spec_formatter.rb
64
+ - rspec1/lib/tlb/spec/spec_task.rb
65
+ - README.markdown
96
66
  homepage: http://github.com/test-load-balancer/tlb.rb
97
67
  licenses: []
98
68
 
99
69
  post_install_message: |
70
+ =========================================================================
71
+ 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.
72
+
100
73
  -------------------------------------------------------------------------
101
- 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.
74
+ 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.
102
75
 
103
76
  -------------------------------------------------------------------------
104
- 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).
105
- 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).
106
- 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.
77
+ 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).
78
+ 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).
79
+ 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.
107
80
 
108
- Examples archive is released along-with TLB, and is available for download at http://code.google.com/p/tlb/downloads/list.
81
+ Examples archive is released along-with TLB and is available for download at http://code.google.com/p/tlb/downloads/list.
109
82
 
110
83
  To execute the example project, drop into the example project directory(examples/rspec2_example for instance) and invoke the './run_balanced.sh'.
111
84
 
112
85
  -------------------------------------------------------------------------
113
- 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.
86
+ Issue Tracker: http://code.google.com/p/tlb/issues/list
114
87
 
115
- -------------------------------------------------------------------------
88
+ =========================================================================
116
89
 
117
90
  rdoc_options:
118
- - --charset=UTF-8
91
+ - --charset=UTF-8
119
92
  require_paths:
120
- - lib
93
+ - rspec1/lib
121
94
  required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
122
96
  requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- segments:
126
- - 0
127
- version: "0"
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
128
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
129
102
  requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- segments:
133
- - 0
134
- version: "0"
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
135
106
  requirements: []
136
107
 
137
108
  rubyforge_project: tlb-rb
138
- rubygems_version: 1.3.6
109
+ rubygems_version: 1.8.3
139
110
  signing_key:
140
111
  specification_version: 3
141
- summary: tlb-rspec1-0.3.1-rspec-1
112
+ summary: tlb-rspec1-0.3.2
142
113
  test_files: []
143
114
 
data/.emacs_project DELETED
@@ -1,19 +0,0 @@
1
- (setq rspec-executable "spec")
2
- (setq rb_platform "jruby")
3
- (setq rb_platform "mri")
4
-
5
- (unless (getenv "ORIG_PATH")
6
- (setenv "ORIG_PATH" (getenv "PATH")))
7
-
8
- (defun add-gem-bin (gem-bin)
9
- (setenv "PATH" (concat gem-bin ":" (getenv "ORIG_PATH"))))
10
-
11
- (if (equal rb_platform "jruby")
12
- (progn
13
- (setenv "GEM_HOME" "/home/janmejay/.rvm/gems/jruby-1.5.6@tlb")
14
- (setenv "GEM_PATH" "/home/janmejay/.rvm/gems/jruby-1.5.6@tlb:/home/janmejay/.rvm/gems/jruby-1.5.6@global")
15
- (add-gem-bin "/home/janmejay/.rvm/gems/jruby-1.5.6@tlb/bin"))
16
- (progn
17
- (setenv "GEM_HOME" "/home/janmejay/.rvm/gems/ruby-1.9.2-head@rspec-1")
18
- (setenv "GEM_PATH" "/home/janmejay/.rvm/gems/ruby-1.9.2-head@rspec-1:/home/janmejay/.rvm/gems/ruby-1.8.7-head@global")
19
- (add-gem-bin "/home/janmejay/.rvm/gems/ruby-1.9.2-head@rspec-1/bin")))
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- TAGS
2
- tmp
3
- tlb_store
4
- tlb-*.jar
5
- .yardoc
6
- doc
data/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule "tlb"]
2
- path = tlb
3
- url = git://github.com/test-load-balancer/tlb.git
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- require 'spec/rake/spectask'
2
-
3
- Spec::Rake::SpecTask.new(:spec) do |t|
4
- t.spec_files = FileList['spec/**/*_spec.rb']
5
- end
6
-
7
- task :build_tlb do
8
- [Dir.glob("tlb-alien*.jar"), Dir.glob("tlb-server*.jar")].flatten.each { |jar| FileUtils.rm(jar) }
9
- sh '(cd tlb && ant clean package -Doffline=t)'
10
- Dir.glob('tlb/target/tlb-alien*').each { |file| FileUtils.copy(file, ".") }
11
- Dir.glob('tlb/target/tlb-server*').each { |file| FileUtils.copy(file, "spec/") }
12
- end
13
-
14
- task :package do
15
- `gem build tlb-rspec1.gemspec`
16
- end
data/gem_common.rb DELETED
@@ -1,66 +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/, '').gsub(/-rspec-1$/, '')
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
- files += Dir.glob(File.join(File.dirname(__FILE__), "doc", "**", "*"))
40
- exclude_dirs.inject(files) { |files, dir| files - `git ls-files #{dir}`.split("\n") }
41
- end
42
-
43
-
44
- def configure_tlb s
45
- s.name = $name
46
- s.version = TAG_VERSION
47
- s.platform = Gem::Platform::RUBY
48
- s.authors = AUTHORS
49
- s.email = EMAIL
50
- s.homepage = HOME_PAGE
51
- s.summary = SUMMARY
52
- s.description = DESC
53
-
54
- s.rubyforge_project = RUBYFORGE_PROJECT
55
- s.rubygems_version = RUBYGEMS_VERSION
56
-
57
- s.post_install_message = POST_INSTALL_MESSAGE
58
-
59
- s.extra_rdoc_files = [ "README.markdown" ]
60
- s.rdoc_options = ["--charset=UTF-8"]
61
- s.require_path = "lib"
62
-
63
- s.add_runtime_dependency 'open4', '>= 1.0.1'
64
- s.add_runtime_dependency 'rake'
65
- s.add_runtime_dependency 'rspec', '>= 1.3.0', '< 2.0.0'
66
- end
data/lib/tasks/tlb.rake DELETED
@@ -1,12 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'tlb'))
2
-
3
- namespace :tlb do
4
- task :start do
5
- Tlb.start_server
6
- at_exit do
7
- $stderr.write "terminating tlb server\n"
8
- Tlb.stop_server
9
- end
10
- end
11
- end
12
-
data/lib/tlb/util.rb DELETED
@@ -1,15 +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
- quote(File.expand_path(File.join(*fragments)))
6
- end
7
-
8
- def self.quote str
9
- "'#{escape_quote(str)}'"
10
- end
11
-
12
- def self.escape_quote str
13
- str.gsub(/'/, "\\'")
14
- end
15
- end
data/lib/tlb.rb DELETED
@@ -1,231 +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
- def self.relative_file_path file_name
63
- abs_file_name = File.expand_path(file_name)
64
- rel_file_name = abs_file_name.sub(/^#{Dir.pwd}/, '.')
65
- end
66
-
67
- def self.balance_and_order file_set
68
- ensure_server_running
69
- Balancer.send(Balancer::BALANCE_PATH,
70
- file_set.map do |file_path|
71
- Tlb.relative_file_path(file_path)
72
- end.join("\n")).split("\n")
73
- end
74
-
75
- def self.suite_result suite_name, result
76
- ensure_server_running
77
- Balancer.send(Balancer::SUITE_RESULT_REPORTING_PATH, "#{suite_name}: #{result}")
78
- end
79
-
80
- def self.suite_time suite_name, mills
81
- ensure_server_running
82
- Balancer.send(Balancer::SUITE_TIME_REPORTING_PATH, "#{suite_name}: #{mills}")
83
- end
84
-
85
- def self.fail_as_balancer_is_not_running
86
- raise "Balancer server must be started before tests are run."
87
- end
88
-
89
- def self.ensure_server_running
90
- server_running? || fail_as_balancer_is_not_running
91
- end
92
-
93
- def self.server_running?
94
- Balancer.running?
95
- end
96
-
97
- def self.root_dir
98
- File.expand_path(File.join(File.dirname(__FILE__), ".."))
99
- end
100
-
101
- def self.tlb_jar
102
- File.expand_path(Dir.glob(File.join(root_dir, "tlb-alien*")).first)
103
- end
104
-
105
- def self.server_command
106
- "java -jar #{tlb_jar}"
107
- end
108
-
109
- def self.can_fork?
110
- RUBY_PLATFORM != 'java'
111
- end
112
-
113
- class BalancerProcess
114
- class StreamPumper
115
- def initialize stream, file
116
- @stream, @file = stream, file
117
- @thd = Thread.new { pump }
118
- end
119
-
120
- def pump
121
- loop do
122
- data_available? && flush_stream
123
- Thread.current[:stop_pumping] && break
124
- sleep 0.1
125
- end
126
- end
127
-
128
- def flush_stream
129
- File.open(ENV[@file], 'a') do |h|
130
- h.write(read)
131
- end
132
- end
133
-
134
- def stop_pumping!
135
- @thd[:stop_pumping] = true
136
- @thd.join
137
- end
138
- end
139
-
140
- def initialize server_command
141
- pumper_type, out, err = start(server_command)
142
- @out_pumper = pumper_type.new(out, TLB_OUT_FILE)
143
- @err_pumper = pumper_type.new(err, TLB_ERR_FILE)
144
- end
145
-
146
- def stop_pumping
147
- @out_pumper.stop_pumping!
148
- @err_pumper.stop_pumping!
149
- end
150
-
151
- def die
152
- Balancer.terminate
153
- stop_pumping
154
- end
155
- end
156
-
157
- class ForkBalancerProcess < BalancerProcess
158
- def start server_command
159
- @pid, input, out, err = Open4.popen4(server_command)
160
- unless (out)
161
- raise "out was nil"
162
- end
163
- return Class.new(StreamPumper) do
164
- def data_available?
165
- not @stream.eof?
166
- end
167
-
168
- def read
169
- @stream.read
170
- end
171
- end, out, err
172
- end
173
-
174
- def die
175
- super
176
- @pid = nil
177
- Process.wait
178
- end
179
- end
180
-
181
- class JavaBalancerProcess < BalancerProcess
182
- def start server_command
183
- require 'java'
184
- pb = java.lang.ProcessBuilder.new(server_command.split)
185
- ENV.each do |key, val|
186
- pb.environment[key] = val
187
- end
188
- @process = pb.start()
189
- return Class.new(StreamPumper) do
190
- def data_available?
191
- @stream.ready
192
- end
193
-
194
- def read
195
- @stream.read_line
196
- end
197
-
198
- def stop_pumping!
199
- super
200
- @stream.close
201
- end
202
- end, buf_reader(@process.input_stream), buf_reader(@process.error_stream)
203
- end
204
-
205
- def buf_reader stream
206
- java.io.BufferedReader.new(java.io.InputStreamReader.new(stream))
207
- end
208
-
209
- def die
210
- super
211
- @process.destroy
212
- @process.waitFor
213
- @process = nil
214
- end
215
- end
216
-
217
- def self.balancer_process_type
218
- can_fork? ? ForkBalancerProcess : JavaBalancerProcess
219
- end
220
-
221
- def self.start_server
222
- ENV[TLB_APP] = 'tlb.balancer.BalancerInitializer'
223
- bal_klass = balancer_process_type
224
- @balancer_process = bal_klass.new(server_command)
225
- Balancer.wait_for_start
226
- end
227
-
228
- def self.stop_server
229
- @balancer_process.die
230
- end
231
- end
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 spec
38
- }
39
-
40
- run_tests_with ruby-1.9.2-head@rspec-1
41
-
42
- run_tests_with jruby-1.5.6@rspec-1
Binary file
data/tlb-rspec1.gemspec DELETED
@@ -1,9 +0,0 @@
1
- $name="tlb-rspec1"
2
- $framework='rspec-1.x'
3
- require File.join(File.dirname(__FILE__), 'gem_common')
4
-
5
- Gem::Specification.new do |s|
6
- configure_tlb(s)
7
-
8
- s.files = files('spec', File.join('lib', 'tlb', 'test_unit'))
9
- end