Example #1
0
    def test_insert_list(self):
        # Perform inserts with multiple documents at once
        doc1 = {'x': 1, 'y': 1}
        doc2 = {'x': 2, 'y': 1}
        operations.multishard_insert('dummy', [doc1, doc2])

        results = list(self.db1.dummy.find({'y': 1}))
        self.assertEquals([doc1], results)

        results = list(self.db2.dummy.find({'y': 1}))
        self.assertEquals([doc2], results)
Example #2
0
    def test_insert_list(self):
        # Perform inserts with multiple documents at once
        doc1 = {'x': 1, 'y': 1}
        doc2 = {'x': 2, 'y': 1}
        operations.multishard_insert('dummy', [doc1, doc2])

        results = list(self.db1.dummy.find({'y': 1}))
        self.assertEquals([doc1], results)

        results = list(self.db2.dummy.find({'y': 1}))
        self.assertEquals([doc2], results)
Example #3
0
    def test_insert(self):
        # Perform an insert with shards set to specific locations.
        doc1 = {'x': 1, 'y': 1}
        doc2 = {'x': 2, 'y': 1}
        operations.multishard_insert('dummy', doc1)
        operations.multishard_insert('dummy', doc2)

        results = list(self.db1.dummy.find({'y': 1}))
        self.assertEquals([doc1], results)

        results = list(self.db2.dummy.find({'y': 1}))
        self.assertEquals([doc2], results)
Example #4
0
    def test_insert(self):
        # Perform an insert with shards set to specific locations.
        doc1 = {'x': 1, 'y': 1}
        doc2 = {'x': 2, 'y': 1}
        operations.multishard_insert('dummy', doc1)
        operations.multishard_insert('dummy', doc2)

        results = list(self.db1.dummy.find({'y': 1}))
        self.assertEquals([doc1], results)

        results = list(self.db2.dummy.find({'y': 1}))
        self.assertEquals([doc2], results)
Example #5
0
    def test_insert_with_longs(self):
        # Perform an insert using longs. This tests a specific bug we found
        # during extended testing
        #api.set_shard_at_rest('dummy', 1L, "dest1/test_sharding")
        #api.set_shard_at_rest('dummy', 2L, "dest2/test_sharding")
        doc1 = {'x': 1L, 'y': 1L}
        doc2 = {'x': 2L, 'y': 1L}
        operations.multishard_insert('dummy', doc1)
        operations.multishard_insert('dummy', doc2)

        results = list(self.db1.dummy.find({'y': 1L}))
        self.assertEquals([doc1], results)

        results = list(self.db2.dummy.find({'y': 1L}))
        self.assertEquals([doc2], results)
Example #6
0
    def test_insert_with_longs(self):
        # Perform an insert using longs. This tests a specific bug we found
        # during extended testing
        #api.set_shard_at_rest('dummy', 1L, "dest1/test_sharding")
        #api.set_shard_at_rest('dummy', 2L, "dest2/test_sharding")
        doc1 = {'x': 1L, 'y': 1L}
        doc2 = {'x': 2L, 'y': 1L}
        operations.multishard_insert('dummy', doc1)
        operations.multishard_insert('dummy', doc2)

        results = list(self.db1.dummy.find({'y': 1L}))
        self.assertEquals([doc1], results)

        results = list(self.db2.dummy.find({'y': 1L}))
        self.assertEquals([doc2], results)
Example #7
0
    def test_insert_to_default_location(self):
        doc1 = {'x': 1, 'y': 1}
        operations.multishard_insert('dummy', doc1)

        results = list(self.db1.dummy.find({'y': 1}))
        self.assertEquals([doc1], results)
Example #8
0
 def insert(self, *args, **kwargs):
     return operations.multishard_insert(
         self.collection_name, *args, **kwargs)
Example #9
0
    def test_insert_to_default_location(self):
        doc1 = {'x': 1, 'y': 1}
        operations.multishard_insert('dummy', doc1)

        results = list(self.db1.dummy.find({'y': 1}))
        self.assertEquals([doc1], results)