Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2792

Fix C# logical type tests to work in other timezones than UTC

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.10.0
    • Component/s: None
    • Labels:
      None

      Description

      I ran the C# unit tests outside of a container and got the following error. This is because my machine's timezone is JST (UTC+9).

      $ cd lang/csharp
      $ ./build.sh test
      
      (snip)
      
        X TestLogical_TimestampMicrosecond() [22ms]
        Error Message:
           Expected: 1990-01-01 14:15:30
        But was:  1990-01-01 05:15:30
      
        Stack Trace:
           at Avro.Test.Generic.GenericTests.test[T](String s, T value) in /home/sekikn/repos/avro/lang/csharp/src/apache/test/Generic/GenericTests.cs:line 38
         at Avro.Test.Generic.GenericTests.TestLogical_TimestampMicrosecond() in /home/sekikn/repos/avro/lang/csharp/src/apache/test/Generic/GenericTests.cs:line 139
      
        X TestLogical_TimestampMillisecond() [< 1ms]
        Error Message:
           Expected: 1990-01-01 14:15:30
        But was:  1990-01-01 05:15:30
      
        Stack Trace:
           at Avro.Test.Generic.GenericTests.test[T](String s, T value) in /home/sekikn/repos/avro/lang/csharp/src/apache/test/Generic/GenericTests.cs:line 38
         at Avro.Test.Generic.GenericTests.TestLogical_TimestampMillisecond() in /home/sekikn/repos/avro/lang/csharp/src/apache/test/Generic/GenericTests.cs:line 133
      
        X TestTimestampMicrosecond("01/01/2019 14:20:00","01/01/2019 14:20:00Z") [< 1ms]
        Error Message:
           Expected: 2019-01-01 14:20:00
        But was:  2019-01-01 05:20:00
      
        Stack Trace:
           at Avro.Test.LogicalTypeTests.TestTimestampMicrosecond(String s, String e) in /home/sekikn/repos/avro/lang/csharp/src/apache/test/Util/LogicalTypeTests.cs:line 143
      
        X TestTimestampMillisecond("01/01/2019 14:20:00","01/01/2019 14:20:00Z") [< 1ms]
        Error Message:
           Expected: 2019-01-01 14:20:00
        But was:  2019-01-01 05:20:00
      
        Stack Trace:
           at Avro.Test.LogicalTypeTests.TestTimestampMillisecond(String s, String e) in /home/sekikn/repos/avro/lang/csharp/src/apache/test/Util/LogicalTypeTests.cs:line 119
      
      
      Test Run Failed.
      Total tests: 584
           Passed: 580
           Failed: 4
       Total time: 2.3598 Seconds
      

      As the specification says, Avro's timestamp logical type has a long value that represents the difference from the unix epoch (1 Jan 1970 00:00:00 UTC) and it doesn't have timezone information. So when deserializing it, it's returned as a C# DateTime object with UTC.
      Therefore, if the input string lacks timezone information, we should assume it represents UTC datetime in these test cases.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sekikn Kengo Seki
                Reporter:
                sekikn Kengo Seki
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: