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

[Integration test] Allows for clouds(...) marker and --no-deploy handling #237

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

addyess
Copy link
Contributor

@addyess addyess commented Jan 7, 2025

Overview

Facilitates running most of the tests on existing models that are already deployed handling situations where specific tests or entire tests modules can be executed. Some tests will be excluded if they match the wrong cloud or require changing the existing model.

  • allows tests to be marked with clouds(...) in order to skip tests unless they are on a certain cloud
  • allows tests to skip certain tests if the --no-deploy flag is provided and the tests would deploy new applications/units into the model

Details

  • Uses the no-deploy pytest variable from pytest-operator to skip deployment of applications into the main kubernetes model in the event this is a model intended to be reused
  • Creates an auto-used fixture which confirms the cloud-type can run the tests if the test is marked with the clouds marker.
  • replace the abort_on_fail marker with a simpler exitfirst argument to pytest.

@addyess addyess requested a review from a team as a code owner January 7, 2025 22:12
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has checked 138 files.

Valid Invalid Ignored Fixed
1 67 70 0
Click to see the invalid file list
  • charms/worker/build-snap-installation.sh
  • charms/worker/charmcraft.yaml
  • charms/worker/k8s/build-snap-installation.sh
  • charms/worker/k8s/charmcraft.yaml
  • charms/worker/k8s/scripts/rules-patches/core-alert-rules.patch
  • charms/worker/k8s/scripts/update_alert_rules.py
  • charms/worker/k8s/scripts/update_dashboards.py
  • charms/worker/k8s/src/charm.py
  • charms/worker/k8s/src/cloud_integration.py
  • charms/worker/k8s/src/config/extra_args.py
  • charms/worker/k8s/src/containerd.py
  • charms/worker/k8s/src/cos_integration.py
  • charms/worker/k8s/src/events/update_status.py
  • charms/worker/k8s/src/inspector.py
  • charms/worker/k8s/src/kube_control.py
  • charms/worker/k8s/src/literals.py
  • charms/worker/k8s/src/prometheus_alert_rules/kubePrometheus-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubeStateMetrics-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubernetesControlPlane-prometheusRule.yaml
  • charms/worker/k8s/src/protocols.py
  • charms/worker/k8s/src/reschedule.py
  • charms/worker/k8s/src/snap.py
  • charms/worker/k8s/src/token_distributor.py
  • charms/worker/k8s/src/upgrade.py
  • charms/worker/k8s/templates/cos_roles.yaml
  • charms/worker/k8s/templates/ksm.yaml
  • charms/worker/k8s/templates/snap_installation.yaml
  • charms/worker/k8s/terraform/main.tf
  • charms/worker/k8s/terraform/outputs.tf
  • charms/worker/k8s/terraform/variables.tf
  • charms/worker/k8s/terraform/versions.tf
  • charms/worker/k8s/tests/unit/test_base.py
  • charms/worker/k8s/tests/unit/test_cloud_integration.py
  • charms/worker/k8s/tests/unit/test_config_options.py
  • charms/worker/k8s/tests/unit/test_containerd.py
  • charms/worker/k8s/tests/unit/test_inspector.py
  • charms/worker/k8s/tests/unit/test_k8sd_api_manager.py
  • charms/worker/k8s/tests/unit/test_reschedule.py
  • charms/worker/k8s/tests/unit/test_snap.py
  • charms/worker/k8s/tests/unit/test_token_distributor.py
  • charms/worker/k8s/tests/unit/test_upgrade.py
  • charms/worker/terraform/main.tf
  • charms/worker/terraform/outputs.tf
  • charms/worker/terraform/variables.tf
  • charms/worker/terraform/versions.tf
  • generate-src-docs.sh
  • tests/integration/init.py
  • tests/integration/conftest.py
  • tests/integration/cos_substrate.py
  • tests/integration/data/cos-offers-overlay.yaml
  • tests/integration/data/k8s.profile
  • tests/integration/data/microk8s.profile
  • tests/integration/data/static-proxy-config.yaml
  • tests/integration/data/test-bundle-ceph.yaml
  • tests/integration/data/test-bundle-etcd.yaml
  • tests/integration/data/test-bundle.yaml
  • tests/integration/data/test_ceph/ceph-xfs-pvc.yaml
  • tests/integration/data/test_ceph/pv-reader-pod.yaml
  • tests/integration/data/test_ceph/pv-writer-pod.yaml
  • tests/integration/grafana.py
  • tests/integration/helpers.py
  • tests/integration/prometheus.py
  • tests/integration/test_ceph.py
  • tests/integration/test_etcd.py
  • tests/integration/test_k8s.py
  • tests/integration/test_openstack.py
  • tests/integration/test_upgrade.py
