Skip to content

Integrate fake logger with test configuration.#473

Merged
jonasbardino merged 26 commits intonextfrom
test/integrate-fake-logger-with-test-configuration
Mar 9, 2026
Merged

Integrate fake logger with test configuration.#473
jonasbardino merged 26 commits intonextfrom
test/integrate-fake-logger-with-test-configuration

Conversation

@albu-diku
Copy link
Contributor

@albu-diku albu-diku commented Mar 2, 2026

Early in the introduction of the supporting libraries, the notion of a FakeLogger was introduced. This is an object that is usable as a substitute .logger property on the MiG configuration and will capture anything output for each channel for the purposes of being able to assert against later.

Almost all codepaths which handle internal error conditions send messages to the error channel. Thus, we can use the presence of messages in the error channel (or lack thereof) as a proxy for whether anything internal went wrong. The wiring to assert no errors were recorded has been there since the initial introduction of FakeLogger, but in order for it to kick in we must be using the instance for the duration of each test case.

The missing piece was ensuring that when we request the "testconfig" via a _provide_configuration() call that we assign the test logger. This commit does that and hence integrates them correctly. Doing so catches a number of cases where we either fail to account for error messages or had conditions causing unexpected errors to be generated - these are repaired here as well.

@albu-diku albu-diku force-pushed the test/integrate-fake-logger-with-test-configuration branch from 3ef3f7f to a63356d Compare March 3, 2026 16:19
@albu-diku
Copy link
Contributor Author

albu-diku commented Mar 4, 2026

@jonasbardino This is the branch I referenced earlier - battening down this particular hatch is surfacing some otherwise silent errors, and I could use second eyes in assessing whether behavioural issues are being highlighted.

There are some issues with a common cause being highlighted - my suggestion is using ./envhelp/lpython -m unittest discover ./tests -f within a checkout to run until the first failure and stop.

The first one I'm seeing that looks decidedly suspect is in grid_events, where banning error logs is catching the following:

RuntimeError: errors reported to logger:
(31894) text formating failed: id() takes exactly one argument (4 given)
raw output is: ...

Copy link
Contributor

@jonasbardino jonasbardino left a comment

Choose a reason for hiding this comment

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

Looks fine but I'll take a look at the tests as suggested before approving.

@albu-diku
Copy link
Contributor Author

@jonasbardino are you sure about that diagnoses wrt the grid events tests? I don’t know the code very well, but reading it I did see it appears to be calling id with multiple arguments in the text formatting case.

I’ll add the fabrication empty settings files here and see what the situation is, but I don’t immediately see how text formatting would be changed. Could I ask you to read over that again?

@jonasbardino
Copy link
Contributor

@jonasbardino are you sure about that diagnoses wrt the grid events tests? I don’t know the code very well, but reading it I did see it appears to be calling id with multiple arguments in the text formatting case.

I’ll add the fabrication empty settings files here and see what the situation is, but I don’t immediately see how text formatting would be changed. Could I ask you to read over that again?

I'll look into it. I already identified and fixed some issues in test_mig_shared_vgrid.py with missing mig_system_files dir and the use of vgrid_add_X over vgrid_set_X causing log noise and therefore failing with extended log monitoring.

@albu-diku
Copy link
Contributor Author

@jonasbardino are you sure about that diagnoses wrt the grid events tests? I don’t know the code very well, but reading it I did see it appears to be calling id with multiple arguments in the text formatting case.
I’ll add the fabrication empty settings files here and see what the situation is, but I don’t immediately see how text formatting would be changed. Could I ask you to read over that again?

I'll look into it. I already identified and fixed some issues in test_mig_shared_vgrid.py with missing mig_system_files dir and the use of vgrid_add_X over vgrid_set_X causing log noise and therefore failing with extended log monitoring.

Great and thanks. Can see bits and pieces trickling in (though haven’t had a chance to look deeply at them yet for transparency) which is great - think this tightening will serve us well going forward!

I’ll obviously contribute to straightening out the machinery and patching things wherever I can, so let me know what I can handle as part of the joint exercise :)

