Skip to content

Appinsights implementation #878

Appinsights implementation

Appinsights implementation #878

name: TEST - Integration with python
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
inputs:
image_tag:
description: 'Optional: Use existing image tag instead of building locally'
required: false
type: string
workflow_call:
inputs:
image_tag:
description: 'Optional: Use existing image tag instead of building locally'
required: false
type: string
permissions:
packages: write
contents: read
id-token: write
env:
# Cluster configuration
CERT_MANAGER_NS: cert-manager
OPERATOR_NS: documentdb-operator
DB_NS: documentdb-preview-ns
DB_NAME: documentdb-preview
# Connection parameters
DB_USERNAME: default_user
DB_PASSWORD: Admin100
DB_PORT: 10260
jobs:
# Use the reusable build workflow - only if no image tag is provided or on pull_request
build:
name: Build Images and Charts
if: ${{ (github.event.inputs.image_tag == '' || github.event.inputs.image_tag == null) || github.event_name == 'pull_request' }}
uses: ./.github/workflows/test-build-and-package.yml
with:
version: '0.2.0'
secrets: inherit
integration-test:
name: Run Integration Tests
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
needs: build
if: always() && (needs.build.result == 'success' || needs.build.result == 'skipped')
strategy:
matrix:
include:
- architecture: amd64
runner: ubuntu-22.04
test_scenario_name: "single-node"
node_count: 1
instances_per_node: 1
- architecture: arm64
runner: ubuntu-22.04-arm
test_scenario_name: "single-node"
node_count: 1
instances_per_node: 1
env:
# Use built image tag on PR or when no external tag provided
IMAGE_TAG: ${{ (github.event_name == 'pull_request' || github.event.inputs.image_tag == '' || github.event.inputs.image_tag == null) && needs.build.outputs.image_tag || github.event.inputs.image_tag }}
EXT_IMAGE_TAG: ${{ needs.build.outputs.ext_image_tag || '' }}
CHART_VERSION: ${{ needs.build.outputs.chart_version || '0.1.0' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
if: ${{ (github.event.inputs.image_tag == '' || github.event.inputs.image_tag == null) || github.event_name == 'pull_request' }}
uses: actions/download-artifact@v4
with:
pattern: 'build-*'
path: ./artifacts
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Log test configuration
run: |
echo "## Integration Test Configuration" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ -n "${{ github.event.inputs.image_tag }}" ]]; then
echo "- **Mode**: Using provided image tag" >> $GITHUB_STEP_SUMMARY
echo "- **Image Tag**: \`${{ github.event.inputs.image_tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Source**: External (no local build)" >> $GITHUB_STEP_SUMMARY
else
echo "- **Mode**: Using locally built images" >> $GITHUB_STEP_SUMMARY
echo "- **Image Tag**: \`${{ env.IMAGE_TAG }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Source**: Local build pipeline" >> $GITHUB_STEP_SUMMARY
fi
echo "- **Architecture**: \`${{ matrix.architecture }}\`" >> $GITHUB_STEP_SUMMARY
- name: Setup test environment
uses: ./.github/actions/setup-test-environment
with:
test-type: 'integration'
architecture: ${{ matrix.architecture }}
runner: ${{ matrix.runner }}
test-scenario-name: ${{ matrix.test_scenario_name }}
node-count: '${{ matrix.node_count }}'
instances-per-node: '${{ matrix.instances_per_node }}'
cert-manager-namespace: ${{ env.CERT_MANAGER_NS }}
operator-namespace: ${{ env.OPERATOR_NS }}
db-namespace: ${{ env.DB_NS }}
db-cluster-name: ${{ env.DB_NAME }}
db-username: ${{ env.DB_USERNAME }}
db-password: ${{ env.DB_PASSWORD }}
db-port: ${{ env.DB_PORT }}
image-tag: ${{ env.IMAGE_TAG }}
documentdb-image-tag: ${{ env.EXT_IMAGE_TAG }}
chart-version: ${{ env.CHART_VERSION }}
use-external-images: ${{ github.event_name != 'pull_request' && github.event.inputs.image_tag != '' && github.event.inputs.image_tag != null }}
github-token: ${{ secrets.GITHUB_TOKEN }}
repository-owner: ${{ github.repository_owner }}
- name: Test connection with mongosh
run: |
echo "Testing connection with mongosh on ${{ matrix.architecture }} architecture..."
chmod +x operator/src/scripts/test-scripts/test-mongodb-connection.sh
./operator/src/scripts/test-scripts/test-mongodb-connection.sh \
--architecture "${{ matrix.architecture }}" \
--namespace "${{ env.DB_NS }}" \
--cluster-name "${{ env.DB_NAME }}" \
--pod-name "${{ env.DB_NAME }}-1" \
--port "${{ env.DB_PORT }}" \
--username "${{ env.DB_USERNAME }}" \
--password "${{ env.DB_PASSWORD }}" \
--test-type 'basic'
- name: Test with Python PyMongo client
run: |
echo "Testing with Python PyMongo client on ${{ matrix.architecture }} architecture..."
chmod +x operator/src/scripts/test-scripts/test-python-pymongo.sh
./operator/src/scripts/test-scripts/test-python-pymongo.sh \
--architecture "${{ matrix.architecture }}" \
--namespace "${{ env.DB_NS }}" \
--cluster-name "${{ env.DB_NAME }}" \
--pod-name "${{ env.DB_NAME }}-1" \
--port "${{ env.DB_PORT }}" \
--username "${{ env.DB_USERNAME }}" \
--password "${{ env.DB_PASSWORD }}"
- name: Collect logs on failure
if: failure()
uses: ./.github/actions/collect-logs
with:
architecture: ${{ matrix.architecture }}
operator-namespace: ${{ env.OPERATOR_NS }}
db-namespace: ${{ env.DB_NS }}
db-cluster-name: ${{ env.DB_NAME }}
cert-manager-namespace: ${{ env.CERT_MANAGER_NS }}