##// END OF EJS Templates
tests: fixes for gunicorn tests workers
marcink -
r2455:82863912 default
parent child Browse files
Show More
@@ -173,9 +173,9 b' def rc_web_server('
173 assert_no_running_instance(host_url)
173 assert_no_running_instance(host_url)
174 command = ['gunicorn', '--worker-class', 'gevent', '--paste', rc_web_server_config]
174 command = ['gunicorn', '--worker-class', 'gevent', '--paste', rc_web_server_config]
175
175
176 print('Starting rhodecode server: {}'.format(host_url))
176 print('rhodecode-web starting at: {}'.format(host_url))
177 print('Command: {}'.format(command))
177 print('rhodecode-web command: {}'.format(command))
178 print('Logfile: {}'.format(rc_log))
178 print('rhodecode-web logfile: {}'.format(rc_log))
179
179
180 proc = subprocess32.Popen(
180 proc = subprocess32.Popen(
181 command, bufsize=0, env=env, stdout=server_out, stderr=server_out)
181 command, bufsize=0, env=env, stdout=server_out, stderr=server_out)
@@ -52,7 +52,8 b' def rc_web_server_config(testini_factory'
52 def test_git_clone_with_small_push_buffer(backend_git, rc_web_server, tmpdir):
52 def test_git_clone_with_small_push_buffer(backend_git, rc_web_server, tmpdir):
53 clone_url = rc_web_server.repo_clone_url(GIT_REPO)
53 clone_url = rc_web_server.repo_clone_url(GIT_REPO)
54 cmd = Command('/tmp')
54 cmd = Command('/tmp')
55 stdout, stderr = cmd.execute('git -c http.postBuffer=1024 clone', clone_url, tmpdir.strpath)
55 stdout, stderr = cmd.execute(
56 'git -c http.postBuffer=1024 clone', clone_url, tmpdir.strpath)
56 _check_proper_clone(stdout, stderr, 'git')
57 _check_proper_clone(stdout, stderr, 'git')
57 cmd.assert_returncode_success()
58 cmd.assert_returncode_success()
58
59
@@ -73,5 +74,6 b' def test_git_push_with_small_push_buffer'
73 branch='master')
74 branch='master')
74
75
75 repo_cmd = Command(repo.path)
76 repo_cmd = Command(repo.path)
76 stdout, stderr = repo_cmd.execute('git -c http.postBuffer=1024 push --verbose origin master')
77 stdout, stderr = repo_cmd.execute(
78 'git -c http.postBuffer=1024 push --verbose origin master')
77 _check_proper_git_push(stdout, stderr, branch='master')
79 _check_proper_git_push(stdout, stderr, branch='master')
@@ -49,6 +49,11 b' from rhodecode.tests.other.vcs_operation'
49 HG_REPO_WITH_GROUP, GIT_REPO_WITH_GROUP)
49 HG_REPO_WITH_GROUP, GIT_REPO_WITH_GROUP)
50
50
51
51
52 @pytest.fixture(scope="session")
53 def vcs_server_config_override():
54 return ({'server:main': {'workers': 2}},)
55
56
52 @pytest.mark.usefixtures("disable_locking", "disable_anonymous_user")
57 @pytest.mark.usefixtures("disable_locking", "disable_anonymous_user")
53 class TestVCSOperations(object):
58 class TestVCSOperations(object):
54
59
@@ -464,8 +469,11 b' class TestVCSOperations(object):'
464 assert 'abort: authorization failed' in stderr
469 assert 'abort: authorization failed' in stderr
465
470
466
471
472 @pytest.mark.usefixtures("disable_locking")
473 class TestVCSOperationsSpecial(object):
474
467 def test_git_sets_default_branch_if_not_master(
475 def test_git_sets_default_branch_if_not_master(
468 backend_git, tmpdir, disable_locking, rc_web_server):
476 self, backend_git, tmpdir, rc_web_server):
469 empty_repo = backend_git.create_repo()
477 empty_repo = backend_git.create_repo()
470 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
478 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
471
479
@@ -491,9 +499,8 b' def test_git_sets_default_branch_if_not_'
491 # Doing an explicit commit in order to get latest user logs on MySQL
499 # Doing an explicit commit in order to get latest user logs on MySQL
492 Session().commit()
500 Session().commit()
493
501
494
495 def test_git_fetches_from_remote_repository_with_annotated_tags(
502 def test_git_fetches_from_remote_repository_with_annotated_tags(
496 backend_git, disable_locking, rc_web_server):
503 self, backend_git, rc_web_server):
497 # Note: This is a test specific to the git backend. It checks the
504 # Note: This is a test specific to the git backend. It checks the
498 # integration of fetching from a remote repository which contains
505 # integration of fetching from a remote repository which contains
499 # annotated tags.
506 # annotated tags.
@@ -504,8 +511,7 b' def test_git_fetches_from_remote_reposit'
504 target_vcs_repo = backend_git.create_repo().scm_instance()
511 target_vcs_repo = backend_git.create_repo().scm_instance()
505 target_vcs_repo.fetch(rc_web_server.repo_clone_url(source_repo.repo_name))
512 target_vcs_repo.fetch(rc_web_server.repo_clone_url(source_repo.repo_name))
506
513
507
514 def test_git_push_shows_pull_request_refs(self, backend_git, rc_web_server, tmpdir):
508 def test_git_push_shows_pull_request_refs(backend_git, rc_web_server, tmpdir):
509 """
515 """
510 test if remote info about refs is visible
516 test if remote info about refs is visible
511 """
517 """
@@ -564,8 +570,7 b' def test_git_push_shows_pull_request_ref'
564 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
570 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
565 assert 'remote: RhodeCode: push completed' in stderr
571 assert 'remote: RhodeCode: push completed' in stderr
566
572
567
573 def test_hg_push_shows_pull_request_refs(self, backend_hg, rc_web_server, tmpdir):
568 def test_hg_push_shows_pull_request_refs(backend_hg, rc_web_server, tmpdir):
569 empty_repo = backend_hg.create_repo()
574 empty_repo = backend_hg.create_repo()
570
575
571 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
576 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
@@ -627,8 +632,7 b' def test_hg_push_shows_pull_request_refs'
627 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
632 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
628 assert 'remote: RhodeCode: push completed' in stdout
633 assert 'remote: RhodeCode: push completed' in stdout
629
634
630
635 def test_hg_push_shows_pull_request_refs_book(self, backend_hg, rc_web_server, tmpdir):
631 def test_hg_push_shows_pull_request_refs_book(backend_hg, rc_web_server, tmpdir):
632 empty_repo = backend_hg.create_repo()
636 empty_repo = backend_hg.create_repo()
633
637
634 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
638 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
@@ -91,6 +91,11 b' def enable_webhook_push_integration(requ'
91 Session().commit()
91 Session().commit()
92
92
93
93
94 @pytest.fixture(scope="session")
95 def vcs_server_config_override():
96 return ({'server:main': {'workers': 2}},)
97
98
94 @pytest.mark.usefixtures(
99 @pytest.mark.usefixtures(
95 "disable_locking", "disable_anonymous_user",
100 "disable_locking", "disable_anonymous_user",
96 "enable_webhook_push_integration")
101 "enable_webhook_push_integration")
@@ -96,8 +96,17 b' def pytest_addoption(parser):'
96 "Start the VCSServer with HTTP protocol support.")
96 "Start the VCSServer with HTTP protocol support.")
97
97
98
98
99 @pytest.fixture(scope="session")
100 def vcs_server_config_override(request):
101 """
102 Allows injecting the overrides by specifying this inside test class
103 """
104
105 return ()
106
107
99 @pytest.fixture(scope='session')
108 @pytest.fixture(scope='session')
100 def vcsserver(request, vcsserver_port, vcsserver_factory):
109 def vcsserver(request, vcsserver_port, vcsserver_factory, vcs_server_config_override):
101 """
110 """
102 Session scope VCSServer.
111 Session scope VCSServer.
103
112
@@ -120,7 +129,8 b' def vcsserver(request, vcsserver_port, v'
120
129
121 use_http = _use_vcs_http_server(request.config)
130 use_http = _use_vcs_http_server(request.config)
122 return vcsserver_factory(
131 return vcsserver_factory(
123 request, use_http=use_http, vcsserver_port=vcsserver_port)
132 request, use_http=use_http, vcsserver_port=vcsserver_port,
133 overrides=vcs_server_config_override)
124
134
125
135
126 @pytest.fixture(scope='session')
136 @pytest.fixture(scope='session')
@@ -213,7 +223,7 b' class HttpVCSServer(VCSServer):'
213 config_data = configobj.ConfigObj(config_file)
223 config_data = configobj.ConfigObj(config_file)
214 self._config = config_data['server:main']
224 self._config = config_data['server:main']
215
225
216 args = ['gunicorn', '--workers', '1', '--paste', config_file]
226 args = ['gunicorn', '--paste', config_file]
217 self._args = args
227 self._args = args
218
228
219 @property
229 @property
@@ -232,9 +242,9 b' class HttpVCSServer(VCSServer):'
232 server_out = open(rc_log, 'w')
242 server_out = open(rc_log, 'w')
233
243
234 command = ' '.join(self._args)
244 command = ' '.join(self._args)
235 print('Starting rhodecode-vcsserver: {}'.format(host_url))
245 print('rhodecode-vcsserver starting at: {}'.format(host_url))
236 print('Command: {}'.format(command))
246 print('rhodecode-vcsserver command: {}'.format(command))
237 print('Logfile: {}'.format(rc_log))
247 print('rhodecode-vcsserver logfile: {}'.format(rc_log))
238 self.process = subprocess32.Popen(
248 self.process = subprocess32.Popen(
239 self._args, bufsize=0, env=env, stdout=server_out, stderr=server_out)
249 self._args, bufsize=0, env=env, stdout=server_out, stderr=server_out)
240
250
General Comments 0
You need to be logged in to leave comments. Login now