test/instrumentation/mongo_test.rb in oboe-2.3.2 vs test/instrumentation/mongo_test.rb in oboe-2.3.3.7

- old
+ new

@@ -4,10 +4,13 @@ before do clear_all_traces @connection = Mongo::Connection.new("localhost", 27017, :slave_ok => true) @db = @connection.db("test-#{ENV['RACK_ENV']}") + @collections = @db.collection_names + @db.create_collection("testCollection") unless @collections.include? "testCollection" + # These are standard entry/exit KVs that are passed up with all mongo operations @entry_kvs = { 'Layer' => 'mongo', 'Label' => 'entry', 'Flavor' => 'mongodb', @@ -65,10 +68,13 @@ traces[1]['New_Collection_Name'].must_equal "create_and_drop_collection_test" traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces] end it "should trace drop_collection" do + # Create a collection so we have one to drop + @db.create_collection("create_and_drop_collection_test") + Oboe::API.start_trace('mongo_test', '', {}) do @db.drop_collection("create_and_drop_collection_test") end traces = get_all_traces @@ -136,11 +142,12 @@ validate_event_keys(traces[2], @exit_kvs) traces[1]['Collection'].must_equal "testCollection" traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces] traces[1]['QueryOp'].must_equal "insert" - traces[1]['Query'].must_equal "{\"name\":\"MyName\",\"type\":\"MyType\",\"count\":1,\"info\":{\"x\":203,\"y\":\"102\"}}" + # Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+ + traces[1].has_key?('Query').must_equal true end it "should trace map_reduce" do coll = @db.collection("testCollection") @@ -298,10 +305,11 @@ validate_event_keys(traces[2], @exit_kvs) traces[1]['Collection'].must_equal "testCollection" traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces] traces[1]['QueryOp'].must_equal "group" - traces[1]['Query'].must_equal "{\"key\":\"type\",\"cond\":{\"count\":1},\"initial\":{\"count\":0},\"reduce\":\"function(obj,prev) { prev.count += obj.c; }\"}" + # Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+ + traces[1].has_key?('Query').must_equal true end it "should trace create, ensure and drop index" do coll = @db.collection("testCollection")