@albu-diku albu-diku changed the title Test/integrate fake logger with test configuration Integrate fake logger with test configuration. Mar 8, 2026
@jonasbardino
Copy link
Contributor

@jonasbardino are you sure about that diagnoses wrt the grid events tests? I don’t know the code very well, but reading it I did see it appears to be calling id with multiple arguments in the text formatting case.
I’ll add the fabrication empty settings files here and see what the situation is, but I don’t immediately see how text formatting would be changed. Could I ask you to read over that again?

I'll look into it. I already identified and fixed some issues in test_mig_shared_vgrid.py with missing mig_system_files dir and the use of vgrid_add_X over vgrid_set_X causing log noise and therefore failing with extended log monitoring.

Great and thanks. Can see bits and pieces trickling in (though haven’t had a chance to look deeply at them yet for transparency) which is great - think this tightening will serve us well going forward!

I’ll obviously contribute to straightening out the machinery and patching things wherever I can, so let me know what I can handle as part of the joint exercise :)

AFAICT the failing id(X) calls come from the events command lookup failing as expected when a bogus command is provided. Then it defaults to the id function rather than a matching actual backend main function. It probably needs some more work to iron out or adjust for a clean exit. I'll continue later.

@albu-diku
Copy link
Contributor Author

I've added a detailed description that explains the context and the changes being made here.

@albu-diku
Copy link
Contributor Author

@jonasbardino are you sure about that diagnoses wrt the grid events tests? I don’t know the code very well, but reading it I did see it appears to be calling id with multiple arguments in the text formatting case.
I’ll add the fabrication empty settings files here and see what the situation is, but I don’t immediately see how text formatting would be changed. Could I ask you to read over that again?

I'll look into it. I already identified and fixed some issues in test_mig_shared_vgrid.py with missing mig_system_files dir and the use of vgrid_add_X over vgrid_set_X causing log noise and therefore failing with extended log monitoring.

Great and thanks. Can see bits and pieces trickling in (though haven’t had a chance to look deeply at them yet for transparency) which is great - think this tightening will serve us well going forward!
I’ll obviously contribute to straightening out the machinery and patching things wherever I can, so let me know what I can handle as part of the joint exercise :)

AFAICT the failing id(X) calls come from the events command lookup failing as expected when a bogus command is provided. Then it defaults to the id function rather than a matching actual backend main function. It probably needs some more work to iron out or adjust for a clean exit. I'll continue later.

Cool - do yo want me to do something there or shall I leave that to you now you're looking at it?

jonasbardino added a commit that referenced this pull request Mar 8, 2026
…bly a

copy/paste error from doing the same for `main`. Sync `main` init to use `None`
as well like in the cron runner.
This should fix a number of errors uncovered in #473, too.
@jonasbardino
Copy link
Contributor

@jonasbardino are you sure about that diagnoses wrt the grid events tests? I don’t know the code very well, but reading it I did see it appears to be calling id with multiple arguments in the text formatting case.
I’ll add the fabrication empty settings files here and see what the situation is, but I don’t immediately see how text formatting would be changed. Could I ask you to read over that again?

I'll look into it. I already identified and fixed some issues in test_mig_shared_vgrid.py with missing mig_system_files dir and the use of vgrid_add_X over vgrid_set_X causing log noise and therefore failing with extended log monitoring.

Great and thanks. Can see bits and pieces trickling in (though haven’t had a chance to look deeply at them yet for transparency) which is great - think this tightening will serve us well going forward!
I’ll obviously contribute to straightening out the machinery and patching things wherever I can, so let me know what I can handle as part of the joint exercise :)

AFAICT the failing id(X) calls come from the events command lookup failing as expected when a bogus command is provided. Then it defaults to the id function rather than a matching actual backend main function. It probably needs some more work to iron out or adjust for a clean exit. I'll continue later.

Cool - do yo want me to do something there or shall I leave that to you now you're looking at it?

Alright, it turned out to be only slightly similar cases of ending up with id for txt_output in valid tests. I believe I've fixed the underlying bug with #479 and we should merge that in here as well to resolve those error logs.

jonasbardino added a commit that referenced this pull request Mar 9, 2026
…bly a

