Skip to content

Added integration tests#481

Merged
Sharpz7 merged 8 commits into
openstack-exporter:mainfrom
Sharpz7:integration-tests
May 6, 2026
Merged

Added integration tests#481
Sharpz7 merged 8 commits into
openstack-exporter:mainfrom
Sharpz7:integration-tests

Conversation

@Sharpz7
Copy link
Copy Markdown
Collaborator

@Sharpz7 Sharpz7 commented Sep 3, 2025

This should help make trusting new changes easier.

@Sharpz7 Sharpz7 added the priority Priority PR or Issue to help with tracking. label Sep 3, 2025
@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Sep 3, 2025

This is copying a significant amount of code from https://github.com/gophercloud/gophercloud/tree/main/internal/acceptance. I am going to create a ticket there about potentially trying to expose this code out instead of copying it.

@Sharpz7 Sharpz7 removed the priority Priority PR or Issue to help with tracking. label Sep 3, 2025
@Sharpz7 Sharpz7 marked this pull request as draft September 3, 2025 04:18
This was referenced Oct 30, 2025
@Sharpz7 Sharpz7 marked this pull request as ready for review December 2, 2025 04:43
@Sharpz7 Sharpz7 requested a review from Copilot December 2, 2025 04:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces comprehensive integration tests for the OpenStack exporter, enabling automated testing against live OpenStack services (Ironic, Nova, Neutron, Glance, Keystone, Placement) via DevStack in CI. The tests validate that the exporter correctly generates Prometheus metrics from real OpenStack resources.

