Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/operator workflow integration test #132

Merged
merged 26 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e4f435f
Create a scirpts directory
yhaliaw Oct 6, 2023
b6540ec
Use operator-workflow for integration tests
yhaliaw Oct 6, 2023
c8efc56
Non-parallel integration tests
yhaliaw Oct 6, 2023
9696033
Try using extra matrix
yhaliaw Oct 6, 2023
1552ded
Fix typo
yhaliaw Oct 6, 2023
20715bc
Update scripts/pre-integration-test.sh
yhaliaw Oct 6, 2023
245e4ff
Debug
yhaliaw Oct 6, 2023
c1215b8
Run integration test in sequence
yhaliaw Oct 6, 2023
52d1396
Fix arg name
yhaliaw Oct 8, 2023
63a3a47
Use modules input
yhaliaw Oct 11, 2023
491f969
Integration test for network access of runner (#99)
yhaliaw Oct 6, 2023
818eb9e
Remove LXD profile prior to retrying creating LXD instance (#131)
yhaliaw Oct 9, 2023
8808652
Adapt charm to support COS integration (#127)
cbartz Oct 10, 2023
548fafd
Merge branch 'main' into feat/operator-workflow-integration-test
yhaliaw Oct 11, 2023
1ef0d5b
Debug
yhaliaw Oct 11, 2023
43d02ff
Revert scripts
yhaliaw Oct 11, 2023
85ea806
Update pre-integration-test.sh
yhaliaw Oct 12, 2023
898675f
Merge branch 'main' into feat/operator-workflow-integration-test
yhaliaw Oct 12, 2023
92fb70a
Write lxd-profile.yaml to built charm
yhaliaw Oct 16, 2023
98f9d1b
Fix typo
yhaliaw Oct 16, 2023
0f9e5e2
Add missing new line
yhaliaw Oct 16, 2023
e619a85
Use str instead of path for charm_file args
yhaliaw Oct 17, 2023
4593f6e
Fix typing
yhaliaw Oct 17, 2023
f2839e3
Update the name of workflow
yhaliaw Oct 17, 2023
bd6c716
Merge branch 'main' into feat/operator-workflow-integration-test
yhaliaw Oct 17, 2023
7c3e140
Parallelize integration test
yhaliaw Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 23 additions & 138 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,141 +4,26 @@ on:
pull_request:

jobs:
integration-test-charm-no-runner:
name: Integration test charm with no runner
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
juju: [3.1, 2.9]
steps:
- uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: ${{ matrix.juju }}/stable
provider: lxd
- name: Enable br_netfilter
run: sudo modprobe br_netfilter
- name: Run Integration tests
run: |
tox -e integration-juju${{ matrix.juju }} -- \
--keep-models \
--path ${{secrets.E2E_TESTING_REPO}} \
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm_no_runner.py
integration-test-charm:
name: Integration test charm
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
juju: [3.1, 2.9]
steps:
- uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: ${{ matrix.juju }}/stable
provider: lxd
- name: Enable br_netfilter
run: sudo modprobe br_netfilter
- name: Run Integration tests
run: |
tox -e integration-juju${{ matrix.juju }} -- \
--keep-models \
--path ${{secrets.E2E_TESTING_REPO}} \
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm.py
integration-test-charm-fork-repo:
name: Integration test charm with fork repo
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
juju: [3.1, 2.9]
steps:
- uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: ${{ matrix.juju }}/stable
provider: lxd
- name: Enable br_netfilter
run: sudo modprobe br_netfilter
- name: Run Integration tests
run: |
tox -e integration-juju${{ matrix.juju }} -- \
--keep-models \
--path ${{secrets.E2E_TESTING_REPO}} \
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm_fork_repo.py
integration-test-charm-scheduled-events:
name: Integration test charm scheduled events
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
juju: [3.1, 2.9]
steps:
- uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: ${{ matrix.juju }}/stable
provider: lxd
- name: Enable br_netfilter
run: sudo modprobe br_netfilter
- name: Run Integration tests
run: |
tox -e integration-juju${{ matrix.juju }} -- \
--keep-models \
--path ${{secrets.E2E_TESTING_REPO}} \
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm_scheduled_events.py
integration-test-charm-metrics:
name: Integration test charm metrics
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
juju: [ 3.1, 2.9 ]
steps:
- uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: ${{ matrix.juju }}/stable
provider: lxd
- name: Enable br_netfilter
run: sudo modprobe br_netfilter
- name: Run Integration tests
run: |
tox -e integration-juju${{ matrix.juju }} -- \
--keep-models \
--path ${{secrets.E2E_TESTING_REPO}} \
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm_metrics.py
required_status_checks:
name: Required Integration Test Status Checks
runs-on: ubuntu-latest
needs:
- integration-test-charm-no-runner
- integration-test-charm
- integration-test-charm-fork-repo
- integration-test-charm-scheduled-events
- integration-test-charm-metrics
if: always() && !cancelled()
timeout-minutes: 30
steps:
- run: |
[ '${{ needs.integration-test-charm-no-runner.result }}' = 'success' ] || (echo integration-test-charm-no-runner failed && false)
[ '${{ needs.integration-test-charm.result }}' = 'success' ] || (echo integration-test-charm failed && false)
[ '${{ needs.integration-test-charm-fork-repo.result }}' = 'success' ] || (echo integration-test-charm-fork-repo failed && false)
[ '${{ needs.integration-test-charm-scheduled-events.result }}' = 'success' ] || (echo integration-test-charm-schedule-events failed && false)
[ '${{ needs.integration-test-charm-metrics.result }}' = 'success' ] || (echo integration-test-charm-metrics failed && false)
integration-test-juju3:
name: Integration test
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
secrets: inherit
with:
juju-channel: 3.1/stable
pre-run-script: scripts/pre-integration-test.sh
provider: lxd
test-tox-env: integration-juju3.1
modules: '["test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics"]'
tmate-debug: true
tmate-timeout: 300
integration-test-juju2:
name: Integration test
needs: integration-test-juju3
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
secrets: inherit
with:
juju-channel: 2.9/stable
pre-run-script: scripts/pre-integration-test.sh
provider: lxd
test-tox-env: integration-juju2.9
modules: '["test_charm_fork_repo", "test_charm_no_runner", "test_charm_scheduled_events", "test_charm_one_runner", "test_charm_metrics"]'
7 changes: 7 additions & 0 deletions scripts/pre-integration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

# Enable kernel module br_netfilter
yhaliaw marked this conversation as resolved.
Show resolved Hide resolved
sudo modprobe br_netfilter
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def pytest_addoption(parser: Parser):
"""Add options to pytest parser."""
parser.addoption("--path", action="store")
parser.addoption("--token", action="store")
parser.addoption("--charm-file", action="store")
parser.addoption("--token-alt", action="store")
parser.addoption("--http-proxy", action="store")
parser.addoption("--https-proxy", action="store")
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ async def charm_path(ops_test: OpsTest, lxd_profile: Path) -> AsyncIterator[Path
yield await ops_test.build_charm(".")


@pytest.fixture(scope="module")
def charm_file(pytestconfig: pytest.Config) -> Path:
charm = pytestconfig.getoption("--charm-file")
# This is not used due to needing injection of lxd_profile.
return Path(charm)


@pytest.fixture(scope="module")
def path(pytestconfig: pytest.Config) -> str:
"""Configured path setting."""
Expand Down
Loading