More cleanup
This commit is contained in:
parent
971b2e230c
commit
d04ab3af2d
2 changed files with 32 additions and 36 deletions
|
|
@ -9,39 +9,38 @@
|
||||||
;; You must not remove this notice, or any other, from this software.
|
;; You must not remove this notice, or any other, from this software.
|
||||||
|
|
||||||
(ns monger.command
|
(ns monger.command
|
||||||
(:use [monger.conversion])
|
(:require monger.core)
|
||||||
(:refer-clojure :exclude [find remove count drop distinct empty?])
|
(:use monger.conversion)
|
||||||
(:import [com.mongodb Mongo DB DBObject CommandResult]
|
(:import com.mongodb.DB))
|
||||||
[java.util Map])
|
|
||||||
(:require [monger core]))
|
|
||||||
|
|
||||||
|
|
||||||
(defn collection-stats
|
(defn collection-stats
|
||||||
([collection]
|
([collection]
|
||||||
(collection-stats monger.core/*mongodb-database* collection))
|
(collection-stats monger.core/*mongodb-database* collection))
|
||||||
([^DB database collection]
|
([^DB database collection]
|
||||||
(monger.core/command database { :collstats collection })))
|
(monger.core/command database { :collstats collection })))
|
||||||
|
|
||||||
(defn db-stats
|
(defn db-stats
|
||||||
([]
|
([]
|
||||||
(db-stats monger.core/*mongodb-database*))
|
(db-stats monger.core/*mongodb-database*))
|
||||||
([^DB database]
|
([^DB database]
|
||||||
(monger.core/command database {:dbStats 1 })))
|
(monger.core/command database {:dbStats 1 })))
|
||||||
|
|
||||||
|
|
||||||
(defn reindex-collection
|
(defn reindex-collection
|
||||||
([collection]
|
([collection]
|
||||||
(reindex-collection monger.core/*mongodb-database* collection))
|
(reindex-collection monger.core/*mongodb-database* collection))
|
||||||
([^DB database collection]
|
([^DB database collection]
|
||||||
(monger.core/command database { :reIndex collection })))
|
(monger.core/command database { :reIndex collection })))
|
||||||
|
|
||||||
|
|
||||||
(defn server-status
|
(defn server-status
|
||||||
([]
|
([]
|
||||||
(server-status monger.core/*mongodb-database*))
|
(server-status monger.core/*mongodb-database*))
|
||||||
([^DB database]
|
([^DB database]
|
||||||
(monger.core/command database {:serverStatus 1 })))
|
(monger.core/command database {:serverStatus 1 })))
|
||||||
|
|
||||||
|
|
||||||
(defn top []
|
(defn top
|
||||||
(monger.core/command (monger.core/get-db "admin") {:top 1 }))
|
[]
|
||||||
|
(monger.core/command (monger.core/get-db "admin") {:top 1}))
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,41 @@
|
||||||
(ns monger.test.command-test
|
(ns monger.test.command-test
|
||||||
(:require [monger core command]
|
(:require [monger.command :as mcom]
|
||||||
[monger.test.helper :as helper]
|
[monger.test.helper :as helper]
|
||||||
[monger.collection :as mgcol])
|
[monger.collection :as mc])
|
||||||
(:import (com.mongodb Mongo DB CommandResult))
|
(:use clojure.test
|
||||||
(:use clojure.test))
|
monger.result))
|
||||||
|
|
||||||
(helper/connect!)
|
(helper/connect!)
|
||||||
|
|
||||||
|
|
||||||
(deftest test-db-stats
|
(deftest test-db-stats
|
||||||
(let [stats (monger.command/db-stats)]
|
(let [stats (mcom/db-stats)]
|
||||||
(is (monger.result/ok? stats))
|
(is (ok? stats))
|
||||||
(is (= "monger-test" (get stats "db")))))
|
(is (= "monger-test" (get stats "db")))))
|
||||||
|
|
||||||
(deftest test-collection-stats
|
(deftest test-collection-stats
|
||||||
(let [collection "stat_test"
|
(let [collection "stat_test"
|
||||||
_ (mgcol/insert collection { :name "Clojure" })
|
_ (mc/insert collection {:name "Clojure"})
|
||||||
check (mgcol/count collection)
|
check (mc/count collection)
|
||||||
stats (monger.command/collection-stats collection)]
|
stats (mcom/collection-stats collection)]
|
||||||
(is (monger.result/ok? stats))
|
(is (ok? stats))
|
||||||
(is (= "monger-test.stat_test" (get stats "ns")))
|
(is (= "monger-test.stat_test" (get stats "ns")))
|
||||||
(is (= check (get stats "count")))))
|
(is (= check (get stats "count")))))
|
||||||
|
|
||||||
|
|
||||||
(deftest test-reindex-collection
|
(deftest test-reindex-collection
|
||||||
(let [_ (mgcol/insert "test" { :name "Clojure" })
|
(let [_ (mc/insert "test" {:name "Clojure"})
|
||||||
result (monger.command/reindex-collection "test")]
|
result (mcom/reindex-collection "test")]
|
||||||
(is (monger.result/ok? result))
|
(is (ok? result))
|
||||||
(is (get result "indexes"))))
|
(is (get result "indexes"))))
|
||||||
|
|
||||||
|
|
||||||
(deftest test-server-status
|
(deftest test-server-status
|
||||||
(let [status (monger.command/server-status)]
|
(let [status (mcom/server-status)]
|
||||||
(is (monger.result/ok? status))
|
(is (ok? status))
|
||||||
(is (not-empty status))
|
(is (not-empty status))
|
||||||
(is (get status "serverUsed"))))
|
(is (get status "serverUsed"))))
|
||||||
|
|
||||||
|
|
||||||
(deftest test-top
|
(deftest test-top
|
||||||
(let [result (monger.command/top)]
|
(let [result (mcom/top)]
|
||||||
(is (monger.result/ok? result))
|
(is (ok? result))
|
||||||
(is (not-empty result))
|
(is (not-empty result))
|
||||||
(is (get result "serverUsed"))))
|
(is (get result "serverUsed"))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue