dtr 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGES +7 -0
  2. data/LICENSE.txt +203 -0
  3. data/README.rdoc +208 -0
  4. data/Rakefile +64 -205
  5. data/TODO +8 -2
  6. data/bin/dtr +27 -60
  7. data/dtr.gemspec +8 -11
  8. data/lib/dtr.rb +5 -94
  9. data/lib/dtr/agent.rb +38 -0
  10. data/lib/dtr/agent/brain.rb +57 -0
  11. data/lib/dtr/agent/herald.rb +60 -0
  12. data/lib/dtr/agent/runner.rb +87 -0
  13. data/lib/dtr/agent/sync_codebase.rb +44 -0
  14. data/lib/dtr/agent/sync_logger.rb +70 -0
  15. data/lib/dtr/agent/test_case.rb +53 -0
  16. data/lib/dtr/agent/test_unit.rb +40 -0
  17. data/lib/dtr/agent/worker.rb +89 -0
  18. data/lib/dtr/agent/working_env_ext.rb +47 -0
  19. data/lib/dtr/facade.rb +65 -0
  20. data/lib/dtr/master.rb +40 -0
  21. data/lib/dtr/monitor.rb +95 -0
  22. data/lib/dtr/raketasks.rb +155 -22
  23. data/lib/dtr/shared.rb +24 -0
  24. data/lib/dtr/shared/adapter.rb +115 -0
  25. data/lib/dtr/shared/configuration.rb +104 -0
  26. data/lib/dtr/shared/message_decorator.rb +28 -0
  27. data/lib/dtr/shared/ruby_ext.rb +129 -0
  28. data/lib/dtr/shared/service.rb +19 -0
  29. data/lib/dtr/shared/service/agent.rb +37 -0
  30. data/lib/dtr/shared/service/file.rb +28 -0
  31. data/lib/dtr/shared/service/rinda.rb +48 -0
  32. data/lib/dtr/shared/service/runner.rb +34 -0
  33. data/lib/dtr/shared/service/working_env.rb +28 -0
  34. data/lib/dtr/shared/sync_codebase.rb +18 -0
  35. data/lib/dtr/shared/sync_codebase/copiable_package.rb +40 -0
  36. data/lib/dtr/shared/sync_codebase/master_ext.rb +40 -0
  37. data/lib/dtr/shared/sync_codebase/package.rb +53 -0
  38. data/lib/dtr/shared/sync_codebase/sync_service.rb +36 -0
  39. data/lib/dtr/shared/sync_logger.rb +64 -0
  40. data/lib/dtr/shared/utils.rb +17 -0
  41. data/lib/dtr/shared/utils/cmd.rb +30 -0
  42. data/lib/dtr/shared/utils/env_store.rb +60 -0
  43. data/lib/dtr/shared/utils/logger.rb +87 -0
  44. data/lib/dtr/shared/working_env.rb +38 -0
  45. data/lib/dtr/test_unit.rb +9 -275
  46. data/lib/dtr/test_unit/drb_test_runner.rb +48 -0
  47. data/lib/dtr/test_unit/injection.rb +29 -0
  48. data/lib/dtr/test_unit/test_case_injection.rb +37 -0
  49. data/lib/dtr/test_unit/test_suite_injection.rb +24 -0
  50. data/lib/dtr/test_unit/testrunnermediator_injection.rb +72 -0
  51. data/lib/dtr/test_unit/thread_safe_test_result.rb +38 -0
  52. data/lib/dtr/test_unit/worker_club.rb +72 -0
  53. data/lib/dtr/test_unit_injection.rb +1 -2
  54. data/test/acceptance/agent_working_env_test.rb +86 -0
  55. data/test/acceptance/dtr_package_task_test.rb +36 -0
  56. data/test/acceptance/general_test.rb +331 -0
  57. data/test/acceptance/raketasks_test.rb +23 -0
  58. data/test/acceptance/sync_codebase_test.rb +66 -0
  59. data/test/acceptance/sync_logger_test.rb +32 -0
  60. data/test/agent_helper.rb +37 -0
  61. data/test/logger_stub.rb +34 -0
  62. data/test/test_helper.rb +71 -0
  63. data/test/unit/adapter_test.rb +149 -0
  64. data/test/unit/configuration_test.rb +44 -0
  65. data/test/unit/facade_test.rb +41 -0
  66. data/test/unit/logger_test.rb +72 -0
  67. data/test/unit/test_unit_test.rb +26 -0
  68. data/test/unit/working_env_test.rb +71 -0
  69. data/testdata/Rakefile +11 -0
  70. data/testdata/a_failed_test_case.rb +8 -0
  71. data/testdata/a_file_system_test_case.rb +8 -0
  72. data/testdata/a_test_case.rb +13 -0
  73. data/testdata/a_test_case2.rb +6 -0
  74. data/testdata/an_error_test_case.rb +9 -0
  75. data/testdata/another_project/Rakefile +6 -0
  76. data/testdata/another_project/passed_test_case.rb +7 -0
  77. data/testdata/hacked_run_method_test_case.rb +15 -0
  78. data/testdata/is_required_by_a_test.rb +9 -0
  79. data/testdata/lib/lib_test_case.rb +7 -0
  80. data/testdata/package_task_test_rakefile +8 -0
  81. data/testdata/raketasks/Rakefile +7 -0
  82. data/testdata/raketasks/success_test_case.rb +6 -0
  83. data/testdata/scenario_test_case.rb +34 -0
  84. data/testdata/setup_agent_env_test_case.rb +9 -0
  85. data/testdata/sleep_3_secs_test_case.rb +9 -0
  86. data/testdata/verify_dir_pwd/Rakefile +6 -0
  87. data/testdata/verify_dir_pwd/verify_dir_pwd_test_case.rb +10 -0
  88. metadata +101 -34
  89. data/README +0 -291
  90. data/install.rb +0 -88
  91. data/lib/dtr/base.rb +0 -172
  92. data/lib/dtr/runner.rb +0 -270
  93. data/lib/dtr/service_provider.rb +0 -160
