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: colour machine names #96152

Merged
merged 1 commit into from Aug 27, 2020

Conversation

JJJollyjim
Copy link
Member

Motivation for this change

This makes NixOS Test output involving many machines a lot easier to visually parse:

2020-08-24-200736_1929x1264_scrot

The machine-readable XML output is unaffected.

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.

@JJJollyjim JJJollyjim requested a review from tfc as a code owner August 24, 2020 08:17
)


@functools.lru_cache()
Copy link
Contributor

Choose a reason for hiding this comment

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

i find it a bit unsound that a caching mechanism is used on a function that uses side effects.

How about making the Machine constructor pick a color from the iterator and then simply store that for its runtime?

Copy link
Contributor

Choose a reason for hiding this comment

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

long term there is the rough plan to use python's logging frame work. a variant where a logger is injected into each machine's constructor would make a lot of sense, as this can be easily combined with coloring of machines.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tfc it isn't unsound, lru_cache is documented to grow infinitely if no maximum size is specified. Making it in the machine was my original plan, but it gets messy, as the Machine doesn't control the Logger which

Copy link
Member Author

Choose a reason for hiding this comment

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

*which has maybe_prefix, which needs the colour

Copy link
Member

@Mic92 Mic92 Aug 24, 2020

Choose a reason for hiding this comment

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

I don't have a strong opinion on that that. The method suggested by @tfc sounds a bit easier to understand is is potentially less code. The color formatting could be even inlined in maybe_prefix.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Mic92 the serial output doesn't come through maybe_prefix though, it happens directly in Machine.process_serial_output

@flokli
Copy link
Contributor

flokli commented Aug 24, 2020

Can we switch to the python logging framework (and by this, making tests more reliable) first, before adding new features?

Discussion started here: #86486 (comment)

@flokli
Copy link
Contributor

flokli commented Aug 24, 2020

I really like this, but this can be solved much more elegantly in the formatter.

@Mic92
Copy link
Member

Mic92 commented Aug 24, 2020

Is the python logging module even needed? print should be thread-safe, no? What is the issue with the current eprint method? I am actually a bit reluctant to ask a contributor to implement something completely different from what they change in a PR.

@JJJollyjim
Copy link
Member Author

JJJollyjim commented Aug 24, 2020

Yeah sorry I really don't have the context to implement the switch to logging, or arm hardware to debug flakeyness with it... if someone else moves to logging later on they can feel free to pull out the colouring if it's making it hard and I'll reimplement it

@flokli
Copy link
Contributor

flokli commented Aug 24, 2020

Is the python logging module even needed? print should be thread-safe, no? What is the issue with the current eprint method?

Things still weren't thread-safe, as I wrote in the linked comment.
I also experienced some random stalls, which are probably connected to the non-thread-safety.

I am actually a bit reluctant to ask a contributor to implement something completely different from what they change in a PR.

Agreed, but I'd also be hesitant adding more features into something we end up needing to refactor anyways. Maybe it's best to keep this PR open, until someone picked up the initial refactor.

@Mic92
Copy link
Member

Mic92 commented Aug 25, 2020

see #96254

@flokli
Copy link
Contributor

flokli commented Aug 26, 2020

@JJJollyjim with #96254 merged, would you be up to update this?

@JJJollyjim JJJollyjim changed the base branch from staging to master August 27, 2020 11:31
@JJJollyjim
Copy link
Member Author

@ofborg test bitwarden.sqlite

@JJJollyjim
Copy link
Member Author

oops, that turns out to want to rebuild a lot.

@ofborg test boot

@JJJollyjim
Copy link
Member Author

ugh, i forget ofborg won't test attrsets

@ofborg test qboot

@Mic92 Mic92 merged commit 1bff6fe into NixOS:master Aug 27, 2020
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
Copy link
Contributor

andersk commented Aug 30, 2020

This had to be reverted (#96703) due to conflicts with the revert of #96254, which had broken several tests (#96699). I assume this should be resubmitted when that’s sorted out.

JJJollyjim added a commit to JJJollyjim/nixpkgs that referenced this pull request Sep 23, 2020
…-test-machines-staging""

This reverts commit a0a421b.
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

7 participants