Key Changes

  • Added integration test infrastructure with helper packages for creating test resources and clients
  • Created service-specific integration test suites (baremetal, compute, networking, images, identity, placement)
  • Set up GitHub Actions workflows to run integration tests on pull requests using DevStack

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
script/stackenv Bash script to prepare DevStack testing environment with required resources and environment variables
script/integration-suites/* Individual test runner scripts for each OpenStack service integration test suite
script/collectlogs Utility script to collect diagnostic logs after integration test failures
integration/utils.go Core integration test utilities for starting the OpenStack exporter
integration/tools/tools.go Helper functions for waiting, random generation, and resource printing in tests
integration/tools/pkg.go Build tags and package documentation for test tools
integration/funcs/compute.go Helper functions for creating and managing compute resources in tests
integration/funcs/baremetal.go Helper functions for creating and managing baremetal nodes in tests
integration/funcs/pkg.go Build tags and package documentation for test resource functions
integration/clients/clients.go OpenStack service client creation functions for various services
integration/clients/conditions.go Test skip conditions for different OpenStack configurations and features
integration/clients/http.go HTTP round tripper with request/response logging and header redaction
integration/*_test.go Integration test files validating exporter metrics for each OpenStack service
.github/workflows/integration-*.yaml GitHub Actions workflows for running integration tests in CI
.github/workflows/ci.yaml Updated to exclude integration tests from unit test runs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread script/integration-suites/image
Comment thread script/integration-suites/compute
Comment thread script/integration-suites/baremetal
Comment thread integration/networking_test.go Outdated
Comment thread integration/clients/http.go Outdated
Comment thread integration/utils.go
Comment thread integration/clients/http.go Outdated
Comment thread integration/utils.go
Comment thread script/stackenv
Comment thread script/stackenv
@openstack-exporter openstack-exporter deleted a comment from Copilot AI Dec 2, 2025
CI Fixes

Fixing more lint errors

Tried to make tests more specific

Fixed issues

Fixes

Fixes

More fixes

Trying more

Test

Fix

Testing

Testing

Changes

Removing placement

Trying things out

More changes

Testing

Trying things

Fixes

Fixes

chore(deps): bump actions/checkout from 4 to 6

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](actions/checkout@v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Update integration/funcs/compute.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Update script/stackenv

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

chore(deps): bump reviewdog/action-actionlint from 1.66.1 to 1.69.0

Bumps [reviewdog/action-actionlint](https://github.com/reviewdog/action-actionlint) from 1.66.1 to 1.69.0.
- [Release notes](https://github.com/reviewdog/action-actionlint/releases)
- [Commits](reviewdog/action-actionlint@e37e2ca...437bbe9)

---
updated-dependencies:
- dependency-name: reviewdog/action-actionlint
  dependency-version: 1.69.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@openstack-exporter openstack-exporter deleted a comment from Copilot AI Dec 2, 2025
@openstack-exporter openstack-exporter deleted a comment from Copilot AI Dec 2, 2025
@openstack-exporter openstack-exporter deleted a comment from Copilot AI Dec 2, 2025
@openstack-exporter openstack-exporter deleted a comment from Copilot AI Dec 2, 2025
@openstack-exporter openstack-exporter deleted a comment from Copilot AI Dec 2, 2025
@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Dec 2, 2025

Service Test Name Coverage
Baremetal (Ironic) TestBaremetalIntegration openstack_ironic_node metric with labels (console_enabled, deploy_kernel, deploy_ramdisk, id, maintenance, name, power_state, provision_state, resource_class, retired, retired_reason); openstack_ironic_up metric; metric metadata (HELP and TYPE comments)
Compute (Nova) TestComputeIntegration openstack_nova_server_status metric for specific server; openstack_nova_total_vms metric; openstack_nova_server_local_gb metric; availability_zone label on server status; openstack_nova_quota_instances for admin tenant; openstack_nova_quota_key_pairs limit for admin tenant
Identity (Keystone) TestIdentityIntegration openstack_identity_up metric with value 1; metric metadata (HELP and TYPE comments); core metrics presence (openstack_identity_projects, openstack_identity_users, openstack_identity_domains); openstack_identity_project_info line format with labels (id, name, domain_id, enabled, parent_id)
Image (Glance) TestImagesIntegration openstack_glance_up metric with value 1; metric metadata (HELP and TYPE comments); core metrics presence (openstack_glance_images, openstack_glance_image_bytes, openstack_glance_image_created_at); openstack_glance_image_bytes line format; openstack_glance_image_created_at line format with labels (hidden, id, name, status, tenant_id, visibility)
Network (Neutron) TestNetworkingIntegration openstack_neutron_up metric with value 1; metric metadata (HELP and TYPE comments); core metrics presence (openstack_neutron_networks, openstack_neutron_ports, openstack_neutron_subnets, openstack_neutron_router); openstack_neutron_network line format with labels (id, name, is_external, is_shared, provider_network_type)

@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Dec 2, 2025

I think the main thing to not is BASIS_OPS for ironic is false. For some reason, this makes the tests pass, where they didn't before

@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Dec 4, 2025

@vooon - I'd appreciate your feedback on this in any capacity

Copy link
Copy Markdown
Contributor

@vooon vooon left a comment

Choose a reason for hiding this comment

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

@Sharpz7 here are a few notes.

Also might be helpful to setup slog to show debug.

Comment thread .github/workflows/integration-baremetal.yml Outdated
Comment thread integration/baremetal_test.go Outdated
Comment thread integration/baremetal_test.go Outdated
Comment thread integration/clients/clients.go Outdated
Comment thread integration/clients/http.go Outdated
@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Dec 5, 2025

@vooon appreciate this. Thank you!

Copy link
Copy Markdown

@ClifHouck ClifHouck left a comment

Choose a reason for hiding this comment

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

I mostly skimmed this. It looks fine on the surface, you can always disable it later or correct things if there's flakiness.

Comment thread integration/funcs/compute.go
@Sharpz7 Sharpz7 requested review from ClifHouck and vooon April 6, 2026 20:21
@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Apr 6, 2026

@vooon @ClifHouck I'll merge after a final approval from either of you, I think this in its present state is better than nothing

Copy link
Copy Markdown
Contributor

@vooon vooon left a comment

Choose a reason for hiding this comment

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

Maybe better to parse prom text and then validate lables/metrics that way instead of simple "contains" in body?
But overall looks good.

Comment thread .github/workflows/ci.yaml
run: |
go test -v -covermode=atomic -coverprofile=coverage.out ./...
mapfile -t packages < <(go list ./... | grep -v '/integration')
go test -v -covermode=atomic -coverprofile=coverage.out "${packages[@]}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not to use something like that in integration tests?

//go:build acceptance

Comment thread script/collectlogs
sudo journalctl -o short-precise --no-pager &> "$LOG_DIR/journal.log"
# shellcheck disable=SC2024
sudo systemctl status "devstack@*" &> "$LOG_DIR/devstack-services.txt"
for service in $(systemctl list-units --output json devstack@* | jq -r '.[].unit | capture("devstack@(?<svc>[a-z\\-]+).service") | '.svc'')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Single quotes around .svc ambiguous and maybe unneeded.

Comment thread script/stackenv
EOL

if _=$(openstack service list | grep container-infra); then
_MAGNUM_IMAGE_ID=$(openstack image list --format value -c Name -c ID | grep coreos | cut -d ' ' -f 1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use filter by property or tag:

openstack image list --property os_distro=fedora-coreos

@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Apr 8, 2026

Honestly @vooon I ripped all of this from gophercloud - if it is good enough for them, its good enough for me. I will note these comments for future work in #548

@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented Apr 8, 2026

@mnaser @niedbalski I intend to merge on or after 14th April. If I don't hear from either of you, I will self merge this

@WizardBit
Copy link
Copy Markdown

Just a bump if this will get merged as the month is ending.

@Sharpz7 Sharpz7 merged commit e64dc81 into openstack-exporter:main May 6, 2026
11 checks passed
@Sharpz7
Copy link
Copy Markdown
Collaborator Author

Sharpz7 commented May 6, 2026

@WizardBit pushed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants