Skip to content

Fix miscalculation on healthcheck tasks#1366

Open
Adman23 wants to merge 4 commits into
mainfrom
fix/1358-healthcheck-task-duration-miscalculated
Open

Fix miscalculation on healthcheck tasks#1366
Adman23 wants to merge 4 commits into
mainfrom
fix/1358-healthcheck-task-duration-miscalculated

Conversation

@Adman23

@Adman23 Adman23 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes the calculation of the duration of the tasks during the healthcheck process. It was a unit mismatch, so the solution was to change seconds by milliseconds to align with the format function.

duration is now used in milliseconds and shown properly in the UI. In the request it will be on milliseconds.

Issues Resolved

#1358

Evidence

evidence1
evidence2.mp4
imagen

Tests

  • Launch dashboard using --base parameter with the repo on the branch.
  • Use yarn start --no-base-path and then reload until you can see the healtcheck window with the server:api-run_as info.
  • Validate that all the fields (startedAt, finishedAt and duration) are the same as the request.
  • Navigate to Dashboard management > Healthcheck and verify that the duration that renders on the detail flyout for the tasks has the same format.

Additional

  • Test shown in evidence was done adding the following code:
      await new Promise(resolve => setTimeout(resolve, 2000));

Add it to wazuh-dashboard-plugins/plugins/main/server/health-check/server-api.ts line 190, that way it takes a couple of seconds more and the difference is more clear.

Check List

  • Commits are signed per the DCO using --signoff

Signed-off-by: Adam Navarro Megías <adam.navarro@wazuh.com>
@Adman23 Adman23 self-assigned this Jun 17, 2026
@Adman23 Adman23 linked an issue Jun 17, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

🔗 Workflow run · commit 817c69bd57b8c1121ecac651133eb7ba24e37e96

❌ 20 Jest Test Failure(s)

📄 junit-jest-group2-Linux/TEST-Jest Tests.xml

❌ OpenSearchDashboardsRequest headers property exposes authorization header if secured = false (0.001s)

Jest Tests.src/core/server/http/router

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Object.<anonymous> (/home/runner/work/wazuh-dashboard/wazuh-dashboard/src/core/server/http/http_service.test.ts:150:10)

❌ logs error if already set up (0.003s)

Jest Tests.src/core/server/http

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" page 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ RenderingService setup() render() renders "core" page for blank basepath (0.017s)

Jest Tests.src/core/server/rendering

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" page for blank basepath 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ RenderingService setup() render() renders "core" page driven by defaults (0.012s)

Jest Tests.src/core/server/rendering

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" page driven by defaults 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ RenderingService setup() render() renders "core" page driven by settings (0.013s)

Jest Tests.src/core/server/rendering

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" page driven by settings 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ RenderingService setup() render() renders "core" page with no defaults or overrides (0.014s)

Jest Tests.src/core/server/rendering

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" page with no defaults or overrides 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ RenderingService setup() render() renders "core" with excluded user settings (0.011s)

Jest Tests.src/core/server/rendering

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" with excluded user settings 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ RenderingService setup() render() renders "core" from legacy request (0.011s)

Jest Tests.src/core/server/rendering

Error: expect(received).toMatchSnapshot(properties)

Snapshot name: `RenderingService setup() render() renders "core" from legacy request 1`

- Snapshot  - 1
+ Received  + 9

@@ -24,10 +24,13 @@
        "branch": Any<String>,
        "buildNum": Any<Number>,
  … (26 more lines)

❌ ApmSystem setup does not init apm if no config provided (0.003s)

Jest Tests.src/core/public

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment in dev mode when isDevClusterMaster (deprecated) is true: env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -28,10 +28,13 @@
      "branch": "some-branch",
      "buildNum": 9007199254740991,
  … (17 more lines)

❌ correctly creates default environment in dev mode when isDevClusterManager is true (0.003s)

Jest Tests.packages/osd-config/src

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment in dev mode when isDevClusterManager is true: env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -28,10 +28,13 @@
      "branch": "some-branch",
      "buildNum": 9007199254740991,
  … (17 more lines)

❌ correctly creates default environment in dev mode when isDevClusterManager and isDevClusterMaster both are true (0.002s)

Jest Tests.packages/osd-config/src

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment in dev mode when isDevClusterManager and isDevClusterMaster both are true: env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -28,10 +28,13 @@
      "branch": "some-branch",
      "buildNum": 9007199254740991,
  … (17 more lines)

