Skip to content

Commit

Permalink
Merge pull request #485 from patroni/master
Browse files Browse the repository at this point in the history
Syncing from upstream patroni/patroni (master)
  • Loading branch information
bt-admin authored Jan 21, 2025
2 parents 4baabe7 + 7db7dfd commit 29649cd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ jobs:
- name: Run tests and flake8
run: python .github/workflows/run_tests.py

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.13
if: matrix.os != 'macos'
- name: Install dependencies
run: python .github/workflows/install_deps.py
if: matrix.os != 'macos'
- name: Run tests and flake8
run: python .github/workflows/run_tests.py
if: matrix.os != 'macos'

- name: Combine coverage
run: python .github/workflows/run_tests.py combine

Expand All @@ -102,7 +114,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu]
python-version: [3.7, 3.12]
python-version: [3.7, 3.13]
dcs: [etcd, etcd3, consul, exhibitor, kubernetes, raft]
include:
- os: macos
Expand Down Expand Up @@ -194,10 +206,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: 3.13
- name: Install dependencies
run: python .github/workflows/install_deps.py
- name: Update ydiff
Expand Down
3 changes: 2 additions & 1 deletion patroni/ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2065,9 +2065,10 @@ def invoke_editor(before_editing: str, cluster_name: str) -> Tuple[str, Dict[str
if not editor_cmd:
raise PatroniCtlException('EDITOR environment variable is not set. editor or vi are not available')

safe_cluster_name = cluster_name.replace("/", "_")
with temporary_file(contents=before_editing.encode('utf-8'),
suffix='.yaml',
prefix='{0}-config-'.format(cluster_name)) as tmpfile:
prefix='{0}-config-'.format(safe_cluster_name)) as tmpfile:
ret = subprocess.call([editor_cmd, tmpfile])
if ret:
raise PatroniCtlException("Editor exited with return code {0}".format(ret))
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: Implementation :: CPython',
]

Expand Down
3 changes: 2 additions & 1 deletion tests/test_consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ def test_update_leader(self, mock_renew):
self.assertTrue(self.c.update_leader(cluster, 12345, failsafe={'foo': 'bar'}))
with patch.object(KV, 'put', Mock(side_effect=ConsulException)):
self.assertFalse(self.c.update_leader(cluster, 12345))
with patch('time.time', Mock(side_effect=[0, 0, 0, 0, 100, 200, 300])):
mock_time = Mock(side_effect=[0, 0, 0, 0, 100, 200, 300])
with patch('time.time', mock_time), patch('time.time_ns', mock_time):
self.assertRaises(ConsulError, self.c.update_leader, cluster, 12345)
with patch('time.time', Mock(side_effect=[0, 100, 200, 300])):
self.assertRaises(ConsulError, self.c.update_leader, cluster, 12345)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ def test__update_leader_with_retry(self, mock_patch, mock_read):
mock_patch.side_effect = [k8s_client.rest.ApiException(409, ''),
k8s_client.rest.ApiException(409, ''), mock_namespaced_kind()]
mock_read.return_value.metadata.resource_version = '2'
with patch('time.time', Mock(side_effect=[0, 0, 100, 200, 0, 0, 0, 0, 0, 100, 200])):
mock_time = Mock(side_effect=[0, 0, 100, 200, 0, 0, 0, 0, 0, 100, 200])
with patch('time.time', mock_time), patch('time.time_ns', mock_time):
self.assertFalse(self.k.update_leader(cluster, '123'))
self.assertFalse(self.k.update_leader(cluster, '123'))
mock_patch.side_effect = k8s_client.rest.ApiException(409, '')
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[common]
python_matrix = {36,37,38,39,310,311}
python_matrix = {36,37,38,39,310,311,312,313}
postgres_matrix =
pg11: PG_MAJOR = 11
pg12: PG_MAJOR = 12
Expand All @@ -8,7 +8,7 @@ postgres_matrix =
pg15: PG_MAJOR = 15
pg16: PG_MAJOR = 16
psycopg_deps =
py{37,38,39,310,311}-{lin,win}: psycopg[binary]
py{37,38,39,310,311,312,313}-{lin,win}: psycopg[binary]
mac: psycopg2-binary
py36: psycopg2-binary
platforms =
Expand Down Expand Up @@ -44,7 +44,7 @@ commands = flake8 {posargs:patroni tests setup.py}
deps =
flake8

[testenv:py{36,37,38,39,310,311}-test-{lin,win,mac}]
[testenv:py{36,37,38,39,310,311,312,313}-test-{lin,win,mac}]
description = Run unit tests with pytest
labels =
test
Expand Down Expand Up @@ -88,7 +88,7 @@ deps =
pipdeptree
{[common]psycopg_deps}

[testenv:py{37,38,39,310,311}-type-{lin,mac,win}]
[testenv:py{37,38,39,310,311,312,313}-type-{lin,mac,win}]
description = Run static type checking with pyright
labels =
type
Expand Down Expand Up @@ -137,7 +137,7 @@ depends =
pg{11,12,13,14,15,16}-docker-build

# There's a bug which affects calling multiple envs on the command line
# This should be a valid command: tox -e 'py{36,37,38,39,310,311}-behave-{env:DCS}-lin'
# This should be a valid command: tox -e 'py{36,37,38,39,310,311,312,313}-behave-{env:DCS}-lin'
# Replaced with workaround, see https://github.com/tox-dev/tox/issues/2850
commands =
docker run \
Expand All @@ -159,7 +159,7 @@ platform =
; win: win32
mac: darwin

[testenv:py{36,38,39,310,311}-behave-{etcd,etcd3}-{lin,win,mac}]
[testenv:py{36,38,39,310,311,312,313}-behave-{etcd,etcd3}-{lin,win,mac}]
description = Run behaviour tests (locally with tox)
deps =
-r requirements.txt
Expand Down

0 comments on commit 29649cd

Please sign in to comment.