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

Improve eliot logging in integration tests. #449

Merged
merged 14 commits into from Jun 29, 2021
Merged

Improve eliot logging in integration tests. #449

merged 14 commits into from Jun 29, 2021

Conversation

tomprince
Copy link
Contributor

@tomprince tomprince commented Jun 26, 2021

Cleanup all the existing eliot logging in the integration tests, in preparation for capturing the logs from the services. (see #445)

The main goal here is to ensure that all eliot logs are captured in an appropriate action (in particular one that hasn't been finished, as eliot won't associate messages from after action was finished, when parsing).

This add a bunch of wrappers to the code for running services and commands, to ensure that logs for each process are consistently captured in a given action, and that that action doesn't end until the process does.

This also puts foolscap log capturing behind a pytest option, as I think that is unlikely to be useful to magic-folder developers most of the time.

This allows automation to not need to special-case the integration tests.
I'm changing the interface of `_magic_folder_runner` to provide
the output of the command directly, so replace this caller
with the already existing wrapper of these commands.
This allows us to separate out (some of) the eliot logs by test, which makes
reading them much easier.
Every caller was doing this already, so just move it into the function.
Also add loggin of each call, including the output.
`_MagicTextProtocol` has two purposes:
- capture output of a service and log it to eliot
- notice when the service has started, and return
  control to the caller via the callback.

The logs from the service want to be associated to with action for
the service. However, we don't want the code in the caller to be
associated to that action. Thus, we move the callback outside of
the action.
Now that we only capture them when asked, we can reasonably write them to the current directory.
This wraps `_MagicTextProtocol`, and ensures that the output is
capture in an appropriate action.
@tomprince
Copy link
Contributor Author

Note that there are a lot of changes in this PR, but they are split into relatively small commits, that can be reviewed on their own.

@tomprince tomprince requested a review from exarkun June 26, 2021 03:59
@tomprince
Copy link
Contributor Author

@exarkun I'm asking you for a review on this, since I think meejah is out next week.

@tomprince
Copy link
Contributor Author

The macOS integration failure is an intermittent issue that hopefully this and #445 will help debug.

@codecov
Copy link

codecov bot commented Jun 26, 2021

Codecov Report

Merging #449 (0a39a55) into main (5c3ffb4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #449   +/-   ##
=======================================
  Coverage   91.08%   91.08%           
=======================================
  Files          33       33           
  Lines        2715     2715           
  Branches      315      315           
=======================================
  Hits         2473     2473           
  Misses        170      170           
  Partials       72       72           
Flag Coverage Δ
integration 70.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c3ffb4...0a39a55. Read the comment docs.

Copy link
Member

@exarkun exarkun left a comment

Choose a reason for hiding this comment

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

Thanks. Seems like a good step overall. Some comments inline, nothing major I think. Please address to your satisfaction and then merge.

integration/conftest.py Show resolved Hide resolved
integration/conftest.py Show resolved Hide resolved
def introducer(reactor, tahoe_venv, temp_dir, flog_gatherer, request):
config = '''
with start_task(action_type=u"integration:introducer").context():
Copy link
Member

Choose a reason for hiding this comment

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

I can't recall a time when I've used start_task instead of start_action. I understand that the difference is that start_task will not search out a parent from the Eliot context: it will always be a new top-level action? So "running the introducer" is a top-level action regardless of the Eliot context in which this fixture is invoked?

I'm not sure how to reason about when it makes sense to start a new top-level action (apart from there being no other active action) and when it makes sense to respect the current Eliot context. Do you have a set of rules for this you can share? Or maybe just a comment about this specific case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly the reason it is this way is that I played around with various options, looking at the eliot-tree output of test runs with them.

  • Partly what is going on is that fixtures are run outside the context of the thing requesting them, particularly session fixtures. One iteration did have a session-scope auto-use fixture that did have a task, that all other session scoped fixtures were child actions of, but that didn't make it easier to read the logs. I do have that for tests, which does work better (though I'm not sure there are fest (i.e. function) scoped fixtures that would capture logs for.
  • If you have multiple, mostly unrelated fixtures, that each have an action wrapping them, then each action is going to be a child of the previous one, but the nesting is going to be somewhat arbitrary, and makes the logs harder to read. (One particular example of confusing nesting, in a slightly different context, is that the magic-folder (stdout) logs from restarting the service where in the test that restarted them, even if it kept running into a later test).

integration/conftest.py Outdated Show resolved Hide resolved


@pytest.fixture(scope='session')
@log_call(action_type=u"integration:introducer:furl", include_args=["temp_dir"])
Copy link
Member

Choose a reason for hiding this comment

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

Is the net of this PR that the Eliot log no longer contains the introducer furl? Previously log_call would log the return value of this function now it doesn't. Does something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so.

integration/test_add.py Show resolved Hide resolved
@@ -0,0 +1 @@
Add your info here
Copy link
Member

Choose a reason for hiding this comment

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

Ticket please.

integration/util.py Show resolved Hide resolved
@tomprince tomprince merged commit b461297 into tahoe-lafs:main Jun 29, 2021
@tomprince tomprince deleted the integration-eliot-logging branch June 29, 2021 18:03
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.

None yet

2 participants