@@ -24,7 +24,7 @@ def debug(level, arg)
2424#
2525module Mongo
2626 class Config
27- DEFAULT_BASE_OPTS = { :host => 'localhost' , :dbpath => 'data' , :logpath => 'data/log' }
27+ DEFAULT_BASE_OPTS = { :host => 'localhost' , :dbpath => 'data' , :logpath => 'data/log' }
2828 DEFAULT_REPLICA_SET = DEFAULT_BASE_OPTS . merge ( :replicas => 3 , :arbiters => 0 )
2929 DEFAULT_SHARDED_SIMPLE = DEFAULT_BASE_OPTS . merge ( :shards => 2 , :configs => 1 , :routers => 4 )
3030 DEFAULT_SHARDED_REPLICA = DEFAULT_SHARDED_SIMPLE . merge ( :replicas => 3 , :arbiters => 0 )
@@ -35,7 +35,7 @@ class Config
3535 MONGODS_OPT_KEYS = [ :mongods ]
3636 CLUSTER_OPT_KEYS = SHARDING_OPT_KEYS + REPLICA_OPT_KEYS + MONGODS_OPT_KEYS
3737
38- FLAGS = [ :noprealloc , :smallfiles , :logappend , :configsvr , :shardsvr , :quiet , :fastsync ]
38+ FLAGS = [ :noprealloc , :smallfiles , :logappend , :configsvr , :shardsvr , :quiet , :fastsync , :auth ]
3939
4040 DEFAULT_VERIFIES = 60
4141 BASE_PORT = 3000
@@ -80,51 +80,52 @@ def self.cluster(opts = DEFAULT_SHARDED_SIMPLE)
8080 end
8181
8282 def self . make_mongo ( kind , opts )
83- dbpath = opts [ :dbpath ]
84- port = self . get_available_port
85- path = "#{ dbpath } /#{ kind } -#{ port } "
83+ dbpath = opts [ :dbpath ]
84+ port = self . get_available_port
85+ path = "#{ dbpath } /#{ kind } -#{ port } "
8686 logpath = "#{ path } /#{ kind } .log"
8787
88- {
89- :host => opts [ :host ] ,
90- :port => port ,
91- :logpath => logpath ,
92- :logappend => true
93- }
88+ { :host => opts [ :host ] ,
89+ :port => port ,
90+ :logpath => logpath ,
91+ :logappend => true }
9492 end
9593
9694 def self . make_mongod ( kind , opts )
9795 params = make_mongo ( 'mongods' , opts )
9896
9997 mongod = ENV [ 'MONGOD' ] || 'mongod'
100- path = File . dirname ( params [ :logpath ] )
98+ path = File . dirname ( params [ :logpath ] )
10199
102100 noprealloc = opts [ :noprealloc ] || true
103101 smallfiles = opts [ :smallfiles ] || true
104102 quiet = opts [ :quiet ] || true
105103 fast_sync = opts [ :fastsync ] || false
106-
107- params . merge (
108- :command => mongod ,
109- :dbpath => path ,
110- :smallfiles => smallfiles ,
111- :noprealloc => noprealloc ,
112- :quiet => quiet ,
113- :fastsync => fast_sync
114- )
104+ auth = opts [ :auth ] || true
105+
106+ params . merge ( :command => mongod ,
107+ :dbpath => path ,
108+ :smallfiles => smallfiles ,
109+ :noprealloc => noprealloc ,
110+ :quiet => quiet ,
111+ :fastsync => fast_sync ,
112+ :auth => auth )
115113 end
116114
117115 def self . make_replica ( opts , count )
118- params = make_mongod ( 'replicas' , opts )
116+ params = make_mongod ( 'replicas' , opts )
119117
120118 replSet = opts [ :replSet ] || 'ruby-driver-test'
121119 oplog_size = opts [ :oplog_size ] || 5
120+ keyFile = opts [ :keyFile ] || '/test/tools/keyfile.txt'
122121
123- params . merge (
124- :_id => count ,
125- :replSet => replSet ,
126- :oplogSize => oplog_size
127- )
122+ keyFile = Dir . pwd << keyFile
123+ system "chmod 600 #{ keyFile } "
124+
125+ params . merge ( :_id => count ,
126+ :replSet => replSet ,
127+ :oplogSize => oplog_size ,
128+ :keyFile => keyFile )
128129 end
129130
130131 def self . make_config ( opts )
0 commit comments