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

Test failure on different pg text search settings #336

Closed
bickelj opened this issue May 5, 2023 · 1 comment
Closed

Test failure on different pg text search settings #336

bickelj opened this issue May 5, 2023 · 1 comment

Comments

@bickelj
Copy link
Contributor

bickelj commented May 5, 2023

Locally, I got this test failure every time on main after the merge of #320:

 FAIL  src/__tests__/proposals.int.test.ts (12.825 s)
  ● /proposals › GET / › returns a subset of proposals present in the database when search is provided

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

    - Expected  - 36
    + Received  +  1

      Object {
    -   "entries": Array [
    -     Object {
    -       "applicantId": 1,
    -       "createdAt": StringMatching /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,
    -       "externalId": "proposal-1",
    -       "id": 1,
    -       "opportunityId": 1,
    -       "versions": Array [
    -         Object {
    -           "applicationFormId": 1,
    -           "createdAt": StringMatching /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,
    -           "fieldValues": Array [
    -             Object {
    -               "applicationFormField": Object {
    -                 "applicationFormId": 1,
    -                 "baseFieldId": 1,
    -                 "createdAt": StringMatching /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,
    -                 "id": 1,
    -                 "label": "Short summary",
    -                 "position": 1,
    -               },
    -               "applicationFormFieldId": 1,
    -               "createdAt": StringMatching /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,
    -               "id": 1,
    -               "position": 1,
    -               "proposalVersionId": 1,
    -               "value": "This is a summary",
    -             },
    -           ],
    -           "id": 1,
    -           "proposalId": 1,
    -           "version": 1,
    -         },
    -       ],
    -     },
    -   ],
    +   "entries": Array [],
        "total": 2,
      }

      181 |         .set(authHeader)
      182 |         .expect(200)
    > 183 |         .expect(
          |          ^
      184 |           (res) => expect(res.body).toEqual(
      185 |             {
      186 |               total: 2,

      at Object.<anonymous> (src/__tests__/proposals.int.test.ts:183:10)
      ----
      at src/__tests__/proposals.int.test.ts:184:37
      at node_modules/supertest/lib/test.js:308:13
      at Test._assertFunction (node_modules/supertest/lib/test.js:285:13)
      at Test.assert (node_modules/supertest/lib/test.js:164:23)
      at Server.localAssert (node_modules/supertest/lib/test.js:120:14)

Locally I experienced this issue with two bitnami images of postgresql (14.7.0-debian-11-r5 and 15.2.0-debian-11-r28) while the automated test job for 320 (that did not see this issue) ran this image, presumably the stock pg 15.2.0 image on debian:

 Digest: sha256:482e881c53826bd27044a88cafa86305958142472cfe49e0facc6671eaa2fbf5
  Status: Downloaded newer image for postgres:latest
  docker.io/library/postgres:latest

Other team members who did not see this issue run from PostgreSQL APT packages for Ubuntu 22.04 or homebrew.

We found a difference in postgres settings for default_text_search_config: pg_catalog.simple vs pg_catalog.english. Where I have pg_catalog.simple as the default tscfg and experience failures, at least one other system not experiencing the failure has pg_catalog.english.

Usually it wouldn't matter if one dev machine has an odd configuration, but this dev machine's configuration is most closely aligned with the test and production machines, so it is likely a real issue.

More details are in chat at https://chat.opentechstrategies.com/#narrow/stream/75-PDC/topic/search.20implementation.

@bickelj bickelj changed the title Test failure on different pg settings Test failure on different pg text search settings May 5, 2023
bickelj added a commit that referenced this issue May 5, 2023
While the postgres (PG) text search (TS) config 'english' is specified
when building the text search column and index in the migration script
`0010-alter-proposal_field_values-value_search.sql`, when the postgres
`default_text_search_config` is set to `pg_catalog.simple` rather than
to `pg_catalog.english`, the test named `returns a subset of proposals
present in the database when search is provided` in file
`proposals.int.test.ts` will fail. For consistency in search results
across instances, this commit sets the query with search to use the
same `english`. Without this commit, tests will fail with different
PG settings for default text search config and inconsistent search
results will appear between instances.

Issue #336 Test failure on different pg text search settings
bickelj added a commit that referenced this issue May 5, 2023
While the postgres (PG) text search (TS) config 'english' is specified
when building the text search column and index in the migration script
`0010-alter-proposal_field_values-value_search.sql`, when the postgres
`default_text_search_config` is set to `pg_catalog.simple` rather than
to `pg_catalog.english`, the test named `returns a subset of proposals
present in the database when search is provided` in file
`proposals.int.test.ts` will fail. For consistency in search results
across instances, this commit sets the query with search to use the
same `english`. Without this commit, tests will fail with different
PG settings for default text search config and inconsistent search
results will appear between instances.

The test now sets a different language than english to ensure that the
search continues to explicitly specify the language when searching.

Issue #336 Test failure on different pg text search settings
bickelj added a commit that referenced this issue May 5, 2023
While the postgres (PG) text search (TS) config 'english' is specified
when building the text search column and index in the migration script
`0010-alter-proposal_field_values-value_search.sql`, when the postgres
`default_text_search_config` is set to `pg_catalog.simple` rather than
to `pg_catalog.english`, the test named `returns a subset of proposals
present in the database when search is provided` in file
`proposals.int.test.ts` will fail. For consistency in search results
across instances, this commit sets the query with search to use the
same `english`. Without this commit, tests will fail with different
PG settings for default text search config and inconsistent search
results will appear between instances.

The test now sets a different language than english to ensure that the
search continues to explicitly specify the language when searching.

Issue #336 Test failure on different pg text search settings
bickelj added a commit that referenced this issue May 8, 2023
While the postgres (PG) text search (TS) config 'english' is specified
when building the text search column and index in the migration script
`0010-alter-proposal_field_values-value_search.sql`, when the postgres
`default_text_search_config` is set to `pg_catalog.simple` rather than
to `pg_catalog.english`, the test named `returns a subset of proposals
present in the database when search is provided` in file
`proposals.int.test.ts` will fail. For consistency in search results
across instances, this commit sets the query with search to use the
same `english`. Without this commit, tests will fail with different
PG settings for default text search config and inconsistent search
results will appear between instances.

Issue #336 Test failure on different pg text search settings
@slifty
Copy link
Member

slifty commented May 9, 2023

I believe this is resolved with #337

@slifty slifty closed this as completed May 9, 2023
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

2 participants