##// 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 173 assert_no_running_instance(host_url)
174 174 command = ['gunicorn', '--worker-class', 'gevent', '--paste', rc_web_server_config]
175 175
176 print('Starting rhodecode server: {}'.format(host_url))
177 print('Command: {}'.format(command))
178 print('Logfile: {}'.format(rc_log))
176 print('rhodecode-web starting at: {}'.format(host_url))
177 print('rhodecode-web command: {}'.format(command))
178 print('rhodecode-web logfile: {}'.format(rc_log))
179 179
180 180 proc = subprocess32.Popen(
181 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 52 def test_git_clone_with_small_push_buffer(backend_git, rc_web_server, tmpdir):
53 53 clone_url = rc_web_server.repo_clone_url(GIT_REPO)
54 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 57 _check_proper_clone(stdout, stderr, 'git')
57 58 cmd.assert_returncode_success()
58 59
@@ -73,5 +74,6 b' def test_git_push_with_small_push_buffer'
73 74 branch='master')
74 75
75 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 79 _check_proper_git_push(stdout, stderr, branch='master')
@@ -49,6 +49,11 b' from rhodecode.tests.other.vcs_operation'
49 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 57 @pytest.mark.usefixtures("disable_locking", "disable_anonymous_user")
53 58 class TestVCSOperations(object):
54 59
@@ -464,215 +469,214 b' class TestVCSOperations(object):'
464 469 assert 'abort: authorization failed' in stderr
465 470
466 471
467 def test_git_sets_default_branch_if_not_master(
468 backend_git, tmpdir, disable_locking, rc_web_server):
469 empty_repo = backend_git.create_repo()
470 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
472 @pytest.mark.usefixtures("disable_locking")
473 class TestVCSOperationsSpecial(object):
471 474
472 cmd = Command(tmpdir.strpath)
473 cmd.execute('git clone', clone_url)
475 def test_git_sets_default_branch_if_not_master(
476 self, backend_git, tmpdir, rc_web_server):
477 empty_repo = backend_git.create_repo()
478 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
479
480 cmd = Command(tmpdir.strpath)
481 cmd.execute('git clone', clone_url)
474 482
475 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
476 repo.in_memory_commit.add(FileNode('file', content=''))
477 repo.in_memory_commit.commit(
478 message='Commit on branch test',
479 author='Automatic test',
480 branch='test')
483 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
484 repo.in_memory_commit.add(FileNode('file', content=''))
485 repo.in_memory_commit.commit(
486 message='Commit on branch test',
487 author='Automatic test',
488 branch='test')
481 489
482 repo_cmd = Command(repo.path)
483 stdout, stderr = repo_cmd.execute('git push --verbose origin test')
484 _check_proper_git_push(
485 stdout, stderr, branch='test', should_set_default_branch=True)
486
487 stdout, stderr = cmd.execute(
488 'git clone', clone_url, empty_repo.repo_name + '-clone')
489 _check_proper_clone(stdout, stderr, 'git')
490 repo_cmd = Command(repo.path)
491 stdout, stderr = repo_cmd.execute('git push --verbose origin test')
492 _check_proper_git_push(
493 stdout, stderr, branch='test', should_set_default_branch=True)
490 494
491 # Doing an explicit commit in order to get latest user logs on MySQL
492 Session().commit()
493
495 stdout, stderr = cmd.execute(
496 'git clone', clone_url, empty_repo.repo_name + '-clone')
497 _check_proper_clone(stdout, stderr, 'git')
494 498
495 def test_git_fetches_from_remote_repository_with_annotated_tags(
496 backend_git, disable_locking, rc_web_server):
497 # Note: This is a test specific to the git backend. It checks the
498 # integration of fetching from a remote repository which contains
499 # annotated tags.
499 # Doing an explicit commit in order to get latest user logs on MySQL
500 Session().commit()
501
502 def test_git_fetches_from_remote_repository_with_annotated_tags(
503 self, backend_git, rc_web_server):
504 # Note: This is a test specific to the git backend. It checks the
505 # integration of fetching from a remote repository which contains
506 # annotated tags.
500 507
501 # Dulwich shows this specific behavior only when
502 # operating against a remote repository.
503 source_repo = backend_git['annotated-tag']
504 target_vcs_repo = backend_git.create_repo().scm_instance()
505 target_vcs_repo.fetch(rc_web_server.repo_clone_url(source_repo.repo_name))
506
508 # Dulwich shows this specific behavior only when
509 # operating against a remote repository.
510 source_repo = backend_git['annotated-tag']
511 target_vcs_repo = backend_git.create_repo().scm_instance()
512 target_vcs_repo.fetch(rc_web_server.repo_clone_url(source_repo.repo_name))
507 513
508 def test_git_push_shows_pull_request_refs(backend_git, rc_web_server, tmpdir):
509 """
510 test if remote info about refs is visible
511 """
512 empty_repo = backend_git.create_repo()
514 def test_git_push_shows_pull_request_refs(self, backend_git, rc_web_server, tmpdir):
515 """
516 test if remote info about refs is visible
517 """
518 empty_repo = backend_git.create_repo()
513 519
514 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
520 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
515 521
516 cmd = Command(tmpdir.strpath)
517 cmd.execute('git clone', clone_url)
522 cmd = Command(tmpdir.strpath)
523 cmd.execute('git clone', clone_url)
518 524
519 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
520 repo.in_memory_commit.add(FileNode('readme.md', content='## Hello'))
521 repo.in_memory_commit.commit(
522 message='Commit on branch Master',
523 author='Automatic test',
524 branch='master')
525 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
526 repo.in_memory_commit.add(FileNode('readme.md', content='## Hello'))
527 repo.in_memory_commit.commit(
528 message='Commit on branch Master',
529 author='Automatic test',
530 branch='master')
525 531
526 repo_cmd = Command(repo.path)
527 stdout, stderr = repo_cmd.execute('git push --verbose origin master')
528 _check_proper_git_push(stdout, stderr, branch='master')
532 repo_cmd = Command(repo.path)
533 stdout, stderr = repo_cmd.execute('git push --verbose origin master')
534 _check_proper_git_push(stdout, stderr, branch='master')
529 535
530 ref = '{}/{}/pull-request/new?branch=master'.format(
531 rc_web_server.host_url(), empty_repo.repo_name)
532 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
533 assert 'remote: RhodeCode: push completed' in stderr
536 ref = '{}/{}/pull-request/new?branch=master'.format(
537 rc_web_server.host_url(), empty_repo.repo_name)
538 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
539 assert 'remote: RhodeCode: push completed' in stderr
534 540
535 # push on the same branch
536 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
537 repo.in_memory_commit.add(FileNode('setup.py', content='print\n'))
538 repo.in_memory_commit.commit(
539 message='Commit2 on branch Master',
540 author='Automatic test2',
541 branch='master')
541 # push on the same branch
542 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
543 repo.in_memory_commit.add(FileNode('setup.py', content='print\n'))
544 repo.in_memory_commit.commit(
545 message='Commit2 on branch Master',
546 author='Automatic test2',
547 branch='master')
542 548
543 repo_cmd = Command(repo.path)
544 stdout, stderr = repo_cmd.execute('git push --verbose origin master')
545 _check_proper_git_push(stdout, stderr, branch='master')
546
547 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
548 assert 'remote: RhodeCode: push completed' in stderr
549 repo_cmd = Command(repo.path)
550 stdout, stderr = repo_cmd.execute('git push --verbose origin master')
551 _check_proper_git_push(stdout, stderr, branch='master')
549 552
550 # new Branch
551 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
552 repo.in_memory_commit.add(FileNode('feature1.py', content='## Hello world'))
553 repo.in_memory_commit.commit(
554 message='Commit on branch feature',
555 author='Automatic test',
556 branch='feature')
553 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
554 assert 'remote: RhodeCode: push completed' in stderr
557 555
558 repo_cmd = Command(repo.path)
559 stdout, stderr = repo_cmd.execute('git push --verbose origin feature')
560 _check_proper_git_push(stdout, stderr, branch='feature')
556 # new Branch
557 repo = GitRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
558 repo.in_memory_commit.add(FileNode('feature1.py', content='## Hello world'))
559 repo.in_memory_commit.commit(
560 message='Commit on branch feature',
561 author='Automatic test',
562 branch='feature')
561 563
562 ref = '{}/{}/pull-request/new?branch=feature'.format(
563 rc_web_server.host_url(), empty_repo.repo_name)
564 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
565 assert 'remote: RhodeCode: push completed' in stderr
564 repo_cmd = Command(repo.path)
565 stdout, stderr = repo_cmd.execute('git push --verbose origin feature')
566 _check_proper_git_push(stdout, stderr, branch='feature')
566 567
568 ref = '{}/{}/pull-request/new?branch=feature'.format(
569 rc_web_server.host_url(), empty_repo.repo_name)
570 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stderr
571 assert 'remote: RhodeCode: push completed' in stderr
567 572
568 def test_hg_push_shows_pull_request_refs(backend_hg, rc_web_server, tmpdir):
569 empty_repo = backend_hg.create_repo()
573 def test_hg_push_shows_pull_request_refs(self, backend_hg, rc_web_server, tmpdir):
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)
572 577
573 cmd = Command(tmpdir.strpath)
574 cmd.execute('hg clone', clone_url)
578 cmd = Command(tmpdir.strpath)
579 cmd.execute('hg clone', clone_url)
575 580
576 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
577 repo.in_memory_commit.add(FileNode(u'readme.md', content=u'## Hello'))
578 repo.in_memory_commit.commit(
579 message=u'Commit on branch default',
580 author=u'Automatic test',
581 branch='default')
581 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
582 repo.in_memory_commit.add(FileNode(u'readme.md', content=u'## Hello'))
583 repo.in_memory_commit.commit(
584 message=u'Commit on branch default',
585 author=u'Automatic test',
586 branch='default')
582 587
583 repo_cmd = Command(repo.path)
584 repo_cmd.execute('hg checkout default')
588 repo_cmd = Command(repo.path)
589 repo_cmd.execute('hg checkout default')
585 590
586 stdout, stderr = repo_cmd.execute('hg push --verbose', clone_url)
587 _check_proper_hg_push(stdout, stderr, branch='default')
591 stdout, stderr = repo_cmd.execute('hg push --verbose', clone_url)
592 _check_proper_hg_push(stdout, stderr, branch='default')
588 593
589 ref = '{}/{}/pull-request/new?branch=default'.format(
590 rc_web_server.host_url(), empty_repo.repo_name)
591 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
592 assert 'remote: RhodeCode: push completed' in stdout
594 ref = '{}/{}/pull-request/new?branch=default'.format(
595 rc_web_server.host_url(), empty_repo.repo_name)
596 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
597 assert 'remote: RhodeCode: push completed' in stdout
593 598
594 # push on the same branch
595 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
596 repo.in_memory_commit.add(FileNode(u'setup.py', content=u'print\n'))
597 repo.in_memory_commit.commit(
598 message=u'Commit2 on branch default',
599 author=u'Automatic test2',
600 branch=u'default')
599 # push on the same branch
600 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
601 repo.in_memory_commit.add(FileNode(u'setup.py', content=u'print\n'))
602 repo.in_memory_commit.commit(
603 message=u'Commit2 on branch default',
604 author=u'Automatic test2',
605 branch=u'default')
601 606
602 repo_cmd = Command(repo.path)
603 repo_cmd.execute('hg checkout default')
607 repo_cmd = Command(repo.path)
608 repo_cmd.execute('hg checkout default')
604 609
605 stdout, stderr = repo_cmd.execute('hg push --verbose', clone_url)
606 _check_proper_hg_push(stdout, stderr, branch='default')
610 stdout, stderr = repo_cmd.execute('hg push --verbose', clone_url)
611 _check_proper_hg_push(stdout, stderr, branch='default')
607 612
608 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
609 assert 'remote: RhodeCode: push completed' in stdout
613 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
614 assert 'remote: RhodeCode: push completed' in stdout
610 615
611 # new Branch
612 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
613 repo.in_memory_commit.add(FileNode(u'feature1.py', content=u'## Hello world'))
614 repo.in_memory_commit.commit(
615 message=u'Commit on branch feature',
616 author=u'Automatic test',
617 branch=u'feature')
616 # new Branch
617 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
618 repo.in_memory_commit.add(FileNode(u'feature1.py', content=u'## Hello world'))
619 repo.in_memory_commit.commit(
620 message=u'Commit on branch feature',
621 author=u'Automatic test',
622 branch=u'feature')
618 623
619 repo_cmd = Command(repo.path)
620 repo_cmd.execute('hg checkout feature')
624 repo_cmd = Command(repo.path)
625 repo_cmd.execute('hg checkout feature')
621 626
622 stdout, stderr = repo_cmd.execute('hg push --new-branch --verbose', clone_url)
623 _check_proper_hg_push(stdout, stderr, branch='feature')
627 stdout, stderr = repo_cmd.execute('hg push --new-branch --verbose', clone_url)
628 _check_proper_hg_push(stdout, stderr, branch='feature')
624 629
625 ref = '{}/{}/pull-request/new?branch=feature'.format(
626 rc_web_server.host_url(), empty_repo.repo_name)
627 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
628 assert 'remote: RhodeCode: push completed' in stdout
630 ref = '{}/{}/pull-request/new?branch=feature'.format(
631 rc_web_server.host_url(), empty_repo.repo_name)
632 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
633 assert 'remote: RhodeCode: push completed' in stdout
629 634
635 def test_hg_push_shows_pull_request_refs_book(self, backend_hg, rc_web_server, tmpdir):
636 empty_repo = backend_hg.create_repo()
630 637
631 def test_hg_push_shows_pull_request_refs_book(backend_hg, rc_web_server, tmpdir):
632 empty_repo = backend_hg.create_repo()
638 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
633 639
634 clone_url = rc_web_server.repo_clone_url(empty_repo.repo_name)
640 cmd = Command(tmpdir.strpath)
641 cmd.execute('hg clone', clone_url)
635 642
636 cmd = Command(tmpdir.strpath)
637 cmd.execute('hg clone', clone_url)
643 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
644 repo.in_memory_commit.add(FileNode(u'readme.md', content=u'## Hello'))
645 repo.in_memory_commit.commit(
646 message=u'Commit on branch default',
647 author=u'Automatic test',
648 branch='default')
638 649
639 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
640 repo.in_memory_commit.add(FileNode(u'readme.md', content=u'## Hello'))
641 repo.in_memory_commit.commit(
642 message=u'Commit on branch default',
643 author=u'Automatic test',
644 branch='default')
650 repo_cmd = Command(repo.path)
651 repo_cmd.execute('hg checkout default')
645 652
646 repo_cmd = Command(repo.path)
647 repo_cmd.execute('hg checkout default')
648
649 stdout, stderr = repo_cmd.execute('hg push --verbose', clone_url)
650 _check_proper_hg_push(stdout, stderr, branch='default')
653 stdout, stderr = repo_cmd.execute('hg push --verbose', clone_url)
654 _check_proper_hg_push(stdout, stderr, branch='default')
651 655
652 ref = '{}/{}/pull-request/new?branch=default'.format(
653 rc_web_server.host_url(), empty_repo.repo_name)
654 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
655 assert 'remote: RhodeCode: push completed' in stdout
656 ref = '{}/{}/pull-request/new?branch=default'.format(
657 rc_web_server.host_url(), empty_repo.repo_name)
658 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
659 assert 'remote: RhodeCode: push completed' in stdout
656 660
657 # add bookmark
658 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
659 repo.in_memory_commit.add(FileNode(u'setup.py', content=u'print\n'))
660 repo.in_memory_commit.commit(
661 message=u'Commit2 on branch default',
662 author=u'Automatic test2',
663 branch=u'default')
661 # add bookmark
662 repo = MercurialRepository(os.path.join(tmpdir.strpath, empty_repo.repo_name))
663 repo.in_memory_commit.add(FileNode(u'setup.py', content=u'print\n'))
664 repo.in_memory_commit.commit(
665 message=u'Commit2 on branch default',
666 author=u'Automatic test2',
667 branch=u'default')
664 668
665 repo_cmd = Command(repo.path)
666 repo_cmd.execute('hg checkout default')
667 repo_cmd.execute('hg bookmark feature2')
668 stdout, stderr = repo_cmd.execute('hg push -B feature2 --verbose', clone_url)
669 _check_proper_hg_push(stdout, stderr, branch='default')
669 repo_cmd = Command(repo.path)
670 repo_cmd.execute('hg checkout default')
671 repo_cmd.execute('hg bookmark feature2')
672 stdout, stderr = repo_cmd.execute('hg push -B feature2 --verbose', clone_url)
673 _check_proper_hg_push(stdout, stderr, branch='default')
670 674
671 ref = '{}/{}/pull-request/new?branch=default'.format(
672 rc_web_server.host_url(), empty_repo.repo_name)
673 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
674 ref = '{}/{}/pull-request/new?bookmark=feature2'.format(
675 rc_web_server.host_url(), empty_repo.repo_name)
676 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
677 assert 'remote: RhodeCode: push completed' in stdout
678 assert 'exporting bookmark feature2' in stdout
675 ref = '{}/{}/pull-request/new?branch=default'.format(
676 rc_web_server.host_url(), empty_repo.repo_name)
677 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
678 ref = '{}/{}/pull-request/new?bookmark=feature2'.format(
679 rc_web_server.host_url(), empty_repo.repo_name)
680 assert 'remote: RhodeCode: open pull request link: {}'.format(ref) in stdout
681 assert 'remote: RhodeCode: push completed' in stdout
682 assert 'exporting bookmark feature2' in stdout
@@ -91,6 +91,11 b' def enable_webhook_push_integration(requ'
91 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 99 @pytest.mark.usefixtures(
95 100 "disable_locking", "disable_anonymous_user",
96 101 "enable_webhook_push_integration")
@@ -96,8 +96,17 b' def pytest_addoption(parser):'
96 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 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 111 Session scope VCSServer.
103 112
@@ -120,7 +129,8 b' def vcsserver(request, vcsserver_port, v'
120 129
121 130 use_http = _use_vcs_http_server(request.config)
122 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 136 @pytest.fixture(scope='session')
@@ -213,7 +223,7 b' class HttpVCSServer(VCSServer):'
213 223 config_data = configobj.ConfigObj(config_file)
214 224 self._config = config_data['server:main']
215 225
216 args = ['gunicorn', '--workers', '1', '--paste', config_file]
226 args = ['gunicorn', '--paste', config_file]
217 227 self._args = args
218 228
219 229 @property
@@ -232,9 +242,9 b' class HttpVCSServer(VCSServer):'
232 242 server_out = open(rc_log, 'w')
233 243
234 244 command = ' '.join(self._args)
235 print('Starting rhodecode-vcsserver: {}'.format(host_url))
236 print('Command: {}'.format(command))
237 print('Logfile: {}'.format(rc_log))
245 print('rhodecode-vcsserver starting at: {}'.format(host_url))
246 print('rhodecode-vcsserver command: {}'.format(command))
247 print('rhodecode-vcsserver logfile: {}'.format(rc_log))
238 248 self.process = subprocess32.Popen(
239 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