data/CHANGES CHANGED
@@ -1,5 +1,12 @@
1
1
  = DTR Changelog
2
2
 
3
+ == release 1.0.0
4
+ * support synchronizing codebase
5
+ * lookup agents by broadcast
6
+ * group agents for different project or environment usage
7
+ * no need launch dtr rinda server anymore
8
+ * agents log would be output into master process log
9
+
3
10
  == release 0.0.4
4
11
  * added timeout for running test more stable
5
12
  the default timeout is 60 sec, can be changed by environment variable 'RUN_TEST_TIMEOUT'
@@ -0,0 +1,203 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
@@ -0,0 +1,208 @@
1
+ = DTR -- Distributed Test Runner
2
+
3
+ Supporting DTR version: 1.x.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
+ * Synchronizing codebase between agent and master processes.
16
+
17
+ * Runtime injection, all tests run in same environment.
18
+
19
+ DTR works in two parts: Runner Agent and DTR Master.
20
+
21
+ * 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. Requisites for running agent: Unix/Linux based OS System for forking sub-process; 'unzip' command for extracting codebase package.
22
+
23
+ * 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 or defining a DTR::TestTask in your rake file. Requisites for running master: 'zip' command for creating codebase package.
24
+
25
+ DTR (version >= 1.0.0) supports synchronizing codebase by a DTR::PackageTask defined in your rake tasks. The DTR::PackageTask is a similar task with Rake::PackageTask, the following is a simple example:
26
+
27
+ require 'dtr/raketasks'
28
+ DTR::PackageTask.new do |p|
29
+ p.package_files.include("**/*")
30
+ p.package_files.exclude('tmp/**/*')
31
+ p.package_files.exclude('log/*')
32
+ end
33
+
34
+ The DTR::TestTask will create a DTR::PackageTask for you directly, and you can specify package_files too.
35
+
36
+ DTR::TestTask.new do |t|
37
+ t.test_files = FileList['test/*_test.rb']
38
+ t.processes = 2
39
+ t.package_files.include('**/*.rb')
40
+ t.package_files.exclude('tmp/**/*')
41
+ t.package_files.exclude('log/*')
42
+ end
43
+
44
+ Note: Exclude('log/*') only excludes all files inside 'log' directory except 'log' directory itself.
45
+
46
+ == Rails plugin
47
+
48
+ For Rails project, you just need copy dtr project directory into your project plugins directory. There are dtr tasks defined for you to run tests within dtr grid, which prefer you have 'config/database.yml.dtr' for setting up database. The test task is 'dtr:test'.
49
+
50
+ Your project directory name would be the default group name of dtr agents. You can specify an environment variable named 'DTR_GROUP' to change the group name. By default, dtr tasks would lookup the broadcast ip by 'ifconfig' command. If it doesn't work for you, you can specify an environment variable named 'BROADCAST_IP' to overwrite it.
51
+
52
+ == Download
53
+
54
+ The latest version of DTR can be found at
55
+
56
+ * http://github.com/xli/dtr/tree/master
57
+
58
+ == GEM Installation
59
+
60
+ === Last stable version from rubyforge.org
61
+
62
+ Download and install DTR with the following.
63
+
64
+ gem install --remote dtr
65
+
66
+ === Last version on github master branch
67
+
68
+ Run the following if you haven't already:
69
+
70
+ gem sources -a http://gems.github.com
71
+
72
+ Install the gem:
73
+
74
+ sudo gem install xli-dtr
75
+
76
+ == Running the DTR Test Suite
77
+
78
+ If you wish to run the unit and functional tests that come with DTR:
79
+
80
+ * CD into the top project directory of dtr.
81
+ * Type the following:
82
+
83
+ rake # You need a version of rake installed
84
+
85
+ == Simple Example
86
+
87
+ Start DTR agent with providing 1 runner in group 'mysql-firefox' as follows:
88
+
89
+ dtr -r runner1 -g mysql-firefox
90
+
91
+ Type "dtr --help" for an up-to-date option summary.
92
+ Invoking <tt>dtr</tt> without any options causes dtr to show help too.
93
+
94
+ Most of time your project test suite need setup environment before run tests, you
95
+ can set setup command by option '--setup', for example:
96
+
97
+ dtr -r runner1,runner2 --setup "rake db:test:prepare"
98
+
99
+ You also can specify DTR_AGENT_ENV_SETUP_CMD in your master process environment to let all agents
100
+ that are not started with '--setup' option specified to setup all agents environment.
101
+
102
+ At last, you need define a DTR::TestTask:
103
+
104
+ require 'dtr'
105
+
106
+ ENV['DTR_AGENT_ENV_SETUP_CMD'] = 'rake db:test:prepare'
107
+ DTR.broadcast_list = ['broadcast_ip']
108
+ DTR.group = 'mysql-firefox'
109
+
110
+ DTR::TestTask.new do |t|
111
+ t.test_files = FileList['test/**/*_test.rb']
112
+ t.processes = 0 # don't start agent in local machine, default is 1, so we reset to 0 here.
113
+ t.package_files.include("Rakefile")
114
+ t.package_files.include("app/**/*")
115
+ t.package_files.include("db/migrate/**/*")
116
+ t.package_files.include("config/**/*")
117
+ t.package_files.include("lib/**/*")
118
+ t.package_files.include("vendor/**/*")
119
+ t.package_files.include("test/**/*")
120
+ end
121
+
122
+ The default task name is 'dtr', and it also creates package tasks you need for packaging files need for running test.
123
+ More details about DTR::TestTask and DTR::PackageTask, see the API doc:
124
+
125
+ ri DTR::TestTask
126
+ ri DTR::PackageTask
127
+
128
+ Notes:
129
+ * DTR broadcast_list and group configuration would be cached in the directory. Name of configuration file is '.dtr_env_pstore'.
130
+ * For packaging codebase, DTR::PackageTask creates tasks: dtr_package, dtr_clobber_package and dtr_repackage; DTR Master just simply run a command 'rake dtr_repackage' to create the package and run 'rake dtr_clobber_package' to clean package. So make sure there are those tasks under root namespace in your rake tasks.
131
+
132
+ == Run tests in multi-processes on one machine
133
+
134
+ For running Runner in multi-processes.
135
+ The following is the test task example in the rake file:
136
+
137
+ require 'dtr/raketasks'
138
+
139
+ DTR::TestTask.new do |t|
140
+ t.test_files = FileList['test/*test.rb']
141
+ t.processes = 2 #default is 1
142
+ end
143
+
144
+ == Credits
145
+
146
+ [<b>Josh Price</b>] For fixing tests packer in release 0.0.1.
147
+
148
+ [<b>Wang Pengchao</b>] For sharing lots of ideas and code contributions.
149
+
150
+ [<b>Barrow H Kwan</b>] For patch of specifying DTR Rinda server port (version 0.0.x) and testing DTR new version.
151
+
152
+ [<b>Mingle team</b>(http://studios.thoughtworks.com/mingle-project-intelligence)] For making all these happen.
153
+
154
+ == License
155
+
156
+ DTR is available under an Apache License Version 2.
157
+
158
+ == Support
159
+
160
+ Feel free to submit commits or feature requests.
161
+ For other information, feel free to contact mailto:iam@li-xiao.com.
162
+
163
+ == Usage
164
+
165
+ DTR agent command is invoked from the command line using:
166
+
167
+ dtr [<em>options</em> ...]
168
+
169
+ === Options are:
170
+
171
+ -p, --port PORT Port number of DTR agent listening. Default is 7788.
172
+ -g, --group GROUP_NAME If you have several DTR grids working for different project or environment, you should group your agents in different names for different usages. Default is none.
173
+ -r runner1_name,runner2_name Start DTR test runner agent with unique runner names.
174
+ -a, --broadcast_address ADDRESS Specify broadcast address for looking up dtr agent service, e.g. 192.168.255.255. Default is 'localhost'. DTR master and monitor would need this.
175
+ -i, --setup COMMAND Set command for initializing test runner test environment, e.g. 'rake db:test:prepare'. Default is do nothing. You also can specify DTR_AGENT_ENV_SETUP_CMD in your master process environment to let all agents setup same environment.
176
+ -d DIRECTORY Specify a directory as agent launching & working directory.
177
+ --working_directory
178
+ -m, --monitor Monitor the status of the dtr agents and master processes. Used for testing your dtr grid environment. CAUTION! monitoring agents causes all idle agents hang on by the monitor process.
179
+ -v, --version Show version
180
+ -h, --help Show this help doc
181
+
182
+ Notes:
183
+ * DTR would always add 'localhost' into broadcast list.
184
+ * Agent start by specifying runners by -r option, every runner would be started in different process for running test. e.g. dtr -r runner1,runner2
185
+ * DTR master environment options:
186
+ * DTR_MASTER_ENV: this variable would be copied into agent process for sharing info between master and agents. Normally used in agent setup environment command.
187
+ * DTR_AGENT_ENV_SETUP_CMD: this variable would be applied as agent setup environment command when agent have no setup environment command specified by --setup option.
188
+ * DTR_LOG_LEVEL: master process logger level, e.g. ENV['DTR_LOG_LEVEL'] = Logger::DEBUG. Agent process logs would be output in master process log file, so setting this option also changes agent logger level.
189
+ * DTR_RUNNER_NAME: this environment variable would be provided in runner process for test environment to get the runner name to setup, e.g. setting up database configuration.
190
+
191
+ Type "dtr --help" for an up-to-date option summary.
192
+
193
+ = Other stuff
194
+
195
+ Author: Li Xiao <iam@li-xiao.com>
196
+
197
+ Requires: Ruby 1.8.6 or later
198
+
199
+ License: Copyright 2007-2008 by Li Xiao.
200
+ Released under an Apache License 2. See the LICENSE file
201
+ included in the distribution.
202
+
203
+ == Warranty
204
+
205
+ This software is provided "as is" and without any express or
206
+ implied warranties, including, without limitation, the implied
207
+ warranties of merchantibility and fitness for a particular
208
+ purpose.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rakefile for DTR -*- ruby -*-
2
2
 
3
- # Copyright 2007 by Li Xiao (swing1979@gmail.com)
3
+ # Copyright 2007 by Li Xiao (iam@li-xiao.com)
4
4
  # All rights reserved.
5
5
 
6
6
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')
@@ -48,82 +48,43 @@ end
48
48
 
49
49
  task :test_all => [:test_units, :tf]
50
50
  task :tu => :test_units
51
- task :tf => [:start_dtr_server, :start_dtr_runners, :test_functionals, :stop_dtr_runners, :stop_dtr_server]
51
+ task :tf => [:test_functionals]
52
52
  task :test => :test_units
53
53
 
54
54
  Rake::TestTask.new(:test_units) do |t|
55
- t.test_files = FileList['test/*test.rb']
55
+ t.test_files = FileList['test/unit/*_test.rb']
56
56
  t.warning = true
57
57
  t.verbose = false
58
58
  end
59
59
 
60
60
  Rake::TestTask.new(:test_functionals) do |t|
61
- t.test_files = FileList['test/scenario*.rb']
62
- t.warning = true
61
+ t.test_files = FileList['test/acceptance/*_test.rb']
62
+ t.warning = false
63
63
  t.verbose = false
64
64
  end
65
65
 
66
- task :start_dtr_server do
67
- ruby "-I#{File.dirname(__FILE__) + "/lib"} #{File.dirname(__FILE__) + "/bin/dtr"} -s -D"
68
- end
69
-
70
- task :start_dtr_runners do
71
- ruby "-I#{File.dirname(__FILE__) + "/lib"} #{File.dirname(__FILE__) + "/bin/dtr"} -r r1,r2,r3 -D"
72
- end
73
-
74
- task :stop_dtr_runners do
75
- ruby "-I#{File.dirname(__FILE__) + "/lib"} #{File.dirname(__FILE__) + "/bin/dtr"} -R"
76
- end
77
-
78
- task :stop_dtr_server do
79
- ruby "-I#{File.dirname(__FILE__) + "/lib"} #{File.dirname(__FILE__) + "/bin/dtr"} -S"
80
- end
81
-
82
- begin
83
- require 'rcov/rcovtask'
84
-
85
- Rcov::RcovTask.new do |t|
86
- t.libs << "test"
87
- t.rcov_opts = [
88
- '-xRakefile', '-xrakefile', '-xpublish.rf', '--text-report',
89
- ]
90
- t.test_files = FileList[
91
- 'test/*test.rb'
92
- ]
93
- t.output_dir = 'coverage'
94
- t.verbose = true
95
- end
96
- rescue LoadError
97
- # No rcov available
98
- end
99
-
100
66
  directory 'testdata'
101
67
  [:test_units].each do |t|
102
68
  task t => ['testdata']
103
69
  end
104
70
 
105
- # CVS Tasks ----------------------------------------------------------
106
-
107
- # Install DTR using the standard install.rb script.
108
-
109
- desc "Install the application"
110
- task :install do
111
- ruby "install.rb"
71
+ task :monitor do
72
+ DTR.monitor
112
73
  end
113
74
 
75
+ # CVS Tasks ----------------------------------------------------------
76
+
114
77
  # Create a task to build the RDOC documentation tree.
115
78
 
116
79
  rd = Rake::RDocTask.new("rdoc") { |rdoc|
117
80
  rdoc.rdoc_dir = 'html'
118
- # rdoc.template = 'kilmer'
119
- # rdoc.template = 'css2'
120
- rdoc.template = 'doc/jamis.rb'
81
+ rdoc.template = 'html'
121
82
  rdoc.title = "DTR -- Distributed Test Runner"
122
83
  rdoc.options << '--line-numbers' << '--inline-source' <<
123
- '--main' << 'README' <<
84
+ '--main' << 'README.rdoc' <<
124
85
  '--title' << '"DTR -- Distributed Test Runner'
125
- rdoc.rdoc_files.include('README', 'LICENSE.txt', 'TODO', 'CHANGES')
126
- rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
86
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE.txt', 'TODO', 'CHANGES')
87
+ rdoc.rdoc_files.include('lib/**/*.rb')
127
88
  }
128
89
 
129
90
  # ====================================================================
@@ -133,8 +94,52 @@ rd = Rake::RDocTask.new("rdoc") { |rdoc|
133
94
  if ! defined?(Gem)
134
95
  puts "Package Target requires RubyGEMs"
135
96
  else
97
+ Dir.glob(File.dirname(__FILE__) + "/testdata/**/log").each do |log_dir|
98
+ FileUtils.rm_rf(log_dir)
99
+ end
100
+
101
+ gem_content = <<-GEM
102
+ Gem::Specification.new do |spec|
103
+ spec.name = 'dtr'
104
+ spec.version = "1.0.0"
105
+ spec.summary = "DTR is a distributed test runner to run tests on distributed computers for decreasing build time."
106
+
107
+ #### Dependencies and requirements.
108
+ spec.files = #{(Dir.glob("lib/**/*.rb") + ["bin/dtr", "CHANGES", "dtr.gemspec", "lib", "LICENSE.TXT", "Rakefile", "README.rdoc", "TODO"]).inspect}
109
+
110
+ spec.test_files = #{(Dir.glob("test/**/*.rb") + Dir.glob("testdata/**/*")).inspect}
111
+
112
+ #### Load-time details: library and application (you will need one or both).
113
+
114
+ spec.require_path = 'lib' # Use these for libraries.
115
+
116
+ spec.bindir = "bin" # Use these for applications.
117
+ spec.executables = ["dtr"]
118
+ spec.default_executable = "dtr"
119
+
120
+ #### Documentation and testing.
121
+
122
+ spec.has_rdoc = true
123
+ spec.extra_rdoc_files = #{rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a.inspect}
124
+ spec.rdoc_options = #{rd.options.inspect}
125
+
126
+ #### Author and project details.
127
+
128
+ spec.author = "Li Xiao"
129
+ spec.email = "iam@li-xiao.com"
130
+ spec.homepage = "http://github.com/xli/dtr/tree/master"
131
+ spec.rubyforge_project = "dtr"
132
+ end
133
+ GEM
134
+ File.open(File.dirname(__FILE__) + '/dtr.gemspec', 'w') do |f|
135
+ f.write(gem_content)
136
+ end
137
+
138
+ #build gem package same steps with github
136
139
  File.open(File.dirname(__FILE__) + '/dtr.gemspec') do |f|
137
- spec = eval(f.read)
140
+ data = f.read
141
+ spec = nil
142
+ Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
138
143
  package_task = Rake::GemPackageTask.new(spec) do |pkg|
139
144
  #pkg.need_zip = true
140
145
  #pkg.need_tar = true
@@ -176,11 +181,6 @@ task :lines do
176
181
  show_line("TOTAL", total_lines, total_code)
177
182
  end
178
183
 
179
- # Define an optional publish target in an external file. If the
180
- # publish.rf file is not found, the publish targets won't be defined.
181
-
182
- load "publish.rf" if File.exist? "publish.rf"
183
-
184
184
  # Support Tasks ------------------------------------------------------
185
185
 
186
186
  RUBY_FILES = FileList['**/*.rb'].exclude('pkg')
@@ -212,162 +212,21 @@ file "TAGS" => RUBY_FILES do
212
212
  sh "#{TAGS} #{RUBY_FILES}", :verbose => false
213
213
  end
214
214
 
215
- # --------------------------------------------------------------------
216
- # Creating a release
217
-
218
215
  task :update_site do
219
216
  puts %x[scp -r html/* lixiao@rubyforge.org:/var/www/gforge-projects/dtr/]
220
217
  end
221
218
 
222
- task :noop
223
-
224
- desc "[rel, reuse, reltest] Make a new release"
225
- task :release => [
226
- :prerelease,
227
- :clobber,
228
- :test_all,
229
- :update_version,
230
- :package,
231
- :tag] do
232
-
233
- announce
234
- announce "**************************************************************"
235
- announce "* Release #{$package_version} Complete."
236
- announce "* Packages ready to upload."
237
- announce "**************************************************************"
238
- announce
239
- end
240
-
241
- # Validate that everything is ready to go for a release.
242
- desc "[rel, reuse, reltest]"
243
- task :prerelease do |t, rel, reuse, reltest|
244
- $package_version = rel
245
- announce
246
- announce "**************************************************************"
247
- announce "* Making RubyGem Release #{$package_version}"
248
- announce "* (current version #{CURRENT_VERSION})"
249
- announce "**************************************************************"
250
- announce
251
-
252
- # Is a release number supplied?
253
- unless rel
254
- fail "Usage: rake release[X.Y.Z] [REUSE=tag_suffix]"
255
- end
256
-
257
- # Is the release different than the current release.
258
- # (or is REUSE set?)
259
- if $package_version == CURRENT_VERSION && ! reuse
260
- fail "Current version is #{$package_version}, must specify REUSE=tag_suffix to reuse version"
261
- end
262
-
263
- # Are all source files checked in?
264
- if reltest
265
- announce "Release Task Testing, skipping checked-in file test"
266
- else
267
- announce "Checking for unchecked-in files..."
268
- data = `svn st`
269
- unless data =~ /^$/
270
- abort "svn status is not clean ... do you have unchecked-in files?"
271
- end
272
- announce "No outstanding checkins found ... OK"
273
- end
274
- end
275
-
276
- desc "[rel, reuse, reltest]"
277
- task :update_version => [:prerelease] do |t, rel, reuse, reltest|
278
- if rel == CURRENT_VERSION
279
- announce "No version change ... skipping version update"
280
- else
281
- announce "Updating DTR version to #{rel}"
282
- open("lib/dtr.rb") do |dtrin|
283
- open("lib/dtr.rb.new", "w") do |dtrout|
284
- dtrin.each do |line|
285
- if line =~ /^DTRVERSION\s*=\s*/
286
- dtrout.puts "DTRVERSION = '#{rel}'"
287
- else
288
- dtrout.puts line
289
- end
290
- end
291
- end
292
- end
293
- mv "lib/dtr.rb.new", "lib/dtr.rb"
294
- if reltest
295
- announce "Release Task Testing, skipping commiting of new version"
296
- else
297
- sh %{svn commit -m "Updated to version #{rel}" lib/dtr.rb} # "
298
- end
299
- end
300
- end
301
-
302
- desc "[rel, reuse, reltest] Tag all the CVS files with the latest release number (REL=x.y.z)"
303
- task :tag => [:prerelease] do |t, rel, reuse, reltest|
304
- reltag = "REL_#{rel.gsub(/\./, '_')}"
305
- reltag << reuse.gsub(/\./, '_') if reuse
306
- announce "Tagging Repository with [#{reltag}]"
307
- if reltest
308
- announce "Release Task Testing, skipping CVS tagging"
309
- else
310
- sh %{svn copy svn+ssh://rubyforge.org/var/svn/dtr/trunk svn+ssh://rubyforge.org/var/svn/dtr/tags/#{reltag} -m 'Commiting release #{reltag}'}
311
- end
312
- end
313
-
314
- desc "Install the jamis RDoc template"
315
- task :install_jamis_template do
316
- require 'rbconfig'
317
- dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
318
- fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
319
- install "doc/jamis.rb", dest_dir, :verbose => true
320
- end
321
-
322
- task :c1 do
323
- Dir.chdir('testdata') do
324
- DTR.launch_runners(['c1'], nil)
325
- end
326
- end
327
-
328
- task :c3 do
329
- Dir.chdir('testdata') do
330
- DTR.launch_runners(['c1', 'c2', 'c3'], nil)
331
- end
332
- end
333
- task :c10 do
334
- Dir.chdir('testdata') do
335
- DTR.launch_runners(['c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'c10'], nil)
336
- end
337
- end
338
-
339
- task :runners do
340
- runners = DTR.runners
341
- if runners.empty?
342
- puts "No runner available!"
343
- else
344
- puts runners.collect{|r| r.name}.join(", ")
345
- end
346
- end
347
-
348
- task :c2 do
349
- DTROPTIONS[:names] = ['c1', 'c2']
350
- DTROPTIONS[:setup] = nil
351
- Dir.chdir('testdata') do
352
- DTR.start_runners
353
- end
354
- end
355
-
356
- task :server do
357
- DTR.start_server
358
- end
359
-
360
- Rake::TestTask.new(:dtr) do |t|
361
- t.libs << DTR.lib_path
362
- t.test_files = FileList['dtr/inject_with_svn.rb', 'testdata/*.rb']
219
+ Rake::TestTask.new(:dtr_injected) do |t|
220
+ t.libs.unshift DTR.lib_path
221
+ t.test_files = FileList['dtr/test_unit_injection.rb', 'testdata/*.rb']
363
222
  t.warning = true
364
223
  t.verbose = false
365
224
  end
366
225
 
367
226
  require 'dtr/raketasks'
368
227
 
369
- DTR::MPTask.new :mt do |t|
228
+ DTR::TestTask.new do |t|
370
229
  t.test_files = FileList['testdata/*.rb']
371
- t.processes = 2
230
+ t.processes = 0
231
+ t.package_files.include('**/*')
372
232
  end
373
-