copy/paste error from doing the same for `main`. Sync `main` init to use `None`
as well like in the cron runner.
This should fix a number of errors uncovered in #473, too.
@jonasbardino jonasbardino force-pushed the test/integrate-fake-logger-with-test-configuration branch from ce8b7d0 to d7073fb Compare March 9, 2026 10:32
jonasbardino added a commit that referenced this pull request Mar 9, 2026
`TEST_USER_DN` user with a TODO about integrating that bit in usersupp instead.
@jonasbardino jonasbardino added enhancement New feature or request help wanted Extra attention is needed test-only Improvements or additions solely for better test coverage - without functionality changes follow-up pending Pending tasks to follow-up on after close labels Mar 9, 2026
@jonasbardino
Copy link
Contributor

I think we finally covered all the silently failing issues this change revealed and CI succeeds again.

Please note that in order to get a few last failing accountreq and janitor test cases running I had to inject forgive_errors for the time being, because they fail on send_email in notification. While we have already discussed solutions to that elsewhere it can't be easily overridden, yet. I've included TODOs about those workarounds and the follow-up tag here.

@albu-diku
Copy link
Contributor Author

I think we finally covered all the silently failing issues this change revealed and CI succeeds again.

Please note that in order to get a few last failing accountreq and janitor test cases running I had to inject forgive_errors for the time being, because they fail on send_email in notification. While we have already discussed solutions to that elsewhere it can't be easily overridden, yet. I've included TODOs about those workarounds and the follow-up tag here.

#467 is open to address this and was updated to line up with he outcomes of the discussion referenced above.

…d unit

tests and use the `vgrid_set_X` variants instead og `vgrid_add_X` in set up to
make sure missing pickles don't cause log noise, which will now cause trouble.
… they

cause log verification errors otherwise.
Sort import with `isort` for consistency.
…s now that

they include log analysis.
Apply isort for consistency.
…ests now

that log analysis will otherwise raise it as errors.
Apply isort for consistency.
…sis.

Apply isort and comments to address the review feedback about marking imports.
…nt to

avoid breakage even on cosmetical changes. Use the same msg matching as other
unit tests in the test suite.
Mark imports according to review feedback.
Removed a stale try/except wrap of imports to avoid autopep8 interference. We
should not need it anymore.
…sis.

Apply isort and comment on import order in line with review feedback.
Various style cleanups to align with PEP8, max line length and mandatory class
docstrings.
…that

the updates to default test user provisioning solves missing settings pickle.
Basically replaces most of the custom DUMMY_X with TEST_X to sue that default
test user for most tests. Obsoletes most ID collision test set up now included.
`TEST_USER_DN` user with a TODO about integrating that bit in usersupp instead.
… a local

SMTP will fail when trying to notify users about various things with send_email
so we adjust janitor tests to silently ignore that until we have a proper
implementation of skip email in tests.
…nd_email

errors from various janitor tests until we integrate a skip email fix.
…n peers

test of accountreq until we have implemented a fix to disable mail notification
in unit tests.
…e of by

test isolation and clean up as pointed out in review (thanks @albu-diku).
@albu-diku albu-diku force-pushed the test/integrate-fake-logger-with-test-configuration branch 2 times, most recently from 1c0d611 to 9eefe3d Compare March 9, 2026 17:23
@albu-diku albu-diku force-pushed the test/integrate-fake-logger-with-test-configuration branch from 9eefe3d to 01422f2 Compare March 9, 2026 17:36
jonasbardino and others added 5 commits March 9, 2026 18:52
Removed a stale try/except wrap of imports to avoid autopep8 interference. We
should not need it anymore.
automatic init of settings file. Requires temporary adjustments to forgive
errors and allow the request files to remain because send_email fails.
@jonasbardino jonasbardino merged commit 927a772 into next Mar 9, 2026
6 checks passed
@jonasbardino jonasbardino deleted the test/integrate-fake-logger-with-test-configuration branch March 9, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request follow-up pending Pending tasks to follow-up on after close help wanted Extra attention is needed test-only Improvements or additions solely for better test coverage - without functionality changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants