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

[receiver/kubeletstats] Improve unit test assertions #27468

Closed
TylerHelmuth opened this issue Oct 6, 2023 · 5 comments · Fixed by #30348
Closed

[receiver/kubeletstats] Improve unit test assertions #27468

TylerHelmuth opened this issue Oct 6, 2023 · 5 comments · Fixed by #30348
Assignees

Comments

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Oct 6, 2023

I see. Thanks for clarifying. Given that `fakeRestClient` provides static values, I think we should generate pdata output and use it for validation the way we do it in most oh other tests. Maybe worth filing an issue with `good first issue` label for this. WDYT?

Originally posted by @dmitryax in #27276 (comment)

Currently the unit tests in scraper_test.go check the results of scraping by cycling through the returned metrics. The tests could be improved by comparing the ResourceMetrics returned by .Scrape() with a expected ResourceMetrics struct that is setup by the test.

@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed good first issue Good for newcomers test coverage Improve test coverage receiver/kubeletstats labels Oct 6, 2023
@TylerHelmuth TylerHelmuth added Contribfest and removed help wanted Extra attention is needed good first issue Good for newcomers labels Oct 23, 2023
@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 13, 2023
@hamzmu
Copy link
Contributor

hamzmu commented Jan 8, 2024

@TylerHelmuth is this issue still open?

@TylerHelmuth
Copy link
Member Author

@hamzmu yes, would you like to work on it?

@hamzmu
Copy link
Contributor

hamzmu commented Jan 8, 2024

yes can i work on it. thanks

@ChrsMark
Copy link
Member

ChrsMark commented Jan 9, 2024

Ah sorry folks, didn't claim the issue when I started working on this yesterday (#30348) before @hamzmu 's comments here 😞 . My bad.

@dmitryax
Copy link
Member

dmitryax commented Jan 9, 2024

Reassigning to @ChrsMark as there is an open PR already

@dmitryax dmitryax assigned ChrsMark and unassigned hamzmu Jan 9, 2024
dmitryax pushed a commit that referenced this issue Jan 11, 2024
…#30348)

**Description:**
This PR introduces the usage of pdata and golden files within the unit
tests of the `kubeletstats` receiver. Insted of manually asserting the
unit-tests' results and having the expected values hard-coded within the
tests we use generated pdata stored in golden files to improve the
assertions by using the
[`pdatatest`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/c87856083e3afa11cd35dbd9cbb8fbda0194fbf4/pkg/pdatatest/README.md#L11)
helper functions.

**Link to tracking Issue:**
Fixes
#27468

**Testing:** <Describe what testing was performed and which tests were
added.>
Unit tests being improved.

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this issue Feb 1, 2024
…open-telemetry#30348)

**Description:**
This PR introduces the usage of pdata and golden files within the unit
tests of the `kubeletstats` receiver. Insted of manually asserting the
unit-tests' results and having the expected values hard-coded within the
tests we use generated pdata stored in golden files to improve the
assertions by using the
[`pdatatest`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/c87856083e3afa11cd35dbd9cbb8fbda0194fbf4/pkg/pdatatest/README.md#L11)
helper functions.

**Link to tracking Issue:**
Fixes
open-telemetry#27468

**Testing:** <Describe what testing was performed and which tests were
added.>
Unit tests being improved.

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants