From a506fe9a598e04579833a8161ec89cdc86e734a9 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Mon, 30 Mar 2026 18:13:26 +0200 Subject: [PATCH 01/16] add spread test workflow --- .github/workflows/docs_spread.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/docs_spread.yaml diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml new file mode 100644 index 000000000..e626d7885 --- /dev/null +++ b/.github/workflows/docs_spread.yaml @@ -0,0 +1,16 @@ +name: Automated spread testing + +on: + workflow_dispatch: + pull_request: + # paths: + # - 'docs/tutorial/getting_started.md' + +jobs: + docs-checks: + uses: canonical/operator-workflows/.github/workflows/docs_spread.yaml@main + secrets: inherit + with: + input-file: docs/tutorial/getting_started.md + output-dir: tests/spread/tutorial + spread-job: github-ci:ubuntu-24.04-64:tests/spread/tutorial From a259298f36bf52c58552673f187303048f6e6d05 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Mon, 30 Mar 2026 18:20:03 +0200 Subject: [PATCH 02/16] update file name --- .github/workflows/docs_spread.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index e626d7885..0dbc19bc3 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -4,13 +4,13 @@ on: workflow_dispatch: pull_request: # paths: - # - 'docs/tutorial/getting_started.md' + # - 'docs/tutorial/getting-started.md' jobs: docs-checks: uses: canonical/operator-workflows/.github/workflows/docs_spread.yaml@main secrets: inherit with: - input-file: docs/tutorial/getting_started.md + input-file: docs/tutorial/getting-started.md output-dir: tests/spread/tutorial spread-job: github-ci:ubuntu-24.04-64:tests/spread/tutorial From 985a65cdae70808d93d990819fb07661baf89fc4 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Mon, 30 Mar 2026 18:23:47 +0200 Subject: [PATCH 03/16] debug --- .github/workflows/docs_spread.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index 0dbc19bc3..9d1680628 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -8,7 +8,7 @@ on: jobs: docs-checks: - uses: canonical/operator-workflows/.github/workflows/docs_spread.yaml@main + uses: canonical/operator-workflows/.github/workflows/docs_spread.yaml@update-spread-package-name secrets: inherit with: input-file: docs/tutorial/getting-started.md From 2d280f0736c20d88936ec2f4e4839647cceea363 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Mon, 30 Mar 2026 18:52:31 +0200 Subject: [PATCH 04/16] add spread.yaml --- spread.yaml | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 spread.yaml diff --git a/spread.yaml b/spread.yaml new file mode 100644 index 000000000..e9277f6e4 --- /dev/null +++ b/spread.yaml @@ -0,0 +1,72 @@ +project: haproxy-operator-tests + + +environment: + PROVIDER: lxd + JUJU_CHANNEL: 3/stable + LXD_CHANNEL: latest/stable + + JUJU_BOOTSTRAP_OPTIONS: --model-default test-mode=true --model-default automatically-retry-hooks=false --model-default + JUJU_EXTRA_BOOTSTRAP_OPTIONS: "" + JUJU_BOOTSTRAP_CONSTRAINTS: "" + + LANG: "C.UTF-8" + LANGUAGE: "en" + + PROJECT_PATH: /home/spread/proj + CRAFT_TEST_LIB_PATH: /home/spread/proj/charm/tests/spread/lib + + +backends: + github-ci: + type: adhoc + + allocate: | + echo "Allocating ad-hoc $SPREAD_SYSTEM" + if [ -z "${GITHUB_RUN_ID:-}" ]; then + FATAL "this back-end only works inside GitHub CI" + exit 1 + fi + echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' | sudo tee /etc/sudoers.d/99-spread-users + ADDRESS localhost:22 + discard: | + echo "Discarding ad-hoc $SPREAD_SYSTEM" + systems: + - ubuntu-24.04: + username: ubuntu + password: ubuntu + workers: 1 + +suites: + haproxy-operator/spread: + summary: Simple examples + systems: + - ubuntu-24.04 + prepare: | + set -e + . "$CRAFT_TEST_LIB_PATH"/test-helpers.sh + DEBIAN_FRONTEND=noninteractive apt-get update -y + DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip + + # Install LXD + snap install lxd --channel "$LXD_CHANNEL" + snap refresh lxd --channel "$LXD_CHANNEL" + lxd waitready + lxd init --auto + chmod a+wr /var/snap/lxd/common/lxd/unix.socket + lxc network set lxdbr0 ipv6.address none + usermod -a -G lxd "$USER" + + # Install juju + snap install juju --classic --channel "$JUJU_CHANNEL" + snap refresh juju --classic --channel "$JUJU_CHANNEL" + mkdir -p "$HOME"/.local/share/juju + snap install juju-crashdump --classic + + # Bootstrap juju controller + juju bootstrap --verbose "$PROVIDER" "$CONTROLLER_NAME" \ + $JUJU_BOOTSTRAP_OPTIONS $JUJU_EXTRA_BOOTSTRAP_OPTIONS \ + --bootstrap-constraints=$JUJU_BOOTSTRAP_CONSTRAINTS + +path: /home/spread/proj +kill-timeout: 1h From a45657382c35411e6d24d44d45e544352cdd23e4 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Mon, 30 Mar 2026 18:55:23 +0200 Subject: [PATCH 05/16] update spread config and wf --- .github/workflows/docs_spread.yaml | 2 +- spread.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index 9d1680628..4f6ca877a 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -13,4 +13,4 @@ jobs: with: input-file: docs/tutorial/getting-started.md output-dir: tests/spread/tutorial - spread-job: github-ci:ubuntu-24.04-64:tests/spread/tutorial + spread-job: github-ci:ubuntu-24.04:haproxy-operator/spread/ diff --git a/spread.yaml b/spread.yaml index e9277f6e4..33d2e72bf 100644 --- a/spread.yaml +++ b/spread.yaml @@ -38,7 +38,7 @@ backends: workers: 1 suites: - haproxy-operator/spread: + haproxy-operator/spread/: summary: Simple examples systems: - ubuntu-24.04 From 29e2947a546ddf98a636ad8e2a5d622a46acda5b Mon Sep 17 00:00:00 2001 From: tphan025 Date: Mon, 30 Mar 2026 18:57:57 +0200 Subject: [PATCH 06/16] update spread config and wf --- .github/workflows/docs_spread.yaml | 2 +- spread.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index 4f6ca877a..519bdbd1f 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -13,4 +13,4 @@ jobs: with: input-file: docs/tutorial/getting-started.md output-dir: tests/spread/tutorial - spread-job: github-ci:ubuntu-24.04:haproxy-operator/spread/ + spread-job: github-ci:ubuntu-24.04:tests/spread/tutorial/ diff --git a/spread.yaml b/spread.yaml index 33d2e72bf..b76803abc 100644 --- a/spread.yaml +++ b/spread.yaml @@ -38,7 +38,7 @@ backends: workers: 1 suites: - haproxy-operator/spread/: + tests/spread/tutorial/: summary: Simple examples systems: - ubuntu-24.04 From 1dfe72fc00960219a02cf5e9dc90ff6612a46506 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:05:29 +0200 Subject: [PATCH 07/16] update spread config --- .github/workflows/docs_spread.yaml | 2 +- .gitignore | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index 519bdbd1f..5cdcd36e2 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -13,4 +13,4 @@ jobs: with: input-file: docs/tutorial/getting-started.md output-dir: tests/spread/tutorial - spread-job: github-ci:ubuntu-24.04:tests/spread/tutorial/ + spread-job: github-ci:ubuntu-24.04:tests/ diff --git a/.gitignore b/.gitignore index c08ae9c7e..61c84dd36 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ terraform/**/*.tfstate* haproxy-route-policy/db.sqlite3 haproxy-route-policy/.python-version +tests/spread/tutorial/ +**/.spread-reuse* \ No newline at end of file From 47b805e786c9fa6a64adc145738954ebe8b5beb9 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:05:39 +0200 Subject: [PATCH 08/16] update spread config --- spread.yaml | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/spread.yaml b/spread.yaml index b76803abc..7e7dec96d 100644 --- a/spread.yaml +++ b/spread.yaml @@ -1,6 +1,5 @@ project: haproxy-operator-tests - environment: PROVIDER: lxd JUJU_CHANNEL: 3/stable @@ -10,13 +9,6 @@ environment: JUJU_EXTRA_BOOTSTRAP_OPTIONS: "" JUJU_BOOTSTRAP_CONSTRAINTS: "" - LANG: "C.UTF-8" - LANGUAGE: "en" - - PROJECT_PATH: /home/spread/proj - CRAFT_TEST_LIB_PATH: /home/spread/proj/charm/tests/spread/lib - - backends: github-ci: type: adhoc @@ -31,42 +23,13 @@ backends: ADDRESS localhost:22 discard: | echo "Discarding ad-hoc $SPREAD_SYSTEM" - systems: - - ubuntu-24.04: - username: ubuntu - password: ubuntu - workers: 1 + systems: [ubuntu-24.04] suites: - tests/spread/tutorial/: + tests/spread/: summary: Simple examples systems: - ubuntu-24.04 - prepare: | - set -e - . "$CRAFT_TEST_LIB_PATH"/test-helpers.sh - DEBIAN_FRONTEND=noninteractive apt-get update -y - DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip - - # Install LXD - snap install lxd --channel "$LXD_CHANNEL" - snap refresh lxd --channel "$LXD_CHANNEL" - lxd waitready - lxd init --auto - chmod a+wr /var/snap/lxd/common/lxd/unix.socket - lxc network set lxdbr0 ipv6.address none - usermod -a -G lxd "$USER" - - # Install juju - snap install juju --classic --channel "$JUJU_CHANNEL" - snap refresh juju --classic --channel "$JUJU_CHANNEL" - mkdir -p "$HOME"/.local/share/juju - snap install juju-crashdump --classic - - # Bootstrap juju controller - juju bootstrap --verbose "$PROVIDER" "$CONTROLLER_NAME" \ - $JUJU_BOOTSTRAP_OPTIONS $JUJU_EXTRA_BOOTSTRAP_OPTIONS \ - --bootstrap-constraints=$JUJU_BOOTSTRAP_CONSTRAINTS path: /home/spread/proj kill-timeout: 1h From cb98e0ff6985496712bdbd9e8271e25c505170c3 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:20:55 +0200 Subject: [PATCH 09/16] update spread config --- spread.yaml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spread.yaml b/spread.yaml index 7e7dec96d..71919695f 100644 --- a/spread.yaml +++ b/spread.yaml @@ -1,14 +1,5 @@ project: haproxy-operator-tests -environment: - PROVIDER: lxd - JUJU_CHANNEL: 3/stable - LXD_CHANNEL: latest/stable - - JUJU_BOOTSTRAP_OPTIONS: --model-default test-mode=true --model-default automatically-retry-hooks=false --model-default - JUJU_EXTRA_BOOTSTRAP_OPTIONS: "" - JUJU_BOOTSTRAP_CONSTRAINTS: "" - backends: github-ci: type: adhoc @@ -23,7 +14,11 @@ backends: ADDRESS localhost:22 discard: | echo "Discarding ad-hoc $SPREAD_SYSTEM" - systems: [ubuntu-24.04] + systems: + - ubuntu-24.04: + username: ubuntu + password: ubuntu + workers: 1 suites: tests/spread/: From 56dc7d911837a1e7ad7dc5e07abdac368b53bb4a Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:44:23 +0200 Subject: [PATCH 10/16] adapt tutorial for spread --- docs/tutorial/getting-started.md | 17 +++++++++++++++++ spread.yaml | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/tutorial/getting-started.md b/docs/tutorial/getting-started.md index 7cdeb1f64..c9177b863 100644 --- a/docs/tutorial/getting-started.md +++ b/docs/tutorial/getting-started.md @@ -70,6 +70,15 @@ juju integrate haproxy:certificates self-signed-certificates Once all the application has settled into an "Idle" state, we can verify by sending a request to the HAProxy's IP address: ```sh +END_TIME=$((SECONDS + 600)) +UNIT_STATUS="" +while [ "$UNIT_STATUS" != "idle" ] && [ "$SECONDS" -lt "$END_TIME" ]; do + sleep 5 + UNIT_STATUS=$(juju status --format json | jq -r '.applications.haproxy.units."haproxy/0"."juju-status".current') + echo "Waiting for haproxy unit: $UNIT_STATUS" +done + + HAPROXY_IP=$(juju status --format json | jq -r '.applications.haproxy.units."haproxy/0"."public-address"') curl $HAPROXY_IP ``` @@ -101,6 +110,14 @@ juju integrate pollen haproxy:haproxy-route Let's check that the request has been properly proxied to the backend service using the `pollinate` script: ```sh +END_TIME=$((SECONDS + 600)) +APP_STATUS="" +while [ "$APP_STATUS" != "active" ] && [ "$SECONDS" -lt "$END_TIME" ]; do + sleep 5 + APP_STATUS=$(juju status --format json | jq -r '.applications.haproxy."application-status".current') + echo "Waiting for haproxy: $APP_STATUS" +done + HAPROXY_IP=$(juju status --format json | jq -r '.applications.haproxy.units."haproxy/0"."public-address"') echo "$HAPROXY_IP pollen.internal" | sudo tee /etc/hosts sudo pollinate -s https://pollen.internal -r -i diff --git a/spread.yaml b/spread.yaml index 71919695f..cd35e561e 100644 --- a/spread.yaml +++ b/spread.yaml @@ -15,6 +15,8 @@ backends: discard: | echo "Discarding ad-hoc $SPREAD_SYSTEM" systems: + # username and password are required because docs-spread.yaml creates a new user (ubuntu:ubuntu) + # Before tests are ran. - ubuntu-24.04: username: ubuntu password: ubuntu @@ -22,7 +24,7 @@ backends: suites: tests/spread/: - summary: Simple examples + summary: Automated spread testing systems: - ubuntu-24.04 From 23db41b27266083075d2e189d0c4be1e268397de Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:45:40 +0200 Subject: [PATCH 11/16] update gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 61c84dd36..6326091fe 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,4 @@ haproxy-route-policy/db.sqlite3 haproxy-route-policy/.python-version tests/spread/tutorial/ -**/.spread-reuse* \ No newline at end of file +**/.spread-reuse* From 981f1183346f645e42239b96dc23add1ae15f459 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:53:27 +0200 Subject: [PATCH 12/16] adapt docs for spread tests --- docs/tutorial/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/getting-started.md b/docs/tutorial/getting-started.md index c9177b863..5910cc6b3 100644 --- a/docs/tutorial/getting-started.md +++ b/docs/tutorial/getting-started.md @@ -142,7 +142,7 @@ Well done! You've successfully completed the HAProxy tutorial. To remove the model environment you created, use the following command: ``` -juju destroy-model haproxy-tutorial +juju destroy-model haproxy-tutorial --no-prompt ``` ## Next steps From 36641931d77a42cf02bfc1df3acdd0acf63165c4 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 00:56:06 +0200 Subject: [PATCH 13/16] add scheduled run for spread --- .github/workflows/docs_spread.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index 5cdcd36e2..1ae6f1dbe 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -3,8 +3,10 @@ name: Automated spread testing on: workflow_dispatch: pull_request: - # paths: - # - 'docs/tutorial/getting-started.md' + paths: + - 'docs/tutorial/getting-started.md' + schedule: + - cron: 0 9 * * 1 # At 09:00 UTC on Monday, aligned with the weekly haproxy stable release. jobs: docs-checks: From 2b8011706a677111294a08b4cd49d39c74adb4d2 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 13:30:41 +0200 Subject: [PATCH 14/16] add license header --- spread.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spread.yaml b/spread.yaml index cd35e561e..b15cc34e8 100644 --- a/spread.yaml +++ b/spread.yaml @@ -1,3 +1,6 @@ +# Copyright 2026 Canonical Ltd. +# See LICENSE file for licensing details. + project: haproxy-operator-tests backends: From 108fa21500eb492c49fa104f8857d7cc501f85d5 Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 20:36:37 +0200 Subject: [PATCH 15/16] update docs to adapt to spread tests --- docs/tutorial/getting-started.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/docs/tutorial/getting-started.md b/docs/tutorial/getting-started.md index 5910cc6b3..9bdd156fa 100644 --- a/docs/tutorial/getting-started.md +++ b/docs/tutorial/getting-started.md @@ -9,6 +9,8 @@ In this tutorial we'll deploy the HAProxy charm to provide ingress to a backend You will need a working station, e.g., a laptop, with AMD64 architecture. Your working station should have at least 4 CPU cores, 8 GB of RAM, and 50 GB of disk space. + + ````{tip} You can use Multipass to create an isolated environment by running: ``` @@ -16,6 +18,8 @@ multipass launch 24.04 --name charm-tutorial-vm --cpus 4 --memory 8G --disk 50G ``` ```` + + This tutorial requires the following software to be installed on your working station (either locally or in the Multipass VM): @@ -69,16 +73,11 @@ juju integrate haproxy:certificates self-signed-certificates Once all the application has settled into an "Idle" state, we can verify by sending a request to the HAProxy's IP address: -```sh -END_TIME=$((SECONDS + 600)) -UNIT_STATUS="" -while [ "$UNIT_STATUS" != "idle" ] && [ "$SECONDS" -lt "$END_TIME" ]; do - sleep 5 - UNIT_STATUS=$(juju status --format json | jq -r '.applications.haproxy.units."haproxy/0"."juju-status".current') - echo "Waiting for haproxy unit: $UNIT_STATUS" -done - + +```sh HAPROXY_IP=$(juju status --format json | jq -r '.applications.haproxy.units."haproxy/0"."public-address"') curl $HAPROXY_IP ``` @@ -109,15 +108,11 @@ juju integrate pollen haproxy:haproxy-route Let's check that the request has been properly proxied to the backend service using the `pollinate` script: -```sh -END_TIME=$((SECONDS + 600)) -APP_STATUS="" -while [ "$APP_STATUS" != "active" ] && [ "$SECONDS" -lt "$END_TIME" ]; do - sleep 5 - APP_STATUS=$(juju status --format json | jq -r '.applications.haproxy."application-status".current') - echo "Waiting for haproxy: $APP_STATUS" -done + +```sh HAPROXY_IP=$(juju status --format json | jq -r '.applications.haproxy.units."haproxy/0"."public-address"') echo "$HAPROXY_IP pollen.internal" | sudo tee /etc/hosts sudo pollinate -s https://pollen.internal -r -i From 27860f8cf51d8f89f19bd142c9f8fc54cf1c439b Mon Sep 17 00:00:00 2001 From: tphan025 Date: Tue, 31 Mar 2026 20:38:36 +0200 Subject: [PATCH 16/16] update upstream wf target --- .github/workflows/docs_spread.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs_spread.yaml b/.github/workflows/docs_spread.yaml index 1ae6f1dbe..323130614 100644 --- a/.github/workflows/docs_spread.yaml +++ b/.github/workflows/docs_spread.yaml @@ -10,7 +10,7 @@ on: jobs: docs-checks: - uses: canonical/operator-workflows/.github/workflows/docs_spread.yaml@update-spread-package-name + uses: canonical/operator-workflows/.github/workflows/docs_spread.yaml@main secrets: inherit with: input-file: docs/tutorial/getting-started.md