Skip to content

Conversation

adombeck
Copy link
Contributor

@adombeck adombeck commented Aug 28, 2025

Changes for improved debuggability, test execution time, and maintainability, including:

  • Lots of improvements to the logs printed by the tests.
  • Avoid unnecessary rebuilds
  • Refactorings

UDENG-8137

@adombeck adombeck force-pushed the improve-ssh-tests branch 11 times, most recently from 7762549 to 28f1faa Compare September 1, 2025 13:35
@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 67.03297% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.74%. Comparing base (3d2b788) to head (70b6f72).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
internal/testlog/testlog.go 59.70% 27 Missing ⚠️
pam/internal/adapter/nativemodel.go 60.00% 2 Missing ⚠️
log/journal.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1046      +/-   ##
==========================================
- Coverage   88.04%   87.74%   -0.30%     
==========================================
  Files          85       87       +2     
  Lines        6039     6112      +73     
  Branches      111      111              
==========================================
+ Hits         5317     5363      +46     
- Misses        666      693      +27     
  Partials       56       56              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adombeck adombeck force-pushed the improve-ssh-tests branch 16 times, most recently from f1d6e86 to a0718d1 Compare September 2, 2025 17:05
To avoid having to pass it to each method call.
We never use more than one output, so let's simplify things a bit.
It's a bit hidden in there. Let's move it to the caller so we don't
wonder in the caller whether the tape is saved as an artifact or not.
When running sshd in daemon mode, the child processes it spawns for
handling ssh connections do not print logs to the log file, and their
stderr is not connected, so the log messages are lost.

By running sshd in the foreground via -D, and making it log to stderr
via -e, we get both the main processes and all child processes logs
printed to stderr.
The service name is used as the filename of the artifact, where
"authd-cli" doesn't make it clear that this is a PAM service file.
... but only print debug1 messages to stderr, to avoid spamming the test
output too much. This can be configured via the
AUTHD_SSHD_STDERR_DEBUG_LEVEL environment variable.
We were building everything twice, because testSSHAuthenticate is called
twice (once with sharedSSHD set to true and once set to false).
We were printing "Building PAM module" when we were building the
sshd_preloader library.
Output written directly to stdout/stderr is sometimes assigned to the
wrong test, even when using `go test -json`. Using `t.Log` instead
should avoid the problem.
This makes our own TestWriter obsolete. Also has the effect that the
output written via this is not prefixed with the file and line, which
makes it a lot more readable.
And use it when running gcov, because its output is a bit verbose and
unhelpful when there is no error.
I've seen this test time out in the CI.
So that we're able to use them from other packages than the
pam/integration-tests.
Writing both stdout and stderr to the same file causes a data race. Lets
use our SyncBuffer instead.
It failed with that error in CI:

      ssh_test.go:491:
          	Error Trace:	/home/runner/work/authd/authd/pam/integration-tests/ssh_test.go:795
          	            				/home/runner/work/authd/authd/pam/integration-tests/ssh_test.go:659
          	            				/home/runner/work/authd/authd/pam/integration-tests/ssh_test.go:491
          	            				/home/runner/work/authd/authd/internal/testutils/testrun.go:83
          	Error:      	Received unexpected error:
          	            	dial tcp :35523: connect: connection reset by peer
          	Test:       	TestSSHAuthenticate/Authenticate_user_switching_auth_mode
The tool's spelling is VHS, not vhs, so let's use that.
The function name RunAuthd made it seem like it would block until authd
has finished, which is not the case. StartAuthd makes it clear that the
function returns once authd was started.
@adombeck adombeck changed the title Improve SSH tests Improve SSH integration tests Sep 25, 2025
@adombeck adombeck changed the title Improve SSH integration tests Make SSH integration tests easier to debug Sep 25, 2025
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