Page MenuHomePhabricator

refinery-drop-older-than failing tests
Closed, ResolvedPublic

Description

While backfilling data for T244771, I had to use refinery-drop-older-than to drop a bunch of Hive partitions. The unit tests failed with

ERROR: test_raises_error_with_invalid_older_than
...
 ValueError: time data '24 invalid' does not match format '%Y-%m-%d'
 During handling of the above exception, another exception occurred:
...
ValueError: invalid literal for int() with base 10: '24 invalid'

I couldn't quite understand why the test was failing so I copied the code from my laptop to stat1004's refinery checkout and tried to run it...and then it worked.

Today I checked up on some jobs for T245124 and noticed the same error in the 'refinery-drop-raw-event' job:

[@an-coord1001:/home/otto] $ sudo journalctl -n 100 -f -u refinery-drop-raw-event.service
Feb 26 16:20:00 an-coord1001 systemd[1]: Started Drop raw event (/wmf/data/raw/event) data imported on HDFS following data retention policies..
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: User analytics executes as user analytics the command ['/srv/deployment/analytics/refinery/bin/refinery-drop-older-than', '--base-path=/wmf/data/raw/event', '--path-format=.+/hourly/(?P<year>[0-9]+)(/(?P<month>[0-9]+)(/(?P<day>[0-9]+)(/(?P<hour>[0-9]+))?)?)?', '--older-than=90', '--skip-trash', '--execute=209837413aff8d4332104e7dc454a27d']
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ...E...................
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ======================================================================
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ERROR: test_raises_error_with_invalid_older_than (__main__.TestRefineryDropOlderThan)
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ----------------------------------------------------------------------
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: Traceback (most recent call last):
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 329, in main
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     threshold = datetime.strptime(older_than, '%Y-%m-%d')
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     tt, fraction = _strptime(data_string, format)
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     (data_string, format))
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ValueError: time data '24 invalid' does not match format '%Y-%m-%d'
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: During handling of the above exception, another exception occurred:
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: Traceback (most recent call last):
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 429, in test_raises_error_with_invalid_older_than
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     self.run_main({'--older-than': '24 invalid'})
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 407, in run_main
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     main(default_args)
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 332, in main
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     threshold = now_hourly_truncated - timedelta(days=int(older_than))
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ValueError: invalid literal for int() with base 10: '24 invalid'
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ----------------------------------------------------------------------
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: Ran 23 tests in 0.012s
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: FAILED (errors=1)
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: Traceback (most recent call last):
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 329, in main
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     threshold = datetime.strptime(older_than, '%Y-%m-%d')
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     tt, fraction = _strptime(data_string, format)
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     (data_string, format))
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ValueError: time data '24 invalid' does not match format '%Y-%m-%d'
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: During handling of the above exception, another exception occurred:
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: Traceback (most recent call last):
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 429, in test_raises_error_with_invalid_older_than
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     self.run_main({'--older-than': '24 invalid'})
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 407, in run_main
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     main(default_args)
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:   File "/srv/deployment/analytics/refinery/bin/refinery-drop-older-than", line 332, in main
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]:     threshold = now_hourly_truncated - timedelta(days=int(older_than))
Feb 26 16:20:00 an-coord1001 kerberos-run-command[62580]: ValueError: invalid literal for int() with base 10: '24 invalid'

Event Timeline

I think this might be caused by the following patch +2 by me (my bad)
https://gerrit.wikimedia.org/r/#/c/analytics/refinery/+/573215/3/bin/refinery-drop-older-than
The error that is popping up in the test is a ValueError, but the one expected in the test was changed to RuntimeError.
I think ValueError does not inherit from RuntimeError, it inherits directly from Exception.

Change 575542 had a related patch set uploaded (by Mforns; owner: Mforns):
[analytics/refinery@master] Fix refinery-drop-older-than tests and parameter check

https://gerrit.wikimedia.org/r/575542

Change 575542 merged by Elukey:
[analytics/refinery@master] Fix refinery-drop-older-than tests and parameter check

https://gerrit.wikimedia.org/r/575542

elukey subscribed.

To keep archives happy: https://gerrit.wikimedia.org/r/#/c/analytics/refinery/+/575464/ was merged before the last fix of Marcel. It seems that all the timers are working now, closing.