Skip to content

Commit

Permalink
compatible(integration_test_charm.yaml): Add microk8s cloud (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical authored Nov 20, 2023
1 parent c9bf1f5 commit 5781558
Showing 1 changed file with 52 additions and 9 deletions.
61 changes: 52 additions & 9 deletions .github/workflows/integration_test_charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@ on:
description: |
Juju cloud
Must be one of: "lxd"
Must be one of: "lxd", "microk8s"
https://juju.is/docs/olm/cloud
required: true
type: string
microk8s-snap-channel:
description: |
microk8s snap channel
Required if `cloud` input is "microk8s"
required: false
type: string
juju-agent-version:
description: Juju agent version
required: false
Expand Down Expand Up @@ -131,10 +138,29 @@ jobs:
run: redact-secrets
env:
SECRETS: ${{ secrets.integration-test }}
- name: Validate cloud input
- name: Parse cloud input
id: parse-cloud
shell: python
# Keep synchronized with inputs.cloud description
run: assert "${{ inputs.cloud }}" in ("lxd")
run: |
import os
CLOUD = "${{ inputs.cloud }}"
if CLOUD == "lxd":
group = "lxd"
elif CLOUD == "microk8s":
SNAP_CHANNEL = "${{ inputs.microk8s-snap-channel }}"
assert (
SNAP_CHANNEL != ""
), '`microk8s-snap-channel` input required if `cloud` is "microk8s"'
assert "strict" in SNAP_CHANNEL.lower(), "Only strict microk8s snap supported"
group = "snap_microk8s"
else:
raise ValueError(f"`cloud` input not recognized: {CLOUD}")
output = f"group={group}"
print(output)
with open(os.environ["GITHUB_OUTPUT"], "a") as file:
file.write(output)
- name: Parse Juju agent version & snap channel
id: parse-versions
shell: python
Expand Down Expand Up @@ -169,16 +195,33 @@ jobs:
- name: Set up lxd
if: ${{ inputs.cloud == 'lxd' }}
run: |
sudo adduser "$USER" lxd
sg lxd -c "lxd waitready"
sg lxd -c "lxd init --auto"
sg lxd -c "lxc network set lxdbr0 ipv6.address none"
sudo adduser "$USER" '${{ steps.parse-cloud.outputs.group }}'
# `newgrp` does not work in GitHub Actions; use `sg` instead
sg '${{ steps.parse-cloud.outputs.group }}' -c "lxd waitready"
sg '${{ steps.parse-cloud.outputs.group }}' -c "lxd init --auto"
sg '${{ steps.parse-cloud.outputs.group }}' -c "lxc network set lxdbr0 ipv6.address none"
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT
- name: Set up microk8s
if: ${{ inputs.cloud == 'microk8s' }}
run: |
sudo apt-get install retry -y
sudo snap install microk8s --channel='${{ inputs.microk8s-snap-channel }}'
sudo adduser "$USER" '${{ steps.parse-cloud.outputs.group }}'
# `newgrp` does not work in GitHub Actions; use `sg` instead
sg '${{ steps.parse-cloud.outputs.group }}' -c "microk8s status --wait-ready"
sg '${{ steps.parse-cloud.outputs.group }}' -c "retry --times 3 --delay 5 -- sudo microk8s enable dns"
sg '${{ steps.parse-cloud.outputs.group }}' -c "microk8s status --wait-ready"
sg '${{ steps.parse-cloud.outputs.group }}' -c "microk8s.kubectl rollout status --namespace kube-system --watch --timeout=5m deployments/coredns"
sg '${{ steps.parse-cloud.outputs.group }}' -c "retry --times 3 --delay 5 -- sudo microk8s enable hostpath-storage"
sg '${{ steps.parse-cloud.outputs.group }}' -c "microk8s.kubectl rollout status --namespace kube-system --watch --timeout=5m deployments/hostpath-provisioner"
mkdir ~/.kube
# Used by lightkube and kubernetes (Python package)
sg '${{ steps.parse-cloud.outputs.group }}' -c "microk8s config > ~/.kube/config"
- name: Set up environment
run: |
mkdir -p ~/.local/share/juju # Workaround for juju 3 strict snap
sg lxd -c "juju bootstrap '${{ inputs.cloud }}' '${{ steps.parse-versions.outputs.agent_bootstrap_option }}'"
sg '${{ steps.parse-cloud.outputs.group }}' -c "juju bootstrap '${{ inputs.cloud }}' '${{ steps.parse-versions.outputs.agent_bootstrap_option }}'"
juju model-defaults logging-config='<root>=INFO; unit=DEBUG'
juju add-model test
pipx install tox
Expand Down Expand Up @@ -207,7 +250,7 @@ jobs:
file.write(output)
- name: Run integration tests
id: tests
run: sg lxd -c "tox run -e integration -- '${{ matrix.groups.path_to_test_file }}' --group='${{ matrix.groups.group_number }}' -m '${{ steps.select-test-stability.outputs.mark_expression }}' --model test"
run: sg '${{ steps.parse-cloud.outputs.group }}' -c "tox run -e integration -- '${{ matrix.groups.path_to_test_file }}' --group='${{ matrix.groups.group_number }}' -m '${{ steps.select-test-stability.outputs.mark_expression }}' --model test"
env:
SECRETS_FROM_GITHUB: ${{ secrets.integration-test }}
- name: Select model
Expand Down

0 comments on commit 5781558

Please sign in to comment.