xli-dtr 0.0.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/CHANGES +7 -0
  2. data/README.rdoc +208 -0
  3. data/Rakefile +54 -63
  4. data/TODO +7 -16
  5. data/bin/dtr +26 -20
  6. data/dtr.gemspec +7 -10
  7. data/lib/dtr/agent/brain.rb +13 -22
  8. data/lib/dtr/agent/herald.rb +24 -14
  9. data/lib/dtr/agent/runner.rb +22 -35
  10. data/lib/dtr/agent/sync_codebase.rb +1 -1
  11. data/lib/dtr/agent/sync_logger.rb +38 -8
  12. data/lib/dtr/agent/test_case.rb +53 -0
  13. data/lib/dtr/agent/test_unit.rb +3 -5
  14. data/lib/dtr/agent/worker.rb +29 -32
  15. data/lib/dtr/agent/working_env_ext.rb +4 -2
  16. data/lib/dtr/agent.rb +2 -1
  17. data/lib/dtr/facade.rb +65 -0
  18. data/lib/dtr/master.rb +3 -3
  19. data/lib/dtr/monitor.rb +69 -11
  20. data/lib/dtr/raketasks.rb +91 -19
  21. data/lib/dtr/shared/adapter.rb +29 -26
  22. data/lib/dtr/shared/configuration.rb +39 -11
  23. data/lib/dtr/shared/message_decorator.rb +1 -1
  24. data/lib/dtr/shared/ruby_ext.rb +1 -25
  25. data/lib/dtr/shared/service/agent.rb +5 -1
  26. data/lib/dtr/shared/service/file.rb +1 -1
  27. data/lib/dtr/shared/service/rinda.rb +11 -3
  28. data/lib/dtr/shared/service/runner.rb +6 -5
  29. data/lib/dtr/shared/service/working_env.rb +1 -1
  30. data/lib/dtr/shared/service.rb +1 -1
  31. data/lib/dtr/shared/sync_codebase/{codebase.rb → copiable_package.rb} +13 -5
  32. data/lib/dtr/shared/sync_codebase/master_ext.rb +6 -18
  33. data/lib/dtr/shared/sync_codebase/package.rb +16 -2
  34. data/lib/dtr/shared/sync_codebase/sync_service.rb +7 -12
  35. data/lib/dtr/shared/sync_codebase.rb +2 -2
  36. data/lib/dtr/shared/sync_logger.rb +6 -14
  37. data/lib/dtr/shared/utils/cmd.rb +5 -5
  38. data/lib/dtr/shared/utils/env_store.rb +1 -1
  39. data/lib/dtr/shared/utils/logger.rb +33 -17
  40. data/lib/dtr/shared/utils.rb +1 -1
  41. data/lib/dtr/shared/working_env.rb +2 -2
  42. data/lib/dtr/shared.rb +1 -1
  43. data/lib/dtr/test_unit/drb_test_runner.rb +5 -14
  44. data/lib/dtr/test_unit/injection.rb +1 -2
  45. data/lib/dtr/test_unit/test_case_injection.rb +13 -13
  46. data/lib/dtr/test_unit/test_suite_injection.rb +24 -0
  47. data/lib/dtr/test_unit/testrunnermediator_injection.rb +11 -11
  48. data/lib/dtr/test_unit/thread_safe_test_result.rb +1 -3
  49. data/lib/dtr/test_unit/worker_club.rb +7 -7
  50. data/lib/dtr/test_unit.rb +2 -1
  51. data/lib/dtr/test_unit_injection.rb +1 -1
  52. data/lib/dtr.rb +5 -36
  53. data/test/acceptance/agent_working_env_test.rb +28 -34
  54. data/test/acceptance/dtr_package_task_test.rb +13 -3
  55. data/test/acceptance/general_test.rb +139 -83
  56. data/test/acceptance/raketasks_test.rb +23 -0
  57. data/test/acceptance/sync_codebase_test.rb +12 -13
  58. data/test/acceptance/sync_logger_test.rb +12 -21
  59. data/test/agent_helper.rb +8 -10
  60. data/test/logger_stub.rb +4 -0
  61. data/test/test_helper.rb +33 -5
  62. data/test/unit/adapter_test.rb +58 -16
  63. data/test/unit/configuration_test.rb +44 -0
  64. data/test/unit/facade_test.rb +41 -0
  65. data/test/unit/logger_test.rb +72 -0
  66. data/test/unit/test_unit_test.rb +0 -21
  67. data/testdata/Rakefile +1 -5
  68. data/testdata/hacked_run_method_test_case.rb +15 -0
  69. data/testdata/raketasks/Rakefile +7 -0
  70. data/testdata/raketasks/success_test_case.rb +6 -0
  71. data/testdata/sleep_3_secs_test_case.rb +9 -0
  72. data/testdata/{should_not_sync_codebase_and_setup_working_dir_when_agent_is_in_same_dir_with_master_process → verify_dir_pwd}/verify_dir_pwd_test_case.rb +1 -1
  73. metadata +33 -13
  74. data/README +0 -182
  75. data/install.rb +0 -88
  76. /data/testdata/{should_not_sync_codebase_and_setup_working_dir_when_agent_is_in_same_dir_with_master_process → verify_dir_pwd}/Rakefile +0 -0
data/README DELETED
@@ -1,182 +0,0 @@
1
- = DTR -- Distributed Test Runner
2
-
3
- Supporting DTR version: 0.0.x
4
-
5
- This package contains DTR, a distributed test runner program for decreasing
6
- time of running ruby tests, only supporting Test::Unit ruby testing framework
7
- currently.
8
-
9
- DTR has the following features:
10
-
11
- * Run tests in mutli processes or on distributed machines.
12
-
13
- * Hot plug distributed agents.
14
-
15
- * Runtime injection, all tests run in same environment.
16
-
17
- DTR works in two parts: Runner Agent and DTR Master.
18
-
19
- * Runner Agent is a DRb service hosting on distributed machines to run tests. For using 'fork' to create runner process, Runner Agent can't run on Windows directly.
20
-
21
- * DTR Master is the process finding runner service to run tests and collect test results. It works by loading 'dtr/test_unit_injection.rb' with all test files.
22
-
23
- DTR doesn't synchronize codebase, so you need to consider using synchronize tools
24
- (e.g. rsync(http://samba.anu.edu.au/rsync/)) or distributed version control system
25
- (e.g. mercurial(http://www.selenic.com/mercurial/wiki/)) to synchronize project
26
- files between machines. The distributed version control system Mercurial is cool for
27
- synchronizing codebase between machines, see the example "Setup a development build
28
- grid".
29
-
30
- == Download
31
-
32
- The latest version of DTR can be found at
33
-
34
- * http://github.com/xli/dtr/tree/master
35
-
36
- == Installation
37
-
38
- === Normal Installation
39
-
40
- You can install DTR with the following command.
41
-
42
- % ruby install.rb
43
-
44
- from its distribution directory.
45
-
46
- === GEM Installation
47
-
48
- Download and install DTR with the following.
49
-
50
- gem install --remote dtr
51
-
52
- === Running the DTR Test Suite
53
-
54
- If you wish to run the unit and functional tests that come with DTR:
55
-
56
- * CD into the top project directory of dtr.
57
- * Type the following:
58
-
59
- rake # You need a version of rake installed
60
-
61
- == Simple Example
62
-
63
- Once installed, you can run DTR server anywhere:
64
-
65
- % dtr -s
66
-
67
- If you are running Runner Agent on remote machine, please specify the DTR server machine ip:
68
-
69
- % dtr -s --server_address dtr_server_ip
70
-
71
- After server started, you can run DTR runner agent at your project directory as follows:
72
-
73
- % dtr --server_address dtr_server_ip -r runner_name
74
-
75
- Type "dtr --help" for an up-to-date option summary.
76
- Invoking <tt>dtr</tt> without any options causes dtr to show help too.
77
-
78
- Most of time your project test suite need setup environment before run tests, you
79
- can set setup command by option '--setup', for example:
80
-
81
- % dtr --server_address dtr_server_ip -r runner1 --setup "rake db:test:prepare"
82
-
83
- At last, you need to add 'dtr/test_unit_injection.rb' into test_files of your test
84
- task in your Rakefile, and for load it, you also need add dtr lib path:
85
-
86
- require 'dtr'
87
-
88
- DTR.broadcast_list = ['dtr server ip']
89
-
90
- Rake::TestTask.new(:dtr_tests) do |t|
91
- t.libs << DTR.lib_path
92
- t.test_files = FileList['dtr/test_unit_injection.rb', 'test/*test.rb']
93
- t.warning = false
94
- t.verbose = false
95
- end
96
-
97
- In the case above we changed dtr broadcast list for listening remote dtr server.
98
- And you also can use *DTR.port = 1234* to change the port listening. These two
99
- options would be cached in the directory running the test or any other dtr processes
100
- (e.g. dtr runner agent or dtr server).
101
-
102
- == Run tests in multi-processes on one machine
103
-
104
- For running Runner in multi-processes.
105
- The following is the test task example in the rake file:
106
-
107
- require 'dtr/raketasks'
108
-
109
- DTR::TestTask.new :test do |t|
110
- t.test_files = FileList['test/*test.rb']
111
- t.processes = 2 #default is 2
112
- end
113
-
114
- === Runner Agent
115
-
116
- * Clone repository from M1 to M2 in home directory: hg clone http: //M1_IP:8000/pet_store
117
- * Start runner agent in the directory ~/pet_store on M2: rake --rakefile dtr_tasks.rake dtr:runner_agent
118
- * Start runner agent on M3 same with above.
119
-
120
- === Run DTR Master on M1
121
-
122
- * Commit all changes into Mercurial
123
- * rake --rakefile dtr_tasks.rake dtr
124
- * After you started the DTR Master, you can type the following to monitor the DTR Server status: dtr -a $DEV_BUILD_SERVER -m
125
- * For output into console, open the debug option: dtr -a $DEV_BUILD_SERVER -d -m
126
-
127
- == Credits
128
-
129
- [<b>Josh Price</b>] For fixing tests packer in release 0.0.1.
130
-
131
- [<b>Wang Pengchao</b>] For sharing lots of ideas.
132
-
133
- [<b>Barrow H Kwan</b>] For patch of specifying DTR server port.
134
-
135
- [<b>Mingle team</b>(http://studios.thoughtworks.com/mingle-project-intelligence)] For making all these happen.
136
-
137
- == License
138
-
139
- DTR is available under an Apache License Version 2.
140
-
141
- == Support
142
-
143
- Feel free to submit commits or feature requests. If you send a patch,
144
- remember to update the corresponding unit tests. If fact, I prefer
145
- new feature to be submitted in the form of new unit tests.
146
-
147
- For other information, feel free to contact mailto:iam@li-xiao.com.
148
-
149
- == Usage
150
-
151
- DTR client is invoked from the command line using:
152
-
153
- % dtr [<em>options</em> ...]
154
-
155
- === Options are:
156
-
157
- -p, --port PORT Port number DTR will listen to. Default is 3344.
158
- -r runner1_name,runner2_name Start DTR test runner agent with unique runner names.
159
- -a, --server_address ADDRESS Specify dtr server address, domain name or ip address, e.g. 192.168.0.1. Default is 'localhost'.
160
- -i, --setup COMMAND Set command for initializing test runner test environment, e.g. 'rake db:test:prepare'. Default is do nothing.
161
- -m, --monitor Monitor the status of the dtr rinda server, e.g. dtr -a 10.11.1.2 -m
162
- -b, --be_silent Only show error messages
163
- -d, --debug output debug log
164
- -v, --version Show version
165
- -h, --help Show this help doc
166
-
167
- Type "dtr --help" for an up-to-date option summary.
168
-
169
- = Other stuff
170
-
171
- Author:: Li Xiao <iam@li-xiao.com>
172
- Requires:: Ruby 1.8.5 or later
173
- License:: Copyright 2007-2008 by Li Xiao.
174
- Released under an Apache License 2. See the LICENSE file
175
- included in the distribution.
176
-
177
- == Warranty
178
-
179
- This software is provided "as is" and without any express or
180
- implied warranties, including, without limitation, the implied
181
- warranties of merchantibility and fitness for a particular
182
- purpose.
data/install.rb DELETED
@@ -1,88 +0,0 @@
1
- require 'rbconfig'
2
- require 'find'
3
- require 'ftools'
4
-
5
- include Config
6
-
7
- $ruby = CONFIG['ruby_install_name']
8
-
9
- ##
10
- # Install a binary file. We patch in on the way through to
11
- # insert a #! line. If this is a Unix install, we name
12
- # the command (for example) 'dtr' and let the shebang line
13
- # handle running it. Under windows, we add a '.rb' extension
14
- # and let file associations to their stuff
15
- #
16
-
17
- def installBIN(from, opfile)
18
-
19
- tmp_dir = nil
20
- for t in [".", "/tmp", "c:/temp", $bindir]
21
- stat = File.stat(t) rescue next
22
- if stat.directory? and stat.writable?
23
- tmp_dir = t
24
- break
25
- end
26
- end
27
-
28
- fail "Cannot find a temporary directory" unless tmp_dir
29
- tmp_file = File.join(tmp_dir, "_tmp")
30
-
31
- File.open(from) do |ip|
32
- File.open(tmp_file, "w") do |op|
33
- ruby = File.join($realbindir, $ruby)
34
- op.puts "#!#{ruby}"
35
- op.write ip.read
36
- end
37
- end
38
-
39
- opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
40
- File::install(tmp_file, File.join($bindir, opfile), 0755, true)
41
- File::unlink(tmp_file)
42
- end
43
-
44
- $sitedir = CONFIG["sitelibdir"]
45
- unless $sitedir
46
- version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
47
- $libdir = File.join(CONFIG["libdir"], "ruby", version)
48
- $sitedir = $:.find {|x| x =~ /site_ruby/}
49
- if !$sitedir
50
- $sitedir = File.join($libdir, "site_ruby")
51
- elsif $sitedir !~ Regexp.quote(version)
52
- $sitedir = File.join($sitedir, version)
53
- end
54
- end
55
-
56
- $bindir = CONFIG["bindir"]
57
-
58
- $realbindir = $bindir
59
-
60
- bindir = CONFIG["bindir"]
61
- if (destdir = ENV['DESTDIR'])
62
- $bindir = destdir + $bindir
63
- $sitedir = destdir + $sitedir
64
-
65
- File::makedirs($bindir)
66
- File::makedirs($sitedir)
67
- end
68
-
69
- dtr_dest = File.join($sitedir, "dtr")
70
- File::makedirs(dtr_dest, true)
71
- File::chmod(0755, dtr_dest)
72
-
73
- # The library files
74
-
75
- files = Dir.chdir('lib') { Dir['**/*.rb', '**/*.rake'] }
76
-
77
- for fn in files
78
- fn_dir = File.dirname(fn)
79
- target_dir = File.join($sitedir, fn_dir)
80
- if ! File.exist?(target_dir)
81
- File.makedirs(target_dir)
82
- end
83
- File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true)
84
- end
85
-
86
- # and the executable
87
-
88
- installBIN("bin/dtr", "dtr")