scottlamb / moonfire-nvr

Moonfire NVR, a security camera network video recorder
Other
1.24k stars 137 forks source link

Possible incorrect test code #53

Closed dolfs closed 5 years ago

dolfs commented 6 years ago

During a build in a Docker instance, I got test failures on code that was straight from github/master and built and tested fine on my rPi:

failures:

---- db::tests::test_adjust_days stdout ----
    thread 'db::tests::test_adjust_days' panicked at 'assertion failed: `(left == right)`
  left: `Some(CameraDayValue { recordings: 1, duration: Duration(5400000) })`,
 right: `None`', src/db.rs:1521:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- db::tests::test_day_bounds stdout ----
    thread 'db::tests::test_day_bounds' panicked at 'assertion failed: `(left == right)`
  left: `Time(135683424000000)..Time(135691200000000)`,
 right: `Time(135685692000000)..Time(135693468000000)`', src/db.rs:1563:9

---- recording::tests::test_format_time stdout ----
    thread 'recording::tests::test_format_time' panicked at 'assertion failed: `(left == right)`
  left: `"2006-01-02T15:04:05:00000-08:00"`,
 right: `"2006-01-02T23:04:05:00000-00:00"`', src/recording.rs:558:9

---- mp4::tests::test_round_trip_with_subtitles stdout ----
    thread 'mp4::tests::test_round_trip_with_subtitles' panicked at 'assertion failed: `(left == right)`
  left: `"de382684a471f178e4e3a163762711b0653bfd83"`,
 right: `"cb5ff51cda4d7dbae05b4a534afd578a0e589570"`', src/mp4.rs:2135:9

---- recording::tests::test_parse_time stdout ----
    thread 'recording::tests::test_parse_time' panicked at 'assertion failed: `(left == right)`
  left: `102261874050000`,
 right: `102259282050000`: parsing 2006-01-02T15:04:05', src/recording.rs:551:13

failures:
    db::tests::test_adjust_days
    db::tests::test_day_bounds
    mp4::tests::test_round_trip_with_subtitles
    recording::tests::test_format_time
    recording::tests::test_parse_time

test result: FAILED. 43 passed; 5 failed; 0 ignored; 0 measured; 0 filtered out

I realized that the Docker instance was on UTC time. I modified the Docker image to be on America/Los_Angeles and run the build again. This time no errors.

The initial built was run at approximately 2018-03-17 06:00 UTC or 2018-03-16 23:00 PDT, the second successful built approximately 30 minutes later (in case the actual time is relevant).

This makes me suspicious of the test code itself, but it may also point at an actual problem in the Moonfire code.

scottlamb commented 6 years ago

The tests are supposed to force the timezone to America/Los_Angeles through this code. I was puzzled why it wouldn't be working, but now I have an idea. Is it possible when your docker instance was set to UTC that the other time zones weren't installed at all?

I suppose the installation instructions have a list of required packages; tzdata isn't in that list but should be.