From f7344c247680834b2a99a84ed528d328055d6008 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 5 Sep 2024 11:01:40 -0400 Subject: [PATCH 1/3] Truncate errors at 256 characters. Signed-off-by: dblock --- CHANGELOG.md | 12 ++++++------ tools/src/tester/ResultLogger.ts | 5 +++-- tools/tests/tester/ResultLogger.test.ts | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 513fea12b..5d253eb39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,13 +98,13 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Renamed `main` release tag to `main-latest` ([#321](https://github.com/opensearch-project/opensearch-api-specification/pull/321)) - Replaced usages of `Opensearch` with `OpenSearch` ([#335](https://github.com/opensearch-project/opensearch-api-specification/pull/335)) - Prevented merger tool from printing warnings when used by tester tool ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359)) -- Replaced the deprecated fs.rmdirSync with fs.rmSync ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359)) -- Tester tool now provides better context for non-2XX responses when --verbose is used ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359)) -- Lock testing for next release of OpenSearch to a specific SHA ([#431](https://github.com/opensearch-project/opensearch-api-specification/pull/431)) -- Replace nullable with null type ([#436](https://github.com/opensearch-project/opensearch-api-specification/pull/436)) +- Replaced the deprecated `fs.rmdirSync` with `fs.rmSync` ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359)) +- Added better context for non-2XX responses when `--verbose` is used with the tester tool ([#359](https://github.com/opensearch-project/opensearch-api-specification/pull/359)) +- Locked testing for next release of OpenSearch to a specific SHA ([#431](https://github.com/opensearch-project/opensearch-api-specification/pull/431)) +- Replaced nullable with `null` type ([#436](https://github.com/opensearch-project/opensearch-api-specification/pull/436)) - Split test suite ([#472])(https://github.com/opensearch-project/opensearch-api-specification/pull/472) - Changed `WriteResponseBase`'s `_primary_term`, `_seq_no` & `_version` to have `int64` format ([#530](https://github.com/opensearch-project/opensearch-api-specification/pull/530)) -- Adjust indices, shards cat API to test against unassigned indices ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551)) +- Adjusted indices, shards cat API to test against unassigned indices ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551)) - Rename `Bytes` component to `StorageType` ([#552](https://github.com/opensearch-project/opensearch-api-specification/pull/552)) - Rename `ByteSize` to `StorageSize` ([#552](https://github.com/opensearch-project/opensearch-api-specification/pull/552)) @@ -143,7 +143,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed `knn` query specification ([#538](https://github.com/opensearch-project/opensearch-api-specification/pull/538)) - Fixed content-type for `/hot_threads` ([#543](https://github.com/opensearch-project/opensearch-api-specification/pull/543)) - Fixed `/_cluster/settings` returning flat results ([#545](https://github.com/opensearch-project/opensearch-api-specification/pull/545)) -- Fixed missing fields in cat API ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551)) +- Fixed missing fields in `_cat` API ([#551](https://github.com/opensearch-project/opensearch-api-specification/pull/551)) ### Security diff --git a/tools/src/tester/ResultLogger.ts b/tools/src/tester/ResultLogger.ts index 0d6d2c929..109b05a7c 100644 --- a/tools/src/tester/ResultLogger.ts +++ b/tools/src/tester/ResultLogger.ts @@ -152,8 +152,9 @@ export class ConsoleResultLogger implements ResultLogger { } #maybe_shorten_error_message(message: string | undefined): string | undefined { - if (message === undefined || message.length <= 128 || this._verbose) return message - const part = message.split(',')[0] + const cut_at = 256 + if (message === undefined || message.length <= cut_at || this._verbose) return message + const part = message.substring(0, cut_at) return part + (part !== message ? ', ...' : '') } diff --git a/tools/tests/tester/ResultLogger.test.ts b/tools/tests/tester/ResultLogger.test.ts index 512619cd9..ff3b1a10c 100644 --- a/tools/tests/tester/ResultLogger.test.ts +++ b/tools/tests/tester/ResultLogger.test.ts @@ -176,6 +176,29 @@ describe('ConsoleResultLogger', () => { ]) }) + test('with a very long error message', () => { + logger.log({ + result: Result.PASSED, + display_path: 'path', + full_path: 'full_path', + description: 'description', + message: "x".repeat(257), + chapters: [{ + title: 'title', + overall: { + result: Result.PASSED + } + }], + epilogues: [], + prologues: [] + }) + + const truncated_error = `(${"x".repeat(256)}, ...)` + expect(log.mock.calls).toEqual([ + [`${ansi.green('PASSED ')} ${ansi.cyan(ansi.b('path'))} ${ansi.gray(truncated_error)}`] + ]) + }) + describe('with warnings', () => { const logger = new ConsoleResultLogger(tab_width, true) From 5c3739f9d419129bf39d17ced02788860c504bac Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 5 Sep 2024 11:20:06 -0400 Subject: [PATCH 2/3] Get shard node before attempting to relocate it. Signed-off-by: dblock --- tests/routing/cluster/reroute.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/routing/cluster/reroute.yaml b/tests/routing/cluster/reroute.yaml index 70128d791..c96b81e4c 100644 --- a/tests/routing/cluster/reroute.yaml +++ b/tests/routing/cluster/reroute.yaml @@ -26,10 +26,13 @@ epilogues: status: [200, 404] chapters: - synopsis: Shows the allocation of shards in a cluster. + id: shard path: /_cluster/reroute method: POST response: status: 200 + output: + node: payload.state.routing_table.indices.movies.shards.0[0].node - synopsis: Shows the allocation of shards in a cluster with parameters. path: /_cluster/reroute method: POST @@ -49,7 +52,7 @@ chapters: - move: index: movies shard: 0 - from_node: opensearch-node1 + from_node: ${shard.node} to_node: opensearch-node2 response: status: 200 From 6a0f9c47448758dc7299195445f32b841203477b Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 5 Sep 2024 11:38:21 -0400 Subject: [PATCH 3/3] Force the shard on node1. Signed-off-by: dblock --- tests/routing/cluster/reroute.yaml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/routing/cluster/reroute.yaml b/tests/routing/cluster/reroute.yaml index c96b81e4c..4fbdf3e51 100644 --- a/tests/routing/cluster/reroute.yaml +++ b/tests/routing/cluster/reroute.yaml @@ -20,19 +20,28 @@ prologues: - {director: Bennett Miller, title: Moneyball, year: 2011} - {create: {_index: movies}} - {director: Nicolas Winding Refn, title: Drive, year: 1960} + # force the shard on node1 in case it was created on node2 + - path: /_cluster/reroute + method: POST + request: + payload: + commands: + - move: + index: movies + shard: 0 + from_node: opensearch-node2 + to_node: opensearch-node1 + status: [200, 400] epilogues: - path: /movies method: DELETE status: [200, 404] chapters: - synopsis: Shows the allocation of shards in a cluster. - id: shard path: /_cluster/reroute method: POST response: status: 200 - output: - node: payload.state.routing_table.indices.movies.shards.0[0].node - synopsis: Shows the allocation of shards in a cluster with parameters. path: /_cluster/reroute method: POST @@ -52,8 +61,11 @@ chapters: - move: index: movies shard: 0 - from_node: ${shard.node} + from_node: opensearch-node1 to_node: opensearch-node2 + retry: + count: 3 + wait: 1000 response: status: 200 payload: