From bc7b4341214f18bf3144556879a76d263c1890fe Mon Sep 17 00:00:00 2001 From: Michael Cook Date: Wed, 23 Aug 2023 14:02:45 +0000 Subject: [PATCH] Always use local time for job compiler timestamp variable The 'Simple Blender Render' job compiler script uses a `{timestamp}` variable to determine the render output path. This variable is now set to the local time, rather than UTC. This fixes #104219: Unit tests are timezone-dependent 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. --- CHANGELOG.md | 1 + internal/manager/job_compilers/job_compilers_test.go | 10 +++++----- internal/worker/common_test.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e45ae4f..1ddce5f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ bugs in actually-released versions. - The webapp automatically reloads after a disconnect, when it reconnects to Flamenco Manager and sees the Manager version changed [#104235](https://projects.blender.org/studio/flamenco/pulls/104235). - Show the configured Flamenco Manager name in the webapp's browser window title. - Workers can be marked as 'restartable' by using the `-restart-exit-code N` commandline option. More info in the [Worker Actions documentation](https://flamenco.blender.org/usage/worker-actions/). +- The `{timestamp}` placeholder in the render output path is now replaced with a local timestamp (rather than UTC). ## 3.2 - released 2023-02-21 diff --git a/internal/manager/job_compilers/job_compilers_test.go b/internal/manager/job_compilers/job_compilers_test.go index 15bc2d11..04bf1e03 100644 --- a/internal/manager/job_compilers/job_compilers_test.go +++ b/internal/manager/job_compilers/job_compilers_test.go @@ -57,7 +57,7 @@ func exampleSubmittedJob() api.SubmittedJob { func mockedClock(t *testing.T) clock.Clock { c := clock.NewMock() - now, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00") + now, err := time.ParseInLocation("2006-01-02T15:04:05", "2006-01-02T15:04:05", time.Local) assert.NoError(t, err) c.Set(now) return c @@ -250,13 +250,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"]) + assert.Equal(t, "/root/2006-01-02_150405/jobname/######", aj.Settings["render_output_path"]) // Tasks should have been created to render the frames: 1-3, 4-6, 7-9, 10, and video-encoding require.Len(t, aj.Tasks, 5) t0 := aj.Tasks[0] expectCliArgs := []interface{}{ // They are strings, but Goja doesn't know that and will produce an []interface{}. - "--render-output", "/root/2006-01-02_090405/jobname/######", + "--render-output", "/root/2006-01-02_150405/jobname/######", "--render-format", sj.Settings.AdditionalProperties["format"].(string), "--render-frame", "1..3", } @@ -271,8 +271,8 @@ func TestSimpleBlenderRenderOutputPathFieldReplacement(t *testing.T) { tVideo := aj.Tasks[4] // This should be a video encoding task assert.EqualValues(t, AuthoredCommandParameters{ "exe": "ffmpeg", - "inputGlob": "/root/2006-01-02_090405/jobname/*.png", - "outputFile": "/root/2006-01-02_090405/jobname/scene123-1-10.mp4", + "inputGlob": "/root/2006-01-02_150405/jobname/*.png", + "outputFile": "/root/2006-01-02_150405/jobname/scene123-1-10.mp4", "fps": int64(24), "args": expectedFramesToVideoArgs, }, tVideo.Commands[0].Parameters) diff --git a/internal/worker/common_test.go b/internal/worker/common_test.go index 05894bf5..ec5be2df 100644 --- a/internal/worker/common_test.go +++ b/internal/worker/common_test.go @@ -12,7 +12,7 @@ import ( func mockedClock(t *testing.T) *clock.Mock { c := clock.NewMock() - now, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00") + now, err := time.ParseInLocation("2006-01-02T15:04:05", "2006-01-02T15:04:05", time.Local) assert.NoError(t, err) c.Set(now) return c