Ubuntu Pastebin

Paste from smoser at Mon, 13 Mar 2017 18:38:50 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
commit 66dfb0915d4abf3f61948f281c4aff8394494ed3 (HEAD -> master)
Author: Scott Moser <smoser@brickies.net>
Date:   Mon Mar 13 14:35:29 2017 -0400

    test: avoid differences in 'date' output due to daylight savings.
    
    When testing for timezone we were testing that 'date' output would
    contain 'HDT' for the current time.  But after a 'spring forward', the
    current time started to have 'HST'.
    
    Instead of asking 'date' for the timezone that applies now, ask it
    for a static date.

diff --git a/tests/cloud_tests/configs/modules/timezone.yaml b/tests/cloud_tests/configs/modules/timezone.yaml
index 6a05aba..8c96ed4 100644
--- a/tests/cloud_tests/configs/modules/timezone.yaml
+++ b/tests/cloud_tests/configs/modules/timezone.yaml
@@ -7,6 +7,8 @@ cloud_config: |
 collect_scripts:
   timezone: |
     #!/bin/bash
-    date +%Z
+    # date will convert this to system's configured time zone.
+    # use a static date to avoid dealing with daylight savings.
+    date "+%Z" --date="Thu, 03 Nov 2016 00:47:00 -0400"
 
 # vi: ts=4 expandtab
diff --git a/tests/cloud_tests/testcases/modules/timezone.py b/tests/cloud_tests/testcases/modules/timezone.py
index 272c266..bf91d49 100644
--- a/tests/cloud_tests/testcases/modules/timezone.py
+++ b/tests/cloud_tests/testcases/modules/timezone.py
@@ -10,6 +10,6 @@ class TestTimezone(base.CloudTestCase):
     def test_timezone(self):
         """Test date prints correct timezone"""
         out = self.get_data_file('timezone')
-        self.assertIn('HST', out)
+        self.assertEqual('HDT', out.rstrip())
 
 # vi: ts=4 expandtab
Download as text