From 485fe9061a9854bab81e6b835a85b81a6ef94bce Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Thu, 11 Apr 2024 14:58:58 +0200 Subject: [PATCH 01/10] generic clean up --- Makefile | 21 ++++++--------------- src/tox.ini | 15 +++------------ 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index cb4081c..d053e19 100644 --- a/Makefile +++ b/Makefile @@ -27,18 +27,15 @@ help: @echo " make release - run clean, submodules, and build targets" @echo " make lint - run flake8 and black --check" @echo " make black - run black and reformat files" - @echo " make proof - run charm proof" @echo " make unittests - run the tests defined in the unittest subdirectory" @echo " make functional - run the tests defined in the functional subdirectory" @echo " make test - run lint, proof, unittests and functional targets" @echo "" clean: - @echo "Cleaning files" - @git clean -ffXd -e '!.idea' - @echo "Cleaning existing build" - @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME} + @echo "Cleaning charmcraft" @charmcraft clean + @echo "Cleaning existing chamr files" @rm -rf ${PROJECTPATH}/${CHARM_NAME}.charm submodules: @@ -48,15 +45,13 @@ submodules-update: @git submodule update --init --recursive --remote --merge build: clean submodules-update - @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}" + @echo "Building charm ${PROJECTPATH}/${CHARM_NAME}.charm" @-git rev-parse --abbrev-ref HEAD > ./src/repo-info @charmcraft -v pack ${BUILD_ARGS} @bash -c ./rename.sh - @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME} - @unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME} release: clean build - @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}" + @echo "Charm is built at ${PROJECTPATH}/${CHARM_NAME}.charm" lint: @echo "Running lint checks" @@ -66,17 +61,13 @@ black: @echo "Reformat files with black" @cd src && tox -e black -proof: build - @echo "Running charm proof" - @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME} - unittests: @echo "Running unit tests" @cd src && tox -e unit functional: build - @echo "Executing functional tests in ${CHARM_BUILD_DIR}" - @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func + @echo "Executing functional tests with ${PROJECTPATH}/${CHARM_NAME}.charm" + @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func -- ${FUNC_ARGS} test: lint proof unittests functional @echo "Tests completed for charm ${CHARM_NAME}." diff --git a/src/tox.ini b/src/tox.ini index 226d06d..0d12aa7 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -21,16 +21,7 @@ passenv = NO_PROXY SNAP_HTTP_PROXY SNAP_HTTPS_PROXY - OS_REGION_NAME - OS_AUTH_VERSION - OS_AUTH_URL - OS_PROJECT_DOMAIN_NAME - OS_USERNAME - OS_PASSWORD - OS_PROJECT_ID - OS_USER_DOMAIN_NAME - OS_PROJECT_NAME - OS_IDENTITY_API_VERSION + OS_* [testenv:lint] commands = @@ -84,5 +75,5 @@ deps = -r{toxinidir}/tests/unit/requirements.txt [testenv:func] changedir = {toxinidir}/tests/functional -commands = functest-run-suite --keep-faulty-model {posargs} -deps = -r{toxinidir}/tests/functional/requirements.txt +commands = functest-run-suite {posargs:--keep-faulty-model} +deps = -r {toxinidir}/tests/functional/requirements.txt From d716e6285490e12f82e60686cd8cbf950a47ca38 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Thu, 11 Apr 2024 15:47:36 +0200 Subject: [PATCH 02/10] Drop bootstack-actions in CI func tests Using master branch for zaza with TEST_JUJU3=1 [1] and dropping bootstack-actions for func in CI to be able to use specific lxd channel. --- [1]: https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6 --- .github/workflows/check.yaml | 34 +++++++++++++++++---------- src/tests/functional/requirements.txt | 2 +- src/tox.ini | 4 +++- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 5df4f72..fc4f66f 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -22,19 +22,29 @@ jobs: working-directory: ./src func: - uses: canonical/bootstack-actions/.github/workflows/func.yaml@v2 + name: Functional tests + runs-on: ubuntu-latest + timeout-minutes: 120 needs: lint-unit strategy: fail-fast: false matrix: - include: - - juju-channel: "3.1/stable" - command: "make functional" - with: - command: ${{ matrix.command }} - juju-channel: ${{ matrix.juju-channel }} - nested-containers: false - provider: "lxd" - python-version: "3.10" - timeout-minutes: 120 - tox-version: "<4" + juju-channel: ['3.4/stable'] + command: ['TEST_JUJU3=1 make functional'] # using TEST_JUJU3 due https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6 + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Setup Juju ${{ matrix.juju-channel }} LXD environment + uses: charmed-kubernetes/actions-operator@main + with: + provider: lxd + juju-channel: ${{ matrix.juju-channel }} + - name: Show juju information + run: | + juju version + juju controllers | grep Version -A 1 | awk '{print $9}' + - name: Run functional test + run: ${{ matrix.command }} diff --git a/src/tests/functional/requirements.txt b/src/tests/functional/requirements.txt index f0a09b0..4a6e1d8 100644 --- a/src/tests/functional/requirements.txt +++ b/src/tests/functional/requirements.txt @@ -1,4 +1,4 @@ flake8 mock -git+https://github.com/openstack-charmers/zaza.git@libjuju-3.1#egg=zaza +git+https://github.com/openstack-charmers/zaza.git#egg=zaza python-openstackclient diff --git a/src/tox.ini b/src/tox.ini index 0d12aa7..fd42aa5 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -22,6 +22,7 @@ passenv = SNAP_HTTP_PROXY SNAP_HTTPS_PROXY OS_* + TEST_* [testenv:lint] commands = @@ -76,4 +77,5 @@ deps = -r{toxinidir}/tests/unit/requirements.txt [testenv:func] changedir = {toxinidir}/tests/functional commands = functest-run-suite {posargs:--keep-faulty-model} -deps = -r {toxinidir}/tests/functional/requirements.txt +deps = + -r {toxinidir}/tests/functional/requirements.txt From dbb7d0b2a8fa96b331979713b94fb17a91764639 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Thu, 11 Apr 2024 16:02:18 +0200 Subject: [PATCH 03/10] using specific version of lxd --- .github/workflows/check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index fc4f66f..3b34f10 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -42,6 +42,7 @@ jobs: with: provider: lxd juju-channel: ${{ matrix.juju-channel }} + lxd-channel: "5.20/stable" # tmp fix until https://github.com/canonical/charmcraft/issues/1640 - name: Show juju information run: | juju version From 1c12b2f7ed39e34034e546a022dfd1fd2d08ab9b Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Thu, 11 Apr 2024 16:25:37 +0200 Subject: [PATCH 04/10] add CHARM_LOCATION --- .github/workflows/check.yaml | 4 ++++ src/CONTRIB.md | 3 --- src/tests/functional/tests/bundles/base.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 3b34f10..120ba59 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -9,6 +9,10 @@ on: - "**.md" - "**.rst" +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + jobs: lint-unit: uses: canonical/bootstack-actions/.github/workflows/lint-unit.yaml@v2 diff --git a/src/CONTRIB.md b/src/CONTRIB.md index 842df2d..51ca9a3 100644 --- a/src/CONTRIB.md +++ b/src/CONTRIB.md @@ -49,9 +49,6 @@ make build charm build ``` -You can set various environment variables (e.g. JUJU_REPOSITORY, CHARM_BUILD_DIR) to build into -your desired directory. By default, the project will build into /tmp/charm-builds/duplicity. - ## Running Tests The following section will review running automated tests in the project. diff --git a/src/tests/functional/tests/bundles/base.yaml b/src/tests/functional/tests/bundles/base.yaml index b84d3cd..0700e61 100644 --- a/src/tests/functional/tests/bundles/base.yaml +++ b/src/tests/functional/tests/bundles/base.yaml @@ -11,7 +11,7 @@ applications: charm: nrpe duplicity: - charm: /tmp/charm-builds/duplicity + charm: duplicity options: backend: file remote_backup_url: 'file:///home/ubuntu/somedir' From a17ee2e6eafc6de54dd3061f02a27d2617f721c0 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Mon, 15 Apr 2024 20:16:20 +0200 Subject: [PATCH 05/10] test of my fix for zaza --- .github/workflows/check.yaml | 8 +++++--- src/tests/functional/requirements.txt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 120ba59..2fd5baf 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -33,8 +33,11 @@ jobs: strategy: fail-fast: false matrix: - juju-channel: ['3.4/stable'] - command: ['TEST_JUJU3=1 make functional'] # using TEST_JUJU3 due https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6 + include: + - juju-channel: '3.4/stable' + command: 'TEST_JUJU3=1 make functional' # using TEST_JUJU3 due https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6 + - juju-channel: '2.9/stable' + command: 'make functional' steps: - uses: actions/checkout@v4 - name: Setup Python @@ -46,7 +49,6 @@ jobs: with: provider: lxd juju-channel: ${{ matrix.juju-channel }} - lxd-channel: "5.20/stable" # tmp fix until https://github.com/canonical/charmcraft/issues/1640 - name: Show juju information run: | juju version diff --git a/src/tests/functional/requirements.txt b/src/tests/functional/requirements.txt index 4a6e1d8..76ac800 100644 --- a/src/tests/functional/requirements.txt +++ b/src/tests/functional/requirements.txt @@ -1,4 +1,4 @@ flake8 mock -git+https://github.com/openstack-charmers/zaza.git#egg=zaza +git+https://github.com/rgildein/zaza.git@chore/no-ref/fix-action-object#egg=zaza python-openstackclient From 53640c03758df9bfca97e295ab1f4e0330d58f1a Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Mon, 15 Apr 2024 22:35:17 +0200 Subject: [PATCH 06/10] fix requirements for install hook Fix requirements for install hook not to failed, drop series from metadata.yaml. --- src/metadata.yaml | 1 - src/requirements.txt | 4 ++++ src/wheelhouse.txt | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/metadata.yaml b/src/metadata.yaml index f419771..425f00d 100644 --- a/src/metadata.yaml +++ b/src/metadata.yaml @@ -14,7 +14,6 @@ tags: # https://jujucharms.com/docs/stable/authors-charm-metadata - backup subordinate: true -series: [] provides: nrpe-external-master: interface: nrpe-external-master diff --git a/src/requirements.txt b/src/requirements.txt index 47e3c05..5d35e6e 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -2,3 +2,7 @@ croniter pidfile fabric +# NOTE(rgildein): The contextvars could not be installed without this requirement to be specified. +setuptools>=42 +# NOTE(rgildein): The typing-extensions could not be installed without this requirement to be specified. +flit-core>=3 diff --git a/src/wheelhouse.txt b/src/wheelhouse.txt index e7a5072..c411668 100644 --- a/src/wheelhouse.txt +++ b/src/wheelhouse.txt @@ -1,3 +1,7 @@ distro<1.7.0 croniter pidfile +# NOTE(rgildein): The contextvars could not be installed without this requirement to be specified. +setuptools>=42 +# NOTE(rgildein): The typing-extensions could not be installed without this requirement to be specified. +flit-core>=3 From ac4e522ee8dfc2d1caa5e5db5ceb1fada9a4897f Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Tue, 16 Apr 2024 23:11:37 +0200 Subject: [PATCH 07/10] revert back usage of bootstack-actions and run only Juju 3.4 --- .github/workflows/check.yaml | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 2fd5baf..e018c57 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -22,36 +22,21 @@ jobs: python-version: ["3.8", "3.10"] with: python-version: ${{ matrix.python-version }} - tox-version: "<4" working-directory: ./src func: - name: Functional tests - runs-on: ubuntu-latest - timeout-minutes: 120 + uses: canonical/bootstack-actions/.github/workflows/func.yaml@v2 needs: lint-unit strategy: fail-fast: false matrix: include: - - juju-channel: '3.4/stable' - command: 'TEST_JUJU3=1 make functional' # using TEST_JUJU3 due https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6 - - juju-channel: '2.9/stable' - command: 'make functional' - steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Setup Juju ${{ matrix.juju-channel }} LXD environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: lxd - juju-channel: ${{ matrix.juju-channel }} - - name: Show juju information - run: | - juju version - juju controllers | grep Version -A 1 | awk '{print $9}' - - name: Run functional test - run: ${{ matrix.command }} + - juju-channel: "3.4/stable" + command: "TEST_JUJU3=1 make functional" # using TEST_JUJU3 due https://github.com/openstack-charmers/zaza/commit/af7eea953dd5d74d3d074fe67b5765dca3911ca6 + with: + command: ${{ matrix.command }} + juju-channel: ${{ matrix.juju-channel }} + nested-containers: false + provider: "lxd" + python-version: "3.10" + timeout-minutes: 120 From 2d8bc20b5abdb3c88e3e5af882bed011bd48d76d Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Thu, 18 Apr 2024 18:34:00 +0200 Subject: [PATCH 08/10] Switch to master branch of zaza --- src/tests/functional/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/requirements.txt b/src/tests/functional/requirements.txt index 76ac800..fc3c00a 100644 --- a/src/tests/functional/requirements.txt +++ b/src/tests/functional/requirements.txt @@ -1,4 +1,4 @@ flake8 mock -git+https://github.com/rgildein/zaza.git@chore/no-ref/fix-action-object#egg=zaza +git+https://github.com/openstack-charmers/zaza.git@master#egg=zaza python-openstackclient From c7463d1d79b40eb26783e59ae9d0f5aaf1b98406 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Fri, 19 Apr 2024 16:22:33 +0200 Subject: [PATCH 09/10] Add custom sshd config instead of changing value The 60-cloudimg-settings.conf exist on new LXD with "PasswordAuthentication no" so we need to define our own config file. --- src/tests/functional/tests/configure.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/functional/tests/configure.py b/src/tests/functional/tests/configure.py index 1bbb104..157443b 100644 --- a/src/tests/functional/tests/configure.py +++ b/src/tests/functional/tests/configure.py @@ -22,8 +22,7 @@ def set_ssh_password_access_on_backup_host(): """Configure ssh access with password on backup host.""" backup_host_unit = _get_unit("backup-host") command = ( - "sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' " - "/etc/ssh/sshd_config && " + 'echo "PasswordAuthentication yes" > 01-test-settings.conf &&' "service sshd reload" ) result = zaza.model.run_on_unit(backup_host_unit.name, command, timeout=15) From f839607614b287c48530e8f267644e2b5773865d Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Wed, 24 Apr 2024 14:01:24 +0200 Subject: [PATCH 10/10] fix path to sshd config file --- src/tests/functional/tests/configure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/functional/tests/configure.py b/src/tests/functional/tests/configure.py index 157443b..419452b 100644 --- a/src/tests/functional/tests/configure.py +++ b/src/tests/functional/tests/configure.py @@ -22,8 +22,8 @@ def set_ssh_password_access_on_backup_host(): """Configure ssh access with password on backup host.""" backup_host_unit = _get_unit("backup-host") command = ( - 'echo "PasswordAuthentication yes" > 01-test-settings.conf &&' - "service sshd reload" + 'echo "PasswordAuthentication yes" > ' + "/etc/ssh/sshd_config.d/01-test-settings.conf && service sshd reload" ) result = zaza.model.run_on_unit(backup_host_unit.name, command, timeout=15) _check_run_result(result)