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.
This commit is contained in:
Michael Cook 2023-08-23 14:02:45 +00:00 committed by Sybren A. Stüvel
parent eb9f46dc9b
commit bc7b434121
3 changed files with 7 additions and 6 deletions

@ -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

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

@ -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