From dc7bffffe253f35f92c18ffd1fbd41c5b31dbaa2 Mon Sep 17 00:00:00 2001 From: Manik Khandelwal Date: Mon, 13 Jan 2025 13:57:18 +0530 Subject: [PATCH] update test --- sdk/cosmosdb/cosmos/review/cosmos.api.md | 1 + .../parallelQueryExecutionContextBase.ts | 7 ++--- .../TestOrderbyQueryExecutionContext.ts | 9 ------ .../pipelinedQueryExecutionContext.spec.ts | 12 ++++---- .../test/public/functional/test-query.spec.ts | 29 ------------------- 5 files changed, 9 insertions(+), 49 deletions(-) delete mode 100644 sdk/cosmosdb/cosmos/test/internal/unit/common/TestOrderbyQueryExecutionContext.ts delete mode 100644 sdk/cosmosdb/cosmos/test/public/functional/test-query.spec.ts diff --git a/sdk/cosmosdb/cosmos/review/cosmos.api.md b/sdk/cosmosdb/cosmos/review/cosmos.api.md index 454f36a290fc..0628fb896ed5 100644 --- a/sdk/cosmosdb/cosmos/review/cosmos.api.md +++ b/sdk/cosmosdb/cosmos/review/cosmos.api.md @@ -1054,6 +1054,7 @@ export interface FeedOptions extends SharedOptions { continuationToken?: string; continuationTokenLimitInKB?: number; disableNonStreamingOrderByQuery?: boolean; + enableQueryControl?: boolean; enableScanInQuery?: boolean; forceQueryPlan?: boolean; maxDegreeOfParallelism?: number; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts index 3e8116be76a5..4003534d55a6 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts @@ -429,7 +429,7 @@ export abstract class ParallelQueryExecutionContextBase implements ExecutionCont documentProducer: DocumentProducer, ): Promise => { try { - await documentProducer.bufferMore(this.getDiagnosticNode()); + await documentProducer.bufferMore(diagnosticNode); // if buffer of document producer is filled, add it to the buffered document producers queue const nextItem = documentProducer.peakNextItem(); if (nextItem !== undefined) { @@ -443,10 +443,7 @@ export abstract class ParallelQueryExecutionContextBase implements ExecutionCont // So that later parts of the code can repair the execution context // refresh the partition key ranges and ctreate new document producers and add it to the queue - await this._enqueueReplacementDocumentProducers( - this.getDiagnosticNode(), - documentProducer, - ); + await this._enqueueReplacementDocumentProducers(diagnosticNode, documentProducer); resolve(); } else { this.err = err; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/common/TestOrderbyQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/test/internal/unit/common/TestOrderbyQueryExecutionContext.ts deleted file mode 100644 index bd1e314490d9..000000000000 --- a/sdk/cosmosdb/cosmos/test/internal/unit/common/TestOrderbyQueryExecutionContext.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { ExecutionContext } from "../../../../src/queryExecutionContext"; -import { OrderByQueryExecutionContext } from "../../../../src/queryExecutionContext/orderByQueryExecutionContext"; - -export class TestOrderbyQueryExecutionContext - extends OrderByQueryExecutionContext - implements ExecutionContext {} diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/query/pipelinedQueryExecutionContext.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/query/pipelinedQueryExecutionContext.spec.ts index 88e736793bba..168e33d7da64 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/query/pipelinedQueryExecutionContext.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/query/pipelinedQueryExecutionContext.spec.ts @@ -84,7 +84,7 @@ describe("PipelineQueryExecutionContext", function () { ); // Mock the endpoint's fetchMore method to return 3 documents in every call context["endpoint"] = { - fetchMore: async (diagnosticNode: any) => { + fetchMore: async () => { return { result: [ createMockDocument("1", "doc1", "value1"), @@ -123,7 +123,7 @@ describe("PipelineQueryExecutionContext", function () { ); let i = 0; context["endpoint"] = { - fetchMore: async (diagnosticNode: any) => { + fetchMore: async () => { if (i < 3) { i++; return { @@ -166,7 +166,7 @@ describe("PipelineQueryExecutionContext", function () { ); let i = 0; context["endpoint"] = { - fetchMore: async (diagnosticNode: any) => { + fetchMore: async () => { if (i < 1) { i++; return { @@ -207,7 +207,7 @@ describe("PipelineQueryExecutionContext", function () { false, ); context["endpoint"] = { - fetchMore: async (diagnosticNode: any) => { + fetchMore: async () => { return { result: undefined, headers: {}, @@ -237,7 +237,7 @@ describe("PipelineQueryExecutionContext", function () { ); let i = 0; context["endpoint"] = { - fetchMore: async (diagnosticNode: any) => { + fetchMore: async () => { if (i < 1) { i++; return { @@ -282,7 +282,7 @@ describe("PipelineQueryExecutionContext", function () { true, ); context["endpoint"] = { - fetchMore: async (diagnosticNode: any) => { + fetchMore: async () => { return { result: [ createMockDocument("1", "doc1", "value1"), diff --git a/sdk/cosmosdb/cosmos/test/public/functional/test-query.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/test-query.spec.ts deleted file mode 100644 index 6a9a4ae40cf1..000000000000 --- a/sdk/cosmosdb/cosmos/test/public/functional/test-query.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -// write tests for testing a group by query -import { assert } from "chai"; -import { getTestContainer } from "../common/TestHelpers"; - -describe("Group-By-Query", function () { - it("should return the correct result for a group by query", async function () { - // create database container and some itmes to for group by response - const container = await getTestContainer("Test", undefined, { - partitionKey: "/name", - throughput: 10000, - }); - await Promise.all([ - container.items.create({ id: "1", name: "foo" }), - container.items.create({ id: "2", name: "bar" }), - container.items.create({ id: "3", name: "foo" }), - ]); - const querySpec = { - query: "SELECT c.id, COUNT(1) AS count FROM c GROUP BY c.id", - }; - const { resources: results } = await container.items.query(querySpec).fetchAll(); - assert.strictEqual(results.length, 3); - assert.strictEqual(results[0].count, 1); - assert.strictEqual(results[1].count, 1); - assert.strictEqual(results[2].count, 1); - }); -});