bdb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,13 @@
1
1
  require 'test/unit'
2
2
  require 'fileutils'
3
- require File.dirname(__FILE__) + '/../ext/bdb'
3
+ require 'pp'
4
+
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../ext')
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../tuple/ext')
8
+
9
+ require 'bdb'
10
+ require 'bdb/database'
4
11
 
5
12
  class Test::Unit::TestCase
6
13
  include FileUtils
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Balthrop
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-20 00:00:00 -08:00
12
+ date: 2009-11-24 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,19 +24,28 @@ extra_rdoc_files:
24
24
  - README.textile
25
25
  files:
26
26
  - VERSION
27
+ - ext/Makefile
28
+ - ext/bdb.bundle
27
29
  - ext/bdb.c
28
30
  - ext/bdb.h
31
+ - ext/bdb.o
32
+ - ext/bdb_aux._c
29
33
  - ext/extconf.rb
34
+ - ext/mkmf.log
30
35
  - lib/bdb/base.rb
31
36
  - lib/bdb/database.rb
32
37
  - lib/bdb/environment.rb
33
38
  - lib/bdb/partitioned_database.rb
39
+ - lib/bdb/replication.rb
34
40
  - lib/bdb/result_set.rb
35
41
  - test/benchmark.rb
36
42
  - test/cursor_test.rb
43
+ - test/database_test.rb
44
+ - test/database_test_helper.rb
37
45
  - test/db_test.rb
46
+ - test/deadlock_test.rb
38
47
  - test/env_test.rb
39
- - test/simple_test.rb
48
+ - test/replication_test.rb
40
49
  - test/stat_test.rb
41
50
  - test/test_helper.rb
42
51
  - test/txn_test.rb
@@ -74,9 +83,13 @@ summary: Ruby Berkeley DB
74
83
  test_files:
75
84
  - test/benchmark.rb
76
85
  - test/cursor_test.rb
86
+ - test/database_test.rb
87
+ - test/database_test_helper.rb
77
88
  - test/db_test.rb
89
+ - test/deadlock_test.rb
78
90
  - test/env_test.rb
79
- - test/simple_test.rb
91
+ - test/replication_test.rb
80
92
  - test/stat_test.rb
81
93
  - test/test_helper.rb
82
94
  - test/txn_test.rb
95
+ - examples/replication.rb
@@ -1,93 +0,0 @@
1
- require 'test_helper'
2
- require File.dirname(__FILE__) + '/../lib/bdb/simple'
3
-
4
- class SimpleTest < Test::Unit::TestCase
5
- def setup
6
- @path = File.join(File.dirname(__FILE__), 'tmp')
7
- rm_rf @path
8
- mkdir @path
9
- open
10
- end
11
-
12
- def teardown
13
- close
14
- rm_rf @path
15
- end
16
-
17
- def open
18
- @db = Bdb::Simple.new(@path)
19
- @dbd = Bdb::Simple.new(@path, :name => 'dup', :dup => true)
20
- end
21
-
22
- def close
23
- @db.close
24
- @dbd.close
25
- end
26
-
27
- def test_put_and_get
28
- @db['key'] = 'data'
29
- assert_equal 'data', @db['key']
30
-
31
- @dbd['key'] = 'data1'
32
- @dbd['key'] = 'data2'
33
- assert_equal ['data1', 'data2'], @dbd['key'].to_a
34
- end
35
-
36
- def test_update
37
- @db[:key] = 0
38
- close
39
-
40
- pids = []
41
- 5.times do
42
- pids << Process.fork do
43
- db = Bdb::Simple.new(@path)
44
- 10.times do
45
- db.update(:key) do |v|
46
- sleep(0.1)
47
- v + 1
48
- end
49
- end
50
- db.close
51
- end
52
- end
53
- pids.each {|pid| Process.wait(pid)}
54
-
55
- open
56
- assert_equal 50, @db[:key]
57
- end
58
-
59
-
60
- def test_delete
61
- @db['key'] = 'data'
62
- assert_equal 'data', @db['key']
63
-
64
- @db.delete('key')
65
- assert_nil @db['key']
66
- end
67
-
68
- def test_range
69
- (1..10).each {|i| @db[i] = "data#{i}"}
70
-
71
- assert_equal (3..7).collect {|i| "data#{i}"}, @db[3..7].to_a
72
- end
73
-
74
- def test_compare_absolute
75
- list = [5, 6, "foo", :bar, "bar", :foo, [1,2,4], true, [1,2,3], false, [1], [2], nil, {}, {:b => 1, :a => 1}, {:b => 2, :a => 1}]
76
-
77
- expected = [nil, false, true, 5, 6, :bar, :foo, "bar", "foo", [1], [1, 2, 3], [1, 2, 4], [2], {}, {:a=>1, :b=>1}, {:a=>1, :b=>2}]
78
- assert_equal expected, list.sort {|a,b| Bdb::Simple.compare_absolute(a,b)}
79
- 100.times do
80
- assert_equal expected, list.shuffle.sort {|a,b| Bdb::Simple.compare_absolute(a,b)}
81
- end
82
- end
83
-
84
- def parallel(n)
85
- threads = []
86
- n.times do |i|
87
- threads << Thread.new do
88
- yield(i)
89
- end
90
- end
91
- threads.each { |thread| thread.join }
92
- end
93
- end