diff --git a/.github/workflows/run_tests.py b/.github/workflows/run_tests.py index 89a9b222..04666996 100644 --- a/.github/workflows/run_tests.py +++ b/.github/workflows/run_tests.py @@ -27,7 +27,7 @@ def main(): version = versions.get(what) path = '/usr/lib/postgresql/{0}/bin:.'.format(version) - unbuffer = ['timeout', '600', 'unbuffer'] + unbuffer = ['timeout', '900', 'unbuffer'] args = ['--tags=-skip'] if what == 'etcd' else [] else: path = os.path.abspath(os.path.join('pgsql', 'bin')) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ecac564b..534cd64b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -93,80 +93,55 @@ jobs: env: DCS: ${{ matrix.dcs }} ETCDVERSION: 3.3.13 + PGVERSION: 12.1-1 # for windows and macos strategy: fail-fast: false matrix: os: [ubuntu] python-version: [2.7, 3.6, 3.9] dcs: [etcd, etcd3, consul, exhibitor, kubernetes, raft] + exclude: + - dcs: kubernetes + python-version: 2.7 + include: + - os: macos + python-version: 3.7 + dcs: raft + - os: macos + python-version: 3.8 + dcs: etcd + - os: macos + python-version: '3.10' + dcs: etcd3 steps: - uses: actions/checkout@v1 - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - name: Set up Python uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - name: Add postgresql apt repo run: sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' + if: matrix.os == 'ubuntu' - name: Install dependencies run: python .github/workflows/install_deps.py - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - name: Run behave tests run: python .github/workflows/run_tests.py - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - uses: actions/setup-python@v2 with: python-version: '3.10' - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - name: Install coveralls run: python -m pip install coveralls - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - name: Upload Coverage env: COVERALLS_FLAG_NAME: behave-${{ matrix.os }}-${{ matrix.dcs }}-${{ matrix.python-version }} COVERALLS_PARALLEL: 'true' GITHUB_TOKEN: ${{ secrets.github_token }} run: python -m coveralls --service=github - if: matrix.python-version != 2.7 || matrix.dcs != 'kubernetes' - -# behavem: -# runs-on: ${{ matrix.os }}-latest -# env: -# DCS: ${{ matrix.dcs }} -# ETCDVERSION: 3.3.13 -# PGVERSION: 14.1-1 # for windows and macos -# strategy: -# fail-fast: false -# matrix: -# os: [macos] #, windows] -# python-version: [3.7] -# dcs: [etcd, etcd3, raft] -# -# steps: -# - uses: actions/checkout@v1 -# - name: Set up Python -# uses: actions/setup-python@v2 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install dependencies -# run: python .github/workflows/install_deps.py -# - name: Run behave tests -# run: python .github/workflows/run_tests.py -# - name: Install coveralls -# run: python -m pip install coveralls -# - name: Upload Coverage -# env: -# COVERALLS_FLAG_NAME: behave-${{ matrix.os }}-${{ matrix.dcs }}-${{ matrix.python-version }} -# COVERALLS_PARALLEL: 'true' -# GITHUB_TOKEN: ${{ secrets.github_token }} -# run: python -m coveralls --service=github coveralls-finish: name: Finalize coveralls.io - needs: [unit, behave] #, behavem] + needs: [unit, behave] runs-on: ubuntu-latest steps: - uses: actions/setup-python@v2 diff --git a/features/environment.py b/features/environment.py index ff4b032f..955e2a39 100644 --- a/features/environment.py +++ b/features/environment.py @@ -660,7 +660,7 @@ class PatroniPoolController(object): def output_dir(self): return self._output_dir - def start(self, name, max_wait_limit=20, custom_config=None): + def start(self, name, max_wait_limit=40, custom_config=None): if name not in self._processes: self._processes[name] = PatroniController(self._context, name, self.patroni_path, self._output_dir, custom_config) diff --git a/features/steps/patroni_api.py b/features/steps/patroni_api.py index c95878a7..c0523ba3 100644 --- a/features/steps/patroni_api.py +++ b/features/steps/patroni_api.py @@ -76,6 +76,8 @@ def do_request(context, request_method, url, data): data = data and json.loads(data) try: r = request_executor.request(request_method, url, data) + if request_method == 'PATCH' and r.status == 409: + r = request_executor.request(request_method, url, data) except Exception: context.status_code = context.response = None else: diff --git a/features/steps/standby_cluster.py b/features/steps/standby_cluster.py index eb011dae..c3ce80e2 100644 --- a/features/steps/standby_cluster.py +++ b/features/steps/standby_cluster.py @@ -57,7 +57,7 @@ def start_patroni_standby_cluster(context, name, cluster_name, name2): @step('{pg_name1:w} is replicating from {pg_name2:w} after {timeout:d} seconds') def check_replication_status(context, pg_name1, pg_name2, timeout): - bound_time = time.time() + timeout + bound_time = time.time() + timeout * context.timeout_multiplier while time.time() < bound_time: cur = context.pctl.query( diff --git a/setup.py b/setup.py index 121c8a82..0e8c660e 100644 --- a/setup.py +++ b/setup.py @@ -109,6 +109,8 @@ class PyTest(_Command): except Exception: raise RuntimeError('py.test is not installed, run: pip install pytest') + logging.getLogger().setLevel(logging.WARNING) + args = ['--verbose', 'tests', '--doctest-modules', MAIN_PACKAGE] +\ ['-s' if logging.getLogger().getEffectiveLevel() < logging.WARNING else '--capture=fd'] +\ ['--cov', MAIN_PACKAGE, '--cov-report', 'term-missing', '--cov-report', 'xml']