From 21bd1068c058c1fac9d008754e49b72ab189cdce Mon Sep 17 00:00:00 2001 From: Andy Wick Date: Mon, 5 Aug 2024 16:16:58 -0400 Subject: [PATCH] Add create-index blocked solution and switch to npm ci (#465) * Add create-index blocked solution and switch to npm ci Signed-off-by: Andy Wick * Updated CHANGELOG Signed-off-by: Andy Wick * add TOC and replace `npm install` with `npm ci` Signed-off-by: Andy Wick --------- Signed-off-by: Andy Wick --- .github/workflows/analyze-pr-changes.yml | 8 ++++---- .github/workflows/build.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/test-spec.yml | 2 +- .github/workflows/test-tools-integ.yml | 4 ++-- .github/workflows/test-tools-unit.yml | 4 ++-- .github/workflows/validate-spec.yml | 2 +- CHANGELOG.md | 1 + DEVELOPER_GUIDE.md | 4 ++-- TESTING_GUIDE.md | 26 +++++++++++++++++++++++- 10 files changed, 40 insertions(+), 15 deletions(-) diff --git a/.github/workflows/analyze-pr-changes.yml b/.github/workflows/analyze-pr-changes.yml index 14bbb1ed..d962fdc9 100644 --- a/.github/workflows/analyze-pr-changes.yml +++ b/.github/workflows/analyze-pr-changes.yml @@ -57,7 +57,7 @@ jobs: -e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_PASSWORD" \ opensearch-with-api-plugin - npm install + npm ci npm run dump-cluster-spec -- --opensearch-insecure --output $CLUSTER_SPEC @@ -72,7 +72,7 @@ jobs: - name: Build BEFORE Spec shell: bash -eo pipefail {0} run: | - npm install + npm ci npm run merge -- --source ./spec --output $BEFORE_SPEC - name: Checkout AFTER Spec @@ -82,7 +82,7 @@ jobs: - name: Build AFTER Spec shell: bash -eo pipefail {0} run: | - npm install + npm ci npm run merge -- --source ./spec --output $AFTER_SPEC - name: Calculate Coverage @@ -216,4 +216,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: pr-comment - path: pr-comment.json \ No newline at end of file + path: pr-comment.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed72ed33..4caefaf1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: node-version: '20' - name: Build - run: npm install && npm run merge + run: npm ci && npm run merge - name: Extract Branch Name id: branch diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 246c9edf..b04c3d12 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: node-version: '20' - name: Install Dependencies - run: npm install + run: npm ci - name: Lint run: npm run lint diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 80f7577f..2449a9b1 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -55,7 +55,7 @@ jobs: node-version: '20' - name: Install Dependencies - run: npm install + run: npm ci - name: Run OpenSearch Cluster working-directory: .github/opensearch-cluster diff --git a/.github/workflows/test-tools-integ.yml b/.github/workflows/test-tools-integ.yml index a48dd751..915e840c 100644 --- a/.github/workflows/test-tools-integ.yml +++ b/.github/workflows/test-tools-integ.yml @@ -43,7 +43,7 @@ jobs: node-version: '20' - name: Install Dependencies - run: npm install + run: npm ci - name: Tests run: | @@ -52,4 +52,4 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v4.0.1 with: - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test-tools-unit.yml b/.github/workflows/test-tools-unit.yml index 00b585bb..d18fc252 100644 --- a/.github/workflows/test-tools-unit.yml +++ b/.github/workflows/test-tools-unit.yml @@ -33,7 +33,7 @@ jobs: node-version: '20' - name: Install Dependencies - run: npm install + run: npm ci - name: Tests run: | @@ -42,4 +42,4 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v4.0.1 with: - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/validate-spec.yml b/.github/workflows/validate-spec.yml index 89213ac6..71f6f478 100644 --- a/.github/workflows/validate-spec.yml +++ b/.github/workflows/validate-spec.yml @@ -25,7 +25,7 @@ jobs: node-version: '20' - name: Install Dependencies - run: npm install + run: npm ci - name: Lint Spec run: npm run lint:spec diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f65144d..1a28aadc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added support for request headers in tests [#461](https://github.com/opensearch-project/opensearch-api-specification/pull/461) - Added metadata additionalProperties to `ErrorCause` ([#462](https://github.com/opensearch-project/opensearch-api-specification/pull/462)) - Added `creation_date` field to `DanglingIndex` ([#462](https://github.com/opensearch-project/opensearch-api-specification/pull/462)) +- Added doc on `cluster create-index blocked` workaround ([#465](https://github.com/opensearch-project/opensearch-api-specification/pull/465)) ### Changed diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index b965e50a..951f00cd 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -159,7 +159,7 @@ A number of [tools](tools) have been authored using TypeScript to aid in the dev To be able to use or develop the tools, some setup is required: 1. Install [Node.js](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs). -2. Run `npm install` from the repository's root. +2. Run `npm ci` from the repository's root. ### [Spec Merger](tools/src/merger) @@ -360,4 +360,4 @@ This workflow runs on PRs to invoke the [tools' integration tests](tools/tests) ### [Validate Spec](.github/workflows/validate-spec.yml) -This workflow runs on PRs to invoke the [spec linter](#spec-linter) and ensure the multi-file spec is correct and follows the design guidelines. \ No newline at end of file +This workflow runs on PRs to invoke the [spec linter](#spec-linter) and ensure the multi-file spec is correct and follows the design guidelines. diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index 31323efc..ad79f85d 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -1,6 +1,9 @@ - [Spec Testing Guide](#spec-testing-guide) - [Running Spec Tests Locally](#running-spec-tests-locally) + - [Common Errors](#common-errors) + - [401 Unauthorized](#401-unauthorized) + - [FORBIDDEN/10/cluster create-index blocked (api)](#forbidden10cluster-create-index-blocked-api) - [Writing Spec Tests](#writing-spec-tests) - [Simple Test Story](#simple-test-story) - [Using Output from Previous Chapters](#using-output-from-previous-chapters) @@ -41,7 +44,28 @@ Verbose output: npm run test:spec -- --opensearch-insecure --verbose ``` -Note: Remember to set the `OPENSEARCH_PASSWORD` environment variable everytime you start a new shell to run the tests. Failing to do so will result in 401 Unauthorized errors. +### Common Errors + +#### 401 Unauthorized + +Remember to set the `OPENSEARCH_PASSWORD` environment variable everytime you start a new shell to run the tests. + +#### FORBIDDEN/10/cluster create-index blocked (api) + +The cluster is most likely hitting a disk watermark threshold. This example sets the disk watermark thresholds to 1500MB low, 100MB high, and 500MB flood stage, allowing the cluster to create indices even if the disk is almost full. + +```bash +curl -k -X PUT --user "admin:${OPENSEARCH_PASSWORD}" https://localhost:9200/_cluster/settings -H 'Content-Type: application/json' -d' +{ + "persistent": { + "cluster.routing.allocation.disk.watermark.low": "1500mb", + "cluster.routing.allocation.disk.watermark.high": "1000mb", + "cluster.routing.allocation.disk.watermark.flood_stage": "500mb", + "cluster.blocks.create_index" : null + } +} +' +``` ## Writing Spec Tests