Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Centralize test indexes for integration tests (#291)
## TLDR This PR takes our integration test timing in CI down from ~37mins to ~10mins! 🎉 ## Problem Our integration tests are currently very flakey (meaning they fail in an non-deterministic manner depending largely on fluctuations in latency on backend operations). ## Solution Centralize the creation and deletion of indexes for integration tests; cleanup the tests where I can. **The tests that now use the centralized indexes:** **- Control:** - `describeIndex.test.ts` - `listIndexes.test.ts` **- Data:** - `fetch.test.ts` - `list.test.ts` - `query.test.ts` **The tests that still have to create/delete their own indexes because their operations are difficult to undo:** **- Control:** - `configureIndex.test.ts` - `createIndex.test.ts` **- Data:** - `delete.test.ts` - `upsertAndUpdate.test.ts` ### New jobs & files - I added a job in `testing.yml` called `setup` that calls a file called `setup.ts` (`src/integration/setup.ts`) - I added a job in `testing.yml` called `teardown` that calls a file called `teardown.ts` (`src/integration/teardown.ts`) - `setup.ts` sets up (creates and seeds) a shared serverless index (only serverless for now b/c we don't have pod-based data plane tests). **The index name is randomized, so simultaneous jobs can occur using the same Pinecone API key** 😄 . - I have put a `todo` in this file to refactor it; right now, it's quite rudimentary in the way it loops and checks conditions; you'll notice other `todo`s in other files that point to where we need more tests, etc. I'd like to keep these in there for now, if that's okay. - `teardown.ts` deletes this index - I found some tests that were not actually testing what they intended to, so I have marked those as skipped for now (e.g. `createIndex.test.ts > `test('insufficient quota')`) - I added a file called `integrationRunner.js`, which is a file for running integration tests locally with a new command in `package.json` that you can execute by running `npm run test:integration-local:node`. This will do the setup, tests, and teardown all in 1 go for you locally. ### Bug fixes - Last week, @austin-denoble and I noticed a bug in `waitUntilReady` where the `status` sometimes evaluated to `Ready` without the index actually being ready. So, this PR includes a fix to that function that also checks for `state.ready` being `true` _and_ adds a value (that it also checks for) to the `IndexModelStatusStateEnum` that accounts for an index's state being `Upgrading`, which accounted for a lot of flakiness in the configureIndex tests. ## Notes - The goal of this PR is to _decrease_ flakiness - I removed one of our Bun versions to try to get the time down a bit; we might want to experiment with upping the `max-parallel` field too in `testing.yml` (although I tried removing it altogether and we had failures) - I _removed_ the job in `testing.yml` that calls `utils/cleanupResources.ts`, since I replaced it with my `Teardown` job. This file (`cleanupResources`) is still called via cron, though, by `testing-cleanup.yml` - I decided _not_ to use [jest's `globalSetup` and `globalTeardown` capabilities](https://jestjs.io/docs/configuration#globalsetup-string) because the "global" scope is per option in our test matrix. Creating a custom setup and teardown job instead allowed me to create a single test index we can use across all options in our matrix, which is more efficient. ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [x] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan CI passes consistently --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1208439494339500 - https://app.asana.com/0/0/1207545518662985
- Loading branch information