use $DEBUG instead of __FILE__ == $0 because that is true when running from bin/run_test_script

This commit is contained in:
Jim Menard 2009-02-05 16:00:45 -05:00
parent 8ecc8cb305
commit 7e1f67538a
11 changed files with 46 additions and 22 deletions

2
tests/mongo-qa/admin Executable file → Normal file
View File

@ -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

2
tests/mongo-qa/capped Executable file → Normal file
View File

@ -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

2
tests/mongo-qa/count1 Executable file → Normal file
View File

@ -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'})

2
tests/mongo-qa/dbs Executable file → Normal file
View File

@ -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

2
tests/mongo-qa/find Executable file → Normal file
View File

@ -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

2
tests/mongo-qa/find1 Executable file → Normal file
View File

@ -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) }

8
tests/mongo-qa/indices Executable file → Normal file
View File

@ -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'])

10
tests/mongo-qa/remove Executable file → Normal file
View File

@ -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

24
tests/mongo-qa/stress1 Executable file → Normal file
View File

@ -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

2
tests/mongo-qa/test1 Executable file → Normal file
View File

@ -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

12
tests/mongo-qa/update Executable file → Normal file
View File

@ -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