A few basic batch insert stress tests
This commit is contained in:
parent
cd26973e89
commit
625db17646
1 changed files with 39 additions and 0 deletions
39
test/monger/test/stress.clj
Normal file
39
test/monger/test/stress.clj
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
(ns monger.test.stress
|
||||
(:import [com.mongodb Mongo DB DBCollection WriteResult DBObject WriteConcern DBCursor]
|
||||
[java.util Date])
|
||||
(:require [monger core])
|
||||
(:use [clojure.test]))
|
||||
|
||||
|
||||
;;
|
||||
;; Fixture functions
|
||||
;;
|
||||
|
||||
(defn purge-collection
|
||||
[collection-name, f]
|
||||
(monger.collection/remove collection-name)
|
||||
(f)
|
||||
(monger.collection/remove collection-name))
|
||||
|
||||
(defn purge-things-collection
|
||||
[f]
|
||||
(purge-collection "things" f))
|
||||
|
||||
(use-fixtures :each purge-things-collection)
|
||||
|
||||
|
||||
|
||||
;;
|
||||
;; Tests
|
||||
;;
|
||||
|
||||
(deftest insert-large-batches-of-documents-without-object-ids
|
||||
(doseq [n [1000 10000 100000 1000000]]
|
||||
(let [collection "things"
|
||||
docs (map (fn [i]
|
||||
(monger.conversion/to-db-object { :title "Untitled" :created-at (Date.) :number i }))
|
||||
(take n (iterate inc 1)))]
|
||||
(monger.collection/remove collection)
|
||||
(println "Inserting " n " documents...")
|
||||
(time (monger.collection/insert-batch collection docs))
|
||||
(is (= n (monger.collection/count collection))))))
|
||||
Loading…
Reference in a new issue