##// END OF EJS Templates
made concurrency test also for git
marcink -
r2895:f5dc0417 beta
parent child Browse files
Show More
@@ -46,15 +46,15 b' from rhodecode.lib.auth import get_crypt'
46 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
46 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
47 from rhodecode.config.environment import load_environment
47 from rhodecode.config.environment import load_environment
48
48
49 rel_path = dn(dn(dn(os.path.abspath(__file__))))
49 rel_path = dn(dn(dn(dn(os.path.abspath(__file__)))))
50 conf = appconfig('config:development.ini', relative_to=rel_path)
50 conf = appconfig('config:rc.ini', relative_to=rel_path)
51 load_environment(conf.global_conf, conf.local_conf)
51 load_environment(conf.global_conf, conf.local_conf)
52
52
53 add_cache(conf)
53 add_cache(conf)
54
54
55 USER = 'test_admin'
55 USER = 'test_admin'
56 PASS = 'test12'
56 PASS = 'test12'
57 HOST = 'hg.local'
57 HOST = 'rc.local'
58 METHOD = 'pull'
58 METHOD = 'pull'
59 DEBUG = True
59 DEBUG = True
60 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
@@ -130,10 +130,10 b' def create_test_repo(force=True):'
130 if repo is None:
130 if repo is None:
131 print 'repo not found creating'
131 print 'repo not found creating'
132
132
133 form_data = {'repo_name':HG_REPO,
133 form_data = {'repo_name': HG_REPO,
134 'repo_type':'hg',
134 'repo_type': 'hg',
135 'private':False,
135 'private':False,
136 'clone_uri':'' }
136 'clone_uri': '' }
137 rm = RepoModel(sa)
137 rm = RepoModel(sa)
138 rm.base_path = '/home/hg'
138 rm.base_path = '/home/hg'
139 rm.create(form_data, user)
139 rm.create(form_data, user)
@@ -158,7 +158,7 b' def get_anonymous_access():'
158 # TESTS
158 # TESTS
159 #==============================================================================
159 #==============================================================================
160 def test_clone_with_credentials(no_errors=False, repo=HG_REPO, method=METHOD,
160 def test_clone_with_credentials(no_errors=False, repo=HG_REPO, method=METHOD,
161 seq=None):
161 seq=None, backend='hg'):
162 cwd = path = jn(TESTS_TMP_PATH, repo)
162 cwd = path = jn(TESTS_TMP_PATH, repo)
163
163
164 if seq == None:
164 if seq == None:
@@ -172,20 +172,23 b' def test_clone_with_credentials(no_error'
172 raise
172 raise
173
173
174 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \
174 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \
175 {'user':USER,
175 {'user': USER,
176 'pass':PASS,
176 'pass': PASS,
177 'host':HOST,
177 'host': HOST,
178 'cloned_repo':repo, }
178 'cloned_repo': repo, }
179
179
180 dest = path + seq
180 dest = path + seq
181 if method == 'pull':
181 if method == 'pull':
182 stdout, stderr = Command(cwd).execute('hg', method, '--cwd', dest, clone_url)
182 stdout, stderr = Command(cwd).execute(backend, method, '--cwd', dest, clone_url)
183 else:
183 else:
184 stdout, stderr = Command(cwd).execute('hg', method, clone_url, dest)
184 stdout, stderr = Command(cwd).execute(backend, method, clone_url, dest)
185
185 print stdout,'sdasdsadsa'
186 if no_errors is False:
186 if no_errors is False:
187 assert """adding file changes""" in stdout, 'no messages about cloning'
187 if backend == 'hg':
188 assert """abort""" not in stderr , 'got error from clone'
188 assert """adding file changes""" in stdout, 'no messages about cloning'
189 assert """abort""" not in stderr , 'got error from clone'
190 elif backend == 'git':
191 assert """Cloning into""" in stdout, 'no messages about cloning'
189
192
190 if __name__ == '__main__':
193 if __name__ == '__main__':
191 try:
194 try:
@@ -198,15 +201,20 b" if __name__ == '__main__':"
198 except:
201 except:
199 pass
202 pass
200
203
204 try:
205 backend = sys.argv[4]
206 except:
207 backend = 'hg'
208
201 if METHOD == 'pull':
209 if METHOD == 'pull':
202 seq = _RandomNameSequence().next()
210 seq = _RandomNameSequence().next()
203 test_clone_with_credentials(repo=sys.argv[1], method='clone',
211 test_clone_with_credentials(repo=sys.argv[1], method='clone',
204 seq=seq)
212 seq=seq, backend=backend)
205 s = time.time()
213 s = time.time()
206 for i in range(1, int(sys.argv[2]) + 1):
214 for i in range(1, int(sys.argv[2]) + 1):
207 print 'take', i
215 print 'take', i
208 test_clone_with_credentials(repo=sys.argv[1], method=METHOD,
216 test_clone_with_credentials(repo=sys.argv[1], method=METHOD,
209 seq=seq)
217 seq=seq, backend=backend)
210 print 'time taken %.3f' % (time.time() - s)
218 print 'time taken %.3f' % (time.time() - s)
211 except Exception, e:
219 except Exception, e:
212 raise
220 raise
General Comments 0
You need to be logged in to leave comments. Login now