Skip to content

nixosTests.wordpress: port to python#73993

Merged
globin merged 3 commits intoNixOS:masterfrom
flokli:nixos-test-port-wordpress
Nov 24, 2019
Merged

nixosTests.wordpress: port to python#73993
globin merged 3 commits intoNixOS:masterfrom
flokli:nixos-test-port-wordpress

Conversation

@flokli
Copy link
Copy Markdown
Member

@flokli flokli commented Nov 23, 2019

Motivation for this change

#72828

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 nix-review --run "nix-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.
Notify maintainers

cc @

Copy link
Copy Markdown
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

@flokli I think you're looking for @mmilata as the test was pretty much written by him. I worked on the file, but it appears @mmilata modified it enough that his name should probably be added to the maintainers on that test. That sound reasonable to you @mmilata? ❤️

That being said... LGTM 👍

@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Nov 23, 2019
Comment on lines 35 to 46
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only thing that defers between these two commands is the service name being 1 or 2 or this directory having site{number}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

True. something like this might be nice:

for nr in 1, 2:
    machine.wait_for_unit(f"phpfpm-wordpress-site{nr}.local")
    machine.succeed(
        f"curl -L site{nr}.local | grep 'Welcome to the famous'",
        ...
    )

@worldofpeace
Copy link
Copy Markdown
Contributor

@GrahamcOfBorg test wordpress

@mmilata
Copy link
Copy Markdown
Member

mmilata commented Nov 24, 2019

@aanderse I don't currently run any Wordpress instances, but feel free to add me as a maintainer of the test for the time being. Hopefully I could be of help now that it's written in language I know how to use;)

@flokli flokli force-pushed the nixos-test-port-wordpress branch from 79e9514 to e2ddd2e Compare November 24, 2019 16:13
@flokli
Copy link
Copy Markdown
Member Author

flokli commented Nov 24, 2019

@mmilata I added you to the maintainers list, and also did some more refactoring to use assertions and get_unit_info instead of all the inline grep commands - looks much cleaner now.

@worldofpeace, @mmilata, PTAL.

@flokli flokli requested a review from worldofpeace November 24, 2019 16:14
Copy link
Copy Markdown
Member

@mmilata mmilata left a comment

Choose a reason for hiding this comment

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

LGTM!

@flokli flokli force-pushed the nixos-test-port-wordpress branch from e2ddd2e to 069364f Compare November 24, 2019 16:24
@flokli
Copy link
Copy Markdown
Member Author

flokli commented Nov 24, 2019

Hm, I broke forgot a ; in maintainer-list.nix. Updated.

@worldofpeace
Copy link
Copy Markdown
Contributor

@flokli Thanks. I hope we can have more of the tests not using grep for where we can actually use python.

@globin globin merged commit 2d49ee8 into NixOS:master Nov 24, 2019
@worldofpeace
Copy link
Copy Markdown
Contributor

Umm, this test had some issue and didn't even succeed on all test cases.

with subtest("wordpress-init went through"):
for site_name in site_names:
info = machine.get_unit_info(f"wordpress-init-{site_name}")
assert info.Result == "success"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a dict so you'd have to do

assert info["Result"] == "success"

to not get an error.

assert info.Result == "success"

with subtest("secret keys are set"):
re.compile(r"^define.*NONCE_SALT.{64,};$")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure what the r is here but you probably wanted to assign this to a variable so you could you it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's raw string literal that doesn't interpret backslash escapes which is useful when working with regular expressions.

Proposed fix: #74086

@mmilata mmilata mentioned this pull request Nov 24, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants