@terascope/elasticsearch-api 3.6.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@terascope/elasticsearch-api",
3
3
  "displayName": "Elasticsearch API",
4
- "version": "3.6.1",
4
+ "version": "3.7.0",
5
5
  "description": "Elasticsearch client api used across multiple services, handles retries and exponential backoff",
6
6
  "homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-api#readme",
7
7
  "bugs": {
@@ -13,17 +13,19 @@
13
13
  "main": "index.js",
14
14
  "typings": "types/index.d.ts",
15
15
  "scripts": {
16
- "test": "ts-scripts test . --",
17
- "test:7": "ELASTICSEARCH_VERSION='7.9.3' yarn run test",
18
- "test:8": "ELASTICSEARCH_VERSION='8.1.2' yarn run test",
19
- "test:debug": "ts-scripts test --debug . --",
20
- "test:legacy": "LEGACY_CLIENT=true yarn run test:debug",
21
- "test:opensearch": "TEST_OPENSEARCH='true' RESTRAINED_OPENSEARCH='true' yarn run test",
22
- "test:watch": "ts-scripts test --watch . --"
16
+ "test": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test . --",
17
+ "test:debug": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test --debug . --",
18
+ "test:elasticsearch6": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test . --",
19
+ "test:elasticsearch7": "TEST_RESTRAINED_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' ts-scripts test . --",
20
+ "test:elasticsearch8": "TEST_RESTRAINED_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='8.1.2' ts-scripts test . --",
21
+ "test:legacy": "TEST_RESTRAINED_ELASTICSEARCH='true' LEGACY_CLIENT=true ts-scripts test . --",
22
+ "test:opensearch1": "TEST_RESTRAINED_OPENSEARCH='true' ts-scripts test --debug . --",
23
+ "test:opensearch2": "TEST_RESTRAINED_OPENSEARCH='true' OPENSEARCH_VERSION='2.8.0' ts-scripts test --debug . --",
24
+ "test:watch": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test --watch . --"
23
25
  },
24
26
  "dependencies": {
25
27
  "@terascope/types": "^0.11.2",
26
- "@terascope/utils": "^0.46.0",
28
+ "@terascope/utils": "^0.47.0",
27
29
  "bluebird": "^3.7.2",
28
30
  "setimmediate": "^1.0.5"
29
31
  },
@@ -31,7 +33,7 @@
31
33
  "@opensearch-project/opensearch": "^1.2.0",
32
34
  "@types/elasticsearch": "^5.0.40",
33
35
  "elasticsearch": "^15.4.1",
34
- "elasticsearch-store": "^0.67.2",
36
+ "elasticsearch-store": "^0.68.0",
35
37
  "elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
36
38
  "elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
37
39
  "elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
@@ -9,37 +9,18 @@ const { ElasticsearchTestHelpers } = require('elasticsearch-store');
9
9
  const elasticsearchAPI = require('../index');
10
10
 
11
11
  const {
12
- makeClient, cleanupIndex,
13
- EvenDateData, TEST_INDEX_PREFIX,
14
- createMappingFromDatatype
12
+ makeClient, cleanupIndex, EvenDateData,
13
+ TEST_INDEX_PREFIX, createMappingFromDatatype,
14
+ formatUploadData
15
15
  } = ElasticsearchTestHelpers;
16
16
 
17
17
  const THREE_MINUTES = 3 * 60 * 1000;
18
18
 
19
19
  jest.setTimeout(THREE_MINUTES + 60000);
20
20
 
21
- function formatUploadData(
22
- index, data, isES8ClientTest = false
23
- ) {
24
- const results = [];
25
-
26
- data.forEach((record, i) => {
27
- const meta = { _index: index, _id: i + 1 };
28
-
29
- if (!isES8ClientTest) {
30
- meta._type = '_doc';
31
- }
32
-
33
- results.push({ action: { index: meta }, data: record });
34
- });
35
-
36
- return results;
37
- }
38
-
39
21
  describe('bulkSend', () => {
40
22
  let client;
41
23
  let api;
42
- let isElasticsearch8 = false;
43
24
 
44
25
  beforeAll(async () => {
45
26
  client = await makeClient();
@@ -52,7 +33,6 @@ describe('bulkSend', () => {
52
33
  beforeAll(async () => {
53
34
  await cleanupIndex(client, index);
54
35
  api = elasticsearchAPI(client, logger, { _dead_letter_action: 'kafka_dead_letter' });
55
- isElasticsearch8 = api.isElasticsearch8();
56
36
 
57
37
  const overrides = {
58
38
  settings: {
@@ -79,7 +59,7 @@ describe('bulkSend', () => {
79
59
 
80
60
  const docs = cloneDeep(EvenDateData.data.slice(0, 2));
81
61
 
82
- const result = await diffApi.bulkSend(formatUploadData(index, docs, isElasticsearch8));
62
+ const result = await diffApi.bulkSend(formatUploadData(index, docs, true));
83
63
 
84
64
  expect(result).toBe(2);
85
65
  });
@@ -91,7 +71,7 @@ describe('bulkSend', () => {
91
71
 
92
72
  docs[0].bytes = 'this is a bad value';
93
73
 
94
- await expect(diffApi.bulkSend(formatUploadData(index, docs, isElasticsearch8)))
74
+ await expect(diffApi.bulkSend(formatUploadData(index, docs, true)))
95
75
  .rejects.toThrow();
96
76
  });
97
77
 
@@ -101,7 +81,7 @@ describe('bulkSend', () => {
101
81
 
102
82
  docs[0].bytes = 'this is a bad value';
103
83
 
104
- const result = await api.bulkSend(formatUploadData(index, docs, isElasticsearch8));
84
+ const result = await api.bulkSend(formatUploadData(index, docs, true));
105
85
 
106
86
  // 1 good doc - so only 1 row affected
107
87
  expect(result).toBe(1);
@@ -113,7 +93,7 @@ describe('bulkSend', () => {
113
93
  it('should return a count if not un-retryable records if dlq is set', async () => {
114
94
  const docs = cloneDeep(EvenDateData.data.slice(0, 2));
115
95
 
116
- const result = await api.bulkSend(formatUploadData(index, docs, isElasticsearch8));
96
+ const result = await api.bulkSend(formatUploadData(index, docs, true));
117
97
 
118
98
  expect(result).toBe(2);
119
99
  });
@@ -10,35 +10,16 @@ const elasticsearchAPI = require('../index');
10
10
 
11
11
  const {
12
12
  makeClient, cleanupIndex, waitForData,
13
- EvenDateData, TEST_INDEX_PREFIX
13
+ EvenDateData, TEST_INDEX_PREFIX, formatUploadData
14
14
  } = ElasticsearchTestHelpers;
15
15
 
16
16
  const THREE_MINUTES = 3 * 60 * 1000;
17
17
 
18
18
  jest.setTimeout(THREE_MINUTES + 60000);
19
19
 
20
- function formatUploadData(
21
- index, data, isES8ClientTest = false
22
- ) {
23
- const results = [];
24
-
25
- data.forEach((record) => {
26
- const meta = { _index: index };
27
-
28
- if (!isES8ClientTest) {
29
- meta._type = '_doc';
30
- }
31
-
32
- results.push({ action: { index: meta }, data: record });
33
- });
34
-
35
- return results;
36
- }
37
-
38
20
  describe('bulkSend', () => {
39
21
  let client;
40
22
  let api;
41
- let isElasticsearch8 = false;
42
23
 
43
24
  beforeAll(async () => {
44
25
  client = await makeClient();
@@ -51,7 +32,6 @@ describe('bulkSend', () => {
51
32
  beforeAll(async () => {
52
33
  await cleanupIndex(client, index);
53
34
  api = elasticsearchAPI(client, logger);
54
- isElasticsearch8 = api.isElasticsearch8();
55
35
  });
56
36
 
57
37
  afterAll(async () => {
@@ -62,7 +42,7 @@ describe('bulkSend', () => {
62
42
  const chunkedData = chunk(EvenDateData.data, 50);
63
43
 
64
44
  await pMap(chunkedData, async (cData) => {
65
- const formattedData = formatUploadData(index, cData, isElasticsearch8);
45
+ const formattedData = formatUploadData(index, cData, true);
66
46
  return api.bulkSend(formattedData);
67
47
  }, { concurrency: 9 });
68
48