zui icon indicating copy to clipboard operation
zui copied to clipboard

Flaky Test: Playwright query.spec.ts

Open jameskerr opened this issue 2 years ago • 0 comments

This is flaky test that has been removed, but documented here in case we get better at writing these tests and can add it back again.

import path from "path"
import {testDataDir} from "../helpers/env"
import TestApp from "../helpers/test-app"
import {sprintf} from "sprintf-js"

describe("Ingest tests", () => {
  const app = new TestApp("Query tests")

  const simpleQueries = [
    "* | count()",
    "* | count() by _path | sort _path",
    '_path=="conn" | count()',
    '_path=="conn" | cut ts, id.orig_h, id.orig_p, id.resp_h, id.resp_p, proto | sort ts',
    "* | every 2s count() | sort ts",
    "* | every 2s count() by _path | sort ts, _path",
    '_path=="x509" or _path=="ssl" | sort _path'
  ]

  beforeAll(async () => {
    await app.init()
    await app.ingestFiles([
      path.normalize(path.join(testDataDir(), "sample.tsv"))
    ])
  })

  afterAll(async () => {
    await app.shutdown()
  })

  for (let i = 0; i < simpleQueries.length; i++) {
    const zql = simpleQueries[i]
    const testId = sprintf("%03d", i)
    test(`query${testId}: "${zql}"`, async () => {
      await app.search(zql)
      const results = await app.getViewerResults()
      expect(results).toMatchSnapshot()
    })
  }
})

The flakiness was about 25% of the time. Each time it failed, the snapshots didn't match in a different way. This makes me guess that the test was grabbing the search results at the wrong time. It is difficult to know when it's time to check the dom for the search results. If we find a way to do that better, we may be able to add this back in.

jameskerr avatar Jan 06 '22 00:01 jameskerr