Skip to content

Commit b52df14

Browse files
author
avandras
committed
Merge test fixes from master
2 parents 9983b12 + 587491e commit b52df14

36 files changed

+454
-138
lines changed

.github/workflows/install_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ def main():
144144

145145

146146
if __name__ == '__main__':
147-
sys.exit(main())
147+
sys.exit(main())

.github/workflows/run_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
import shutil
33
import subprocess
44
import sys
5-
import tempfile
65

76

87
def main():
98
what = os.environ.get('DCS', sys.argv[1] if len(sys.argv) > 1 else 'all')
9+
tmp = os.environ.get('RUNNER_TEMP')
1010

1111
if what == 'all':
1212
flake8 = subprocess.call([sys.executable, 'setup.py', 'flake8'])
1313
test = subprocess.call([sys.executable, 'setup.py', 'test'])
1414
version = '.'.join(map(str, sys.version_info[:2]))
15-
shutil.move('.coverage', os.path.join(tempfile.gettempdir(), '.coverage.' + version))
15+
print(shutil.move('.coverage', '.coverage.' + version))
16+
print(os.getcwd())
1617
return flake8 | test
1718
elif what == 'combine':
18-
tmp = tempfile.gettempdir()
1919
for name in os.listdir(tmp):
2020
if name.startswith('.coverage.'):
2121
shutil.move(os.path.join(tmp, name), name)

.github/workflows/tests.yaml

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,72 +13,64 @@ env:
1313

1414
jobs:
1515
unit:
16-
runs-on: ${{ matrix.os }}-latest
16+
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
os: [ubuntu, windows, macos]
20+
os: [ubuntu-latest, windows-latest, macos-latest]
21+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
22+
exclude:
23+
- os: macos-latest
24+
python-version: 3.7
25+
- os: ubuntu-latest
26+
python-version: 3.7
27+
include:
28+
- os: ubuntu-22.04
29+
python-version: 3.7
2130

2231
steps:
2332
- uses: actions/checkout@v4
2433

25-
- name: Set up Python 3.7
34+
- name: Set up Python ${{ matrix.python-version }}
2635
uses: actions/setup-python@v5
2736
with:
28-
python-version: 3.7
29-
if: matrix.os != 'macos'
37+
python-version: ${{ matrix.python-version }}
3038
- name: Install dependencies
3139
run: python .github/workflows/install_deps.py
3240
if: matrix.os != 'macos'
3341
- name: Run tests and flake8
3442
run: python .github/workflows/run_tests.py
35-
if: matrix.os != 'macos'
36-
37-
- name: Set up Python 3.8
38-
uses: actions/setup-python@v5
39-
with:
40-
python-version: 3.8
41-
- name: Install dependencies
42-
run: python .github/workflows/install_deps.py
43-
- name: Run tests and flake8
44-
run: python .github/workflows/run_tests.py
45-
46-
- name: Set up Python 3.9
47-
uses: actions/setup-python@v5
43+
- name: Upload logs from unit tests
44+
uses: actions/upload-artifact@v4
4845
with:
49-
python-version: 3.9
50-
- name: Install dependencies
51-
run: python .github/workflows/install_deps.py
52-
- name: Run tests and flake8
53-
run: python .github/workflows/run_tests.py
46+
name: logs-${{ matrix.os }}-${{ matrix.python-version }}
47+
path: ${{ github.workspace }}/.coverage.*
48+
include-hidden-files: true
49+
retention-days: 1
5450

55-
- name: Set up Python 3.10
56-
uses: actions/setup-python@v5
57-
with:
58-
python-version: '3.10'
59-
- name: Install dependencies
60-
run: python .github/workflows/install_deps.py
61-
- name: Run tests and flake8
62-
run: python .github/workflows/run_tests.py
51+
post-unit-coverage:
52+
runs-on: ${{ matrix.os }}
53+
needs: unit
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os: [ubuntu-latest, windows-latest, macos-latest]
58+
steps:
59+
- uses: actions/checkout@v4
6360

64-
- name: Set up Python 3.11
61+
- name: Set up Python
6562
uses: actions/setup-python@v5
6663
with:
6764
python-version: 3.11
68-
- name: Install dependencies
69-
run: python .github/workflows/install_deps.py
70-
- name: Run tests and flake8
71-
run: python .github/workflows/run_tests.py
7265

73-
- name: Set up Python 3.12
74-
uses: actions/setup-python@v5
75-
with:
76-
python-version: 3.12
7766
- name: Install dependencies
7867
run: python .github/workflows/install_deps.py
79-
- name: Run tests and flake8
80-
run: python .github/workflows/run_tests.py
8168

69+
- name: Download logs from unit tests
70+
uses: actions/download-artifact@v4
71+
with:
72+
pattern: logs-${{ matrix.os }}-*
73+
merge-multiple: true
8274
- name: Combine coverage
8375
run: python .github/workflows/run_tests.py combine
8476

@@ -93,27 +85,28 @@ jobs:
9385
run: python -m coveralls --service=github
9486

9587
behave:
96-
runs-on: ${{ matrix.os }}-latest
88+
runs-on: ${{ matrix.os }}
9789
env:
9890
DCS: ${{ matrix.dcs }}
9991
ETCDVERSION: 3.4.23
10092
PGVERSION: 16.1-1 # for windows and macos
10193
strategy:
10294
fail-fast: false
10395
matrix:
104-
os: [ubuntu]
105-
python-version: [3.7, 3.12]
96+
os: [ubuntu-22.04]
97+
python-version: [3.13]
98+
# python-version: [3.7, 3.13]
10699
dcs: [etcd, etcd3, consul, exhibitor, kubernetes, raft]
107-
include:
108-
- os: macos
109-
python-version: 3.8
110-
dcs: raft
111-
- os: macos
112-
python-version: 3.9
113-
dcs: etcd
114-
- os: macos
115-
python-version: 3.11
116-
dcs: etcd3
100+
# include:
101+
# - os: macos-latest
102+
# python-version: 3.8
103+
# dcs: raft
104+
# - os: macos-latest
105+
# python-version: 3.9
106+
# dcs: etcd
107+
# - os: macos-latest
108+
# python-version: 3.11
109+
# dcs: etcd3
117110

118111
steps:
119112
- uses: actions/checkout@v4
@@ -131,7 +124,7 @@ jobs:
131124
sudo sh -c 'wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg'
132125
sudo sh -c 'echo "deb [signed-by=/etc/apt/trusted.gpg.d/citusdata_community.gpg] https://packagecloud.io/citusdata/community/ubuntu/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/citusdata_community.list'
133126
sudo sh -c 'wget -qO - https://packagecloud.io/citusdata/community/gpgkey | gpg --dearmor > /etc/apt/trusted.gpg.d/citusdata_community.gpg'
134-
if: matrix.os == 'ubuntu'
127+
if: startsWith(matrix.os, 'ubuntu')
135128
- name: Install dependencies
136129
run: python .github/workflows/install_deps.py
137130
- name: Run behave tests
@@ -154,7 +147,7 @@ jobs:
154147

155148
coveralls-finish:
156149
name: Finalize coveralls.io
157-
needs: unit
150+
needs: post-unit-coverage
158151
runs-on: ubuntu-latest
159152
steps:
160153
- uses: actions/setup-python@v5
@@ -176,7 +169,7 @@ jobs:
176169
steps:
177170
- uses: actions/checkout@v4
178171

179-
- name: Set up Python 3.12
172+
- name: Set up Python 3.11
180173
uses: actions/setup-python@v5
181174
with:
182175
python-version: 3.12

patroni/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def _get_json_formatter(self, logformat: type_logformat, dateformat: Optional[st
399399
# compatibility with python 3.12, that added a new attribute to LogRecord
400400
jsonlogger.RESERVED_ATTRS += ('taskName',)
401401

402-
return jsonlogger.JsonFormatter(
402+
return jsonlogger.JsonFormatter( # pyright: ignore [reportPrivateImportUsage]
403403
jsonformat,
404404
dateformat,
405405
rename_fields=rename_fields,

requirements.docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sphinx>=4
1+
sphinx>=4,<8.2.0
22
sphinx_rtd_theme>1
33
sphinxcontrib-apidoc
44
sphinx-github-style<1.0.3

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ cryptography>=1.4
1212
psutil>=2.0.0
1313
ydiff>=1.2.0,<1.5,!=1.4.0,!=1.4.1
1414
python-json-logger>=2.0.2
15-
kubernetes>=22.6
15+
setuptools

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import shutil
44
import unittest
55

6-
from unittest.mock import Mock, patch, PropertyMock
6+
from unittest.mock import Mock, PropertyMock, patch
77

88
import urllib3
99

tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from http.server import HTTPServer
77
from io import BytesIO as IO
8+
from unittest.mock import Mock, PropertyMock, patch
89
from socketserver import ThreadingMixIn
910
from unittest.mock import Mock, patch, PropertyMock
1011

tests/test_async_executor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import unittest
22

3+
from unittest.mock import Mock, patch
4+
from patroni.async_executor import AsyncExecutor, CriticalTask
35
from threading import Thread
46
from unittest.mock import Mock, patch
57

tests/test_aws.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
import unittest
33

4+
from unittest.mock import Mock, PropertyMock, patch
45
from collections import namedtuple
56
from unittest.mock import Mock, patch, PropertyMock
67

0 commit comments

Comments
 (0)