Skip to content

[DPE-3721] - chore: add cruise-control to snap #110

[DPE-3721] - chore: add cruise-control to snap

[DPE-3721] - chore: add cruise-control to snap #110

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:
name: Test Snap
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
state=$(curl http://localhost:9090/kafkacruisecontrol/state)
if [ "$state" != *"state: RUNNING"* ]; then
exit 1
fi