Skip to content

Commit

Permalink
Merge pull request #97 from pagopa/fix-perf-test
Browse files Browse the repository at this point in the history
fix cosmos client
  • Loading branch information
cap-ang authored Jul 19, 2023
2 parents 153ce4b + 62a8ec6 commit 41446c1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions performance-test/src/helpers/cosmosdb_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getDocumentById(cosmosDbURI, databaseId, containerId, authorizat
let authorizationToken = getCosmosDBAuthorizationToken(verb,authorizationType,authorizationVersion,authorizationSignature,resourceType,resourceLink,date);

let partitionKeyArray = [];
let headers = getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, 'application/query+json');
let headers = getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, 'application/query+json', 'true');

const body = {
"query": "SELECT * FROM c where c.id=\"" + id + "\"",
Expand All @@ -38,7 +38,7 @@ export function createDocument(cosmosDbURI, databaseId, containerId, authorizati
let authorizationToken = getCosmosDBAuthorizationToken(verb,authorizationType,authorizationVersion,authorizationSignature,resourceType,resourceLink,date);

let partitionKeyArray = "[\""+pk+"\"]";
let headers = getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, 'application/json');
let headers = getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, 'application/json', 'false');

const body = JSON.stringify(document);

Expand All @@ -60,7 +60,7 @@ export function deleteDocument(cosmosDbURI, databaseId, containerId, authorizati
let authorizationToken = getCosmosDBAuthorizationToken(verb,authorizationType,authorizationVersion,authorizationSignature,resourceType,resourceLink,date);

let partitionKeyArray = "[\""+pk+"\"]";
let headers = getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, 'application/json');
let headers = getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, 'application/json', 'false');

let params = {
headers: headers,
Expand All @@ -71,14 +71,14 @@ export function deleteDocument(cosmosDbURI, databaseId, containerId, authorizati



function getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, contentType){
function getCosmosDBAPIHeaders(authorizationToken, date, partitionKeyArray, contentType, isQuery){

return {'Accept': 'application/json',
'Content-Type': contentType,
'Authorization': authorizationToken,
'x-ms-version': cosmosDBApiVersion,
'x-ms-date': date,
'x-ms-documentdb-isquery': 'true',
'x-ms-documentdb-isquery': isQuery,
'x-ms-query-enable-crosspartition': 'true',
'x-ms-documentdb-partitionkey': partitionKeyArray};
}
Expand Down

0 comments on commit 41446c1

Please sign in to comment.