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

nixos/test-driver: use pythons logging module #96254

Merged
merged 4 commits into from Aug 26, 2020
Merged

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Aug 25, 2020

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This way we not accidentally use introduce/use global variables.
Also it explictly mark the code for the mypy type checker.
@Mic92 Mic92 requested a review from tfc as a code owner August 25, 2020 08:39
@Mic92
Copy link
Member Author

Mic92 commented Aug 25, 2020

@GrahamcOfBorg test ferm

@Mic92 Mic92 changed the title Logging nixos/test-driver: use pythons logging module Aug 25, 2020
- Less code
- more thread-safe according to @flokli
@tfc tfc requested a review from flokli August 25, 2020 09:31
@JJJollyjim
Copy link
Member

Haha, I just opened github to open the same PR

@JJJollyjim
Copy link
Member

Here's mine for comparison: https://github.com/JJJollyjim/nixpkgs/tree/python-logging

@JJJollyjim
Copy link
Member

btw, as-is this will break a few tests which were depending on log functions:

2020-08-25-222342_838x934_scrot

@JJJollyjim
Copy link
Member

JJJollyjim commented Aug 25, 2020

Personally, I'd like to see automatic (streaming) output to the logger from .succeed and related functions, which would remove the need for most of these log statements (and generally make test development easier in some cases)

(not saying that's needed for this PR, of course)

Appearantly this is used in tests
@Mic92
Copy link
Member Author

Mic92 commented Aug 25, 2020

@GrahamcOfBorg test nsd

@Mic92
Copy link
Member Author

Mic92 commented Aug 25, 2020

I re-added the log() function.

@JJJollyjim
Copy link
Member

lgtm :)

@Mic92 Mic92 merged commit 4fc7085 into NixOS:master Aug 26, 2020
@Mic92 Mic92 deleted the logging branch August 26, 2020 18:45
@flokli
Copy link
Contributor

flokli commented Aug 26, 2020

Thanks for this! :-)

Comment on lines -298 to -301
def nested(self, msg: str, attrs: Dict[str, str] = {}) -> _GeneratorContextManager:
my_attrs = {"machine": self.name}
my_attrs.update(attrs)
return self.logger.nested(msg, my_attrs)
Copy link
Contributor

@andersk andersk Aug 30, 2020

Choose a reason for hiding this comment

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

Removing Machine.nested has broken a number of tests that used it, including the channel-blocking chromium test:

$ git grep '\.nested' nixos/tests
nixos/tests/chromium.nix:        with machine.nested("Creating a new Chromium window"):
nixos/tests/chromium.nix:        with machine.nested("Waiting for new Chromium window to appear"):
nixos/tests/chromium.nix:        with machine.nested(description):
nixos/tests/dhparams.nix:      with machine.nested("switch to generation ${toString gen}"):
nixos/tests/dhparams.nix:        with machine.nested(f"check bit size of {path}"):
nixos/tests/initrd-network-ssh/default.nix:    with client.nested("waiting for SSH server to come up"):
nixos/tests/taskserver.nix:            with client.nested(f"initialize client for user {user}"):
nixos/tests/taskserver.nix:                with client.nested("importing taskwarrior configuration"):
nixos/tests/taskserver.nix:        with server.nested("(re-)add imperative user bar"):
nixos/tests/virtualbox.nix:      with machine.nested("Checking for privilege escalation"):
nixos/tests/virtualbox.nix:    with machine.nested("Checking for privilege escalation"):

#96699

andersk added a commit to andersk/nixpkgs that referenced this pull request Aug 30, 2020
…chines-staging"

This reverts commit 1bff6fe, reversing
changes made to 2995fa4.

There’s presumably nothing wrong with this PR, except that it
conflicts with reverting NixOS#96254 which broke several tests (NixOS#96699).

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk added a commit to andersk/nixpkgs that referenced this pull request Aug 30, 2020
This reverts commit 4fc7085, reversing
changes made to 0e54f3a.

Fixes NixOS#96699.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
worldofpeace added a commit that referenced this pull request Aug 30, 2020
Revert “nixos/test-driver: use pythons logging module” (#96254)
@andersk
Copy link
Contributor

andersk commented Aug 30, 2020

This was reverted for now in #96703 to fix #96699.

JJJollyjim added a commit to JJJollyjim/nixpkgs that referenced this pull request Sep 23, 2020
am-on added a commit to marijanp/nixpkgs that referenced this pull request Dec 8, 2021
Add changes from NixOS#96254 and
NixOS#96152.

Remove `Machine.nested` - use `with subtest("Test")` in tests that used
`nested`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants