Skip to content

[test]: add mock for test #1887

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

Closed

Conversation

SamYuan1990
Copy link
Collaborator

should we consider using mock to increasing our test coverage?

maryamtahhan and others added 30 commits August 8, 2024 08:21
Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
Signed-off-by: Anthony Harivel <aharivel@redhat.com>
By default the name chosen to define the Virtual Machine ID is the one
found in /proc/<pid>/cgroup/.

Many IaaS platform like Openstack use metadata in libvirt to customise
among other things the instance's ID.

Allow the user to use the metadata in libvirt to set the name of the
vm metrics and gives a better user experience.

Set "LIBVIRT_METADATA_URI" with the uri of the XML namespace identifier.
Set "LIBVIRT_METADATA_TOKEN" to choose the string used for VM ID. By
default, the token "name" is used.

Signed-off-by: Anthony Harivel <aharivel@redhat.com>
Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
…move-model-globals

chore: cleanup globals in pkg/model
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
…gister-new-process

fix(bpf): use prev_tgid to register process
Update the register counters one step before metrics sample is taken
  instead of updating registers every time which is increasing overhead

Signed-off-by: Vimal Kumar <vimal78@gmail.com>
…1 updates

Bumps the go-dependencies group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [github.com/beevik/etree](https://github.com/beevik/etree) | `1.4.0` | `1.4.1` |
| [github.com/cilium/ebpf](https://github.com/cilium/ebpf) | `0.15.0` | `0.16.0` |
| [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.19.1` | `2.20.0` |
| [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) | `1.19.1` | `1.20.0` |
| [github.com/prometheus/prometheus](https://github.com/prometheus/prometheus) | `0.53.1` | `0.54.0` |
| [golang.org/x/time](https://github.com/golang/time) | `0.5.0` | `0.6.0` |
| [k8s.io/api](https://github.com/kubernetes/api) | `0.29.7` | `0.29.8` |
| [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.29.7` | `0.29.8` |



Updates `github.com/beevik/etree` from 1.4.0 to 1.4.1
- [Release notes](https://github.com/beevik/etree/releases)
- [Changelog](https://github.com/beevik/etree/blob/main/RELEASE_NOTES.md)
- [Commits](beevik/etree@v1.4.0...v1.4.1)

Updates `github.com/cilium/ebpf` from 0.15.0 to 0.16.0
- [Release notes](https://github.com/cilium/ebpf/releases)
- [Commits](cilium/ebpf@v0.15.0...v0.16.0)

Updates `github.com/onsi/ginkgo/v2` from 2.19.1 to 2.20.0
- [Release notes](https://github.com/onsi/ginkgo/releases)
- [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md)
- [Commits](onsi/ginkgo@v2.19.1...v2.20.0)

Updates `github.com/prometheus/client_golang` from 1.19.1 to 1.20.0
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](prometheus/client_golang@v1.19.1...v1.20.0)

Updates `github.com/prometheus/prometheus` from 0.53.1 to 0.54.0
- [Release notes](https://github.com/prometheus/prometheus/releases)
- [Changelog](https://github.com/prometheus/prometheus/blob/main/CHANGELOG.md)
- [Commits](prometheus/prometheus@v0.53.1...v0.54.0)

Updates `golang.org/x/sys` from 0.22.0 to 0.23.0
- [Commits](golang/sys@v0.22.0...v0.23.0)

Updates `golang.org/x/time` from 0.5.0 to 0.6.0
- [Commits](golang/time@v0.5.0...v0.6.0)

Updates `k8s.io/api` from 0.29.7 to 0.29.8
- [Commits](kubernetes/api@v0.29.7...v0.29.8)

Updates `k8s.io/apimachinery` from 0.29.7 to 0.29.8
- [Commits](kubernetes/apimachinery@v0.29.7...v0.29.8)

Updates `k8s.io/client-go` from 0.29.7 to 0.29.8
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](kubernetes/client-go@v0.29.7...v0.29.8)

Updates `k8s.io/klog/v2` from 2.120.1 to 2.130.1
- [Release notes](https://github.com/kubernetes/klog/releases)
- [Changelog](https://github.com/kubernetes/klog/blob/main/RELEASE.md)
- [Commits](kubernetes/klog@v2.120.1...v2.130.1)

---
updated-dependencies:
- dependency-name: github.com/beevik/etree
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: github.com/cilium/ebpf
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/onsi/ginkgo/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: github.com/prometheus/prometheus
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: golang.org/x/time
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
- dependency-name: k8s.io/api
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: k8s.io/apimachinery
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: k8s.io/client-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: go-dependencies
- dependency-name: k8s.io/klog/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: go-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
…puting-io/dependabot/go_modules/go-dependencies-bb1f50d887

build(deps): bump the go-dependencies group across 1 directory with 11 updates
…updates

Bumps the github-actions group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `3` | `4` |
| [anchore/sbom-action](https://github.com/anchore/sbom-action) | `0.16.1` | `0.17.1` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.3.4` | `4.3.6` |
| [actions/setup-python](https://github.com/actions/setup-python) | `3` | `5` |
| [ossf/scorecard-action](https://github.com/ossf/scorecard-action) | `2.3.3` | `2.4.0` |



Updates `actions/checkout` from 3 to 4
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](actions/checkout@v3...v4)

Updates `anchore/sbom-action` from 0.16.1 to 0.17.1
- [Release notes](https://github.com/anchore/sbom-action/releases)
- [Commits](anchore/sbom-action@v0.16.1...v0.17.1)

Updates `actions/upload-artifact` from 4.3.4 to 4.3.6
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4.3.4...v4.3.6)

Updates `actions/setup-python` from 3 to 5
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v3...v5)

Updates `ossf/scorecard-action` from 2.3.3 to 2.4.0
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](ossf/scorecard-action@dc50aa9...62b2cac)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: anchore/sbom-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
…puting-io/dependabot/github_actions/github-actions-5a7b011f50

build(deps): bump the github-actions group across 1 directory with 5 updates
Signed-off-by: Sunyanan Choochotkaew <sunyanan.choochotkaew1@ibm.com>
…server-patch-1

feat: add model_name attribute to ComponentModelWeights
Signed-off-by: Sunyanan Choochotkaew <sunyanan.choochotkaew1@ibm.com>
Signed-off-by: Sunil Thaha <sthaha@redhat.com>
…r-longer-test

chore(validator): run stress test for longer
This commit introduces a workflow for testing ACPI functionality
using Equinix self-hosted runners. The workflow deploys Kepler using
mock-acpi compose setup and runs validator to ensure functionality.

Key-features:
- Workflow is triggered on pull requests that include a specific commit
  message `/test-acpi`.
- Environment setup is handled by ansible.

Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com>
…puting-io/add-acpi-wkf

feat(ci): implement mock-ACPI workflow
…server-patch-1

fix: format ComponentModelWeights
This commit moves model_weights from/var/lib/kepler/data/ to its own
directory - var/lib/kepler/data/model_weights/ this allows additional data
like machine-spec to be stored its own directory.

Additionally this change fixes the blank cpu.yaml that gets created when
running compose files.

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
…k-cpu-yaml

chore: move model_weights to its own directory
Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
This commit resolves two key issues with the mock-acpi workflow:
- Checkout correct branch: The workflow previously checkout out the
  default branch when triggered by a pull request. This fix ensures
  that the correct pull request branch is checked out during CI run.
- Attach workflow to pull request checks: The workflow was not
  being reflected under pull request checks. With this fix, the workflow
  will be correctly attached, ensuring its status visible and reported
  under pull request checks.

Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com>
…eanup-exporter-globals

chore: cleanup globals in exporter
Signed-off-by: Sunyanan Choochotkaew <sunyanan.choochotkaew1@ibm.com>
…server-patch-1

fix: set default trainer only for local regressor
…pi-wk-status

fix(ci): ensure proper status reporting for mock-acpi workflow
KaiyiLiu1234 and others added 27 commits November 18, 2024 19:22
…d-process-exporter

feat(process-exporter): Add process-exporter to dev and metal
…updates (sustainable-computing-io#1853)

Bumps the github-actions group with 2 updates in the / directory: [anchore/sbom-action](https://github.com/anchore/sbom-action) and [codecov/codecov-action](https://github.com/codecov/codecov-action).


Updates `anchore/sbom-action` from 0.17.6 to 0.17.7
- [Release notes](https://github.com/anchore/sbom-action/releases)
- [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md)
- [Commits](anchore/sbom-action@v0.17.6...v0.17.7)

Updates `codecov/codecov-action` from 4.6.0 to 5.0.2
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v4.6.0...v5.0.2)

---
updated-dependencies:
- dependency-name: anchore/sbom-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…tainable-computing-io#1855)

* [fix]: update ginkgo version in CI process keep same with go mod

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: Test Panicked with nil pointer

Signed-off-by: Sam Yuan <yy19902439@126.com>

---------

Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
* [fix]: base image elfutils version issue

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: missing base image check in CI

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: libbpf version upgrade in base image

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: update libbpf version

Signed-off-by: Sam Yuan <yy19902439@126.com>

---------

Signed-off-by: Sam Yuan <yy19902439@126.com>
Run pre-commit autoupdate and add a monthly workflow
to update hooks.

Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
…e-computing-io#1863)

Bumps the github-actions group with 3 updates: [anchore/sbom-action](https://github.com/anchore/sbom-action), [xt0rted/pull-request-comment-branch](https://github.com/xt0rted/pull-request-comment-branch) and [codecov/codecov-action](https://github.com/codecov/codecov-action).


Updates `anchore/sbom-action` from 0.17.7 to 0.17.8
- [Release notes](https://github.com/anchore/sbom-action/releases)
- [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md)
- [Commits](anchore/sbom-action@v0.17.7...v0.17.8)

Updates `xt0rted/pull-request-comment-branch` from 2 to 3
- [Release notes](https://github.com/xt0rted/pull-request-comment-branch/releases)
- [Changelog](https://github.com/xt0rted/pull-request-comment-branch/blob/main/CHANGELOG.md)
- [Commits](xt0rted/pull-request-comment-branch@v2...v3)

Updates `codecov/codecov-action` from 5.0.2 to 5.0.7
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v5.0.2...v5.0.7)

---
updated-dependencies:
- dependency-name: anchore/sbom-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: xt0rted/pull-request-comment-branch
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
…puting-io/ghapermissions

[fix]: update gha permission settings
* [fix]: add test case with darwin OS

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: use same function naming conventions and behavior

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: update with review comments

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: update contributing.md as PR review comments

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: remove unused package

Signed-off-by: Sam Yuan <yy19902439@126.com>

---------

Signed-off-by: Sam Yuan <yy19902439@126.com>
)

Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>
…puting-io/pre-commit-autoupdate

Auto-update pre-commit hooks
Bumps the github-actions group with 1 update: [jidicula/clang-format-action](https://github.com/jidicula/clang-format-action).


Updates `jidicula/clang-format-action` from 4.13.0 to 4.14.0
- [Release notes](https://github.com/jidicula/clang-format-action/releases)
- [Commits](jidicula/clang-format-action@v4.13.0...v4.14.0)

---
updated-dependencies:
- dependency-name: jidicula/clang-format-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
…puting-io/dependabot/github_actions/github-actions-d1805d1051

build(deps): bump jidicula/clang-format-action from 4.13.0 to 4.14.0 in the github-actions group
This commit migrates the mock-acpi workflow to use the
GitHub runner instead of the Equinix self-hosted runner.
Since the workflow is designed for testing ACPI functionality,
using a mock, a self-hosted runner is not required.

Running the workflow on the GitHub runner, which operates as a VM,
enables execution on every pull request, ensuring consistent validation
of ACPI functionality for Kepler.

Signed-off-by: vprashar2929 <vibhu.sharma2929@gmail.com>
…pi-wkf

chore(ci): migrate mock-acpi workflow to GH runner
* [test]: add test case on package cgroup

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: update cache setting logic when error happen

Signed-off-by: Sam Yuan <yy19902439@126.com>

* [fix]: fix lint

Signed-off-by: Sam Yuan <yy19902439@126.com>

---------

Signed-off-by: Sam Yuan <yy19902439@126.com>
Signed-off-by: Sam Yuan <yy19902439@126.com>
Copy link
Contributor

github-actions bot commented Dec 7, 2024

🤖 SeineSailor

Here is a concise summary of the pull request changes:

Summary: This pull request introduces mocking functionality for testing, updates the toolchain, and refactors test setup and teardown.

Key Modifications:

  1. Mocking functionality: The go.uber.org/mock package (v0.5.0) is added, enabling mocking for testing purposes. Generated mocks for kubelet and cgroup packages improve test coverage and flexibility.
  2. Toolchain update: The Go version is updated from 1.21.9 to 1.23.1.
  3. Test setup and teardown refactoring: The BeforeSuite setup is removed, potentially affecting test behavior.

Impact on Codebase:

  • Improved test coverage and flexibility with mocking functionality
  • Updated toolchain may introduce compatibility changes
  • Refactored test setup and teardown may require adjustments to test code

Suggestions for Improvement:

  • Ensure thorough testing of the updated code to catch any compatibility issues
  • Review and update existing test code to leverage the new mocking functionality
  • Consider adding documentation or comments to explain the reasoning behind the test setup and teardown changes

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.