Skip to content

Commit

Permalink
test(spread): test-deploy charms in large spread tests (#1324)
Browse files Browse the repository at this point in the history
This also deploys the charms/bundles for the large spread cluster
https://github.com/canonical/charmcraft/actions/runs/6695906302

---------

Co-authored-by: Callahan <[email protected]>
  • Loading branch information
lengau and mr-cal authored Nov 2, 2023
1 parent 9053bae commit a14d6d9
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 26 deletions.
65 changes: 47 additions & 18 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ backends:
multipass exec "$instance_name" -- \
sudo systemctl restart ssh
multipass exec "$instance_name" -- sudo snap refresh --channel=latest/stable lxd
multipass exec "$instance_name" -- sudo lxd init --auto
# Get the IP from the instance
ip=$(multipass info --format csv "$instance_name" | tail -1 | cut -d\, -f3)
ADDRESS "$ip"
Expand All @@ -75,7 +72,6 @@ backends:
workers: 1
- ubuntu-22.04-64:
workers: 4

prepare: |
set -e
Expand Down Expand Up @@ -127,29 +123,63 @@ suites:
summary: simple charmcraft commands
tests/spread/charms/:
summary: real charm building tests
prepare: |
snap install juju --channel=3.2/stable
snap install microk8s --channel=1.28-strict/stable
# Set up Juju controllers for the charms
lxc network set lxdbr0 ipv6.address none
mkdir -p ~/.local/share # Workaround for Juju not being able to create the directory
microk8s enable hostpath-storage
microk8s enable dns
snap alias microk8s.kubectl kubectl
if ! juju controllers | grep -q k8s; then
juju bootstrap microk8s k8s
fi
if ! juju controllers | grep -q lxd; then
juju bootstrap localhost lxd
fi
prepare-each: |
if [[ -v JUJU_MODEL ]] && ! juju add-model "${JUJU_MODEL}"; then
juju destroy-model --force --no-prompt --destroy-storage "${JUJU_MODEL}" || true
juju add-model "${JUJU_MODEL}"
fi
restore-each: |
if [[ -v JUJU_MODEL ]]; then
juju destroy-model --no-prompt --force --destroy-storage $JUJU_MODEL
fi
rm -f ~/*.charm
tests/spread/dependencies/:
summary: test charm dependencies
systems:
- ubuntu-22.04-64
prepare: |
snap install lxd || true
snap install juju || true
lxd init --auto
snap install juju --channel=3.2/stable
snap install microk8s --channel=1.28-strict/stable
# Set up Juju controllers for the charms
lxc network set lxdbr0 ipv6.address none
mkdir -p ~/.local/share
# This should better detect the controller
juju bootstrap localhost test-controller || true
mkdir -p ~/.local/share # Workaround for Juju not being able to create the directory
microk8s enable hostpath-storage
microk8s enable dns
snap alias microk8s.kubectl kubectl
if ! juju controllers | grep -q k8s; then
juju bootstrap microk8s k8s
fi
if ! juju controllers | grep -q lxd; then
juju bootstrap localhost lxd
fi
prepare-each: |
if ! juju add-model test-model; then
juju destroy-model --force --no-prompt --destroy-storage test-model
juju add-model test-model
if [[ -v JUJU_MODEL ]] && ! juju add-model "${JUJU_MODEL}"; then
juju destroy-model --force --no-prompt --destroy-storage "${JUJU_MODEL}" || true
juju add-model "${JUJU_MODEL}"
fi
restore-each: |
rm -rf charm
juju destroy-model --force --no-prompt --destroy-storage --no-wait test-model
if [[ -v JUJU_MODEL ]]; then
juju destroy-model --no-prompt --force --no-wait --timeout 15s --destroy-storage $JUJU_MODEL
fi
rm -f ~/*.charm
rm -rf charm
tests/spread/smoketests/:
summary: basic charm builds in different combinations
systems:
Expand Down Expand Up @@ -208,4 +238,3 @@ suites:
# in staging Charmhub authenticating with the configured credentials
CHARM_DEFAULT_NAME: "$(HOST: echo ${CHARM_DEFAULT_NAME:-$USER-test-charm})"
BUNDLE_DEFAULT_NAME: "$(HOST: echo ${BUNDLE_DEFAULT_NAME:-$USER-test-bundle})"

11 changes: 7 additions & 4 deletions tests/spread/charms/bundle/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ systems:
- ubuntu-22.04-64
# Run these earlier since they can take a very long time
priority: 100
kill-timeout: 60m
kill-timeout: 90m

environment:
BUNDLE/argo: https://github.com/canonical/argo-operators
Expand All @@ -13,6 +13,8 @@ environment:
BUNDLE/kfp: https://github.com/canonical/kfp-operators
BUNDLE/kubeflow: https://github.com/canonical/bundle-kubeflow
BUNDLE/notebook_operators: https://github.com/canonical/notebook-operators
JUJU_CONTROLLER: lxd
JUJU_MODEL: bundle-test

prepare: |
tests.pkgs install python3-yaml
Expand All @@ -35,8 +37,9 @@ prepare: |
popd
restore: |
rm ~/*.zip
for directory in $(ls -1 bundle/charms); do
pushd "bundle/charms/${directory}"
charmcraft clean
Expand All @@ -58,5 +61,5 @@ execute: |
fi
# Test deploying the bundle.
# TODO: install juju on the runner and re-enable this.
# juju deploy --dry-run *.zip
mv *.zip ~/
juju deploy --trust ~/*.zip
12 changes: 12 additions & 0 deletions tests/spread/charms/k8s-operator/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ environment:
CHARM/grafana: https://github.com/canonical/grafana-k8s-operator
# Requires some pre-setup.
# CHARM/grafana_agent: https://github.com/canonical/grafana-agent-k8s-operator
CHARM/hydra: https://github.com/canonical/hydra-operator
CHARM/identity_platform: https://github.com/canonical/identity-platform-login-ui-operator
CHARM/indico: https://github.com/canonical/indico-operator
CHARM/kafka: https://github.com/canonical/kafka-k8s-operator
CHARM/loki: https://github.com/canonical/loki-k8s-operator
CHARM/mattermost: https://git.launchpad.net/charm-k8s-mattermost
Expand All @@ -23,11 +26,16 @@ environment:
CHARM/traefik: https://github.com/canonical/traefik-k8s-operator
CHARM/wordpress: https://github.com/canonical/wordpress-k8s-operator
CHARM/zookeeper: https://github.com/canonical/zookeeper-k8s-operator
JUJU_CONTROLLER: k8s
JUJU_MODEL: k8s-operator-test


prepare: |
git clone --depth=1 "${CHARM}" charm
restore: |
rm -f ~/*.charm
pushd charm
charmcraft clean
popd
Expand All @@ -37,3 +45,7 @@ restore: |
execute: |
cd charm
charmcraft pack --verbose
mv *.charm ~/
# TODO: pull the referenced OCI images and deploy to juju.
# ls -1 ~/*.charm | head -n 1 | xargs -n 1 juju deploy
11 changes: 8 additions & 3 deletions tests/spread/charms/operator/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ environment:
CHARM/dex_auth: https://github.com/canonical/dex-auth-operator
CHARM/github_runner: https://github.com/canonical/github-runner-operator
CHARM/hardware_observer: https://github.com/canonical/hardware-observer-operator
CHARM/hydra: https://github.com/canonical/hydra-operator
CHARM/identity_platform: https://github.com/canonical/identity-platform-login-ui-operator
CHARM/indico: https://github.com/canonical/indico-operator
CHARM/kafka: https://github.com/canonical/kafka-operator
CHARM/kratos: https://github.com/canonical/kratos-operator
CHARM/minio: https://github.com/canonical/minio-operator
Expand All @@ -28,11 +25,15 @@ environment:
CHARM/seldon_core: https://github.com/canonical/seldon-core-operator
CHARM/tls_certificates: https://github.com/canonical/tls-certificates-operator
CHARM/zookeeper: https://github.com/canonical/zookeeper-operator
JUJU_CONTROLLER: lxd
JUJU_MODEL: operator-test

prepare: |
git clone --depth=1 "${CHARM}" charm
restore: |
rm -f ~/*.charm
pushd charm
charmcraft clean
popd
Expand All @@ -42,3 +43,7 @@ restore: |
execute: |
cd charm
charmcraft pack --verbose
mv *.charm ~/
# We can only deploy one of the charms in the model, so deploy the first one.
ls -1 ~/*.charm | head -n 1 | xargs -n 1 juju deploy
9 changes: 8 additions & 1 deletion tests/spread/charms/reactive/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ kill-timeout: 30m

environment:
CHARM: https://git.launchpad.net/content-cache-charm
JUJU_CONTROLLER: lxd
JUJU_MODEL: reactive-test

prepare: |
git clone --depth=1 "${CHARM}" charm
restore: |
rm -f ~/*.charm
pushd charm
charmcraft clean
popd
rm -rf charm
execute: |
cd charm
charmcraft pack --verbose
mv *.charm ~/
juju deploy ~/20.04-amd64.charm
3 changes: 3 additions & 0 deletions tests/spread/dependencies/requirements/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:
REQUIREMENTS_FILE/hash,hash_deps,hash_pydeps,hash_deps_pydeps: requirements-hashes.txt
CHARMCRAFT_YAML/deps,deps_pydeps,hash_deps,hash_deps_pydeps: charmcraft-python-packages.yaml
PYDEPS/pydeps,hash_pydeps,deps_pydeps,hash_deps_pydeps: '["cosl", "pydantic"]'
JUJU_MODEL: requirements-test

include:
- tests/spread/dependencies
Expand Down Expand Up @@ -36,6 +37,8 @@ execute: |
juju deploy ~/*.charm
restore: |
rm ~/*.charm
pushd charm
charmcraft clean
popd

0 comments on commit a14d6d9

Please sign in to comment.