Skip to content

Commit

Permalink
test(cbjs): increase getQueryIndexes timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusTheHun committed Aug 15, 2024
1 parent a26b786 commit 6656679
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 186 deletions.
7 changes: 2 additions & 5 deletions packages/http-client/src/services/query/getQueryIndexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { hasOwn, invariant, Keyspace } from '@cbjsdev/shared';
import { hasOwn, Keyspace } from '@cbjsdev/shared';

import { CouchbaseHttpApiConfig } from '../../types.js';
import { ApiQueryResponseBody } from '../../types/Api/query/ApiQueryResponseBody.js';
import { HttpClientQueryIndex } from '../../types/HttpClient/HttpClientQueryIndex.js';
import {
QueryResultGsiIndex,
QueryResultSearchIndex,
} from '../../types/QueryResult/index.js';
import { QueryResultGsiIndex } from '../../types/QueryResult/index.js';
import { createHttpError } from '../../utils/createHttpError.js';
import { requestGetQueryIndexes } from './requests/requestGetQueryIndexes.js';

Expand Down
358 changes: 177 additions & 181 deletions tests/http-client/tests/query/getQueryIndexes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,196 +18,192 @@ import { describe } from 'vitest';
import { getQueryIndexes } from '@cbjsdev/http-client';
import { createCouchbaseTest } from '@cbjsdev/vitest';

describe(
'getQueryIndexes',
async () => {
const test = await createCouchbaseTest();
describe('getQueryIndexes', { timeout: 40_000 }, async () => {
const test = await createCouchbaseTest();

test('cluster level primary index', async ({
expect,
usePrimaryIndex,
serverTestContext,
apiConfig,
}) => {
const name = await usePrimaryIndex({ bucketName: serverTestContext.bucket.name });
test('cluster level primary index', async ({
expect,
usePrimaryIndex,
serverTestContext,
apiConfig,
}) => {
const name = await usePrimaryIndex({ bucketName: serverTestContext.bucket.name });

await expect(
getQueryIndexes(apiConfig, { bucket: serverTestContext.bucket.name })
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name,
bucketName: serverTestContext.bucket.name,
isPrimary: true,
fields: [],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
});

test('cluster level secondary index', async ({
expect,
useIndex,
serverTestContext,
apiConfig,
}) => {
const name = await useIndex({
bucketName: serverTestContext.bucket.name,
fields: ['name'],
});
await expect(
getQueryIndexes(apiConfig, { bucket: serverTestContext.bucket.name })
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name,
bucketName: serverTestContext.bucket.name,
isPrimary: true,
fields: [],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
});

await expect(
getQueryIndexes(apiConfig, { bucket: serverTestContext.bucket.name })
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name,
bucketName: serverTestContext.bucket.name,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
test('cluster level secondary index', async ({
expect,
useIndex,
serverTestContext,
apiConfig,
}) => {
const name = await useIndex({
bucketName: serverTestContext.bucket.name,
fields: ['name'],
});

test('collection level primary index', async ({
expect,
usePrimaryIndex,
serverTestContext,
apiConfig,
}) => {
const name = await usePrimaryIndex({
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
});
await expect(
getQueryIndexes(apiConfig, { bucket: serverTestContext.bucket.name })
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name,
bucketName: serverTestContext.bucket.name,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
});

await expect(
getQueryIndexes(apiConfig, {
bucket: serverTestContext.bucket.name,
scope: serverTestContext.scope.name,
collection: serverTestContext.collection.name,
})
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
isPrimary: true,
fields: [],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
test('collection level primary index', async ({
expect,
usePrimaryIndex,
serverTestContext,
apiConfig,
}) => {
const name = await usePrimaryIndex({
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
});

test('collection level secondary index', async ({
expect,
useIndex,
serverTestContext,
apiConfig,
useCollection,
}) => {
const collectionName = await useCollection();

const indexName1 = await useIndex({
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
fields: ['name'],
});
await expect(
getQueryIndexes(apiConfig, {
bucket: serverTestContext.bucket.name,
scope: serverTestContext.scope.name,
collection: serverTestContext.collection.name,
})
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
isPrimary: true,
fields: [],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
});

const indexName2 = await useIndex({
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName,
fields: ['name'],
});
test('collection level secondary index', async ({
expect,
useIndex,
serverTestContext,
apiConfig,
useCollection,
}) => {
const collectionName = await useCollection();

// Get the indexes on a single collection
await expect(
getQueryIndexes(apiConfig, {
bucket: serverTestContext.bucket.name,
scope: serverTestContext.scope.name,
collection: serverTestContext.collection.name,
})
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name: indexName1,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
const indexName1 = await useIndex({
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
fields: ['name'],
});

// Get the indexes on all the collections of a scope
await expect(
getQueryIndexes(apiConfig, {
bucket: serverTestContext.bucket.name,
scope: serverTestContext.scope.name,
})
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name: indexName1,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
{
id: expect.any(String),
name: indexName2,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
const indexName2 = await useIndex({
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName,
fields: ['name'],
});
},
{ timeout: 20_000 }
);

// Get the indexes on a single collection
await expect(
getQueryIndexes(apiConfig, {
bucket: serverTestContext.bucket.name,
scope: serverTestContext.scope.name,
collection: serverTestContext.collection.name,
})
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name: indexName1,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);

// Get the indexes on all the collections of a scope
await expect(
getQueryIndexes(apiConfig, {
bucket: serverTestContext.bucket.name,
scope: serverTestContext.scope.name,
})
).resolves.toEqual(
expect.arrayContaining([
{
id: expect.any(String),
name: indexName1,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName: serverTestContext.collection.name,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
{
id: expect.any(String),
name: indexName2,
bucketName: serverTestContext.bucket.name,
scopeName: serverTestContext.scope.name,
collectionName,
isPrimary: false,
fields: ['name'],
node: 'http://127.0.0.1:8091',
numReplicas: 0,
namespace: 'default',
state: 'online',
using: 'gsi',
},
])
);
});
});

0 comments on commit 6656679

Please sign in to comment.