Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone issues affecting tests #8

Open
auphof opened this issue Aug 20, 2023 · 0 comments
Open

Timezone issues affecting tests #8

auphof opened this issue Aug 20, 2023 · 0 comments

Comments

@auphof
Copy link

auphof commented Aug 20, 2023

A fresh build fails on tests index.test.ts and parser.extend.test.ts
I will raise a PR addressing these

Details

Fail index.tests.ts

FAIL  src/parser/index.test.ts (145.972 s)
  ● uql › default

    expect(received).toStrictEqual(expected) // deep equality

    - Expected  - 9
    + Received  + 9

      Array [
        Object {
          "disk": "DISK-F1266E1D0AAC2C3F",
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.disk.avail",
    -     "timestamp": 2069-11-11T09:38:20.000Z,
    +     "timestamp": 2069-11-11T22:38:20.000Z,
          "value": 11.1,
        },
        Object {
          "disk": "DISK-F1266E1D0AAC2C3D",
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.disk.avail",
    -     "timestamp": 2069-11-11T09:38:20.000Z,
    +     "timestamp": 2069-11-11T22:38:20.000Z,
          "value": 111.1,
        },
        Object {
          "disk": undefined,
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.cpu.idle",
    -     "timestamp": 2069-11-11T09:38:20.000Z,
    +     "timestamp": 2069-11-11T22:38:20.000Z,
          "value": 1.1,
        },
        Object {
          "disk": "DISK-F1266E1D0AAC2C3F",
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.disk.avail",
    -     "timestamp": 2069-11-11T10:38:20.000Z,
    +     "timestamp": 2069-11-11T23:38:20.000Z,
          "value": 22.2,
        },
        Object {
          "disk": "DISK-F1266E1D0AAC2C3D",
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.disk.avail",
    -     "timestamp": 2069-11-11T10:38:20.000Z,
    +     "timestamp": 2069-11-11T23:38:20.000Z,
          "value": 222.2,
        },
        Object {
          "disk": undefined,
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.cpu.idle",
    -     "timestamp": 2069-11-11T10:38:20.000Z,
    +     "timestamp": 2069-11-11T23:38:20.000Z,
          "value": 2.2,
        },
        Object {
          "disk": "DISK-F1266E1D0AAC2C3F",
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.disk.avail",
    -     "timestamp": 2069-11-11T11:38:20.000Z,
    +     "timestamp": 2069-11-12T00:38:20.000Z,
          "value": 33.3,
        },
        Object {
          "disk": "DISK-F1266E1D0AAC2C3D",
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.disk.avail",
    -     "timestamp": 2069-11-11T11:38:20.000Z,
    +     "timestamp": 2069-11-12T00:38:20.000Z,
          "value": 333.3,
        },
        Object {
          "disk": undefined,
          "host": "HOST-F1266E1D0AAC2C3C",
          "metricId": "builtin:host.cpu.idle",
    -     "timestamp": 2069-11-11T11:38:20.000Z,
    +     "timestamp": 2069-11-12T00:38:20.000Z,
          "value": 3.3,
        },
      ]

      85 |         { data }
      86 |       )
    > 87 |     ).toStrictEqual([
         |       ^
      88 |       { timestamp: new Date("2069-11-11 22:38:20"), disk: "DISK-F1266E1D0AAC2C3F", host: "HOST-F1266E1D0AAC2C3C", value: 11.1, metricId: "builtin:host.disk.avail" },
      89 |       { timestamp: new Date("2069-11-11 22:38:20"), disk: "DISK-F1266E1D0AAC2C3D", host: "HOST-F1266E1D0AAC2C3C", value: 111.1, metricId: "builtin:host.disk.avail" },
      90 |       { timestamp: new Date("2069-11-11 22:38:20"), disk: undefined, host: "HOST-F1266E1D0AAC2C3C", value: 1.1, metricId: "builtin:host.cpu.idle" },

      at src/parser/index.test.ts:87:7
      at step (src/parser/index.test.ts:33:23)
      at Object.next (src/parser/index.test.ts:14:53)
      at fulfilled (src/parser/index.test.ts:5:58)

Fail in parser.extend.test.ts

 FAIL  src/parser/tests/parser.extend.test.ts (14.303 s)
  ● extend › date › add_datetime

    expect(received).toStrictEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 1

      Array [
        Object {
    -     "in": 1990-02-26T10:00:00.000Z,
    +     "in": 1990-02-26T23:00:00.000Z,
        },
      ]

      58 |       expect(await uql(`extend "in"=todatetime("in") | extend "in"=add_datetime("in",'1d')  | project "in"`, { data: [{ in: "1990-02-27" }] })).toStrictEqual([{ in: new Date("1990-02-28") }]);
      59 |       expect(await uql(`extend "in"=todatetime("in") | extend "in"=add_datetime("in",'-1d')  | project "in"`, { data: [{ in: "1990-02-27" }] })).toStrictEqual([{ in: new Date("1990-02-26") }]);
    > 60 |       expect(await uql(`extend "in"=todatetime("in") | extend "in"=add_datetime("in",'-1h')  | project "in"`, { data: [{ in: "1990-02-27" }] })).toStrictEqual([
         |                                                                                                                                                  ^
      61 |         { in: new Date("1990-02-26 23:00:00") },
      62 |       ]);
      63 |       expect(await uql(`extend "in"=todatetime("in") | extend "in"=add_datetime("in",'-1y')  | project "in"`, { data: [{ in: "1990-02-27" }] })).toStrictEqual([

      at src/parser/tests/parser.extend.test.ts:60:146
      at step (src/parser/tests/parser.extend.test.ts:33:23)
      at Object.next (src/parser/tests/parser.extend.test.ts:14:53)
      at fulfilled (src/parser/tests/parser.extend.test.ts:5:58)

Steps to reproduce

# in a Ubuntu 20 WSL2 instance in timezone GMT+12
git clone https://github.com/yesoreyeram/uql.git
cd uql
# Check commit
git log -1
# commit 3882e4d3146b864cca9e5ac7fac5d718dcf9f964 (HEAD -> main, origin/main, origin/HEAD)
# Author: Sriramajeyam Sugumaran <153843+yesoreyeram@users.noreply.github.com>
# Date:   Mon Mar 27 07:39:30 2023 +0100

# Check Versions
node --version # responds with v18.17.1
npm --version # responds with 9.8.1

# Install and build
npm install 
npm run build
auphof added a commit to auphof/uql that referenced this issue Aug 20, 2023
make test not dependant on location
if original test is run in GMT+12 location it failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant