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

nixosTests.wordpress: port to python #73993

Merged
merged 3 commits into from Nov 24, 2019

Conversation

flokli
Copy link
Contributor

@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
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 👍

Comment on lines 35 to 46
machine.succeed(
"systemctl --no-pager show wordpress-init-site1.local.service | grep 'ExecStart=.*status=0'"
)
machine.succeed(
"systemctl --no-pager show wordpress-init-site2.local.service | grep 'ExecStart=.*status=0'"
)
machine.succeed(
"grep -E '^define.*NONCE_SALT.{64,};\$' /var/lib/wordpress/site1.local/secret-keys.php"
)
machine.succeed(
"grep -E '^define.*NONCE_SALT.{64,};\$' /var/lib/wordpress/site2.local/secret-keys.php"
)
Copy link
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
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
Contributor

@GrahamcOfBorg test wordpress

@mmilata
Copy link
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
Copy link
Contributor 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.

Copy link
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
Copy link
Contributor Author

flokli commented Nov 24, 2019

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

@worldofpeace
Copy link
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
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
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
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants