diff --git a/.github/workflows/ISSUE_TEMPLATE/bug_report.md b/.github/workflows/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..6ecc03d --- /dev/null +++ b/.github/workflows/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: File a bug report +labels: bug + +--- + + + +## Steps to reproduce +1. + +## Expected behavior + + +## Actual behavior + + + +## Versions + + +Operating system: + +## Log output + + + +## Additional context + \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..65da291 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,67 @@ +name: Build + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_call: + pull_request: + workflow_dispatch: + +jobs: + build: + name: Build Rock + runs-on: ubuntu-latest + timeout-minutes: 30 + outputs: + rock-file: ${{ steps.build-snap.outputs.rock }} + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup LXD + uses: canonical/setup-lxd@main + + - name: Install required dependencies + run: | + # docker + sudo snap install docker + sudo addgroup --system docker; sudo adduser $USER docker + newgrp docker + sudo snap disable docker; sudo snap enable docker + + # skopeo + sudo snap install --devmode --channel edge skopeo + + # rockcraft + sudo snap install rockcraft --classic --edge + + # jq and yq + sudo snap install jq yq + + - name: Upgrade linux deps with security updates + run: | + sudo apt-get update + + # install security updates + sudo apt-get -s dist-upgrade \ + | grep "^Inst" \ + | grep -i securi \ + | awk -F " " {'print $2'} \ + | xargs sudo apt-get install -y + + sudo apt-get autoremove -y + + - name: Build rock + run: | + rockcraft pack --verbose + + - name: Upload built rock job artifact + uses: actions/upload-artifact@v3 + with: + name: mongodb_benchmarking_oci_rock_amd64 + path: "mongodb-benchmarking-oci*.rock" + diff --git a/.github/workflows/on_push.yaml b/.github/workflows/on_push.yaml new file mode 100644 index 0000000..fa70c48 --- /dev/null +++ b/.github/workflows/on_push.yaml @@ -0,0 +1,10 @@ +name: Build +on: + push: + branches: + - feature/** + +jobs: + build-run-tests: + name: Build and Run Tests + uses: ./.github/workflows/ci.yaml \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4ae5c39 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,77 @@ +name: Publish to GHCR + +env: + RELEASE: edge + +on: + push: + branches: + - main + +jobs: + ci-tests: + name: Build + uses: ./.github/workflows/ci.yaml + + publish: + name: publish + runs-on: ubuntu-latest + timeout-minutes: 15 + needs: + - ci-tests + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Install required dependencies + run: | + # docker + sudo snap install docker + sudo addgroup --system docker; sudo adduser $USER docker + newgrp docker + sudo snap disable docker; sudo snap enable docker + + # skopeo + sudo snap install --devmode --channel edge skopeo + + # yq + sudo snap install yq + + - name: Download rock file + uses: actions/download-artifact@v3 + with: + name: mongodb_benchmarking_oci_rock_amd64 + path: . + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Publish rock to Store + run: | + version="$(cat rockcraft.yaml | yq .version)" + + base="$(cat rockcraft.yaml | yq .base)" + base="${base#*:}" + + # push major version to edge + major_tag_version="${version%%.*}-${{ env.RELEASE }}" + sudo skopeo \ + --insecure-policy \ + copy \ + oci-archive:mongodb-benchmarking_${version}_amd64.rock \ + docker-daemon:ghcr.io/canonical/mongodb-benchmarking:${major_tag_version} + docker push ghcr.io/canonical/mongodb-benchmarking:${major_tag_version} + + ### push full version to edge + tag_version="${version}-${base}_${{ env.RELEASE }}" + echo "Publishing mongodb-benchmarking:${tag_version}" + sudo skopeo \ + --insecure-policy \ + copy \ + oci-archive:mongodb-benchmarking_${version}_amd64.rock \ + docker-daemon:ghcr.io/canonical/mongodb-benchmarking:${tag_version} + docker push ghcr.io/canonical/mongodb-benchmarking:${tag_version} \ No newline at end of file diff --git a/.github/workflows/sync_issues_to_jira.yaml b/.github/workflows/sync_issues_to_jira.yaml new file mode 100644 index 0000000..d4fc37b --- /dev/null +++ b/.github/workflows/sync_issues_to_jira.yaml @@ -0,0 +1,21 @@ +# Copyright 2023 Canonical Ltd. +# See LICENSE file for licensing details. +name: Sync issue to Jira + +on: + issues: + types: [opened, reopened, closed] + +jobs: + sync: + name: Sync GitHub issue to Jira + uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v2 + with: + jira-base-url: https://warthogs.atlassian.net + jira-project-key: DPE + jira-component-names: opensearch-k8s,rock + secrets: + jira-api-token: ${{ secrets.JIRA_API_TOKEN }} + jira-user-email: ${{ secrets.JIRA_USER_EMAIL }} + permissions: + issues: write # Needed to create GitHub issue comment \ No newline at end of file diff --git a/README.md b/README.md index 0502220..c804b62 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # mongodb-benchmarking-oci Contains OCI image for perf testing of Charmed MongoDB K8s + + +# Usage + +TBD \ No newline at end of file diff --git a/mongodb-benchmarking.yaml b/mongodb-benchmarking.yaml new file mode 100644 index 0000000..7b06e77 --- /dev/null +++ b/mongodb-benchmarking.yaml @@ -0,0 +1,23 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongodb-benchmarking + namespace: perf-test + labels: + app: mongodb-benchmarking +spec: + selector: + matchLabels: + app: mongodb-benchmarking + template: + metadata: + labels: + app: mongodb-benchmarking + spec: + containers: + - name: mongodb-benchmarking + image: mongodb-benchmarking:1.0 + diff --git a/rockcraft.yaml b/rockcraft.yaml new file mode 100644 index 0000000..930c286 --- /dev/null +++ b/rockcraft.yaml @@ -0,0 +1,46 @@ +# Copyright 2024 Canonical Ltd. +# See LICENSE file for licensing details. +name: mongodb-benchmarking-oci # the name of your ROCK +base: ubuntu@22.04 # the base environment for this ROCK +license: Apache-2.0 + +version: '1.0.0' # just for humans. Semantic versioning is recommended + +summary: 'Performacnce testing for Charmed MongoDB' +description: | + This ROCK contains tools for performace\load testing of + Charmed MongoDB. The image contains YCSB and NoSQLBench tools. + +platforms: # The platforms this ROCK should be built on and run on + amd64: + +parts: + entry: + plugin: dump + source: scripts + organize: + ycsb_load_data.sh: bin/ycsb_load_data.sh + ycsb_run_operations.sh: bin/ycsb_run_operations.sh + + stage: + - bin/ycsb_load_data.sh + - bin/ycsb_run_operations.sh + + setup_ycsb: + plugin: nil + after: [entry] + stage-packages: + - openjdk-21-jdk + - maven + - python2 + override-prime: | + craftctl default + mkdir -p $CRAFT_PRIME/var/load-testing/ + + chown -R 584788:584788 $CRAFT_PRIME/var/load-testing/ + + cd $CRAFT_PRIME/var/load-testing + curl -O --location https://github.com/brianfrankcooper/YCSB/releases/download/0.17.0/ycsb-0.17.0.tar.gz + tar xfvz ycsb-0.17.0.tar.gz + chmod +x $CRAFT_PRIME/bin/ycsb_load_data.sh + chmod +x $CRAFT_PRIME/bin/ycsb_run_operations.sh diff --git a/scripts/ycsb_load_data.sh b/scripts/ycsb_load_data.sh new file mode 100644 index 0000000..85707eb --- /dev/null +++ b/scripts/ycsb_load_data.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# preparation steps +ln -sf /usr/bin/python2.7 /usr/bin/python +export PATH="/usr/lib/jvm/java-21-openjdk-amd64/bin/:/usr/share/maven/bin/:$PATH" + +# Default values +RECORD_COUNT_DEFAULT=500000 +LOAD_THREADS_COUNT_DEFAULT=16 +MONGODB_URI_DEFAULT="mongodb://localhost:21017/admin?replicaSet=mongodb" +WORKLOAD_DEFAULT="workloada" + +# Read parameters or use defaults +WORKLOAD=${1:-$WORKLOAD_DEFAULT} +RECORD_COUNT=${2:-$RECORD_COUNT_DEFAULT} +LOAD_THREADS_COUNT=${3:-$LOAD_THREADS_COUNT_DEFAULT} +MONGODB_URI=${4:-$MONGODB_URI_DEFAULT} + +/var/load-testing/ycsb-0.17.0/bin/ycsb \ + load mongodb -s \ + -P "/var/load-testing/ycsb-0.17.0/workloads/$WORKLOAD" \ + -p recordcount=$RECORD_COUNT \ + -threads $LOAD_THREADS_COUNT \ + -p mongodb.url="$MONGODB_URI" + \ No newline at end of file diff --git a/scripts/ycsb_run_operations.sh b/scripts/ycsb_run_operations.sh new file mode 100644 index 0000000..f34d807 --- /dev/null +++ b/scripts/ycsb_run_operations.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# preparation steps +ln -sf /usr/bin/python2.7 /usr/bin/python +export PATH="/usr/lib/jvm/java-21-openjdk-amd64/bin/:/usr/share/maven/bin/:$PATH" + +# Default values +OPERATIONS_COUNT=1000000 +OPERATIONS_THREADS_COUNT=2 +MONGODB_URI_DEFAULT="mongodb://localhost:21017/admin?replicaSet=mongodb" +WORKLOAD_DEFAULT="workloada" + +# Read parameters or use defaults +WORKLOAD=${1:-$WORKLOAD_DEFAULT} +RECORD_COUNT=${2:-$RECORD_COUNT_DEFAULT} +LOAD_THREADS_COUNT=${3:-$LOAD_THREADS_COUNT_DEFAULT} +MONGODB_URI=${4:-$MONGODB_URI_DEFAULT} + + + +/var/load-testing/ycsb-0.17.0/bin/ycsb \ + run mongodb -s \ + -P "/var/load-testing/ycsb-0.17.0/workloads/$WORKLOAD" \ + -p operationcount=$OPERATIONS_COUNT -threads $OPERATIONS_THREADS_COUNT \ + -p mongodb.url="$MONGODB_URI" + \ No newline at end of file