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

tests(pam/testutils): Integration tests for the PAM CLI #109

Merged
merged 8 commits into from
Jan 11, 2024

Conversation

denisonbarbosa
Copy link
Member

This adds integration tests for the PAM module and moves some code around to avoid copying and maintain consistency between our integration tests.
The golden files are ASCII representations of terminal screenshots, so don't get scared by the number of lines changed (I promise it will be okay).

UDENG-1456

@denisonbarbosa
Copy link
Member Author

denisonbarbosa commented Nov 21, 2023

I could extract the testutils changes to another pull request if they seem too much for this one. I didn't do it yet because I thought it would feel like an "empty" change in main.

@denisonbarbosa denisonbarbosa force-pushed the integration-tests-pam branch 13 times, most recently from 5385449 to 6619df5 Compare November 27, 2023 17:41
@denisonbarbosa denisonbarbosa marked this pull request as ready for review November 27, 2023 17:46
@denisonbarbosa denisonbarbosa requested a review from a team as a code owner November 27, 2023 17:46
@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (8b3c1cd) 88.62% compared to head (23d4351) 83.21%.
Report is 43 commits behind head on main.

Files Patch % Lines
internal/users/withgpasswdmock.go 77.77% 1 Missing and 1 partial ⚠️
internal/brokers/examplebroker/broker.go 97.43% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #109      +/-   ##
==========================================
- Coverage   88.62%   83.21%   -5.42%     
==========================================
  Files          34       56      +22     
  Lines        2532     4473    +1941     
==========================================
+ Hits         2244     3722    +1478     
- Misses        221      583     +362     
- Partials       67      168     +101     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@GabrielNagy GabrielNagy left a comment

Choose a reason for hiding this comment

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

Great work! Nice to see the vhs thing working in the end. I left my comments inline

.github/workflows/qa.yaml Outdated Show resolved Hide resolved
pam/integration-tests/integration_test.go Outdated Show resolved Hide resolved
pam/integration-tests/integration_test.go Outdated Show resolved Hide resolved
@3v1n0
Copy link
Collaborator

3v1n0 commented Nov 29, 2023

I didn't go through the vhs docs yet, but maybe it would be convenient adding a README.md to the testdata folder how to generate or update the recorded files?

@denisonbarbosa
Copy link
Member Author

I didn't go through the vhs docs yet, but maybe it would be convenient adding a README.md to the testdata folder how to generate or update the recorded files?

I don't really like adding assets that are not related to the tests themselves inside testdata/. If you feel like it's necessary to point to the vhs documentation, I could add a line comment inside the TestIntegration function (before spawning the vhs subprocess) explaining that we rely on the tool and pointing to their documentation, WDYT?

@3v1n0
Copy link
Collaborator

3v1n0 commented Nov 29, 2023

I didn't go through the vhs docs yet, but maybe it would be convenient adding a README.md to the testdata folder how to generate or update the recorded files?

I don't really like adding assets that are not related to the tests themselves inside testdata/. If you feel like it's necessary to point to the vhs documentation, I could add a line comment inside the TestIntegration function (before spawning the vhs subprocess) explaining that we rely on the tool and pointing to their documentation, WDYT?

Well I'm not sure where is the right place, in other projects I contribute or mantain we normally keep a readme in the places the artifacts are so that it's easy for everyone to find out how those are generated.

However, I'm fine with other options too, I just think it's important to have the process documented so that when others will have to regenerate them can figure it out easily.

@didrocks
Copy link
Member

I didn't go through the vhs docs yet, but maybe it would be convenient adding a README.md to the testdata folder how to generate or update the recorded files?

I don't really like adding assets that are not related to the tests themselves inside testdata/. If you feel like it's necessary to point to the vhs documentation, I could add a line comment inside the TestIntegration function (before spawning the vhs subprocess) explaining that we rely on the tool and pointing to their documentation, WDYT?

Well I'm not sure where is the right place, in other projects I contribute or mantain we normally keep a readme in the places the artifacts are so that it's easy for everyone to find out how those are generated.

However, I'm fine with other options too, I just think it's important to have the process documented so that when others will have to regenerate them can figure it out easily.

Note: I didn’t look at any comments than this exchange.

I think this is the perfect place for the contributing guide on "how to refresh blablabla" (same for golden files btw)

Copy link
Contributor

@GabrielNagy GabrielNagy left a comment

Choose a reason for hiding this comment

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

Great job on this! Can we ensure debian packaging works properly with these changes as well?

pam/integration-tests/integration_test.go Outdated Show resolved Hide resolved
@3v1n0
Copy link
Collaborator

3v1n0 commented Dec 13, 2023

I didn't go through the vhs docs yet, but maybe it would be convenient adding a README.md to the testdata folder how to generate or update the recorded files?

I don't really like adding assets that are not related to the tests themselves inside testdata/. If you feel like it's necessary to point to the vhs documentation, I could add a line comment inside the TestIntegration function (before spawning the vhs subprocess) explaining that we rely on the tool and pointing to their documentation, WDYT?

Well I'm not sure where is the right place, in other projects I contribute or mantain we normally keep a readme in the places the artifacts are so that it's easy for everyone to find out how those are generated.
However, I'm fine with other options too, I just think it's important to have the process documented so that when others will have to regenerate them can figure it out easily.

Note: I didn’t look at any comments than this exchange.

I think this is the perfect place for the contributing guide on "how to refresh blablabla" (same for golden files btw)

@denisonbarbosa I was quickly grepping on the diff and I didn't notice anything related to this, is the process documented now?

Copy link
Collaborator

@3v1n0 3v1n0 left a comment

Choose a reason for hiding this comment

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

I think we're there, I've spotted few tiny things.

pam/integration-tests/integration_test.go Show resolved Hide resolved
internal/testutils/daemon.go Outdated Show resolved Hide resolved
.github/workflows/qa.yaml Outdated Show resolved Hide resolved
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

I think I was able to review every changes since the rebase. I have only 2 minor comments and then, we’ll be good from my side of things!

internal/users/withoutgpasswdmock.go Outdated Show resolved Hide resolved
.github/workflows/qa.yaml Show resolved Hide resolved
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

All good from my side! Of course, needs to solve the conflict while rebasing, but otherwise, good! :)

Copy link
Contributor

@GabrielNagy GabrielNagy left a comment

Choose a reason for hiding this comment

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

Looks good to me, great work here!

Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

I think Gabriel is right, we need to skip them during autopkgtests too.

debian/rules Show resolved Hide resolved
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Great work! Once fixing the conflicts and rebase, you can merge :)

CONTRIBUTING.md Show resolved Hide resolved
We wrote some helper functions for the NSS integration tests, but they
will be helpful for the PAM integration tests as well. So, in order to
avoid copying code and then having to maintain both helpers, it's better
to move the helpers to testutils.
We need to install vhs and ttyd to run the integration tests in the CI
and also export an environment variable to build the PAM module without
any warnings
The CLI tests rely on external dependencies to run and they are not
available in the archive, so we must skip them on environments that do
not support external sources.
Since we rely on the mock to test some behaviors in the CLI tests, we
have to be able to build the binary with the mock. This now is doable by
using the "integrationtests" build tag.
@denisonbarbosa denisonbarbosa merged commit edc6202 into main Jan 11, 2024
5 checks passed
@denisonbarbosa denisonbarbosa deleted the integration-tests-pam branch January 11, 2024 15:10
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.

5 participants