From b974919b5f8fc02105cba208ee6fc3344c0ec4bd Mon Sep 17 00:00:00 2001 From: Jared Casey Date: Tue, 29 Jul 2025 20:31:27 -0600 Subject: [PATCH] PYCO-65: Add cbdino job for integration tests --- .github/workflows/tests.yml | 98 ++++++++++++++++++- .../tests/connect_integration_t.py | 3 +- .../tests/connect_integration_t.py | 3 +- 3 files changed, 100 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ea2b503..cfddc67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -227,8 +227,8 @@ jobs: cat pycbac_test/requirements-test.txt echo "pycbac_test/pytest.ini contents:" cat pycbac_test/pytest.ini - echo "pycbac_test/test_config.ini contents:" - cat pycbac_test/test_config.ini + echo "pycbac_test/tests/test_config.ini contents:" + cat pycbac_test/tests/test_config.ini - name: Upload test setup uses: actions/upload-artifact@v4 with: @@ -562,3 +562,97 @@ jobs: if ( $TEST_COUCHBASE_API = "true" ) { python -m pytest -m "pycbac_couchbase and pycbac_unit" -rA -vv } + + cbdino-integration-tests: + needs: [setup, test-setup, sdist-wheel] + if: >- + ${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.has_linux_cbdino + && !fromJson(needs.setup.outputs.stage_matrices).test_integration.skip_cbdino }} + name: Run integration tests w/ cbdino; Python ${{ matrix.python-version }} - ${{ matrix.os }} (${{ matrix.arch }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.linux_cbdino }} + steps: + - name: Install cbdinocluster + run: | + mkdir -p "$HOME/bin" + CB_DINO_VERSION=${{ env.CBCI_CBDINO_VERSION }} + CB_DINO_TYPE="cbdinocluster-${{ matrix.arch == 'x86_64' && 'linux-amd64' || 'linux-arm64' }}" + wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/$CB_DINO_VERSION/$CB_DINO_TYPE + chmod +x $HOME/bin/cbdinocluster + echo "$HOME/bin" >> $GITHUB_PATH + - name: Install s3mock + run: | + docker pull adobe/s3mock + docker pull nginx + - name: Initialize cbdinocluster + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cbdinocluster -v init --auto + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Confirm Python version + run: python -c "import sys; print(sys.version)" + - name: Download CI scripts + uses: actions/download-artifact@v4 + with: + name: ci_scripts + path: ci_scripts + - name: Enable CI Scripts + run: | + chmod +x ci_scripts/gha.sh + - name: Download wheel + uses: actions/download-artifact@v4 + with: + name: pycbac-artifact-wheel + path: pycbac + - name: Download test setup + uses: actions/download-artifact@v4 + with: + name: pycbac-test-setup + path: pycbac + - name: Start couchbase cluster + run: | + cd pycbac + cat cluster_def.yaml + CBDC_ID=$(cbdinocluster -v alloc --def-file=cluster_def.yaml) + CBDC_CONNSTR=$(cbdinocluster -v connstr --analytics $CBDC_ID) + echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV" + echo "CBDC_CONNSTR=$CBDC_CONNSTR" >> "$GITHUB_ENV" + echo "CBDC_CONNSTR=$CBDC_CONNSTR" + cbdinocluster buckets load-sample $CBDC_ID travel-sample + - name: Update test_config.ini + env: + PYCBAC_USERNAME: 'Administrator' + PYCBAC_PASSWORD: 'password' + PYCBAC_FQDN: 'travel-sample.inventory.airline' + CBCONNSTR: ${{ env.CBDC_CONNSTR }} + run: | + ./ci_scripts/gha.sh build_test_config_ini pycbac/tests + - name: Run tests + timeout-minutes: 30 + run: | + python -m pip install --upgrade pip setuptools wheel + cd pycbac + ls -alh + cat tests/test_config.ini + python -m pip install -r requirements-test.txt + WHEEL_NAME=${{ needs.sdist-wheel.outputs.wheel_name }} + echo "WHEEL_NAME=$WHEEL_NAME" + python -m pip install ${WHEEL_NAME} + python -m pip list + TEST_ACOUCHBASE_API=${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.test_acouchbase_api }} + if [ "$TEST_ACOUCHBASE_API" = "true" ]; then + python -m pytest -m "pycbac_acouchbase and pycbac_integration" -rA -vv + fi + TEST_COUCHBASE_API=${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.test_couchbase_api }} + if [ "$TEST_COUCHBASE_API" = "true" ]; then + python -m pytest -m "pycbac_couchbase and pycbac_integration" -rA -vv + fi + - name: Cleanup cbdino cluster + run: | + cbdinocluster rm ${{ env.CBDC_ID }} diff --git a/acouchbase_analytics/tests/connect_integration_t.py b/acouchbase_analytics/tests/connect_integration_t.py index 48180a3..a9c15be 100644 --- a/acouchbase_analytics/tests/connect_integration_t.py +++ b/acouchbase_analytics/tests/connect_integration_t.py @@ -63,7 +63,8 @@ async def test_connect_timeout_query_timeout(self, test_env: AsyncTestEnvironmen connstr = test_env.config.get_connection_string(ignore_port=True) cluster = AsyncCluster.create_instance(connstr, cred) - q_opts = QueryOptions(timeout=timedelta(seconds=3)) + # increase the max retries to ensure that the timeout is hit + q_opts = QueryOptions(max_retries=20, timeout=timedelta(seconds=3)) with pytest.raises(TimeoutError) as ex: await cluster.execute_query(statement, q_opts) diff --git a/couchbase_analytics/tests/connect_integration_t.py b/couchbase_analytics/tests/connect_integration_t.py index 4b83859..76923bd 100644 --- a/couchbase_analytics/tests/connect_integration_t.py +++ b/couchbase_analytics/tests/connect_integration_t.py @@ -63,7 +63,8 @@ def test_connect_timeout_query_timeout(self, test_env: BlockingTestEnvironment) connstr = test_env.config.get_connection_string(ignore_port=True) cluster = Cluster.create_instance(connstr, cred) - q_opts = QueryOptions(timeout=timedelta(seconds=3)) + # increase the max retries to ensure that the timeout is hit + q_opts = QueryOptions(max_retries=20, timeout=timedelta(seconds=3)) with pytest.raises(TimeoutError) as ex: cluster.execute_query(statement, q_opts)