From f2b54c1445d3c544b6896350d10ebf0a103dbe36 Mon Sep 17 00:00:00 2001 From: aulorbe Date: Mon, 23 Dec 2024 11:54:27 -0800 Subject: [PATCH 1/4] Build out index tags tests a bit more --- .../control/configureIndex.test.ts | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index 1f203b9f..b5825f53 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -136,17 +136,52 @@ describe('configure index', () => { }); }); + test('Add index tag to a serverless index', async () => { + const description = await pinecone.describeIndex(serverlessIndexName); + expect(description.tags).toEqual({ + project: 'pinecone-integration-tests', + }); + + await pinecone.configureIndex(serverlessIndexName, { + tags: { testTag: 'testValue' }, + }); + const description2 = await pinecone.describeIndex(serverlessIndexName); + expect(description2.tags).toEqual({ + project: 'pinecone-integration-tests', + testTag: 'testValue', + }); + }); + test('Remove index tag from serverless index', async () => { const description = await pinecone.describeIndex(serverlessIndexName); expect(description.tags).toEqual({ project: 'pinecone-integration-tests', + testTag: 'testValue', }); await pinecone.configureIndex(serverlessIndexName, { tags: { project: '' }, }); const description2 = await pinecone.describeIndex(serverlessIndexName); - expect(description2.tags).toBeUndefined(); + if (description2.tags != null) { + expect(description2.tags['project']).toBeUndefined(); + expect(description2.tags['testTag']).toEqual('testValue'); + } + }); + + test('Update a tag value in a serverless index', async () => { + const description = await pinecone.describeIndex(serverlessIndexName); + expect(description.tags).toEqual({ + testTag: 'testValue', + }); + + await pinecone.configureIndex(serverlessIndexName, { + tags: { testTag: 'newValue' }, + }); + const description2 = await pinecone.describeIndex(serverlessIndexName); + if (description2.tags != null) { + expect(description2.tags['testTag']).toEqual('newValue'); + } }); }); From 9fa9108de188ea8eef87ec4b924f81e9f83aff98 Mon Sep 17 00:00:00 2001 From: aulorbe Date: Tue, 7 Jan 2025 12:47:03 -0800 Subject: [PATCH 2/4] Make index tests a bit more robust --- .../control/configureIndex.test.ts | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index b5825f53..0b7208f4 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -160,27 +160,46 @@ describe('configure index', () => { }); await pinecone.configureIndex(serverlessIndexName, { - tags: { project: '' }, + tags: { testTag: '' }, }); const description2 = await pinecone.describeIndex(serverlessIndexName); if (description2.tags != null) { - expect(description2.tags['project']).toBeUndefined(); - expect(description2.tags['testTag']).toEqual('testValue'); + expect(description2.tags['testTag']).toBeUndefined(); + expect(description2.tags['project']).toEqual( + 'pinecone-integration-tests' + ); + } + + // Confirm when config'ing other things about the index, tags are not changed + await pinecone.configureIndex(serverlessIndexName, { + deletionProtection: 'enabled', + }); + const description3 = await pinecone.describeIndex(serverlessIndexName); + if (description3.tags != null) { + expect(description3.tags['testTag']).toBeUndefined(); + expect(description3.tags['project']).toEqual( + 'pinecone-integration-tests' + ); } + + // (Cleanup) Disable deletion protection + await pinecone.configureIndex(serverlessIndexName, { + deletionProtection: 'disabled', + }); }); test('Update a tag value in a serverless index', async () => { const description = await pinecone.describeIndex(serverlessIndexName); expect(description.tags).toEqual({ - testTag: 'testValue', + project: 'pinecone-integration-tests', }); await pinecone.configureIndex(serverlessIndexName, { - tags: { testTag: 'newValue' }, + tags: { project: 'updated-project' }, }); const description2 = await pinecone.describeIndex(serverlessIndexName); if (description2.tags != null) { - expect(description2.tags['testTag']).toEqual('newValue'); + expect(description2.tags['project']).toEqual('updated-project'); } }); }); From 01f8cf428bdc73ac07ed728035a923bdcbcdd1d9 Mon Sep 17 00:00:00 2001 From: aulorbe Date: Tue, 7 Jan 2025 12:55:01 -0800 Subject: [PATCH 3/4] Reorganize tests --- .../control/configureIndex.test.ts | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index 0b7208f4..98df7dbb 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -136,12 +136,13 @@ describe('configure index', () => { }); }); - test('Add index tag to a serverless index', async () => { + test('Add/remove/update index tag(s) on serverless index', async () => { const description = await pinecone.describeIndex(serverlessIndexName); expect(description.tags).toEqual({ project: 'pinecone-integration-tests', }); + // Add a tag await pinecone.configureIndex(serverlessIndexName, { tags: { testTag: 'testValue' }, }); @@ -150,22 +151,15 @@ describe('configure index', () => { project: 'pinecone-integration-tests', testTag: 'testValue', }); - }); - - test('Remove index tag from serverless index', async () => { - const description = await pinecone.describeIndex(serverlessIndexName); - expect(description.tags).toEqual({ - project: 'pinecone-integration-tests', - testTag: 'testValue', - }); + // Remove that tag await pinecone.configureIndex(serverlessIndexName, { - tags: { testTag: '' }, + tags: { testTag: '' }, // Passing null/undefined here is not allowed due to type safety (must eval to string) }); - const description2 = await pinecone.describeIndex(serverlessIndexName); - if (description2.tags != null) { - expect(description2.tags['testTag']).toBeUndefined(); - expect(description2.tags['project']).toEqual( + const description3 = await pinecone.describeIndex(serverlessIndexName); + if (description3.tags != null) { + expect(description3.tags['testTag']).toBeUndefined(); + expect(description3.tags['project']).toEqual( 'pinecone-integration-tests' ); } @@ -174,10 +168,10 @@ describe('configure index', () => { await pinecone.configureIndex(serverlessIndexName, { deletionProtection: 'enabled', }); - const description3 = await pinecone.describeIndex(serverlessIndexName); - if (description3.tags != null) { - expect(description3.tags['testTag']).toBeUndefined(); - expect(description3.tags['project']).toEqual( + const description4 = await pinecone.describeIndex(serverlessIndexName); + if (description4.tags != null) { + expect(description4.tags['testTag']).toBeUndefined(); + expect(description4.tags['project']).toEqual( 'pinecone-integration-tests' ); } From 621fdb99dd7fd89dd662193f1b5360272aba8120 Mon Sep 17 00:00:00 2001 From: aulorbe Date: Tue, 7 Jan 2025 12:57:10 -0800 Subject: [PATCH 4/4] Fix comment --- src/integration/control/configureIndex.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index 98df7dbb..a0daa6c2 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -136,7 +136,7 @@ describe('configure index', () => { }); }); - test('Add/remove/update index tag(s) on serverless index', async () => { + test('Add/remove index tag(s) on serverless index', async () => { const description = await pinecone.describeIndex(serverlessIndexName); expect(description.tags).toEqual({ project: 'pinecone-integration-tests',