❌ correctly creates default environment in prod distributable mode. (0.003s)

Jest Tests.packages/osd-config/src

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment in prod distributable mode.: env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -28,10 +28,13 @@
      "branch": "feature-v1",
      "buildNum": 100,
  … (17 more lines)

❌ correctly creates default environment in prod non-distributable mode. (0.002s)

Jest Tests.packages/osd-config/src

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment in prod non-distributable mode.: env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -28,10 +28,13 @@
      "branch": "feature-v1",
      "buildNum": 9007199254740991,
  … (17 more lines)

❌ correctly creates default environment if --env.name is supplied. (0.002s)

Jest Tests.packages/osd-config/src

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment if \`--env.name\` is supplied.: dev env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -29,10 +29,13 @@
      "branch": "feature-v1",
      "buildNum": 9007199254740991,
  … (17 more lines)
Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates default environment if \`--env.name\` is supplied.: prod env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -29,10 +29,13 @@
      "branch": "feature-v1",
      "buildNum": 9007199254740991,
  … (17 more lines)

❌ correctly creates environment with constructor. (0.002s)

Jest Tests.packages/osd-config/src

Error: expect(received).toMatchSnapshot(hint)

Snapshot name: `correctly creates environment with constructor.: env properties 1`

- Snapshot  - 0
+ Received  + 3

@@ -28,10 +28,13 @@
      "branch": "feature-v1",
      "buildNum": 100,
  … (17 more lines)

❌ CelestialCard Group functionality renders group toggle button when isGroup is true (0.025s)

Jest Tests.packages/osd-apm-topology/src/components/celestial_card

Error: expect(received).toMatchSnapshot()

Snapshot name: `Header help menu hides survey link 1`

- Snapshot  - 1
+ Received  + 0

@@ -1853,11 +1853,10 @@
                            </span>
                          </a>
  … (15 more lines)

📄 junit-jest-integration-Linux/TEST-Jest Integration Tests.xml

❌ copyAll() applies select globs if specified, ignores dot files (0.024s)

Jest Integration Tests.src/dev/build/lib/integration_tests

Error: expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `builds a generated plugin into a viable archive 2`

- Snapshot  - 0
+ Received  + 3

@@ -3,8 +3,11 @@
   │ info initialized, 0 bundles cached
   │ info starting worker [1 bundle]
  … (11 more lines)

❌ builds a non-semver generated plugin into a viable archive (7.112s)

Jest Integration Tests.packages/osd-plugin-helpers/src/integration_tests

Error: expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `builds a non-semver generated plugin into a viable archive 2`

- Snapshot  - 0
+ Received  + 3

@@ -3,8 +3,11 @@
   │ info initialized, 0 bundles cached
   │ info starting worker [1 bundle]
  … (11 more lines)

📄 junit-jest-integration-Windows/TEST-Jest Integration Tests.xml

❌ copyAll() applies select globs if specified, ignores dot files (0.043s)

Jest Integration Tests.src\dev\build\lib\integration_tests

Error: expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `builds a generated plugin into a viable archive 2`

- Snapshot  - 0
+ Received  + 3

@@ -3,8 +3,11 @@
   │ info initialized, 0 bundles cached
   │ info starting worker [1 bundle]
  … (11 more lines)

❌ builds a non-semver generated plugin into a viable archive (13.285s)

Jest Integration Tests.packages\osd-plugin-helpers\src\integration_tests

Error: expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `builds a non-semver generated plugin into a viable archive 2`

- Snapshot  - 0
+ Received  + 3

@@ -3,8 +3,11 @@
   │ info initialized, 0 bundles cached
   │ info starting worker [1 bundle]
  … (11 more lines)

20 failure(s) across 3 suite(s). Full XML reports are in the junit-jest-* artifacts.

Adman23 and others added 3 commits June 17, 2026 12:18
Signed-off-by: Adam Navarro Megías <adam.navarro@wazuh.com>
Signed-off-by: Adam Navarro Megías <adam.navarro@wazuh.com>
Signed-off-by: Adam Navarro Megías <145340543+Adman23@users.noreply.github.com>

@FernandoCastilla FernandoCastilla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 CR

@FernandoCastilla FernandoCastilla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM

@Ripdiegozz Ripdiegozz self-requested a review June 17, 2026 13:22

@Ripdiegozz Ripdiegozz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tests:

Image Image

@jcorredor-spec jcorredor-spec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test: Ok

Image Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Health check task duration miscalculated

4 participants