Skip to content

Commit

Permalink
Merge branch 'main' into console-mappings-ts
Browse files Browse the repository at this point in the history
Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh authored Jun 28, 2023
2 parents fc52bb3 + dcdc68d commit ccdee60
Show file tree
Hide file tree
Showing 52 changed files with 452 additions and 3,375 deletions.
5 changes: 3 additions & 2 deletions .lycheeexclude
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ http://www.creedthoughts.gov
https://media-for-the-masses.theacademyofperformingartsandscience.org/
https://yarnpkg.com/latest.msi
https://forum.opensearch.org/
https://facebook.github.io/jest/
https://facebook.github.io/jest/docs/cli.html
https://facebook.github.io/jest/*
http://helpmenow.com/problem2
https://sass-lang.com/*
http://api.jquery.com/*
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [@osd/pm] Fix `file:`-linked dependencies' resolution to improve ability to test with local packages ([#4342](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4342))
- [Multiple DataSource] Backend support for adding sample data ([#4268](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4268))
- Add configurable defaults and overrides to uiSettings ([#4344](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4344))
- Bump OUI to `1.1.2` to make `anomalyDetection` icon available ([#4408](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4408))

### 🐛 Bug Fixes

Expand All @@ -39,6 +40,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add an achievement badger to the PR ([#3721](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3721))
- Upgrade the backport workflow ([#4343](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4343))
- [Lint] Add custom stylelint rules and config to prevent unintended style overrides ([#4290](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4290))
- [Lint] Add stylelint rule to define properties that are restricted from being used ([#4374](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4374))

### 📝 Documentation

Expand All @@ -60,10 +62,13 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fix EUI/OUI type errors ([#3798](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3798))
- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
- [Table Visualization] Remove custom styling for text-align:center in favor of OUI utility class. ([#4164](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4164))
- Migrate from legacy elasticsearch client to opensearch-js client in `osd-opensearch-archiver` package([#4142](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4142))
- Replace the use of `bluebird` in `saved_objects` plugin ([#4026](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4026))
- [Vis Colors] Replace color maps with OUI color palettes ([#4293](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4293))
- [Vis Colors] [Maps] Replace hardcoded color to OUI color in `maps_legacy` plugin ([#4294](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4294))
- [Vis Colors] [TSVB] Update default color in `vis_type_timeseries` to use `ouiPaletteColorBlind()[0]`([#4363](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4363))
- [Vis Colors] [Timeline] Replace `vis_type_timeline` colors with `ouiPaletteColorBlind()` ([#4366](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4366))
- [Vis Colors] Update legacy seed colors to use `ouiPaletteColorBlind()` ([#4348](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4348))
- [Console] Migrate `/lib/mappings/` module to TypeScript ([#4008](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4008))

### 🔩 Tests
Expand Down Expand Up @@ -163,6 +168,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Monaco editor] Add json worker support ([#3424](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3424))
- [Multiple DataSource] Allow create and distinguish index pattern with same name but from different datasources ([#3604](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3604))
- [Multiple DataSource] Integrate multiple datasource with dev tool console ([#3754](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3754))
- [Navigation] Remove unused tags ([#3964](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3964))
- [Notifications] Add id to toast api for deduplication ([#3752](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3752))
- [UI] Add support for comma delimiters in the global filter bar ([#3686](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3686))
- [UI] Indicate that IE is no longer supported ([#3641](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3641))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"dependencies": {
"@aws-crypto/client-node": "^3.1.1",
"@elastic/datemath": "5.0.3",
"@elastic/eui": "npm:@opensearch-project/oui@1.1.1",
"@elastic/eui": "npm:@opensearch-project/oui@1.1.2",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/numeral": "^2.5.0",
"@elastic/request-crypto": "2.0.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/osd-opensearch-archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
},
"dependencies": {
"@osd/dev-utils": "1.0.0",
"elasticsearch": "^16.7.0"
"@opensearch-project/opensearch": "^2.2.0"
},
"devDependencies": {
"@types/elasticsearch": "^5.0.33"
}
"devDependencies": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import { Client } from 'elasticsearch';
import { Client } from '@opensearch-project/opensearch';
import { ToolingLog, OsdClient } from '@osd/dev-utils';

import {
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-opensearch-archiver/src/actions/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { resolve } from 'path';
import { createReadStream } from 'fs';
import { Readable } from 'stream';
import { ToolingLog, OsdClient } from '@osd/dev-utils';
import { Client } from 'elasticsearch';
import { Client } from '@opensearch-project/opensearch';

import { createPromiseFromStreams, concatStreamProviders } from '../lib/streams';

Expand Down Expand Up @@ -114,7 +114,7 @@ export async function loadAction({

await client.indices.refresh({
index: '_all',
allowNoIndices: true,
allow_no_indices: true,
});

// If we affected the OpenSearch Dashboards index, we need to ensure it's migrated...
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch-archiver/src/actions/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import { resolve } from 'path';
import { createWriteStream, mkdirSync } from 'fs';
import { Readable, Writable } from 'stream';
import { Client } from 'elasticsearch';
import { Client } from '@opensearch-project/opensearch';
import { ToolingLog } from '@osd/dev-utils';

import { createListStream, createPromiseFromStreams } from '../lib/streams';
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-opensearch-archiver/src/actions/unload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import { resolve } from 'path';
import { createReadStream } from 'fs';
import { Readable, Writable } from 'stream';
import { Client } from 'elasticsearch';
import { Client } from '@opensearch-project/opensearch';
import { ToolingLog, OsdClient } from '@osd/dev-utils';

import { createPromiseFromStreams } from '../lib/streams';
Expand Down
13 changes: 7 additions & 6 deletions packages/osd-opensearch-archiver/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import Path from 'path';
import readline from 'readline';

import { RunWithCommands, createFlagError } from '@osd/dev-utils';
import { Client, ClientOptions } from '@opensearch-project/opensearch';
import { readConfigFile } from '@osd/test';
import legacyElasticsearch from 'elasticsearch';

import { OpenSearchArchiver } from './opensearch_archiver';

Expand All @@ -56,7 +56,7 @@ export function runCli() {
default: ${defaultConfigPath}
--opensearch-url url for OpenSearch, prefer the --config flag
--opensearch-dashboards-url url for OpenSearch Dashboards, prefer the --config flag
--dir where arechives are stored, prefer the --config flag
--dir where archives are stored, prefer the --config flag
`,
},
async extendContext({ log, flags, addCleanupTask }) {
Expand Down Expand Up @@ -99,10 +99,11 @@ export function runCli() {
throw createFlagError('--dir or --config must be defined');
}

const client = new legacyElasticsearch.Client({
host: opensearchUrl,
log: flags.verbose ? 'trace' : [],
});
const clientOptions: ClientOptions = {
node: opensearchUrl.toString(),
};

const client = new Client(clientOptions);
addCleanupTask(() => client.close());

const opensearchArchiver = new OpenSearchArchiver({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ describe('opensearchArchiver: createGenerateDocRecordsStream()', () => {
expect(params).to.have.property('index', 'logstash-*');
expect(params).to.have.property('size', 1000);
return {
hits: {
total: 0,
hits: [],
body: {
hits: {
total: 0,
hits: [],
},
},
};
},
Expand All @@ -74,9 +76,11 @@ describe('opensearchArchiver: createGenerateDocRecordsStream()', () => {
expect(params).to.have.property('scroll', '1m');
expect(params).to.have.property('rest_total_hits_as_int', true);
return {
hits: {
total: 0,
hits: [],
body: {
hits: {
total: 0,
hits: [],
},
},
};
},
Expand All @@ -101,25 +105,27 @@ describe('opensearchArchiver: createGenerateDocRecordsStream()', () => {
expect(params).to.have.property('index', 'index1');
await delay(200);
return {
_scroll_id: 'index1ScrollId',
hits: { total: 2, hits: [{ _id: 1, _index: '.opensearch_dashboards_1' }] },
body: {
_scroll_id: 'index1ScrollId',
hits: { total: 2, hits: [{ _id: 1, _index: '.opensearch_dashboards_1' }] },
},
};
},
async (name, params) => {
expect(name).to.be('scroll');
expect(params).to.have.property('scrollId', 'index1ScrollId');
expect(params).to.have.property('scroll_id', 'index1ScrollId');
expect(Date.now() - checkpoint).to.not.be.lessThan(200);
checkpoint = Date.now();
await delay(200);
return { hits: { total: 2, hits: [{ _id: 2, _index: 'foo' }] } };
return { body: { hits: { total: 2, hits: [{ _id: 2, _index: 'foo' }] } } };
},
async (name, params) => {
expect(name).to.be('search');
expect(params).to.have.property('index', 'index2');
expect(Date.now() - checkpoint).to.not.be.lessThan(200);
checkpoint = Date.now();
await delay(200);
return { hits: { total: 0, hits: [] } };
return { body: { hits: { total: 0, hits: [] } } };
},
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import { Transform } from 'stream';
import { Client, SearchParams, SearchResponse } from 'elasticsearch';
import { Client, ApiResponse } from '@opensearch-project/opensearch';
import { Stats } from '../stats';
import { Progress } from '../progress';

Expand All @@ -53,7 +53,7 @@ export function createGenerateDocRecordsStream({
async transform(index, enc, callback) {
try {
let remainingHits = 0;
let resp: SearchResponse<any> | null = null;
let resp: ApiResponse<any> | null = null;

while (!resp || remainingHits > 0) {
if (!resp) {
Expand All @@ -66,17 +66,17 @@ export function createGenerateDocRecordsStream({
query,
},
rest_total_hits_as_int: true, // not declared on SearchParams type
} as SearchParams);
remainingHits = resp.hits.total;
});
remainingHits = resp.body.hits.total;
progress.addToTotal(remainingHits);
} else {
resp = await client.scroll({
scrollId: resp._scroll_id!,
scroll_id: resp.body._scroll_id!,
scroll: SCROLL_TIMEOUT,
});
}

for (const hit of resp.hits.hits) {
for (const hit of resp.body?.hits.hits) {
remainingHits -= 1;
stats.archivedDoc(hit._index);
this.push({
Expand All @@ -94,7 +94,7 @@ export function createGenerateDocRecordsStream({
});
}

progress.addToComplete(resp.hits.hits.length);
progress.addToComplete(resp.body.hits.hits.length);
}

callback(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ describe('opensearchArchiver: createIndexDocRecordsStream()', () => {
const client = createStubClient([
async (name, params) => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records),
requestTimeout: 120000,
});
return { ok: true };
expect(params).to.eql({ body: recordsToBulkBody(records) });
return {
body: {
ok: true,
},
};
},
]);
const stats = createStubStats();
Expand All @@ -88,19 +89,21 @@ describe('opensearchArchiver: createIndexDocRecordsStream()', () => {
const client = createStubClient([
async (name, params) => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(0, 1)),
requestTimeout: 120000,
});
return { ok: true };
expect(params).to.eql({ body: recordsToBulkBody(records.slice(0, 1)) });
return {
body: {
ok: true,
},
};
},
async (name, params) => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(1)),
requestTimeout: 120000,
});
return { ok: true };
expect(params).to.eql({ body: recordsToBulkBody(records.slice(1)) });
return {
body: {
ok: true,
},
};
},
]);
const stats = createStubStats();
Expand All @@ -124,21 +127,23 @@ describe('opensearchArchiver: createIndexDocRecordsStream()', () => {
const client = createStubClient([
async (name, params) => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(0, 1)),
requestTimeout: 120000,
});
expect(params).to.eql({ body: recordsToBulkBody(records.slice(0, 1)) });
await delay(delayMs);
return { ok: true };
return {
body: {
ok: true,
},
};
},
async (name, params) => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(1)),
requestTimeout: 120000,
});
expect(params).to.eql({ body: recordsToBulkBody(records.slice(1)) });
expect(Date.now() - start).to.not.be.lessThan(delayMs);
return { ok: true };
return {
body: {
ok: true,
},
};
},
]);
const progress = new Progress();
Expand All @@ -160,17 +165,29 @@ describe('opensearchArchiver: createIndexDocRecordsStream()', () => {
async (name, params) => {
expect(name).to.be('bulk');
expect(params.body.length).to.eql(1 * 2);
return { ok: true };
return {
body: {
ok: true,
},
};
},
async (name, params) => {
expect(name).to.be('bulk');
expect(params.body.length).to.eql(299 * 2);
return { ok: true };
return {
body: {
ok: true,
},
};
},
async (name, params) => {
expect(name).to.be('bulk');
expect(params.body.length).to.eql(1 * 2);
return { ok: true };
return {
body: {
ok: true,
},
};
},
]);
const progress = new Progress();
Expand All @@ -189,8 +206,8 @@ describe('opensearchArchiver: createIndexDocRecordsStream()', () => {
const records = createPersonDocRecords(2);
const stats = createStubStats();
const client = createStubClient([
async () => ({ ok: true }),
async () => ({ errors: true, forcedError: true }),
async () => ({ body: { ok: true } }),
async () => ({ body: { errors: true, forcedError: true } }),
]);
const progress = new Progress();

Expand Down
Loading

0 comments on commit ccdee60

Please sign in to comment.