archipelago 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/GPL-2 +339 -0
- data/README +39 -0
- data/TODO +3 -0
- data/lib/archipelago.rb +24 -0
- data/lib/current.rb +128 -0
- data/lib/disco.rb +548 -0
- data/lib/hashish.rb +199 -0
- data/lib/pirate.rb +205 -0
- data/lib/tranny.rb +650 -0
- data/lib/treasure.rb +679 -0
- data/profiles/1000xChest#join!-prepare!-commit!.rb +19 -0
- data/profiles/1000xDubloon#[]=(t).rb +19 -0
- data/profiles/1000xDubloon#method_missing(t).rb +21 -0
- data/profiles/README +3 -0
- data/profiles/profile_helper.rb +25 -0
- data/scripts/chest.rb +20 -0
- data/scripts/console +3 -0
- data/scripts/pirate.rb +6 -0
- data/scripts/tranny.rb +20 -0
- data/tests/current_test.rb +28 -0
- data/tests/disco_test.rb +179 -0
- data/tests/pirate_test.rb +75 -0
- data/tests/test_helper.rb +60 -0
- data/tests/tranny_test.rb +70 -0
- data/tests/treasure_test.rb +257 -0
- metadata +69 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
|
|
2
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
|
3
|
+
require 'treasure'
|
|
4
|
+
require 'drb'
|
|
5
|
+
require 'tranny'
|
|
6
|
+
require 'hashish'
|
|
7
|
+
|
|
8
|
+
class TreasureTest < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
DRb.start_service
|
|
12
|
+
@c = TestChest.new(:persistence_provider => Archipelago::Hashish::BerkeleyHashishProvider.new(Pathname.new(__FILE__).parent.join("chest.db")))
|
|
13
|
+
@c2 = TestChest.new(:persistence_provider => Archipelago::Hashish::BerkeleyHashishProvider.new(Pathname.new(__FILE__).parent.join("chest2.db")))
|
|
14
|
+
@tm = TestManager.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def teardown
|
|
18
|
+
@c.persistence_provider.unlink
|
|
19
|
+
@c2.persistence_provider.unlink
|
|
20
|
+
@tm.persistence_provider.unlink
|
|
21
|
+
DRb.stop_service
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_store_load_update
|
|
25
|
+
s = "hehu"
|
|
26
|
+
@c["oj"] = "hehu"
|
|
27
|
+
oj1 = @c["oj"]
|
|
28
|
+
assert_equal(oj1, @c["oj"])
|
|
29
|
+
assert_equal("hehu", oj1)
|
|
30
|
+
|
|
31
|
+
s2 = @c["oj"]
|
|
32
|
+
assert_equal(s, s2)
|
|
33
|
+
assert_equal(s.upcase, s2.upcase)
|
|
34
|
+
assert(s.object_id != s2.object_id)
|
|
35
|
+
|
|
36
|
+
s2 << "kissekotte"
|
|
37
|
+
s << "kissekotte"
|
|
38
|
+
assert_equal(s, s2)
|
|
39
|
+
|
|
40
|
+
s3 = @c["oj"]
|
|
41
|
+
assert_equal(s2, s3)
|
|
42
|
+
assert_equal(s2.object_id, s3.object_id)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_multi_transaction
|
|
46
|
+
@c["oj"] = "hehu"
|
|
47
|
+
|
|
48
|
+
t = @tm.begin
|
|
49
|
+
t2 = @tm.begin
|
|
50
|
+
|
|
51
|
+
@c["oj", t] = "kiss"
|
|
52
|
+
@c["oj", t].upcase!
|
|
53
|
+
@c["oj", t2].upcase!
|
|
54
|
+
|
|
55
|
+
assert_equal(:commited, t.commit!)
|
|
56
|
+
assert_equal(:aborted, t2.commit!)
|
|
57
|
+
assert_equal("KISS", @c["oj"])
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_multi_chest
|
|
61
|
+
@c["oj"] = "hehu"
|
|
62
|
+
@c2["bla"] = "hirr"
|
|
63
|
+
|
|
64
|
+
t = @tm.begin
|
|
65
|
+
|
|
66
|
+
@c["oj", t].upcase!
|
|
67
|
+
@c2["bla", t].upcase!
|
|
68
|
+
|
|
69
|
+
t.abort!
|
|
70
|
+
|
|
71
|
+
assert_equal("hehu", @c["oj"])
|
|
72
|
+
assert_equal("hirr", @c2["bla"])
|
|
73
|
+
|
|
74
|
+
t = @tm.begin
|
|
75
|
+
|
|
76
|
+
@c["oj", t].upcase!
|
|
77
|
+
@c2["bla", t].upcase!
|
|
78
|
+
|
|
79
|
+
assert_equal(:commited, t.commit!)
|
|
80
|
+
assert_equal("HEHU", @c["oj"])
|
|
81
|
+
assert_equal("HIRR", @c2["bla"])
|
|
82
|
+
|
|
83
|
+
t = @tm.begin
|
|
84
|
+
|
|
85
|
+
@c["oj", t] = "bark"
|
|
86
|
+
@c2["bla", t] = "boll"
|
|
87
|
+
@c2["bla"] = "burk"
|
|
88
|
+
|
|
89
|
+
assert_equal(:aborted, t.commit!)
|
|
90
|
+
assert_equal("HEHU", @c["oj"])
|
|
91
|
+
assert_equal("burk", @c2["bla"])
|
|
92
|
+
|
|
93
|
+
t = @tm.begin
|
|
94
|
+
t2 = @tm.begin
|
|
95
|
+
|
|
96
|
+
s = @c["oj", t]
|
|
97
|
+
s2 = @c["oj", t2]
|
|
98
|
+
s3 = @c2["bla", t]
|
|
99
|
+
|
|
100
|
+
s.swapcase!
|
|
101
|
+
s2.swapcase!
|
|
102
|
+
s3.swapcase!
|
|
103
|
+
|
|
104
|
+
assert_equal(:commited, t2.commit!)
|
|
105
|
+
assert_equal(:aborted, t.commit!)
|
|
106
|
+
assert_equal("hehu", @c["oj"])
|
|
107
|
+
assert_equal("burk", @c2["bla"])
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_chained_linking
|
|
111
|
+
@c["oj"] = "hehu"
|
|
112
|
+
s = @c["oj"]
|
|
113
|
+
@c2["oj"] = s
|
|
114
|
+
s2 = @c2["oj"]
|
|
115
|
+
s2.swapcase!
|
|
116
|
+
assert_equal("HEHU", @c["oj"])
|
|
117
|
+
assert_equal("HEHU", s2)
|
|
118
|
+
assert_equal("HEHU", @c2["oj"])
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_transaction_store_load_update_commit
|
|
122
|
+
@c["oj"] = "hehu"
|
|
123
|
+
oj = @c["oj"]
|
|
124
|
+
|
|
125
|
+
t = @tm.begin
|
|
126
|
+
|
|
127
|
+
@c["oj", t] = "hirr"
|
|
128
|
+
oj2 = @c["oj", t]
|
|
129
|
+
|
|
130
|
+
assert(oj != oj2)
|
|
131
|
+
assert_equal("hehu", oj)
|
|
132
|
+
assert_equal("hirr", oj2)
|
|
133
|
+
|
|
134
|
+
assert_equal(:commited, t.commit!)
|
|
135
|
+
assert_raise(Archipelago::Treasure::UnknownTransactionException) do
|
|
136
|
+
oj2.size
|
|
137
|
+
end
|
|
138
|
+
assert_raise(Archipelago::Treasure::IllegalJoinException) do
|
|
139
|
+
@c["oj", t]
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
assert_equal("hirr", oj)
|
|
143
|
+
assert_equal("hirr", @c["oj"])
|
|
144
|
+
|
|
145
|
+
t = @tm.begin
|
|
146
|
+
@c["oj", t] = "blar"
|
|
147
|
+
@c["oj"] = "kuk"
|
|
148
|
+
assert_equal(:aborted, t.commit!)
|
|
149
|
+
assert_equal("kuk", @c["oj"])
|
|
150
|
+
|
|
151
|
+
t = @tm.begin
|
|
152
|
+
@c["oj", t] = "bungk"
|
|
153
|
+
@c.delete("oj")
|
|
154
|
+
assert_equal(:aborted, t.commit!)
|
|
155
|
+
assert_equal(nil, @c["oj"])
|
|
156
|
+
|
|
157
|
+
t = @tm.begin
|
|
158
|
+
@c["oj"] = "baba"
|
|
159
|
+
@c.delete("oj", t)
|
|
160
|
+
assert_equal(:commited, t.commit!)
|
|
161
|
+
assert_equal(nil, @c["oj"])
|
|
162
|
+
|
|
163
|
+
t = @tm.begin
|
|
164
|
+
@c["oj"] = "bagi"
|
|
165
|
+
@c.delete("oj", t)
|
|
166
|
+
@c["oj"] = "ooqoq"
|
|
167
|
+
assert_equal(:aborted, t.commit!)
|
|
168
|
+
assert_equal("ooqoq", @c["oj"])
|
|
169
|
+
|
|
170
|
+
@c.delete("oj")
|
|
171
|
+
t = @tm.begin
|
|
172
|
+
@c["oj", t] = "ghgh"
|
|
173
|
+
assert_equal(nil, @c["oj"])
|
|
174
|
+
assert_equal(:commited, t.commit!)
|
|
175
|
+
assert_equal("ghgh", @c["oj"])
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def test_transaction_store_load_update_abort
|
|
179
|
+
@c["oj"] = "hehu"
|
|
180
|
+
oj1 = @c["oj"]
|
|
181
|
+
|
|
182
|
+
assert(@c.active_transactions.empty?)
|
|
183
|
+
|
|
184
|
+
t = @tm.begin
|
|
185
|
+
oj2 = @c["oj", t]
|
|
186
|
+
assert_equal(oj1, oj2)
|
|
187
|
+
|
|
188
|
+
@c["oj", t] = "hehu2"
|
|
189
|
+
|
|
190
|
+
assert_equal([t], @c.active_transactions)
|
|
191
|
+
|
|
192
|
+
assert_equal("hehu2", @c["oj", t])
|
|
193
|
+
assert_equal("hehu2", oj2)
|
|
194
|
+
assert("hehu2" != @c["oj"])
|
|
195
|
+
assert("hehu2" != oj1)
|
|
196
|
+
assert(@c["oj"] != @c["oj", t])
|
|
197
|
+
assert(oj1 != oj2)
|
|
198
|
+
assert_equal(@c["oj", t], @c["oj", t])
|
|
199
|
+
assert_equal(oj2, @c["oj", t])
|
|
200
|
+
|
|
201
|
+
t2 = @tm.begin
|
|
202
|
+
assert_equal(@c["oj"], @c["oj", t2])
|
|
203
|
+
oj3 = @c["oj", t2]
|
|
204
|
+
assert_equal(oj1, oj3)
|
|
205
|
+
assert(oj2 != oj3)
|
|
206
|
+
|
|
207
|
+
@c["oj", t2] = "bar"
|
|
208
|
+
assert_equal(oj3, @c["oj", t2])
|
|
209
|
+
assert(@c["oj", t] != @c["oj", t2])
|
|
210
|
+
assert(oj2 != oj3)
|
|
211
|
+
|
|
212
|
+
assert_equal("hehu", @c["oj"])
|
|
213
|
+
assert_equal("hehu", oj1)
|
|
214
|
+
|
|
215
|
+
assert_equal(tranny_sort([t, t2]),
|
|
216
|
+
tranny_sort(@c.active_transactions))
|
|
217
|
+
|
|
218
|
+
oj1.replace("brumma")
|
|
219
|
+
oj2.replace("bajs")
|
|
220
|
+
|
|
221
|
+
assert_equal("brumma", @c["oj"])
|
|
222
|
+
assert_equal("bar", @c["oj", t2])
|
|
223
|
+
assert_equal("bajs", @c["oj", t])
|
|
224
|
+
|
|
225
|
+
@c.delete("oj")
|
|
226
|
+
@c.delete("oj", t)
|
|
227
|
+
|
|
228
|
+
assert_equal("bar", @c["oj", t2])
|
|
229
|
+
assert_equal(nil, @c["oj", t])
|
|
230
|
+
|
|
231
|
+
t.abort!
|
|
232
|
+
|
|
233
|
+
assert_equal([t2], @c.active_transactions)
|
|
234
|
+
assert_raise(Archipelago::Treasure::IllegalJoinException) do
|
|
235
|
+
@c["oj", t]
|
|
236
|
+
end
|
|
237
|
+
assert_raise(Archipelago::Treasure::UnknownTransactionException) do
|
|
238
|
+
"hej" == oj2
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
t2.abort!
|
|
242
|
+
|
|
243
|
+
assert_raise(Archipelago::Treasure::UnknownTransactionException) do
|
|
244
|
+
oj3.size
|
|
245
|
+
end
|
|
246
|
+
assert(@c.active_transactions.empty?)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
private
|
|
250
|
+
|
|
251
|
+
def tranny_sort(a)
|
|
252
|
+
a.sort do |x,y|
|
|
253
|
+
x.transaction_id <=> y.transaction_id
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
rubygems_version: 0.8.11
|
|
3
|
+
specification_version: 1
|
|
4
|
+
name: archipelago
|
|
5
|
+
version: !ruby/object:Gem::Version
|
|
6
|
+
version: 0.1.0
|
|
7
|
+
date: 2006-11-12 00:00:00 +01:00
|
|
8
|
+
summary: A set of tools for distributed computing in ruby.
|
|
9
|
+
require_paths:
|
|
10
|
+
- lib
|
|
11
|
+
email: zond at troja dot ath dot cx
|
|
12
|
+
homepage:
|
|
13
|
+
rubyforge_project:
|
|
14
|
+
description:
|
|
15
|
+
autorequire: archipelago
|
|
16
|
+
default_executable:
|
|
17
|
+
bindir: bin
|
|
18
|
+
has_rdoc: true
|
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">"
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.0.0
|
|
24
|
+
version:
|
|
25
|
+
platform: ruby
|
|
26
|
+
signing_key:
|
|
27
|
+
cert_chain:
|
|
28
|
+
authors:
|
|
29
|
+
- Martin Kihlgren
|
|
30
|
+
files:
|
|
31
|
+
- lib/archipelago.rb
|
|
32
|
+
- lib/current.rb
|
|
33
|
+
- lib/disco.rb
|
|
34
|
+
- lib/hashish.rb
|
|
35
|
+
- lib/pirate.rb
|
|
36
|
+
- lib/tranny.rb
|
|
37
|
+
- lib/treasure.rb
|
|
38
|
+
- scripts/chest.rb
|
|
39
|
+
- scripts/console
|
|
40
|
+
- scripts/pirate.rb
|
|
41
|
+
- scripts/tranny.rb
|
|
42
|
+
- GPL-2
|
|
43
|
+
- TODO
|
|
44
|
+
- profiles/1000xChest#join!-prepare!-commit!.rb
|
|
45
|
+
- profiles/1000xDubloon#[]=(t).rb
|
|
46
|
+
- profiles/1000xDubloon#method_missing(t).rb
|
|
47
|
+
- profiles/profile_helper.rb
|
|
48
|
+
- profiles/README
|
|
49
|
+
- README
|
|
50
|
+
test_files:
|
|
51
|
+
- tests/current_test.rb
|
|
52
|
+
- tests/disco_test.rb
|
|
53
|
+
- tests/pirate_test.rb
|
|
54
|
+
- tests/tranny_test.rb
|
|
55
|
+
- tests/treasure_test.rb
|
|
56
|
+
- tests/test_helper.rb
|
|
57
|
+
rdoc_options:
|
|
58
|
+
- --line-numbers
|
|
59
|
+
- --inline-source
|
|
60
|
+
extra_rdoc_files:
|
|
61
|
+
- README
|
|
62
|
+
executables: []
|
|
63
|
+
|
|
64
|
+
extensions: []
|
|
65
|
+
|
|
66
|
+
requirements: []
|
|
67
|
+
|
|
68
|
+
dependencies: []
|
|
69
|
+
|