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/tests/timezone: port to python #74858

Merged
merged 1 commit into from Dec 5, 2019
Merged

nixos/tests/timezone: port to python #74858

merged 1 commit into from Dec 5, 2019

Conversation

x123
Copy link
Contributor

@x123 x123 commented Dec 2, 2019

Motivation for this change

Port timezone test to python for #72828

Things done

Ported timezone test to python.

  • 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) nixos/tests/timezone.nix
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @lheckemann

@flokli
Copy link
Contributor

flokli commented Dec 2, 2019

Can you add this test to nixos/tests/all-tests.nix?

@x123
Copy link
Contributor Author

x123 commented Dec 2, 2019

@flokli yep, done.

my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"');
print $dateResult[1];
$dateResult[1] eq "1970-01-01 09:00:00\n" or die "Timezone adjustment was not persisted";
machine.shutdown()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make comments like "Adjustment should persist across a reboot" a subtest, so this information is even visible in the log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tfc done

@flokli
Copy link
Contributor

flokli commented Dec 4, 2019

@GrahamcOfBorg test timezone

date_result = machine.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
assert (
date_result == "1970-01-01 01:00:00\n"
), "Timezone seems to be wrong"
Copy link
Contributor

Choose a reason for hiding this comment

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

The linter complains here:

⇒  nix-build nixos/tests/timezone.nix -A timezone-static    
these derivations will be built:
  /nix/store/q7dwy5fkiahdv9q65c17pzgh90aqxppj-nixos-test-driver-timezone-static.drv
  /nix/store/769fsp2qh581h181ffg09n6dlb0pxmn2-vm-test-run-timezone-static.drv
building '/nix/store/q7dwy5fkiahdv9q65c17pzgh90aqxppj-nixos-test-driver-timezone-static.drv'...
--- /nix/store/q0z2dazvilyzyk57sw0y4fcfw80zmf3x-nixos-test-driver-timezone-static/test-script   2019-12-04 00:10:57.981288 +0000
+++ /nix/store/q0z2dazvilyzyk57sw0y4fcfw80zmf3x-nixos-test-driver-timezone-static/test-script   2019-12-04 00:10:58.142654 +0000
@@ -1,7 +1,5 @@
 machine.wait_for_unit("dbus.socket")
 machine.fail("timedatectl set-timezone Asia/Tokyo")
 date_result = machine.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
-assert (
-    date_result == "1970-01-01 01:00:00\n"
-), "Timezone seems to be wrong"
+assert date_result == "1970-01-01 01:00:00\n", "Timezone seems to be wrong"

would reformat /nix/store/q0z2dazvilyzyk57sw0y4fcfw80zmf3x-nixos-test-driver-timezone-static/test-script
Oh no! 💥 💔 💥
1 file would be reformatted.
builder for '/nix/store/q7dwy5fkiahdv9q65c17pzgh90aqxppj-nixos-test-driver-timezone-static.drv' failed with exit code 1
cannot build derivation '/nix/store/769fsp2qh581h181ffg09n6dlb0pxmn2-vm-test-run-timezone-static.drv': 1 dependencies couldn't be built
error: build of '/nix/store/769fsp2qh581h181ffg09n6dlb0pxmn2-vm-test-run-timezone-static.drv' failed

@@ -266,6 +266,7 @@ in
taskserver = handleTest ./taskserver.nix {};
telegraf = handleTest ./telegraf.nix {};
tiddlywiki = handleTest ./tiddlywiki.nix {};
timezone = handleTest ./timezone.nix {};
Copy link
Contributor

Choose a reason for hiding this comment

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

This fails to run:

⇒  nix-build -A nixosTests.timezone                   
error: attempt to call something which is not a function but a set, at /home/flokli/dev/nixos/nixpkgs-gitlab/nixos/tests/all-tests.nix:18:20

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@flokli try with the latest commit.

@flokli
Copy link
Contributor

flokli commented Dec 4, 2019

ping @x123

@x123
Copy link
Contributor Author

x123 commented Dec 5, 2019

@flokli actually, I think I managed to fix it.

@flokli
Copy link
Contributor

flokli commented Dec 5, 2019

There was a stray newline. Rebased on latest master and squashed.

@flokli
Copy link
Contributor

flokli commented Dec 5, 2019

@GrahamcOfBorg test timezone

@flokli flokli merged commit a6391cf into NixOS:master Dec 5, 2019
@x123 x123 deleted the x123-test-timezone-python branch December 6, 2019 06:21
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

3 participants