brendan-skynet 0.9.33 → 0.9.303
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/License.txt +1 -0
- data/Manifest.txt +19 -112
- data/Rakefile +3 -3
- data/app_generators/skynet_install/templates/skynet_config.rb +1 -1
- data/extras/rails/views/skynet/index.html.erb +137 -0
- data/lib/skynet.rb +15 -15
- data/lib/skynet/{skynet_active_record_extensions.rb → active_record_extensions.rb} +0 -0
- data/lib/skynet/{skynet_config.rb → config.rb} +0 -0
- data/lib/skynet/{skynet_console.rb → console.rb} +1 -1
- data/lib/skynet/{skynet_console_helper.rb → console_helper.rb} +0 -0
- data/lib/skynet/{skynet_debugger.rb → debugger.rb} +0 -0
- data/lib/skynet/{skynet_guid_generator.rb → guid_generator.rb} +0 -0
- data/lib/skynet/{skynet_job.rb → job.rb} +0 -0
- data/lib/skynet/{skynet_launcher.rb → launcher.rb} +0 -0
- data/lib/skynet/{skynet_logger.rb → logger.rb} +0 -0
- data/lib/skynet/{skynet_manager.rb → manager.rb} +0 -0
- data/lib/skynet/{skynet_message.rb → message.rb} +0 -0
- data/lib/skynet/{skynet_message_queue.rb → message_queue.rb} +0 -0
- data/lib/skynet/{skynet_partitioners.rb → partitioners.rb} +0 -0
- data/lib/skynet/{skynet_ruby_extensions.rb → ruby_extensions.rb} +0 -0
- data/lib/skynet/{skynet_task.rb → task.rb} +0 -0
- data/lib/skynet/{skynet_tuplespace_server.rb → tuplespace_server.rb} +0 -0
- data/lib/skynet/version.rb +1 -1
- data/lib/skynet/{skynet_worker.rb → worker.rb} +0 -0
- data/skynet.gemspec +21 -132
- metadata +22 -130
- data/examples/dgrep/README +0 -70
- data/examples/dgrep/config/skynet_config.rb +0 -26
- data/examples/dgrep/data/shakespeare/README +0 -2
- data/examples/dgrep/data/shakespeare/poetry/loverscomplaint +0 -381
- data/examples/dgrep/data/shakespeare/poetry/rapeoflucrece +0 -2199
- data/examples/dgrep/data/shakespeare/poetry/sonnets +0 -2633
- data/examples/dgrep/data/shakespeare/poetry/various +0 -640
- data/examples/dgrep/data/shakespeare/poetry/venusandadonis +0 -1423
- data/examples/dgrep/data/testfile1.txt +0 -1
- data/examples/dgrep/data/testfile2.txt +0 -1
- data/examples/dgrep/data/testfile3.txt +0 -1
- data/examples/dgrep/data/testfile4.txt +0 -1
- data/examples/dgrep/lib/dgrep.rb +0 -59
- data/examples/dgrep/lib/mapreduce_test.rb +0 -32
- data/examples/dgrep/lib/most_common_words.rb +0 -45
- data/examples/dgrep/script/dgrep +0 -75
- data/examples/rails_mysql_example/README +0 -66
- data/examples/rails_mysql_example/Rakefile +0 -10
- data/examples/rails_mysql_example/app/controllers/application.rb +0 -10
- data/examples/rails_mysql_example/app/helpers/application_helper.rb +0 -3
- data/examples/rails_mysql_example/app/models/user.rb +0 -21
- data/examples/rails_mysql_example/app/models/user_favorite.rb +0 -5
- data/examples/rails_mysql_example/app/models/user_mailer.rb +0 -12
- data/examples/rails_mysql_example/app/views/user_mailer/welcome.erb +0 -5
- data/examples/rails_mysql_example/config/boot.rb +0 -109
- data/examples/rails_mysql_example/config/database.yml +0 -42
- data/examples/rails_mysql_example/config/environment.rb +0 -59
- data/examples/rails_mysql_example/config/environments/development.rb +0 -18
- data/examples/rails_mysql_example/config/environments/production.rb +0 -19
- data/examples/rails_mysql_example/config/environments/test.rb +0 -22
- data/examples/rails_mysql_example/config/initializers/inflections.rb +0 -10
- data/examples/rails_mysql_example/config/initializers/mime_types.rb +0 -5
- data/examples/rails_mysql_example/config/initializers/skynet.rb +0 -1
- data/examples/rails_mysql_example/config/routes.rb +0 -35
- data/examples/rails_mysql_example/config/skynet_config.rb +0 -36
- data/examples/rails_mysql_example/db/migrate/001_create_skynet_tables.rb +0 -43
- data/examples/rails_mysql_example/db/migrate/002_create_users.rb +0 -16
- data/examples/rails_mysql_example/db/migrate/003_create_user_favorites.rb +0 -14
- data/examples/rails_mysql_example/db/schema.rb +0 -85
- data/examples/rails_mysql_example/db/skynet_mysql_schema.sql +0 -33
- data/examples/rails_mysql_example/doc/README_FOR_APP +0 -2
- data/examples/rails_mysql_example/lib/tasks/rails_mysql_example.rake +0 -20
- data/examples/rails_mysql_example/public/404.html +0 -30
- data/examples/rails_mysql_example/public/422.html +0 -30
- data/examples/rails_mysql_example/public/500.html +0 -30
- data/examples/rails_mysql_example/public/dispatch.cgi +0 -10
- data/examples/rails_mysql_example/public/dispatch.fcgi +0 -24
- data/examples/rails_mysql_example/public/dispatch.rb +0 -10
- data/examples/rails_mysql_example/public/favicon.ico +0 -0
- data/examples/rails_mysql_example/public/images/rails.png +0 -0
- data/examples/rails_mysql_example/public/index.html +0 -277
- data/examples/rails_mysql_example/public/javascripts/application.js +0 -2
- data/examples/rails_mysql_example/public/javascripts/controls.js +0 -963
- data/examples/rails_mysql_example/public/javascripts/dragdrop.js +0 -972
- data/examples/rails_mysql_example/public/javascripts/effects.js +0 -1120
- data/examples/rails_mysql_example/public/javascripts/prototype.js +0 -4225
- data/examples/rails_mysql_example/public/robots.txt +0 -5
- data/examples/rails_mysql_example/script/about +0 -3
- data/examples/rails_mysql_example/script/console +0 -3
- data/examples/rails_mysql_example/script/destroy +0 -3
- data/examples/rails_mysql_example/script/generate +0 -3
- data/examples/rails_mysql_example/script/performance/benchmarker +0 -3
- data/examples/rails_mysql_example/script/performance/profiler +0 -3
- data/examples/rails_mysql_example/script/performance/request +0 -3
- data/examples/rails_mysql_example/script/plugin +0 -3
- data/examples/rails_mysql_example/script/process/inspector +0 -3
- data/examples/rails_mysql_example/script/process/reaper +0 -3
- data/examples/rails_mysql_example/script/process/spawner +0 -3
- data/examples/rails_mysql_example/script/runner +0 -3
- data/examples/rails_mysql_example/script/server +0 -3
- data/examples/rails_mysql_example/test/fixtures/user_favorites.yml +0 -9
- data/examples/rails_mysql_example/test/fixtures/users.yml +0 -11
- data/examples/rails_mysql_example/test/test_helper.rb +0 -38
- data/examples/rails_mysql_example/test/unit/user_favorite_test.rb +0 -8
- data/examples/rails_mysql_example/test/unit/user_test.rb +0 -8
- data/extras/nagios/check_skynet.sh +0 -121
- data/extras/rails/views/skynet/index.rhtml +0 -137
- data/tasks/website.rake +0 -17
- data/test/test_active_record_extensions.rb +0 -138
- data/test/test_generator_helper.rb +0 -20
- data/test/test_helper.rb +0 -10
- data/test/test_mysql_message_queue_adapter.rb +0 -263
- data/test/test_skynet.rb +0 -19
- data/test/test_skynet_install_generator.rb +0 -49
- data/test/test_skynet_job.rb +0 -717
- data/test/test_skynet_manager.rb +0 -157
- data/test/test_skynet_message.rb +0 -229
- data/test/test_skynet_task.rb +0 -24
- data/test/test_tuplespace_message_queue.rb +0 -174
- data/website/index.html +0 -181
- data/website/index.txt +0 -98
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
@@ -1,38 +0,0 @@
|
|
1
|
-
ENV["RAILS_ENV"] = "test"
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
-
require 'test_help'
|
4
|
-
|
5
|
-
class Test::Unit::TestCase
|
6
|
-
# Transactional fixtures accelerate your tests by wrapping each test method
|
7
|
-
# in a transaction that's rolled back on completion. This ensures that the
|
8
|
-
# test database remains unchanged so your fixtures don't have to be reloaded
|
9
|
-
# between every test method. Fewer database queries means faster tests.
|
10
|
-
#
|
11
|
-
# Read Mike Clark's excellent walkthrough at
|
12
|
-
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
13
|
-
#
|
14
|
-
# Every Active Record database supports transactions except MyISAM tables
|
15
|
-
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
16
|
-
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
17
|
-
# is recommended.
|
18
|
-
#
|
19
|
-
# The only drawback to using transactional fixtures is when you actually
|
20
|
-
# need to test transactions. Since your test is bracketed by a transaction,
|
21
|
-
# any transactions started in your code will be automatically rolled back.
|
22
|
-
self.use_transactional_fixtures = true
|
23
|
-
|
24
|
-
# Instantiated fixtures are slow, but give you @david where otherwise you
|
25
|
-
# would need people(:david). If you don't want to migrate your existing
|
26
|
-
# test cases which use the @david style and don't mind the speed hit (each
|
27
|
-
# instantiated fixtures translates to a database query per test method),
|
28
|
-
# then set this back to true.
|
29
|
-
self.use_instantiated_fixtures = false
|
30
|
-
|
31
|
-
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
32
|
-
#
|
33
|
-
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
34
|
-
# -- they do not yet inherit this setting
|
35
|
-
fixtures :all
|
36
|
-
|
37
|
-
# Add more helper methods to be used by all tests here...
|
38
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
#! /bin/sh
|
2
|
-
#
|
3
|
-
# Usage: ./check_skynet --help
|
4
|
-
#
|
5
|
-
# Examples:
|
6
|
-
# ./check_skynet -w 300 -c 2000 -u
|
7
|
-
|
8
|
-
# Paths to commands used in this script. These
|
9
|
-
# may have to be modified to match your system setup.
|
10
|
-
|
11
|
-
PATH=""
|
12
|
-
|
13
|
-
ECHO="/bin/echo"
|
14
|
-
SED="/bin/sed"
|
15
|
-
GREP="/bin/grep"
|
16
|
-
TAIL="/bin/tail"
|
17
|
-
CAT="/bin/cat"
|
18
|
-
CUT="/bin/cut"
|
19
|
-
WC="/bin/wc"
|
20
|
-
CURL="/usr/bin/curl -f"
|
21
|
-
|
22
|
-
PROGNAME=`/bin/basename $0`
|
23
|
-
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
|
24
|
-
REVISION=`echo '$Revision: 0.1 $' | /bin/sed -e 's/[^0-9.]//g'`
|
25
|
-
|
26
|
-
. /usr/local/nagios/libexec/utils.sh
|
27
|
-
|
28
|
-
print_usage() {
|
29
|
-
echo "Usage: $PROGNAME -w <threshold> -c <threshold> -u <url of skynet status page>"
|
30
|
-
echo "Usage: $PROGNAME --help"
|
31
|
-
echo "Usage: $PROGNAME --version"
|
32
|
-
}
|
33
|
-
|
34
|
-
print_help() {
|
35
|
-
print_revision $PROGNAME $REVISION
|
36
|
-
echo ""
|
37
|
-
print_usage
|
38
|
-
echo ""
|
39
|
-
echo "Check Skynet's untaken_tasks"
|
40
|
-
echo ""
|
41
|
-
support
|
42
|
-
}
|
43
|
-
|
44
|
-
# Make sure the correct number of command line
|
45
|
-
# arguments have been supplied
|
46
|
-
|
47
|
-
if [ $# -lt 3 ]; then
|
48
|
-
print_usage
|
49
|
-
exit $STATE_UNKNOWN
|
50
|
-
fi
|
51
|
-
|
52
|
-
# Grab the command line arguments
|
53
|
-
|
54
|
-
exitstatus=$STATE_UNKNOWN #default
|
55
|
-
while test -n "$1"; do
|
56
|
-
case "$1" in
|
57
|
-
--help)
|
58
|
-
print_help
|
59
|
-
exit $STATE_OK
|
60
|
-
;;
|
61
|
-
-h)
|
62
|
-
print_help
|
63
|
-
exit $STATE_OK
|
64
|
-
;;
|
65
|
-
--version)
|
66
|
-
print_revision $PROGNAME $VERSION
|
67
|
-
exit $STATE_OK
|
68
|
-
;;
|
69
|
-
-V)
|
70
|
-
print_revision $PROGNAME $VERSION
|
71
|
-
exit $STATE_OK
|
72
|
-
;;
|
73
|
-
-w)
|
74
|
-
WARNING=$2;
|
75
|
-
shift;
|
76
|
-
;;
|
77
|
-
-c)
|
78
|
-
CRITICAL=$2;
|
79
|
-
shift;
|
80
|
-
;;
|
81
|
-
-u)
|
82
|
-
URL=$2;
|
83
|
-
shift;
|
84
|
-
;;
|
85
|
-
*)
|
86
|
-
echo "Unknown argument: $1"
|
87
|
-
print_usage
|
88
|
-
exit $STATE_UNKNOWN
|
89
|
-
;;
|
90
|
-
esac
|
91
|
-
shift
|
92
|
-
done
|
93
|
-
|
94
|
-
|
95
|
-
CURRENT=$($CURL $URL | $GREP "untaken_tasks\|down"| $CUT -d: -f2)
|
96
|
-
|
97
|
-
if [ -z $CURRENT ] ;then
|
98
|
-
$ECHO "CANNOT GATHER SKYNET TASKS CALL NOPS"
|
99
|
-
exit $STATE_UNKNOWN
|
100
|
-
fi
|
101
|
-
|
102
|
-
if [ $CURRENT -ge $CRITICAL ]; then
|
103
|
-
$ECHO "Skynet untaken_tasks: $CURRENT threshold: $CRITICAL CRITICAL"
|
104
|
-
$ECHO " "
|
105
|
-
exit $STATE_CRITICAL
|
106
|
-
fi
|
107
|
-
|
108
|
-
if [ $CURRENT -ge $WARNING ]; then
|
109
|
-
$ECHO "Skynet untaken_tasks: $CURRENT threshold: $WARNING WARNING"
|
110
|
-
$ECHO " "
|
111
|
-
exit $STATE_WARNING
|
112
|
-
fi
|
113
|
-
|
114
|
-
if [[ $CURRENT -lt $CRITICAL && $CURRENT -lt $WARNING ]]; then
|
115
|
-
$ECHO "Skynet untaken_tasks: $CURRENT threshold critical: $CRITICAL threshold warning: $WARNING OK"
|
116
|
-
$ECHO " "
|
117
|
-
exit $STATE_OK
|
118
|
-
|
119
|
-
fi
|
120
|
-
$ECHO "NO SCRIPT OUTPUT CALL NOPS!"
|
121
|
-
exit $STATE_CRITICAL
|
@@ -1,137 +0,0 @@
|
|
1
|
-
|
2
|
-
<div class="hd">
|
3
|
-
<h1>SKYNET STATUS</h1>
|
4
|
-
<span>Last updated: <%= @last_updated || 'N/A' %></span>
|
5
|
-
<br />
|
6
|
-
<br />
|
7
|
-
</div>
|
8
|
-
|
9
|
-
<% if @stats %>
|
10
|
-
|
11
|
-
<h2>Overall Stats</h2>
|
12
|
-
<table class="admin_table">
|
13
|
-
<thead>
|
14
|
-
<tr>
|
15
|
-
<th>Hosts</th>
|
16
|
-
<th>Workers</th>
|
17
|
-
<th>Active Workers<BR>(Masters / Tasks / Either)</th>
|
18
|
-
<th>Idle Workers<BR>(Masters / Tasks / Either)</th>
|
19
|
-
<th>Untaken Tasks<BR>(Master / Task) Future</th>
|
20
|
-
<th>Taken Tasks<BR>(Master / Task)</th>
|
21
|
-
<th>Results</th>
|
22
|
-
<th>Processed <br />(by active workers)</th>
|
23
|
-
<th>Process Time</th>
|
24
|
-
</tr>
|
25
|
-
</thead>
|
26
|
-
<tbody>
|
27
|
-
<tr>
|
28
|
-
<td class="numeric"><%= @stats[:hosts] %></td>
|
29
|
-
<td class="numeric"><%= @stats[:number_of_workers] %></td>
|
30
|
-
<td class="numeric"><b><%= @stats[:active_workers] %></b> (<%= @stats[:active_masters] %> / <%= @stats[:active_taskworkers] %> / <%= @stats[:active_master_or_task_workers] %>)</td>
|
31
|
-
<td class="numeric"><b><%= @stats[:idle_workers] %></b> (<%= @stats[:idle_masters] %> / <%= @stats[:idle_taskworkers] %> / <%= @stats[:idle_master_or_task_workers] %>)</td>
|
32
|
-
<td class="numeric"><%= @stats[:untaken_tasks] %> (<b><%= @stats[:untaken_master_tasks] %></b> / <%= @stats[:untaken_task_tasks] %>) <%= @stats[:untaken_future_tasks] %></td>
|
33
|
-
<td class="numeric"><b><%= @stats[:taken_tasks] %></b> (<%= @stats[:taken_master_tasks] %> / <%= @stats[:taken_task_tasks] %>)</td>
|
34
|
-
<td class="numeric"><%= @stats[:results] %></td>
|
35
|
-
<td class="numeric"><%= @stats[:processed] %> (<%= @stats[:processed_by_active_workers] %>)</td>
|
36
|
-
<td><%= @stats[:processed_time] %></td>
|
37
|
-
</tr>
|
38
|
-
</tbody>
|
39
|
-
</table>
|
40
|
-
|
41
|
-
|
42
|
-
<BR>
|
43
|
-
<h2>Servers</h2>
|
44
|
-
<table class="admin_table">
|
45
|
-
<colgroup>
|
46
|
-
<col span="1" width="3%" />
|
47
|
-
<col span="1" width="10%" />
|
48
|
-
<col span="1" width="5%" />
|
49
|
-
<col span="1" width="5%" />
|
50
|
-
<col span="1" width="5%" />
|
51
|
-
<col span="1" width="5%" />
|
52
|
-
</colgroup>
|
53
|
-
<thead>
|
54
|
-
<tr>
|
55
|
-
<th class="numeric">#</th>
|
56
|
-
<th>Hostname</th>
|
57
|
-
<th>Number of Workers</th>
|
58
|
-
<th>Active Workers<BR>Masters / Tasks / Either</th>
|
59
|
-
<th>Idle Workers<BR>Masters / Tasks / Either</th>
|
60
|
-
<th>Processed <br />(by active workers)</th>
|
61
|
-
</tr>
|
62
|
-
</thead>
|
63
|
-
|
64
|
-
<% if @stats[:servers] %>
|
65
|
-
<tbody>
|
66
|
-
<% @stats[:servers].keys.sort.each do |hostname| %>
|
67
|
-
<% server = @stats[:servers][hostname] %>
|
68
|
-
<% i = 1 %>
|
69
|
-
<tr>
|
70
|
-
<td class="numeric"><%= i %></td>
|
71
|
-
<td><%= server[:hostname] %></td>
|
72
|
-
<td class="numeric"><%= server[:number_of_workers] %></td>
|
73
|
-
<td class="numeric"><%= server[:active_workers] %> (<%= server[:active_masters] %> / <%= server[:active_taskworkers] %> / <%= server[:active_master_or_task_workers] %>) </td>
|
74
|
-
<td class="numeric"><%= server[:idle_workers] %> (<%= server[:idle_masters] %> / <%= server[:idle_taskworkers] %> / <%= server[:idle_master_or_task_workers] %>) </td>
|
75
|
-
<td class="numeric"><%= server[:processed] %> (<%= server[:processed_by_active_workers] %>)</td>
|
76
|
-
</tr>
|
77
|
-
<% i += 1 %>
|
78
|
-
<% end %>
|
79
|
-
</tbody>
|
80
|
-
<% end %>
|
81
|
-
|
82
|
-
</table>
|
83
|
-
|
84
|
-
<% end %>
|
85
|
-
|
86
|
-
<!-- <table class="admin_table">
|
87
|
-
<colgroup>
|
88
|
-
<col span="1" width="5%" />
|
89
|
-
<col span="1" width="8%" />
|
90
|
-
<col span="1" width="10%" />
|
91
|
-
<col span="1" width="10%" />
|
92
|
-
<col span="1" width="5%" />
|
93
|
-
<col span="1" width="5%" />
|
94
|
-
</colgroup>
|
95
|
-
<thead>
|
96
|
-
<tr>
|
97
|
-
<th class="numeric">#</th>
|
98
|
-
<th>Worker ID</th>
|
99
|
-
<th>Hostname</th>
|
100
|
-
<th>PID</th>
|
101
|
-
<th>Job ID</th>
|
102
|
-
<th>Task ID</th>
|
103
|
-
<th>Version</th>
|
104
|
-
<th>Processed</th>
|
105
|
-
<th>M/R</th>
|
106
|
-
<th>Name</th>
|
107
|
-
</tr>
|
108
|
-
</thead>
|
109
|
-
|
110
|
-
<% if false and @servers %>
|
111
|
-
<tbody>
|
112
|
-
<% @servers.each do |server| %>
|
113
|
-
<tr>
|
114
|
-
<td colspan="10"><%= server[:manager] %></td>
|
115
|
-
</tr>
|
116
|
-
<% i = 1 %>
|
117
|
-
<% server[:workers].each do |w| %>
|
118
|
-
<tr>
|
119
|
-
<td class="numeric"><%= i %></td>
|
120
|
-
<td><%= w.worker_id %></td>
|
121
|
-
<td><%= w.hostname %></td>
|
122
|
-
<td class="numeric"><%= w.process_id %></td>
|
123
|
-
<td class="numeric"><%= w.job_id %></td>
|
124
|
-
<td class="numeric"><%= w.task_id %></td>
|
125
|
-
<td class="numeric"><%= w.version %></td>
|
126
|
-
<td class="numeric"><%= w.processed %></td>
|
127
|
-
<td><%= w.map_or_reduce || '-' %></td>
|
128
|
-
<td><%= w.name %></td>
|
129
|
-
</tr>
|
130
|
-
<% i += 1 %>
|
131
|
-
<% end %>
|
132
|
-
<% end %>
|
133
|
-
</tbody>
|
134
|
-
<% end %>
|
135
|
-
|
136
|
-
</table> -->
|
137
|
-
|
data/tasks/website.rake
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
desc 'Generate website files'
|
2
|
-
task :website_generate => :ruby_env do
|
3
|
-
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
-
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'Upload website files to rubyforge'
|
9
|
-
task :website_upload do
|
10
|
-
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
-
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
-
local_dir = 'website'
|
13
|
-
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'Generate and upload website files'
|
17
|
-
task :website => [:website_generate, :website_upload, :publish_docs]
|
@@ -1,138 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class AllModelsTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_true
|
6
|
-
true
|
7
|
-
end
|
8
|
-
|
9
|
-
# def test_map
|
10
|
-
# eachmeth = lambda do |profile|
|
11
|
-
# profile.claimed = false
|
12
|
-
# profile.save
|
13
|
-
# end
|
14
|
-
# data = [1,10,{:conditions => "profiles.claimed = 1"},"Profile",eachmeth]
|
15
|
-
#
|
16
|
-
# assert Profile.find(2).claimed, "claimed"
|
17
|
-
#
|
18
|
-
# ActiveRecord::Mapreduce.map([data])
|
19
|
-
#
|
20
|
-
# assert !Profile.find(2).claimed, "not claimed"
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# def test_each_with_proc
|
24
|
-
# Skynet.solo do
|
25
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile", :limit => 5).each do |profile|
|
26
|
-
# profile.suffix = 'z'
|
27
|
-
# profile.save
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
# assert_equal 'z', Profile.find(2).suffix
|
31
|
-
# end
|
32
|
-
#
|
33
|
-
# def test_big_batch
|
34
|
-
# Skynet.solo do
|
35
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "claimed = 1", :batch_size => 200, :model_class => "Profile").each do |profile|
|
36
|
-
# profile.suffix = 'z'
|
37
|
-
# profile.save
|
38
|
-
# end
|
39
|
-
# end
|
40
|
-
# assert_equal 'z', Profile.find(2).suffix
|
41
|
-
# end
|
42
|
-
#
|
43
|
-
# def test_joins
|
44
|
-
# p = Profile.find(1)
|
45
|
-
# p.details.zodiac_sign = 'hermit'
|
46
|
-
# p.details.save
|
47
|
-
# Skynet.solo do
|
48
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "profile_details.zodiac_sign='hermit'", :joins => "JOIN profile_details ON profiles.id = profile_details.profile_id", :batch_size => 2, :model_class => "Profile").each do |profile|
|
49
|
-
# profile.suffix = 'z'
|
50
|
-
# profile.save
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
# assert_equal 'z', Profile.find(1).suffix
|
54
|
-
# end
|
55
|
-
#
|
56
|
-
# def test_stragglers
|
57
|
-
# profiles = Profile.find(:all)
|
58
|
-
# Skynet.solo do
|
59
|
-
# ActiveRecord::Mapreduce.find(:all, :batch_size => profiles.size-1, :model_class => "Profile").each do |profile|
|
60
|
-
# profile.suffix = 'z'
|
61
|
-
# profile.save
|
62
|
-
# end
|
63
|
-
# end
|
64
|
-
# profiles.last.reload
|
65
|
-
# assert_equal 'z', profiles.last.suffix
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
# def test_small_limit
|
69
|
-
# Skynet.solo do
|
70
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile", :limit => 3).each do |profile|
|
71
|
-
# profile.suffix = 'z'
|
72
|
-
# profile.save
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
# assert_equal 'z', Profile.find(2).suffix
|
76
|
-
# end
|
77
|
-
#
|
78
|
-
# def test_each_with_proc_exception
|
79
|
-
# Skynet.solo(:SKYNET_LOG_LEVEL => Logger::FATAL) do
|
80
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each do |profile|
|
81
|
-
# raise "BUSTED" if profile.id == 6
|
82
|
-
# profile.suffix = 'z'
|
83
|
-
# profile.save
|
84
|
-
# end
|
85
|
-
# end
|
86
|
-
# assert_equal 'z', Profile.find(2).suffix
|
87
|
-
# assert_equal nil, Profile.find(6).suffix
|
88
|
-
# end
|
89
|
-
#
|
90
|
-
# def test_each_with_class_exception
|
91
|
-
# Skynet.solo(:SKYNET_LOG_LEVEL => Logger::FATAL) do
|
92
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(ActiveRecord::MapreduceExTest)
|
93
|
-
# end
|
94
|
-
# assert_equal 'k', Profile.find(2).suffix
|
95
|
-
# assert_equal nil, Profile.find(8).suffix
|
96
|
-
# end
|
97
|
-
#
|
98
|
-
# def test_each_with_class
|
99
|
-
# Skynet.solo do
|
100
|
-
# ActiveRecord::Mapreduce.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(self.class)
|
101
|
-
# end
|
102
|
-
# assert_equal 'k', Profile.find(2).suffix
|
103
|
-
# end
|
104
|
-
#
|
105
|
-
# def test_distributed_each
|
106
|
-
# Skynet.solo do
|
107
|
-
# Profile.distributed_find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each do |profile|
|
108
|
-
# profile.suffix = 'gg'
|
109
|
-
# profile.save
|
110
|
-
# end
|
111
|
-
# assert_equal 'gg', Profile.find(2).suffix
|
112
|
-
# Profile.distributed_find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(self.class)
|
113
|
-
# assert_equal 'k', Profile.find(2).suffix
|
114
|
-
# end
|
115
|
-
# end
|
116
|
-
#
|
117
|
-
# def test_distributed_each_with_symbol
|
118
|
-
# Skynet.solo do
|
119
|
-
# Profile.distributed_find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(:mark_modified)
|
120
|
-
# end
|
121
|
-
# assert ModifiedProfile.find(:first, :conditions => "profile_id = 2")
|
122
|
-
# end
|
123
|
-
#
|
124
|
-
# def self.each(profile)
|
125
|
-
# profile.suffix = 'k'
|
126
|
-
# profile.save
|
127
|
-
# end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
class AllModelsExTest
|
132
|
-
def self.each(profile)
|
133
|
-
raise "BUSTED" if profile.id == 8
|
134
|
-
profile.suffix = 'k'
|
135
|
-
profile.save
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|