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