##// END OF EJS Templates
tests: make repeat flag unique for vcsserver sources
super-admin -
r1032:78ea273c default
parent child Browse files
Show More
@@ -1,57 +1,56 b''
1 # RhodeCode VCSServer provides access to different vcs backends via network.
1 # RhodeCode VCSServer provides access to different vcs backends via network.
2 # Copyright (C) 2014-2020 RhodeCode GmbH
2 # Copyright (C) 2014-2020 RhodeCode GmbH
3 #
3 #
4 # This program is free software; you can redistribute it and/or modify
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
7 # (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
18 import socket
18 import socket
19
20 import pytest
19 import pytest
21
20
22
21
23 def pytest_addoption(parser):
22 def pytest_addoption(parser):
24 parser.addoption(
23 parser.addoption(
25 '--repeat', type=int, default=100,
24 '--perf-repeat-vcs', type=int, default=100,
26 help="Number of repetitions in performance tests.")
25 help="Number of repetitions in performance tests.")
27
26
28
27
29 @pytest.fixture(scope='session')
28 @pytest.fixture(scope='session')
30 def repeat(request):
29 def repeat(request):
31 """
30 """
32 The number of repetitions is based on this fixture.
31 The number of repetitions is based on this fixture.
33
32
34 Slower calls may divide it by 10 or 100. It is chosen in a way so that the
33 Slower calls may divide it by 10 or 100. It is chosen in a way so that the
35 tests are not too slow in our default test suite.
34 tests are not too slow in our default test suite.
36 """
35 """
37 return request.config.getoption('--repeat')
36 return request.config.getoption('--perf-repeat-vcs')
38
37
39
38
40 @pytest.fixture(scope='session')
39 @pytest.fixture(scope='session')
41 def vcsserver_port(request):
40 def vcsserver_port(request):
42 port = get_available_port()
41 port = get_available_port()
43 print('Using vcsserver port %s' % (port, ))
42 print('Using vcsserver port %s' % (port, ))
44 return port
43 return port
45
44
46
45
47 def get_available_port():
46 def get_available_port():
48 family = socket.AF_INET
47 family = socket.AF_INET
49 socktype = socket.SOCK_STREAM
48 socktype = socket.SOCK_STREAM
50 host = '127.0.0.1'
49 host = '127.0.0.1'
51
50
52 mysocket = socket.socket(family, socktype)
51 mysocket = socket.socket(family, socktype)
53 mysocket.bind((host, 0))
52 mysocket.bind((host, 0))
54 port = mysocket.getsockname()[1]
53 port = mysocket.getsockname()[1]
55 mysocket.close()
54 mysocket.close()
56 del mysocket
55 del mysocket
57 return port
56 return port
General Comments 0
You need to be logged in to leave comments. Login now