Run Flamenco Unit Tests in the local timezone #104236
No reviewers
Labels
No Label
Good First Issue
Priority
High
Priority
Low
Priority
Normal
Status
Archived
Status
Confirmed
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Job Type
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: studio/flamenco#104236
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "michael-2/flamenco:mock_test_timezone_aware"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves having to specify Europe/Amsterdam timezone before running Flamenco mocked-clock tests.
#104219
The solution uses Go time.Local timezone to satisfy unit tests assertions using a Mock clock. The timezone of the local workstation running the tests.
Tested by setting the local workstation to two different timezones to America/New_York and Europe/Amsterdam.
timezone_make_test.txt
Thanks for the PR. I'm wondering if this is the right approach, though. If there is code in Flamenco that makes assumptions about the timezones, then I feel that that's a bug that needs fixing.
@ -250,13 +251,13 @@ func TestSimpleBlenderRenderOutputPathFieldReplacement(t *testing.T) {
require.NotNil(t, aj)
// The job compiler should have replaced the {timestamp} and {ext} fields.
assert.Equal(t, "/root/2006-01-02_090405/jobname/######", aj.Settings["render_output_path"])
This was intentionally using a mocked clock in a different timezone, and ensuring that the created timestamp is in UTC. By moving this all to the local timezone, the test semantics are changed.
I did wonder about that but moved it to local timezone. I didn't realise it was intentionally a timezone test. I can fix that back up to test UTC timestamps.
I'd assumed by the issue/bug description that these tests were supposed to run independently of timezones. I dont think Flamenco is timezone aware or has a timezone bug... but the tests seemed to be hard coded to Amsterdam (+7)... and thought that was the problem in the issue you raised. Is this the wrong assumption?
They are supposed to work regardless of which timezone the computer that runs them is in.
I'm in Amsterdam, The Netherlands. Not sure which Amsterdam is in +7, but the local time here is UTC+2 (at least now, in summertime). I wrote the test to use a different-than-local timezone intentionally.
I've looked a bit more at the code base with your hint that this is supposed to be testing that the output path directory name uses UTC timestamp, and not a local timestamp.
With this context... I think the following is true...
If I swap timestamp.Local() for timestamp.UTC() then the output folder path is in UTC and if the assertion checks against 08h04m (instead of 09h04m) this makes sense and the test passes. I dont think this is the right change though.
Instead, this javascript jsFormatTimestampLocal() should be local date and time to simplify the end-user experience looking for render output paths.
So I would expect that the test case needs check against the local timestamp and not UTC.
Am I on the right path here?
Thanks for your analysis.
I agree, using local timestamps in the paths is indeed easier for end users, and simplicity is king.
The code looks good to me!
I've added a few inline comments, I'll address those while landing the PR. Thanks again!
@ -58,3 +58,3 @@
func mockedClock(t *testing.T) clock.Clock {
c := clock.NewMock()
now, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00")
//current_location, err := time.LoadLocation("Local")
Please remove the commented-out code.
@ -270,3 +270,3 @@
mockedClock := clock.NewMock()
mockedNow, err := time.Parse(time.RFC3339, "2022-06-07T11:14:47+02:00")
mockedNow, err := time.ParseInLocation("2006-01-02T15:04:05", "2022-06-07T11:14:47", time.Local)
The sleep scheduler should work well (that is, always treat the schedule as local time), regardless of whether the mocked clock is set to local time or not. I've taken the liberty of addressing this myself in
eb9f46dc9b
, so this change can be removed from this PR.