Use this command to fix any missing license headers
```bash

docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix

</details>

@addyess addyess force-pushed the KU-2417/skip-if-cloud-markers branch from 24fa49f to 6f1d4da Compare January 7, 2025 22:35
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has checked 138 files.

Valid Invalid Ignored Fixed
2 66 70 0
Click to see the invalid file list
  • charms/worker/build-snap-installation.sh
  • charms/worker/charmcraft.yaml
  • charms/worker/k8s/build-snap-installation.sh
  • charms/worker/k8s/charmcraft.yaml
  • charms/worker/k8s/scripts/rules-patches/core-alert-rules.patch
  • charms/worker/k8s/scripts/update_alert_rules.py
  • charms/worker/k8s/scripts/update_dashboards.py
  • charms/worker/k8s/src/charm.py
  • charms/worker/k8s/src/cloud_integration.py
  • charms/worker/k8s/src/config/extra_args.py
  • charms/worker/k8s/src/containerd.py
  • charms/worker/k8s/src/cos_integration.py
  • charms/worker/k8s/src/events/update_status.py
  • charms/worker/k8s/src/inspector.py
  • charms/worker/k8s/src/kube_control.py
  • charms/worker/k8s/src/literals.py
  • charms/worker/k8s/src/prometheus_alert_rules/kubePrometheus-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubeStateMetrics-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubernetesControlPlane-prometheusRule.yaml
  • charms/worker/k8s/src/protocols.py
  • charms/worker/k8s/src/reschedule.py
  • charms/worker/k8s/src/snap.py
  • charms/worker/k8s/src/token_distributor.py
  • charms/worker/k8s/src/upgrade.py
  • charms/worker/k8s/templates/cos_roles.yaml
  • charms/worker/k8s/templates/ksm.yaml
  • charms/worker/k8s/templates/snap_installation.yaml
  • charms/worker/k8s/terraform/main.tf
  • charms/worker/k8s/terraform/outputs.tf
  • charms/worker/k8s/terraform/variables.tf
  • charms/worker/k8s/terraform/versions.tf
  • charms/worker/k8s/tests/unit/test_base.py
  • charms/worker/k8s/tests/unit/test_cloud_integration.py
  • charms/worker/k8s/tests/unit/test_config_options.py
  • charms/worker/k8s/tests/unit/test_containerd.py
  • charms/worker/k8s/tests/unit/test_inspector.py
  • charms/worker/k8s/tests/unit/test_k8sd_api_manager.py
  • charms/worker/k8s/tests/unit/test_reschedule.py
  • charms/worker/k8s/tests/unit/test_snap.py
  • charms/worker/k8s/tests/unit/test_token_distributor.py
  • charms/worker/k8s/tests/unit/test_upgrade.py
  • charms/worker/terraform/main.tf
  • charms/worker/terraform/outputs.tf
  • charms/worker/terraform/variables.tf
  • charms/worker/terraform/versions.tf
  • generate-src-docs.sh
  • tests/integration/init.py
  • tests/integration/conftest.py
  • tests/integration/cos_substrate.py
  • tests/integration/data/cos-offers-overlay.yaml
  • tests/integration/data/k8s.profile
  • tests/integration/data/microk8s.profile
  • tests/integration/data/static-proxy-config.yaml
  • tests/integration/data/test-bundle-ceph.yaml
  • tests/integration/data/test-bundle-etcd.yaml
  • tests/integration/data/test-bundle.yaml
  • tests/integration/data/test_ceph/ceph-xfs-pvc.yaml
  • tests/integration/data/test_ceph/pv-reader-pod.yaml
  • tests/integration/data/test_ceph/pv-writer-pod.yaml
  • tests/integration/grafana.py
  • tests/integration/helpers.py
  • tests/integration/prometheus.py
  • tests/integration/test_ceph.py
  • tests/integration/test_etcd.py
  • tests/integration/test_k8s.py
  • tests/integration/test_upgrade.py
Use this command to fix any missing license headers
```bash

docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix

</details>

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has checked 138 files.

