Skip to content

Commit

Permalink
Merge pull request #3334 from terascope/update-facade-client-tests
Browse files Browse the repository at this point in the history
Update facade client tests
  • Loading branch information
jsnoble authored Feb 1, 2023
2 parents 89fffb5 + d634a86 commit 20d6e4b
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 104 deletions.
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"bunyan": "^1.8.15",
"elasticsearch-store": "^0.65.2",
"elasticsearch-store": "^0.65.3",
"fs-extra": "^10.1.0",
"ms": "^2.1.3",
"nanoid": "^3.3.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/data-mate/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-mate",
"displayName": "Data-Mate",
"version": "0.40.1",
"version": "0.40.2",
"description": "Library of data validations/transformations",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-mate#readme",
"repository": {
Expand Down Expand Up @@ -29,9 +29,9 @@
"test:watch": "TZ=utc ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-types": "^0.36.2",
"@terascope/types": "^0.11.1",
"@terascope/utils": "^0.45.2",
"@terascope/data-types": "^0.36.3",
"@terascope/types": "^0.11.2",
"@terascope/utils": "^0.45.3",
"@types/validator": "^13.7.7",
"awesome-phonenumber": "^2.70.0",
"date-fns": "^2.29.3",
Expand All @@ -46,7 +46,7 @@
"uuid": "^9.0.0",
"valid-url": "^1.0.9",
"validator": "^13.7.0",
"xlucene-parser": "^0.43.2"
"xlucene-parser": "^0.43.3"
},
"devDependencies": {
"@types/ip6addr": "^0.2.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/data-types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-types",
"displayName": "Data Types",
"version": "0.36.2",
"version": "0.36.3",
"description": "A library for defining the data structures and mapping",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-types#readme",
"bugs": {
Expand All @@ -26,8 +26,8 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/types": "^0.11.1",
"@terascope/utils": "^0.45.2",
"@terascope/types": "^0.11.2",
"@terascope/utils": "^0.45.3",
"graphql": "^14.7.0",
"lodash": "^4.17.21",
"yargs": "^17.6.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/elasticsearch-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/elasticsearch-api",
"displayName": "Elasticsearch API",
"version": "3.3.4",
"version": "3.3.5",
"description": "Elasticsearch client api used across multiple services, handles retries and exponential backoff",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-api#readme",
"bugs": {
Expand All @@ -22,16 +22,16 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/types": "^0.11.1",
"@terascope/utils": "^0.45.2",
"@terascope/types": "^0.11.2",
"@terascope/utils": "^0.45.3",
"bluebird": "^3.7.2",
"setimmediate": "^1.0.5"
},
"devDependencies": {
"@opensearch-project/opensearch": "^1.1.0",
"@types/elasticsearch": "^5.0.40",
"elasticsearch": "^15.4.1",
"elasticsearch-store": "^0.65.2",
"elasticsearch-store": "^0.65.3",
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
Expand Down
12 changes: 6 additions & 6 deletions packages/elasticsearch-store/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticsearch-store",
"displayName": "Elasticsearch Store",
"version": "0.65.2",
"version": "0.65.3",
"description": "An API for managing an elasticsearch index, with versioning and migration support.",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-store#readme",
"bugs": {
Expand Down Expand Up @@ -29,18 +29,18 @@
},
"dependencies": {
"@opensearch-project/opensearch": "^1.1.0",
"@terascope/data-mate": "^0.40.1",
"@terascope/data-types": "^0.36.2",
"@terascope/types": "^0.11.1",
"@terascope/utils": "^0.45.2",
"@terascope/data-mate": "^0.40.2",
"@terascope/data-types": "^0.36.3",
"@terascope/types": "^0.11.2",
"@terascope/utils": "^0.45.3",
"ajv": "^6.12.6",
"elasticsearch": "^15.4.1",
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0",
"setimmediate": "^1.0.5",
"uuid": "^9.0.0",
"xlucene-translator": "^0.28.3"
"xlucene-translator": "^0.28.4"
},
"devDependencies": {
"@types/uuid": "^8.3.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ export class Client {
distributionMeta
);

const resp = await client.indices.getSettings(parsedParams);
const resp = await client.indices.getFieldMapping(parsedParams);

return _removeBody(resp);
},
Expand All @@ -580,7 +580,7 @@ export class Client {
* @returns IndicesGetSettingsResponse
*/
async getSettings(
params: ClientParams.IndicesGetSettingsParams
params: ClientParams.IndicesGetSettingsParams = {}
): Promise<ClientResponse.IndicesGetSettingsResponse> {
const parsedParams = methods.convertIndicesGetSettingsParams(
params as ClientParams.IndicesGetSettingsParams,
Expand Down Expand Up @@ -617,7 +617,7 @@ export class Client {
* can be an empty query
*/
async refresh(
params: ClientParams.IndicesRefreshParams
params: ClientParams.IndicesRefreshParams = {}
): Promise<ClientResponse.IndicesRefreshResponse> {
const parsedParams = methods.convertIndicesRefreshParams(
params as ClientParams.IndicesRefreshParams,
Expand All @@ -636,7 +636,7 @@ export class Client {
* can be an empty query
*/
async recovery(
params: ClientParams.IndicesRecoveryParams
params: ClientParams.IndicesRecoveryParams = {}
): Promise<ClientResponse.IndicesRecoveryResponse> {
const parsedParams = methods.convertIndicesRecoveryParams(
params as ClientParams.IndicesRecoveryParams,
Expand Down
29 changes: 16 additions & 13 deletions packages/elasticsearch-store/src/test-helpers/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ export async function upload(
return client.bulk(query);
}

export function createMappingFromDatatype(
client: Client,
dataType: DataType,
type = '_doc',
overrides = {}
) {
const metaData = getClientMetadata(client);
const mapping = dataType.toESMapping({ typeName: type, overrides, ...metaData });

return fixMappingRequest(client, { body: mapping }, false);
}

export async function populateIndex(
client: Client,
index: string,
Expand All @@ -103,21 +115,12 @@ export async function populateIndex(
},
};

const metaData = getClientMetadata(client);
const mapping = dataType.toESMapping({ typeName: type, overrides, ...metaData });

await client.indices.create(
fixMappingRequest(
client,
{
index,
wait_for_active_shards: 'all',
body: mapping,
},
false
)
const mapping = createMappingFromDatatype(
client, dataType, type, overrides
);

await client.indices.create(mapping);

const body = formatUploadData(index, records);

const results = await client.bulk({
Expand Down
1 change: 1 addition & 0 deletions packages/elasticsearch-store/src/utils/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export function isElasticsearch8(client: Client): boolean {
return distribution === ElasticsearchDistribution.elasticsearch && parsedVersion === 8;
}

// TODO: move this logic over to datatype
export function fixMappingRequest(
client: Client, _params: Record<string, any>, isTemplate: boolean
): any {
Expand Down
Loading

0 comments on commit 20d6e4b

Please sign in to comment.