Skip to content

Commit 12894be

Browse files
committed
PYCO-65: Add cbdino job for integration tests (#1)
1 parent 7d6384e commit 12894be

3 files changed

Lines changed: 100 additions & 4 deletions

File tree

.github/workflows/tests.yml

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ jobs:
227227
cat pycbac_test/requirements-test.txt
228228
echo "pycbac_test/pytest.ini contents:"
229229
cat pycbac_test/pytest.ini
230-
echo "pycbac_test/test_config.ini contents:"
231-
cat pycbac_test/test_config.ini
230+
echo "pycbac_test/tests/test_config.ini contents:"
231+
cat pycbac_test/tests/test_config.ini
232232
- name: Upload test setup
233233
uses: actions/upload-artifact@v4
234234
with:
@@ -562,3 +562,97 @@ jobs:
562562
if ( $TEST_COUCHBASE_API = "true" ) {
563563
python -m pytest -m "pycbac_couchbase and pycbac_unit" -rA -vv
564564
}
565+
566+
cbdino-integration-tests:
567+
needs: [setup, test-setup, sdist-wheel]
568+
if: >-
569+
${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.has_linux_cbdino
570+
&& !fromJson(needs.setup.outputs.stage_matrices).test_integration.skip_cbdino }}
571+
name: Run integration tests w/ cbdino; Python ${{ matrix.python-version }} - ${{ matrix.os }} (${{ matrix.arch }})
572+
runs-on: ${{ matrix.os }}
573+
strategy:
574+
fail-fast: false
575+
matrix: ${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.linux_cbdino }}
576+
steps:
577+
- name: Install cbdinocluster
578+
run: |
579+
mkdir -p "$HOME/bin"
580+
CB_DINO_VERSION=${{ env.CBCI_CBDINO_VERSION }}
581+
CB_DINO_TYPE="cbdinocluster-${{ matrix.arch == 'x86_64' && 'linux-amd64' || 'linux-arm64' }}"
582+
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/$CB_DINO_VERSION/$CB_DINO_TYPE
583+
chmod +x $HOME/bin/cbdinocluster
584+
echo "$HOME/bin" >> $GITHUB_PATH
585+
- name: Install s3mock
586+
run: |
587+
docker pull adobe/s3mock
588+
docker pull nginx
589+
- name: Initialize cbdinocluster
590+
env:
591+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
592+
run: |
593+
cbdinocluster -v init --auto
594+
- name: Setup Python
595+
uses: actions/setup-python@v5
596+
with:
597+
python-version: ${{ matrix.python-version }}
598+
- name: Confirm Python version
599+
run: python -c "import sys; print(sys.version)"
600+
- name: Download CI scripts
601+
uses: actions/download-artifact@v4
602+
with:
603+
name: ci_scripts
604+
path: ci_scripts
605+
- name: Enable CI Scripts
606+
run: |
607+
chmod +x ci_scripts/gha.sh
608+
- name: Download wheel
609+
uses: actions/download-artifact@v4
610+
with:
611+
name: pycbac-artifact-wheel
612+
path: pycbac
613+
- name: Download test setup
614+
uses: actions/download-artifact@v4
615+
with:
616+
name: pycbac-test-setup
617+
path: pycbac
618+
- name: Start couchbase cluster
619+
run: |
620+
cd pycbac
621+
cat cluster_def.yaml
622+
CBDC_ID=$(cbdinocluster -v alloc --def-file=cluster_def.yaml)
623+
CBDC_CONNSTR=$(cbdinocluster -v connstr --analytics $CBDC_ID)
624+
echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV"
625+
echo "CBDC_CONNSTR=$CBDC_CONNSTR" >> "$GITHUB_ENV"
626+
echo "CBDC_CONNSTR=$CBDC_CONNSTR"
627+
cbdinocluster buckets load-sample $CBDC_ID travel-sample
628+
- name: Update test_config.ini
629+
env:
630+
PYCBAC_USERNAME: 'Administrator'
631+
PYCBAC_PASSWORD: 'password'
632+
PYCBAC_FQDN: 'travel-sample.inventory.airline'
633+
CBCONNSTR: ${{ env.CBDC_CONNSTR }}
634+
run: |
635+
./ci_scripts/gha.sh build_test_config_ini pycbac/tests
636+
- name: Run tests
637+
timeout-minutes: 30
638+
run: |
639+
python -m pip install --upgrade pip setuptools wheel
640+
cd pycbac
641+
ls -alh
642+
cat tests/test_config.ini
643+
python -m pip install -r requirements-test.txt
644+
WHEEL_NAME=${{ needs.sdist-wheel.outputs.wheel_name }}
645+
echo "WHEEL_NAME=$WHEEL_NAME"
646+
python -m pip install ${WHEEL_NAME}
647+
python -m pip list
648+
TEST_ACOUCHBASE_API=${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.test_acouchbase_api }}
649+
if [ "$TEST_ACOUCHBASE_API" = "true" ]; then
650+
python -m pytest -m "pycbac_acouchbase and pycbac_integration" -rA -vv
651+
fi
652+
TEST_COUCHBASE_API=${{ fromJson(needs.setup.outputs.stage_matrices).test_integration.test_couchbase_api }}
653+
if [ "$TEST_COUCHBASE_API" = "true" ]; then
654+
python -m pytest -m "pycbac_couchbase and pycbac_integration" -rA -vv
655+
fi
656+
- name: Cleanup cbdino cluster
657+
run: |
658+
cbdinocluster rm ${{ env.CBDC_ID }}

acouchbase_analytics/tests/connect_integration_t.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ async def test_connect_timeout_query_timeout(self, test_env: AsyncTestEnvironmen
6363
connstr = test_env.config.get_connection_string(ignore_port=True)
6464
cluster = AsyncCluster.create_instance(connstr, cred)
6565

66-
q_opts = QueryOptions(timeout=timedelta(seconds=3))
66+
# increase the max retries to ensure that the timeout is hit
67+
q_opts = QueryOptions(max_retries=20, timeout=timedelta(seconds=3))
6768
with pytest.raises(TimeoutError) as ex:
6869
await cluster.execute_query(statement, q_opts)
6970

couchbase_analytics/tests/connect_integration_t.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def test_connect_timeout_query_timeout(self, test_env: BlockingTestEnvironment)
6363
connstr = test_env.config.get_connection_string(ignore_port=True)
6464
cluster = Cluster.create_instance(connstr, cred)
6565

66-
q_opts = QueryOptions(timeout=timedelta(seconds=3))
66+
# increase the max retries to ensure that the timeout is hit
67+
q_opts = QueryOptions(max_retries=20, timeout=timedelta(seconds=3))
6768
with pytest.raises(TimeoutError) as ex:
6869
cluster.execute_query(statement, q_opts)
6970

0 commit comments

Comments
 (0)