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

Conversation

@x123
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

flokli commented Dec 2, 2019

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

@x123 x123 force-pushed the x123:x123-test-timezone-python branch from c181f16 to 0616873 Dec 2, 2019
@x123

This comment has been minimized.

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()

This comment has been minimized.

Copy link
@tfc

tfc Dec 3, 2019

Contributor

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

This comment has been minimized.

Copy link
@x123

x123 Dec 3, 2019

Author Contributor

@tfc done

@tfc
tfc approved these changes Dec 3, 2019
@flokli

This comment has been minimized.

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"

This comment has been minimized.

Copy link
@flokli

flokli Dec 4, 2019

Contributor

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 {};

This comment has been minimized.

Copy link
@flokli

flokli Dec 4, 2019

Contributor

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

This comment has been minimized.

Copy link
@x123

x123 Dec 5, 2019

Author Contributor

@flokli try with the latest commit.

@flokli

This comment has been minimized.

Copy link
Contributor

flokli commented Dec 4, 2019

ping @x123

@x123

This comment has been minimized.

Copy link
Contributor Author

x123 commented Dec 5, 2019

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

@x123 x123 force-pushed the x123:x123-test-timezone-python branch from 48437ec to df13d3f Dec 5, 2019
@flokli flokli force-pushed the x123:x123-test-timezone-python branch from df13d3f to 07be580 Dec 5, 2019
@flokli

This comment has been minimized.

Copy link
Contributor

flokli commented Dec 5, 2019

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

@flokli

This comment has been minimized.

Copy link
Contributor

flokli commented Dec 5, 2019

@GrahamcOfBorg test timezone

@flokli flokli merged commit a6391cf into NixOS:master Dec 5, 2019
2 of 3 checks passed
2 of 3 checks passed
grahamcofborg-eval Checking original out paths
Details
tests.timezone on aarch64-linux Success
Details
tests.timezone on x86_64-linux Success
Details
@x123 x123 deleted the x123:x123-test-timezone-python branch Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.