mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-26 23:50:23 +00:00
The only advantage of localkube was being a low weight. Anything else started creating only problems: 1. It is not properly maintained for many years. 2. It effectively worked only on Linux, but stopped on modern version due to changes in iptables. Instead, we will use widely adoped tools like kind or k3s. The "kind-kind" is the default K8s context (see ~/.kube/config), but it could be overriden using `PATRONI_KUBERNETES_CONTEXT` environment variable. When executed from GH actions the context is set to k3d-k3s-default, because K3s is much faster to start.
52 lines
1.7 KiB
Python
52 lines
1.7 KiB
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
|
|
def main():
|
|
what = os.environ.get('DCS', sys.argv[1] if len(sys.argv) > 1 else 'all')
|
|
|
|
if what == 'all':
|
|
flake8 = subprocess.call([sys.executable, 'setup.py', 'flake8'])
|
|
test = subprocess.call([sys.executable, 'setup.py', 'test'])
|
|
version = '.'.join(map(str, sys.version_info[:2]))
|
|
shutil.move('.coverage', os.path.join(tempfile.gettempdir(), '.coverage.' + version))
|
|
return flake8 | test
|
|
elif what == 'combine':
|
|
tmp = tempfile.gettempdir()
|
|
for name in os.listdir(tmp):
|
|
if name.startswith('.coverage.'):
|
|
shutil.move(os.path.join(tmp, name), name)
|
|
return subprocess.call([sys.executable, '-m', 'coverage', 'combine'])
|
|
|
|
env = os.environ.copy()
|
|
if sys.platform.startswith('linux'):
|
|
from mapping import versions
|
|
|
|
version = versions.get(what)
|
|
path = '/usr/lib/postgresql/{0}/bin:.'.format(version)
|
|
unbuffer = ['timeout', '900', 'unbuffer']
|
|
else:
|
|
path = os.path.abspath(os.path.join('pgsql', 'bin'))
|
|
if sys.platform == 'darwin':
|
|
path += ':.'
|
|
unbuffer = []
|
|
env['PATH'] = path + os.pathsep + env['PATH']
|
|
env['DCS'] = what
|
|
if what == 'kubernetes':
|
|
env['PATRONI_KUBERNETES_CONTEXT'] = 'k3d-k3s-default'
|
|
|
|
ret = subprocess.call(unbuffer + [sys.executable, '-m', 'behave'], env=env)
|
|
|
|
if ret != 0:
|
|
if subprocess.call('grep . features/output/*_failed/*postgres?.*', shell=True) != 0:
|
|
subprocess.call('grep . features/output/*/*postgres?.*', shell=True)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|