charmkeeper-integration-tests
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlan:
- Find the integration tests in the repository (their could be multiple "tests/integration" folders).
- Ensure each set of integration tests is following the implementation standards.
- Run the tests to ensure the code work as expected.
计划:
- 在仓库中找到集成测试(可能存在多个"tests/integration"文件夹)。
- 确保每一组集成测试都符合实现标准。
- 运行测试以确保代码按预期工作。
Implementation standards
实现标准
-
Expected versions:
- : ~> 1.7
jubilant
-
Lint produced code with.
tox -e lint
-
预期版本:
- : ~> 1.7
jubilant
-
使用对生成的代码进行代码检查。
tox -e lint
Testing
测试
Writing integrations tests
编写集成测试
-
Integration test must be implemented with:
jubilant- See How to migrate from pytest-operator to Jubilant if the charm is currently using pytest-operator.
-
For each charm in the repository, there should be afolder like: https://github.com/canonical/platform-engineering-charm-template/tree/main/tests
tests/- There is a file to add options to pytest. See an example here: https://github.com/canonical/haproxy-operator/blob/main/haproxy-spoe-auth-operator/tests/conftest.py
tests/conftest.py - Integration tests goes in
tests/integration - There is a file with the same fixtures as: https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/tests/integration/conftest.py
tests/integration/conftest.py - Fixtures should look like the ones in https://raw.githubusercontent.com/canonical/netbox-k8s-operator/refs/heads/main/tests/integration/conftest.py
- Helper functions should go in . See an example here: https://raw.githubusercontent.com/canonical/netbox-k8s-operator/refs/heads/main/tests/integration/helpers.py
tests/integration/helpers.py - There is a to test the basic behaviors of the charm.
tests/integration/test_charm.py - There should be additional files to test specific integrations of the charm.
tests/integration/test_xxx.py
- There is a
-
If the repository contains multiple charms, there should be aat the root of the repository. You can find an example here: https://github.com/canonical/haproxy-operator/tree/main/tests
tests/integration -
Dependencies
- The charms used in the integration tests should be deployed using the channel (or "track/edge").
latest/edge - An explicit revision should be set to deploy the charm.
- Revisions are defined through constants defined at the beginning of the file.
- Each constant is preceded with a '# renovate: depName="xxx"' directive to let renovate detect and update the revision.
- The charms used in the integration tests should be deployed using the
-
集成测试必须使用实现:
jubilant- 如果当前charm使用pytest-operator,请查看如何从pytest-operator迁移到Jubilant。
-
对于仓库中的每个charm,都应该有一个文件夹,示例可参考:https://github.com/canonical/platform-engineering-charm-template/tree/main/tests
tests/- 存在文件用于为pytest添加选项,示例可参考:https://github.com/canonical/haproxy-operator/blob/main/haproxy-spoe-auth-operator/tests/conftest.py
tests/conftest.py - 集成测试放在目录下
tests/integration - 存在文件,其中的fixture与以下文件中的一致:https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/tests/integration/conftest.py
tests/integration/conftest.py - Fixture应该与https://raw.githubusercontent.com/canonical/netbox-k8s-operator/refs/heads/main/tests/integration/conftest.py中的示例类似
- 辅助函数应放在中,示例可参考:https://raw.githubusercontent.com/canonical/netbox-k8s-operator/refs/heads/main/tests/integration/helpers.py
tests/integration/helpers.py - 存在文件用于测试charm的基本行为
tests/integration/test_charm.py - 应添加额外的文件来测试charm的特定集成功能
tests/integration/test_xxx.py
- 存在
-
如果仓库包含多个charm,应在仓库根目录下创建目录,示例可参考:https://github.com/canonical/haproxy-operator/tree/main/tests
tests/integration -
依赖项
- 集成测试中使用的charm应通过渠道(或"track/edge")部署
latest/edge - 应设置明确的修订版本来部署charm
- 修订版本通过文件开头定义的常量来指定
- 每个常量前应添加'# renovate: depName="xxx"'指令,以便renovate检测并更新修订版本
- 集成测试中使用的charm应通过
Local testing
本地测试
The integration tests should be run in a virtual machine named "charmkeeper".
If the machine doesn't exist, create it with: .
scripts/create-charmkeeper-vm.shIf not already done, mount the working directory folder in the machine with
bash
multipass mount --type native $PWD charmkeeper:/workdirRun tests with:
bash
multipass exec charmkeeper -d /workdir/ -- tox
multipass exec charmkeeper -d /workdir/ -- tox -e integrationYou may find additional information to run the tests in CONTRIBUTING.md
集成测试应在名为"charmkeeper"的虚拟机中运行。
如果该虚拟机不存在,请使用以下命令创建:。
scripts/create-charmkeeper-vm.sh如果尚未挂载工作目录,请使用以下命令将其挂载到虚拟机中:
bash
multipass mount --type native $PWD charmkeeper:/workdir使用以下命令运行测试:
bash
multipass exec charmkeeper -d /workdir/ -- tox
multipass exec charmkeeper -d /workdir/ -- tox -e integration你可以在CONTRIBUTING.md中找到更多运行测试的相关信息。
Maintain
维护
Configuring renovate
配置Renovate
Configure renovate with a charmhub customDatasource like in https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/renovate.json to
- Add a regex customManager to update the revisions
- Set ignorePath to an empty array to not exclude the folders
tests
- 添加正则表达式自定义管理器来更新修订版本
- 将ignorePath设置为空数组,以不排除文件夹
tests