diff --git a/tests/mongo-qa/admin b/tests/mongo-qa/admin old mode 100755 new mode 100644 index fcba1fb..fa7103b --- a/tests/mongo-qa/admin +++ b/tests/mongo-qa/admin @@ -6,7 +6,7 @@ db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) db.collection('test').insert({'test' => 1}) admin = db.admin -if __FILE__ == $0 +if $DEBUG db.drop_collection('tester') admin.profiling_level = :slow_only end diff --git a/tests/mongo-qa/capped b/tests/mongo-qa/capped old mode 100755 new mode 100644 index 85b8fa5..40832f4 --- a/tests/mongo-qa/capped +++ b/tests/mongo-qa/capped @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) -if __FILE__ == $0 +if $DEBUG db.drop_collection('capped1') db.drop_collection('capped2') end diff --git a/tests/mongo-qa/count1 b/tests/mongo-qa/count1 old mode 100755 new mode 100644 index 6465b55..32f6de8 --- a/tests/mongo-qa/count1 +++ b/tests/mongo-qa/count1 @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) -if __FILE__ == $0 +if $DEBUG 3.times { |i| db.drop_collection("test#{i+1}") } db.create_collection('test1') db.collection('test2').insert({:name => 'a'}) diff --git a/tests/mongo-qa/dbs b/tests/mongo-qa/dbs old mode 100755 new mode 100644 index a82d8f9..e0e7ebb --- a/tests/mongo-qa/dbs +++ b/tests/mongo-qa/dbs @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) -if __FILE__ == $0 +if $DEBUG 3.times { |i| db.drop_collection("dbs_#{i+1}") } end diff --git a/tests/mongo-qa/find b/tests/mongo-qa/find old mode 100755 new mode 100644 index 2b948b0..700bcac --- a/tests/mongo-qa/find +++ b/tests/mongo-qa/find @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) -if __FILE__ == $0 +if $DEBUG db.drop_collection('test') end diff --git a/tests/mongo-qa/find1 b/tests/mongo-qa/find1 old mode 100755 new mode 100644 index f45ce1f..f78dda1 --- a/tests/mongo-qa/find1 +++ b/tests/mongo-qa/find1 @@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) -if __FILE__ == $0 +if $DEBUG db.drop_collection('c') c = db.collection('c') (5..15).each { |i| c.insert(:x => 0, :y => i, :z => (i+64).chr) } diff --git a/tests/mongo-qa/indices b/tests/mongo-qa/indices old mode 100755 new mode 100644 index 6a37f7f..a940fc9 --- a/tests/mongo-qa/indices +++ b/tests/mongo-qa/indices @@ -5,18 +5,18 @@ db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) x = db.collection('x') y = db.collection('y') -if __FILE__ == $0 +if $DEBUG x.drop x.insert('field1' => 'f1', 'field2' => 'f2') - x.create_index('field1', 'field1') - x.create_index('field2', 'field2') + x.create_index('field1_1', 'field1') + x.create_index('field2_1', 'field2') end def print_sorted_info_keys(info) puts info[:keys].keys.sort.collect { |key| "#{key}_1" }.join("_") end -x.drop_index('field1') +x.drop_index('field1_1') x.index_information.each { |info| print_sorted_info_keys(info) } y.create_index('abc', ['a', 'b', 'c']) diff --git a/tests/mongo-qa/remove b/tests/mongo-qa/remove old mode 100755 new mode 100644 index cb9fa88..6dfc4d9 --- a/tests/mongo-qa/remove +++ b/tests/mongo-qa/remove @@ -3,10 +3,12 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) -if __FILE__ == $0 +if $DEBUG c = db.collection('remove1') + c.clear 50.times { |i| c.insert(:a => i) } c = db.collection('remove2') + c.clear c.insert(:a => 3, :b => 1) c.insert(:a => 3, :b => 3) c.insert(:a => 2, :b => 3) @@ -15,3 +17,9 @@ end db.collection('remove1').clear db.collection('remove2').remove('a' => 3) + +if $DEBUG + puts "remove1 count = #{db.collection('remove1').count}" + puts "remove2 count = #{db.collection('remove2').count}" + db.collection('remove2').find.each { |row| puts row.inspect } +end diff --git a/tests/mongo-qa/stress1 b/tests/mongo-qa/stress1 old mode 100755 new mode 100644 index 46ba4c3..1205093 --- a/tests/mongo-qa/stress1 +++ b/tests/mongo-qa/stress1 @@ -6,21 +6,33 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) c = db.collection('stress1') -if __FILE__ == $0 +n1 = 50_000 +n2 = 10_000 + +if $DEBUG + raise "WHAT THE HELL?" # DEBUG + n1 = 5 + n2 = 1 c.drop end -50000.times { |i| - c.insert(:name => "asdf#{i}", :date => Time.now, :_id => i, +n1.times { |i| + c.insert(:name => "asdf#{i}", :date => Time.now, :id => i, :blah => LONG_STRING, :subarray => []) } puts -10000.times { |i| - cursor = c.find({:_id => i}) +n2.times { |i| + cursor = c.find({:id => i}) x = cursor.next_object cursor.close x['subarray'] = "foo#{i}" - c.insert(x) + p x + c.modify({:id => i}, x) } puts + +if $DEBUG + puts "stress1 has #{c.count} records" + c.find.each { |row| puts "#{row['id']}: #{row['subarray'].inspect}" } +end diff --git a/tests/mongo-qa/test1 b/tests/mongo-qa/test1 old mode 100755 new mode 100644 index 667babf..b372bc7 --- a/tests/mongo-qa/test1 +++ b/tests/mongo-qa/test1 @@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) coll = db.collection('part1') -if __FILE__ == $0 +if $DEBUG coll.drop end diff --git a/tests/mongo-qa/update b/tests/mongo-qa/update old mode 100755 new mode 100644 index 562c12b..a575183 --- a/tests/mongo-qa/update +++ b/tests/mongo-qa/update @@ -4,11 +4,15 @@ require File.join(File.dirname(__FILE__), '_common.rb') db = Mongo.new(DEFAULT_HOST, DEFAULT_PORT).db(DEFAULT_DB) foo = db.collection('foo') -if __FILE__ == $0 +if $DEBUG foo.drop foo.insert(:x => 1) end -foo.replace({:x => 1}, {:x => 1, :y => 2}) -foo.replace({:x => 2}, {:x => 1, :y => 7}) -foo.replace({:x => 3}, {:x => 4, :y => 1}) +foo.modify({:x => 1}, {:x => 1, :y => 2}) +foo.modify({:x => 2}, {:x => 1, :y => 7}) +foo.repsert({:x => 3}, {:x => 4, :y => 1}) + +if $DEBUG + foo.find.each { |row| puts row.inspect } +end