Skip to content

[MISC] Adding manual Github Action trigger #11

[MISC] Adding manual Github Action trigger

[MISC] Adding manual Github Action trigger #11

Workflow file for this run

# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
name: MongoDB Integrated Tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
workflow_call:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: setup-python
name: Setup Python
uses: actions/[email protected]
with:
python-version: "3.10"
architecture: x64
- name: Install App
shell: bash
run: pip install .
- name: Setup Kafka
id: kafka
uses: deusebio/setup-kafka-action@main
with:
zookeeper-units: 1
broker-units: 1
- name: Setup MongoDB
id: mongodb
uses: deusebio/setup-mongodb-action@main
with:
units: 1
database: test-topic
- name: Run Integrated Job
shell: bash
run: |
export BOOTSTRAP_SERVER="${{ steps.kafka.outputs.bootstrap-server }}"
export USERNAME="${{ steps.kafka.outputs.username }}"
export PASSWORD="${{ steps.kafka.outputs.password }}"
export MONGO="${{ steps.mongodb.outputs.uris }}"
python -m kafka_app.main create-topic test-topic --num-partitions 6 \
--replication-factor 1 --username $USERNAME \
--password $PASSWORD --bootstrap-server $BOOTSTRAP_SERVER
python -m kafka_app.main producer test-topic 180 --username $USERNAME \
--password $PASSWORD --bootstrap-server $BOOTSTRAP_SERVER > p1.out 2> p1.err &
python -m kafka_app.main consumer test-topic --username $USERNAME \
--password $PASSWORD --bootstrap-server $BOOTSTRAP_SERVER \
--consumer-group cg --mongo-uri "${MONGO}" > c1.out 2> c1.err &
python -m kafka_app.main consumer test-topic --username $USERNAME \
--password $PASSWORD --bootstrap-server $BOOTSTRAP_SERVER \
--consumer-group cg --mongo-uri "${MONGO}" > c2.out 2> c2.err
- name: Check Results
shell: bash
run: |
export MONGO="${{ steps.mongodb.outputs.uris }}"
python -m kafka_app.main report test-topic "${MONGO}" \
--fields origin_id,destination --output result.csv
echo "##############"
echo "## Output ##"
echo "##############"
cat result.csv
echo "##############"
# Test that all messages have been received
python -c "import pandas as pd;assert pd.read_csv('result.csv')['count'].sum()==180"