Valid Invalid Ignored Fixed
2 66 70 0
Click to see the invalid file list
  • charms/worker/build-snap-installation.sh
  • charms/worker/charmcraft.yaml
  • charms/worker/k8s/build-snap-installation.sh
  • charms/worker/k8s/charmcraft.yaml
  • charms/worker/k8s/scripts/rules-patches/core-alert-rules.patch
  • charms/worker/k8s/scripts/update_alert_rules.py
  • charms/worker/k8s/scripts/update_dashboards.py
  • charms/worker/k8s/src/charm.py
  • charms/worker/k8s/src/cloud_integration.py
  • charms/worker/k8s/src/config/extra_args.py
  • charms/worker/k8s/src/containerd.py
  • charms/worker/k8s/src/cos_integration.py
  • charms/worker/k8s/src/events/update_status.py
  • charms/worker/k8s/src/inspector.py
  • charms/worker/k8s/src/kube_control.py
  • charms/worker/k8s/src/literals.py
  • charms/worker/k8s/src/prometheus_alert_rules/kubePrometheus-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubeStateMetrics-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubernetesControlPlane-prometheusRule.yaml
  • charms/worker/k8s/src/protocols.py
  • charms/worker/k8s/src/reschedule.py
  • charms/worker/k8s/src/snap.py
  • charms/worker/k8s/src/token_distributor.py
  • charms/worker/k8s/src/upgrade.py
  • charms/worker/k8s/templates/cos_roles.yaml
  • charms/worker/k8s/templates/ksm.yaml
  • charms/worker/k8s/templates/snap_installation.yaml
  • charms/worker/k8s/terraform/main.tf
  • charms/worker/k8s/terraform/outputs.tf
  • charms/worker/k8s/terraform/variables.tf
  • charms/worker/k8s/terraform/versions.tf
  • charms/worker/k8s/tests/unit/test_base.py
  • charms/worker/k8s/tests/unit/test_cloud_integration.py
  • charms/worker/k8s/tests/unit/test_config_options.py
  • charms/worker/k8s/tests/unit/test_containerd.py
  • charms/worker/k8s/tests/unit/test_inspector.py
  • charms/worker/k8s/tests/unit/test_k8sd_api_manager.py
  • charms/worker/k8s/tests/unit/test_reschedule.py
  • charms/worker/k8s/tests/unit/test_snap.py
  • charms/worker/k8s/tests/unit/test_token_distributor.py
  • charms/worker/k8s/tests/unit/test_upgrade.py
  • charms/worker/terraform/main.tf
  • charms/worker/terraform/outputs.tf
  • charms/worker/terraform/variables.tf
  • charms/worker/terraform/versions.tf
  • generate-src-docs.sh
  • tests/integration/init.py
  • tests/integration/conftest.py
  • tests/integration/cos_substrate.py
  • tests/integration/data/cos-offers-overlay.yaml
  • tests/integration/data/k8s.profile
  • tests/integration/data/microk8s.profile
  • tests/integration/data/static-proxy-config.yaml
  • tests/integration/data/test-bundle-ceph.yaml
  • tests/integration/data/test-bundle-etcd.yaml
  • tests/integration/data/test-bundle.yaml
  • tests/integration/data/test_ceph/ceph-xfs-pvc.yaml
  • tests/integration/data/test_ceph/pv-reader-pod.yaml
  • tests/integration/data/test_ceph/pv-writer-pod.yaml
  • tests/integration/grafana.py
  • tests/integration/helpers.py
  • tests/integration/prometheus.py
  • tests/integration/test_ceph.py
  • tests/integration/test_etcd.py
  • tests/integration/test_k8s.py
  • tests/integration/test_upgrade.py
Use this command to fix any missing license headers
```bash

docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix

</details>

@addyess addyess force-pushed the KU-2417/skip-if-cloud-markers branch from 6f1d4da to c33473f Compare January 7, 2025 22:58
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license-eye has checked 138 files.

Valid Invalid Ignored Fixed
2 66 70 0
Click to see the invalid file list
  • charms/worker/build-snap-installation.sh
  • charms/worker/charmcraft.yaml
  • charms/worker/k8s/build-snap-installation.sh
  • charms/worker/k8s/charmcraft.yaml
  • charms/worker/k8s/scripts/rules-patches/core-alert-rules.patch
  • charms/worker/k8s/scripts/update_alert_rules.py
  • charms/worker/k8s/scripts/update_dashboards.py
  • charms/worker/k8s/src/charm.py
  • charms/worker/k8s/src/cloud_integration.py
  • charms/worker/k8s/src/config/extra_args.py
  • charms/worker/k8s/src/containerd.py
  • charms/worker/k8s/src/cos_integration.py
  • charms/worker/k8s/src/events/update_status.py
  • charms/worker/k8s/src/inspector.py
  • charms/worker/k8s/src/kube_control.py
  • charms/worker/k8s/src/literals.py
  • charms/worker/k8s/src/prometheus_alert_rules/kubePrometheus-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubeStateMetrics-prometheusRule.yaml
  • charms/worker/k8s/src/prometheus_alert_rules/kubernetesControlPlane-prometheusRule.yaml
  • charms/worker/k8s/src/protocols.py
  • charms/worker/k8s/src/reschedule.py
  • charms/worker/k8s/src/snap.py
  • charms/worker/k8s/src/token_distributor.py
  • charms/worker/k8s/src/upgrade.py
  • charms/worker/k8s/templates/cos_roles.yaml
  • charms/worker/k8s/templates/ksm.yaml
  • charms/worker/k8s/templates/snap_installation.yaml
  • charms/worker/k8s/terraform/main.tf
  • charms/worker/k8s/terraform/outputs.tf
  • charms/worker/k8s/terraform/variables.tf
  • charms/worker/k8s/terraform/versions.tf
  • charms/worker/k8s/tests/unit/test_base.py
  • charms/worker/k8s/tests/unit/test_cloud_integration.py
  • charms/worker/k8s/tests/unit/test_config_options.py
  • charms/worker/k8s/tests/unit/test_containerd.py
  • charms/worker/k8s/tests/unit/test_inspector.py
  • charms/worker/k8s/tests/unit/test_k8sd_api_manager.py
  • charms/worker/k8s/tests/unit/test_reschedule.py
  • charms/worker/k8s/tests/unit/test_snap.py
  • charms/worker/k8s/tests/unit/test_token_distributor.py
  • charms/worker/k8s/tests/unit/test_upgrade.py
  • charms/worker/terraform/main.tf
  • charms/worker/terraform/outputs.tf
  • charms/worker/terraform/variables.tf
  • charms/worker/terraform/versions.tf
  • generate-src-docs.sh
  • tests/integration/init.py
  • tests/integration/conftest.py
  • tests/integration/cos_substrate.py
  • tests/integration/data/cos-offers-overlay.yaml
  • tests/integration/data/k8s.profile
  • tests/integration/data/microk8s.profile
  • tests/integration/data/static-proxy-config.yaml
  • tests/integration/data/test-bundle-ceph.yaml
  • tests/integration/data/test-bundle-etcd.yaml
  • tests/integration/data/test-bundle.yaml
  • tests/integration/data/test_ceph/ceph-xfs-pvc.yaml
  • tests/integration/data/test_ceph/pv-reader-pod.yaml
  • tests/integration/data/test_ceph/pv-writer-pod.yaml
  • tests/integration/grafana.py
  • tests/integration/helpers.py
  • tests/integration/prometheus.py
  • tests/integration/test_ceph.py
  • tests/integration/test_etcd.py
  • tests/integration/test_k8s.py
  • tests/integration/test_upgrade.py
Use this command to fix any missing license headers
```bash

docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix

</details>

@addyess addyess force-pushed the KU-2417/skip-if-cloud-markers branch 3 times, most recently from acb52b3 to 3e1cfb2 Compare January 17, 2025 04:13
@addyess addyess force-pushed the KU-2417/skip-if-cloud-markers branch from 29d933d to abe3b91 Compare January 21, 2025 14:50
Copy link
Contributor

Test coverage for abe3b91

coverage-report: install_deps /home/runner/work/k8s-operator/k8s-operator/charms/worker/k8s> /home/runner/.local/share/uv/tools/tox/bin/uv pip install 'coverage[toml]'
coverage-report: commands[0] /home/runner/work/k8s-operator/k8s-operator/charms/worker/k8s> coverage report
Name                                    Stmts   Miss  Cover
-----------------------------------------------------------
lib/charms/k8s/v0/k8sd_api_manager.py     286     29    90%
src/charm.py                              501    260    48%
src/cloud_integration.py                   80      3    96%
src/config/extra_args.py                   31      2    94%
src/containerd.py                         140     22    84%
src/cos_integration.py                     33     12    64%
src/events/update_status.py                68     24    65%
src/inspector.py                           41      4    90%
src/kube_control.py                        43     32    26%
src/literals.py                            25      0   100%
src/protocols.py                           28      5    82%
src/reschedule.py                          77      4    95%
src/snap.py                               193     29    85%
src/token_distributor.py                  181    109    40%
src/upgrade.py                            108     48    56%
-----------------------------------------------------------
TOTAL                                    1835    583    68%
coverage-report: OK (0.30=setup[0.03]+cmd[0.28] seconds)
congratulations :) (0.35 seconds)

Static code analysis report

Run started:2025-01-21 14:51:02.925751

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 3910
  Total lines skipped (#nosec): 3
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I probably would have used test tags to mark tests for specific clouds but this also works.
Great work @addyess

@addyess addyess merged commit 1376086 into main Jan 22, 2025
70 checks passed
@addyess addyess deleted the KU-2417/skip-if-cloud-markers branch January 22, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants