Skip to content

[DPE-4779] Add Kraft test #118

[DPE-4779] Add Kraft test

[DPE-4779] Add Kraft test #118

Workflow file for this run

name: Build and Test
on:
workflow_dispatch:
pull_request:
jobs:
build:
name: Build Snap
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout repository
uses: actions/checkout@v3
- id: dependencies
name: Upgrade linux deps
run: |
sudo apt update
# https://askubuntu.com/questions/1276111/error-upgrading-grub-efi-amd64-signed-special-device-old-ssd-does-not-exist
sudo apt-mark hold grub-efi-amd64-signed grub-efi-amd64-bin
sudo DEBIAN_FRONTEND=noninteractive apt upgrade --yes
- id: get-version
name: Retrieve workload version
run: |
VERSION=$(yq '(.version|split("-"))[0]' snap/snapcraft.yaml)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- id: snapcraft
name: Build snap
uses: snapcore/action-build@v1
- id: upload
name: Upload built snap job artifact
uses: actions/upload-artifact@v3
with:
name: charmed-kafka_snap_amd64
path: charmed-kafka_${{ steps.get-version.outputs.version }}_amd64.snap
outputs:
snap-file: ${{ steps.snapcraft.outputs.snap }}
version: ${{ steps.get-version.outputs.version }}
test-with-zk:
name: Test Snap with ZooKeeper
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download snap file
uses: actions/download-artifact@v3
with:
name: charmed-kafka_snap_amd64
path: .
- name: Install snap file
run: |
sudo snap install charmed-kafka_${{ needs.build.outputs.version }}_amd64.snap --dangerous
sudo snap install charmed-zookeeper --channel=3/edge
- name: Set default config
run: |
sudo cp /snap/charmed-kafka/current/opt/kafka/config/server.properties /var/snap/charmed-kafka/current/etc/kafka
sudo cp /snap/charmed-zookeeper/current/opt/zookeeper/conf/zoo_sample.cfg /var/snap/charmed-zookeeper/current/etc/zookeeper/zoo.cfg
sudo cp /snap/charmed-kafka/current/opt/cruise-control/config/cruisecontrol.properties /var/snap/charmed-kafka/current/etc/cruise-control
sudo sed -i -e 's/sample.store.topic.replication.factor=2/sample.store.topic.replication.factor=1/g' /var/snap/charmed-kafka/current/etc/cruise-control/cruisecontrol.properties
sudo sed -i -e 's|capacity.config.file=config/capacityJBOD.json|capacity.config.file=/var/snap/charmed-kafka/current/etc/cruise-control/capacityJBOD.json|g' /var/snap/charmed-kafka/current/etc/cruise-control/cruisecontrol.properties
sudo cp /snap/charmed-kafka/current/opt/cruise-control/config/capacityJBOD.json /var/snap/charmed-kafka/current/etc/cruise-control
- name: Start snap services
run: |
sudo snap start charmed-zookeeper.daemon
sleep 5
sudo snap start charmed-kafka.daemon
sleep 5
- name: Check topic creation
run: |
topic_creation=$(charmed-kafka.topics --create --topic test --bootstrap-server localhost:9092)
if [ "$topic_creation" != "Created topic test." ]; then
exit 1
fi
- name: Check CruiseControl state
run: |
sudo snap start charmed-kafka.cruise-control
sleep 20
curl -s http://localhost:9090/kafkacruisecontrol/state | grep "state: RUNNING"
test-with-kraft:
name: Test Snap with Kraft
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download snap file
uses: actions/download-artifact@v3
with:
name: charmed-kafka_snap_amd64
path: .
- name: Install snap file
run: |
sudo snap install charmed-kafka_${{ needs.build.outputs.version }}_amd64.snap --dangerous
- name: Set default kraft config
run: |
sudo cp /snap/charmed-kafka/current/opt/kafka/config/kraft/server.properties /var/snap/charmed-kafka/current/etc/kafka
sudo sed -i '/log.dirs=/c\log.dirs=/var/snap/charmed-kafka/common/var/log/kafka' /var/snap/charmed-kafka/current/etc/kafka/server.properties
uuid=$(sudo charmed-kafka.storage random-uuid)
sudo charmed-kafka.storage format --cluster-id $uuid -c /var/snap/charmed-kafka/current/etc/kafka/server.properties
- name: Start snap services
run: |
sudo snap start charmed-kafka.daemon
sleep 5
- name: Check topic creation
run: |
topic_creation=$(charmed-kafka.topics --create --topic test --bootstrap-server localhost:9092)
if [ "$topic_creation" != "Created topic test." ]; then
exit 1
fi