From 7930e32bdf0492f5676f919cb61cb4808cc26792 Mon Sep 17 00:00:00 2001 From: Miki Date: Thu, 19 Jan 2023 19:34:59 -0800 Subject: [PATCH] Enhance the Build and Test workflow * Run GitHub workflow unit tests in band (#1306) * Fix JUnit Reporter test (#1338) * Add src/test_utils/ and src/core paths to the target clean patterns (#1442) * Add code coverage reporting (#1478) * Add release build verification workflow (#1502) * Add Windows CI to the workflow (#2966) * Add retrying flaky jest tests (#2967) * Record functional test artifacts in case of failure (#3190) * Increase timeout waiting for the exiting of an optimizer worker (#3193) * Improve yarn's performance in workflows by caching yarn's cache folder (#3194) * Fix the version of Chrome to 107 to match `chromedriver@107.0.1`, the last that works on NodeJS v10 * Prevent `AbortError` from breaking unit tests for ExecutionContract Signed-off-by: Miki --- .github/workflows/build_and_test_workflow.yml | 457 ++++++++++++++++++ .github/workflows/pr_check_workflow.yml | 306 ------------ CHANGELOG.md | 52 +- config/opensearch_dashboards.yml | 226 ++++----- package.json | 18 +- .../osd-optimizer/src/worker/run_worker.ts | 6 +- src/dev/jest/config.js | 13 +- .../integration_tests/__fixtures__/test.js | 5 +- .../execution/execution_contract.test.ts | 2 +- yarn.lock | 75 ++- 10 files changed, 683 insertions(+), 477 deletions(-) create mode 100644 .github/workflows/build_and_test_workflow.yml delete mode 100644 .github/workflows/pr_check_workflow.yml diff --git a/.github/workflows/build_and_test_workflow.yml b/.github/workflows/build_and_test_workflow.yml new file mode 100644 index 000000000000..39df9a5f30fd --- /dev/null +++ b/.github/workflows/build_and_test_workflow.yml @@ -0,0 +1,457 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Build and test + +# trigger on every commit push and PR for all branches except pushes for backport branches +on: + push: + branches: [ '**', '!backport/**' ] + paths-ignore: + - '**/*.md' + - 'docs/**' + pull_request: + branches: [ '**' ] + paths-ignore: + - '**/*.md' + - 'docs/**' + +env: + TEST_BROWSER_HEADLESS: 1 + CI: 1 + GCS_UPLOAD_PREFIX: fake + TEST_OPENSEARCH_DASHBOARDS_HOST: localhost + TEST_OPENSEARCH_DASHBOARDS_PORT: 6610 + TEST_OPENSEARCH_TRANSPORT_PORT: 9403 + TEST_OPENSEARCH_PORT: 9400 + OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true + NODE_OPTIONS: "--max_old_space_size=4096" + +jobs: + build-lint-test-linux: + runs-on: ubuntu-latest + name: Build and Verify on Linux + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + - name: Run bootstrap + run: yarn osd bootstrap + + - name: Run linter + id: linter + run: yarn lint + + - name: Run unit tests with coverage + id: unit-tests + run: yarn test:jest:ci:coverage + + - name: Run mocha tests with coverage + id: mocha-tests + run: yarn test:mocha:coverage + + - name: Upload Code Coverage + id: upload-code-coverage + uses: codecov/codecov-action@v3 + with: + directory: ./target/opensearch-dashboards-coverage + flags: Linux + + - name: Run integration tests + id: integration-tests + run: yarn test:jest_integration:ci + + build-lint-test-windows: + runs-on: windows-latest + name: Build and Verify on Windows + defaults: + run: + shell: powershell + steps: + - name: Configure git's autocrlf + run: | + git config --global core.autocrlf false + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup JDK + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: | + echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + - name: Run bootstrap + run: | + yarn osd bootstrap + if ($LASTEXITCODE) { yarn osd bootstrap } + + - name: Run linter + id: linter + run: yarn lint + + - name: Run unit tests with coverage + id: unit-tests + run: yarn test:jest:ci:coverage + + - name: Run mocha tests with coverage + id: mocha-tests + run: yarn test:mocha:coverage + + - name: Upload Code Coverage + id: upload-code-coverage + uses: codecov/codecov-action@v3 + with: + directory: ./target/opensearch-dashboards-coverage + flags: Windows + + - name: Run integration tests + id: integration-tests + run: yarn test:jest_integration:ci + + functional-tests-linux: + runs-on: ubuntu-latest + name: Run functional tests on Linux + strategy: + matrix: + group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] + steps: + - run: echo Running functional tests for ciGroup${{ matrix.group }} + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + # Node 10 is only supported by ChromeDriver 107 and lower + - name: Download Chrome + id: download-chrome + uses: abhi1693/setup-browser@v0.3.5 + with: + browser: chrome + # https://omahaproxy.appspot.com/deps.json?version=107.0.5304.150 + version: 1047731 + + - name: Setup Chrome + run: | + sudo rm -rf /usr/bin/google-chrome + sudo ln -s ${{steps.download-chrome.outputs.path}}/${{steps.download-chrome.outputs.binary}} /usr/bin/google-chrome + + - name: Run bootstrap + run: yarn osd bootstrap + + - name: Build plugins + run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 + + - name: Run CI test group ${{ matrix.group }} + id: ftr-tests + run: node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }} + env: + CI_GROUP: ciGroup${{ matrix.group }} + CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} + JOB: ci${{ matrix.group }} + CACHE_DIR: ciGroup${{ matrix.group }} + + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: failure-artifacts + path: | + test/*/failure_debug/ + test/*/screenshots/ + + functional-tests-windows: + runs-on: windows-latest + name: Run functional tests on Windows + strategy: + matrix: + group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] + defaults: + run: + shell: powershell + steps: + - run: echo Running functional tests for ciGroup${{ matrix.group }} + + - name: Configure git's autocrlf + run: | + git config --global core.autocrlf false + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup JDK + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: | + echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + # Node 10 is only supported by ChromeDriver 107 and lower + - name: Download Chrome + id: download-chrome + uses: abhi1693/setup-browser@v0.3.5 + with: + browser: chrome + # https://omahaproxy.appspot.com/deps.json?version=107.0.5296.1 + version: 1045634 + + - name: Setup Chrome + run: | + New-Item -Force -Type Directory "$Env:Programfiles/Google/Chrome/Application" + Remove-Item -Recurse -Force "$Env:Programfiles/Google/Chrome/Application/*" + Copy-Item -Force -Recurse "${{steps.download-chrome.outputs.path}}/*" "$Env:Programfiles/Google/Chrome/Application" + + - name: Run bootstrap + run: | + yarn osd bootstrap + if ($LASTEXITCODE) { yarn osd bootstrap } + + - name: Build plugins + run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 + + - name: Run CI test group ${{ matrix.group }} + id: ftr-tests + run: node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }} + env: + CI_GROUP: ciGroup${{ matrix.group }} + CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} + JOB: ci${{ matrix.group }} + CACHE_DIR: ciGroup${{ matrix.group }} + + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: failure-artifacts-ci${{ matrix.group }} + path: | + test/*/failure_debug/ + test/*/screenshots/ + + build-min-artifact-tests-linux: + runs-on: ubuntu-latest + name: Build min release artifacts on Linux + defaults: + run: + working-directory: ./artifacts + strategy: + matrix: + include: + - name: Linux x64 + ext: tar.gz + suffix: linux-x64 + script: build-platform --linux --skip-os-packages + - name: Linux ARM64 + ext: tar.gz + suffix: linux-arm64 + script: build-platform --linux-arm --skip-os-packages + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + path: ./artifacts + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: './artifacts/.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $GITHUB_ENV + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + - name: Get package version + run: | + echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV + + - name: Get artifact build name + run: | + echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $GITHUB_ENV + + - name: Run bootstrap + run: yarn osd bootstrap + + - name: Build `${{ matrix.name }}` + run: yarn ${{ matrix.script }} --release + + - uses: actions/upload-artifact@v3 + if: success() + with: + name: ${{ matrix.suffix }}-${{ env.VERSION }} + path: ./artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} + retention-days: 1 + + build-min-artifact-tests-windows: + runs-on: windows-latest + name: Build min release artifacts on Windows + defaults: + run: + working-directory: artifacts + strategy: + matrix: + include: + - name: Windows x64 + ext: zip + suffix: windows-x64 + script: build-platform --windows --skip-os-packages + steps: + - name: Configure git's autocrlf + run: | + git config --global core.autocrlf false + working-directory: . + + - name: Checkout code + uses: actions/checkout@v3 + with: + path: artifacts + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: 'artifacts/.nvmrc' + registry-url: 'https://registry.npmjs.org' + + - name: Setup Yarn + run: | + npm uninstall -g yarn + npm i -g yarn@1.22.10 + yarn config set network-timeout 1000000 -g + + - name: Configure Yarn Cache + run: | + echo "YARN_CACHE_LOCATION=$(yarn cache dir)" >> $env:GITHUB_ENV + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" + + - name: Initialize Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ env.YARN_CACHE_LOCATION }} + key: yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + yarn- + + - name: Get package version + run: | + echo "VERSION=$(yarn --silent pkg-version)" >> $env:GITHUB_ENV + + - name: Get artifact build name + run: | + echo "ARTIFACT_BUILD_NAME=opensearch-dashboards-${{ env.VERSION }}-${{ matrix.suffix }}.${{ matrix.ext }}" >> $env:GITHUB_ENV + + - name: Run bootstrap + run: yarn osd bootstrap + + - name: Build `${{ matrix.name }}` + run: yarn ${{ matrix.script }} --release + + - uses: actions/upload-artifact@v3 + if: success() + with: + name: ${{ matrix.suffix }}-${{ env.VERSION }} + path: artifacts/target/${{ env.ARTIFACT_BUILD_NAME }} + retention-days: 1 diff --git a/.github/workflows/pr_check_workflow.yml b/.github/workflows/pr_check_workflow.yml deleted file mode 100644 index 0e096200b9ab..000000000000 --- a/.github/workflows/pr_check_workflow.yml +++ /dev/null @@ -1,306 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Build and test - -# trigger on every commit push and PR for all branches except feature branches -on: - push: - branches: [ '**', '!feature/**' ] - pull_request: - branches: [ '**', '!feature/**' ] - -env: - CACHE_NAME: osd-node-modules - TEST_BROWSER_HEADLESS: 1 - CI: 1 - GCS_UPLOAD_PREFIX: fake - TEST_OPENSEARCH_DASHBOARDS_HOST: localhost - TEST_OPENSEARCH_DASHBOARDS_PORT: 6610 - TEST_OPENSEARCH_TRANSPORT_PORT: 9403 - TEST_OPENSEARCH_PORT: 9400 - OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true - -jobs: - build-lint-test-linux: - runs-on: ubuntu-latest - name: Build and Verify - steps: - # Access a cache of set results from a previous run of the job - # This is to prevent re-running steps that were already successful since it is not native to github actions - # Can be used to verify flaky steps with reduced times - - name: Restore the cached run - uses: actions/cache@v2 - with: - path: | - job_successful - linter_results - unit_tests_results - integration_tests_results - key: ${{ github.run_id }}-${{ github.job }}-${{ github.sha }} - restore-keys: | - ${{ github.run_id }}-${{ github.job }}-${{ github.sha }} - - - name: Get if previous job was successful - id: job_successful - run: cat job_successful 2>/dev/null || echo 'false' - - - name: Get the previous linter results - id: linter_results - run: cat linter_results 2>/dev/null || echo 'default' - - - name: Get the previous unit tests results - id: unit_tests_results - run: cat unit_tests_results 2>/dev/null || echo 'default' - - - name: Get the previous integration tests results - id: integration_tests_results - run: cat integration_tests_results 2>/dev/null || echo 'default' - - - name: Checkout code - if: steps.job_successful.outputs.job_successful != 'true' - uses: actions/checkout@v3 - - - name: Setup Node - if: steps.job_successful.outputs.job_successful != 'true' - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - registry-url: 'https://registry.npmjs.org' - - - name: Setup Yarn - if: steps.job_successful.outputs.job_successful != 'true' - run: | - npm uninstall -g yarn - npm i -g yarn@1.22.10 - - - name: Run bootstrap - if: steps.job_successful.outputs.job_successful != 'true' - run: yarn osd bootstrap - - - name: Run linter - if: steps.linter_results.outputs.linter_results != 'success' - id: linter - run: yarn lint - - # Runs unit tests while limiting workers because github actions will spawn more than it can handle and crash - # Continues on error but will create a comment on the pull request if this step failed. - - name: Run unit tests - if: steps.unit_tests_results.outputs.unit_tests_results != 'success' - id: unit-tests - continue-on-error: true - run: node scripts/jest --ci --colors --maxWorkers=10 - env: - SKIP_BAD_APPLES: true - - - run: echo Unit tests completed unsuccessfully. However, unit tests are inconsistent on the CI so please verify locally with `yarn test:jest`. - if: steps.unit_tests_results.outputs.unit_tests_results != 'success' && steps.unit-tests.outcome != 'success' - - - name: Run integration tests - if: steps.integration_tests_results.outputs.integration_tests_results != 'success' - id: integration-tests - run: node scripts/jest_integration --ci --colors --max-old-space-size=5120 - - # Set cache if linter, unit tests, and integration tests were successful then the job will be marked successful - # Sets individual results to empower re-runs of the same build without re-running successful steps. - - if: | - (steps.linter.outcome == 'success' || steps.linter.outcome == 'skipped') && - (steps.unit-tests.outcome == 'success' || steps.unit-tests.outcome == 'skipped') && - (steps.integration-tests.outcome == 'success' || steps.integration-tests.outcome == 'skipped') - run: echo "::set-output name=job_successful::true" > job_successful - - if: steps.linter.outcome == 'success' || steps.linter.outcome == 'skipped' - run: echo "::set-output name=linter_results::success" > linter_results - - if: steps.unit-tests.outcome == 'success' || steps.unit-tests.outcome == 'skipped' - run: echo "::set-output name=unit_tests_results::success" > unit_tests_results - - if: steps.integration-tests.outcome == 'success' || steps.integration-tests.outcome == 'skipped' - run: echo "::set-output name=integration_tests_results::success" > integration_tests_results - - build-lint-test-windows: - runs-on: windows-latest - name: Build and Verify on Windows - steps: - - name: Configure git's autocrlf - run: | - git config --global core.autocrlf false - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup JDK - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - registry-url: 'https://registry.npmjs.org' - - - name: Setup Yarn - run: | - npm uninstall -g yarn - npm i -g yarn@1.22.10 - - - name: Run bootstrap - run: yarn osd bootstrap - - - name: Run linter - id: linter - run: yarn lint - - - name: Run unit tests with coverage - id: unit-tests - run: yarn test:jest:ci:coverage - - - name: Run mocha tests with coverage - id: mocha-tests - run: yarn test:mocha:coverage - - - name: Upload Code Coverage - id: upload-code-coverage - uses: codecov/codecov-action@v3 - with: - directory: ./target/opensearch-dashboards-coverage - flags: Windows - - - name: Run integration tests - id: integration-tests - run: yarn test:jest_integration:ci - - functional-tests-linux: - needs: [ build-lint-test-linux ] - runs-on: ubuntu-latest - name: Run functional tests - strategy: - matrix: - group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] - steps: - - run: echo Running functional tests for ciGroup${{ matrix.group }} - - # Access a cache of set results from a previous run of the job - # This is to prevent re-running a CI group that was already successful since it is not native to github actions - # Can be used to verify flaky steps with reduced times - - name: Restore the cached run - uses: actions/cache@v2 - with: - path: | - ftr_tests_results - key: ${{ github.run_id }}-${{ github.job }}-${{ matrix.group }}-${{ github.sha }} - restore-keys: | - ${{ github.run_id }}-${{ github.job }}-${{ matrix.group }}-${{ github.sha }} - - - name: Get the cached tests results - id: ftr_tests_results - run: cat ftr_tests_results 2>/dev/null || echo 'default' - - - name: Checkout code - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - uses: actions/checkout@v3 - - - name: Setup Node - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - registry-url: 'https://registry.npmjs.org' - - - name: Setup Yarn - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - run: | - npm uninstall -g yarn - npm i -g yarn@1.22.10 - - - name: Get cache path - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - id: cache-path - run: echo "::set-output name=CACHE_DIR::$(yarn cache dir)" - - - name: Setup cache - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - uses: actions/cache@v2 - with: - path: ${{ steps.cache-path.outputs.CACHE_DIR }} - key: ${{ runner.os }}-yarn-${{ env.CACHE_NAME }}-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn-${{ env.CACHE_NAME }}- - ${{ runner.os }}-yarn- - ${{ runner.os }}- - - # github virtual env is the latest chrome - - name: Setup chromedriver - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - run: node scripts/upgrade_chromedriver.js - - - name: Run bootstrap - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - run: yarn osd bootstrap - - - name: Build plugins - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 - - - if: steps.ftr_tests_results.outputs.ftr_tests_results != 'success' - id: ftr-tests - run: node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }} - env: - CI_GROUP: ciGroup${{ matrix.group }} - CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} - JOB: ci${{ matrix.group }} - CACHE_DIR: ciGroup${{ matrix.group }} - - - if: steps.ftr-tests.outcome == 'success' || steps.ftr-tests.outcome == 'skipped' - run: echo "::set-output name=ftr_tests_results::success" > ftr_tests_results - - functional-tests-windows: - runs-on: windows-latest - name: Run functional tests on Windows - strategy: - matrix: - group: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] - steps: - - run: echo Running functional tests for ciGroup${{ matrix.group }} - - - name: Configure git's autocrlf - run: | - git config --global core.autocrlf false - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup JDK - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - registry-url: 'https://registry.npmjs.org' - - - name: Setup Yarn - run: | - npm uninstall -g yarn - npm i -g yarn@1.22.10 - - # image has the latest chrome v99 - - name: Setup chromedriver - run: node scripts/upgrade_chromedriver.js - - - name: Run bootstrap - run: yarn osd bootstrap - - - name: Build plugins - run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10 - - - name: Run CI test group ${{ matrix.group }} - id: ftr-tests - run: node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }} - env: - CI_GROUP: ciGroup${{ matrix.group }} - CI_PARALLEL_PROCESS_NUMBER: ciGroup${{ matrix.group }} - JOB: ci${{ matrix.group }} - CACHE_DIR: ciGroup${{ matrix.group }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 78562760a15d..77a6b9c84b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,50 +8,62 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### 🛡 Security -* [CVE-2022-3517] Bumps minimatch from 3.0.4 to 3.0.5 and [IBM X-Force ID: 220063] unset-value from 1.0.1 to 2.0.1 ([#2640](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2640)) -* [CVE-2022-0144] Bump shelljs from 0.8.4 to 0.8.5 ([#2511](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2511)) -* [Legacy Maps Plugin] Prevent reverse-tabnabbing ([#2540](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2540)) -* [CVE-2022-0155] Bump follow-redirects to 1.15.2 ([#2653](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2653)) -* [CVE-2022-0536] Bump follow-redirects to 1.15.2 ([#2653](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2653)) -* [CVE-2022-23647] Bump prismjs to 1.29.0 ([#2668](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2668)) -* [CVE-2021-24033] Remove storybook package to fix CVE-2021-42740 and CVE-2021-24033 ([#2660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2660)) -* [CVE-2021-42740] Remove storybook package to fix CVE-2021-42740 and CVE-2021-24033 ([#2660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2660)) -* [CVE-2022-37601] Bump loader-utils to 2.0.3 ([#2707](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2707)) -* [CVE-2022-37599] Bump loader-utils to 2.0.4 ([#2995](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2995)) -* [CVE-2022-37603] Bump loader-utils to 2.0.4 ([#2995](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2995)) +- [CVE-2022-3517] Bumps minimatch from 3.0.4 to 3.0.5 and [IBM X-Force ID: 220063] unset-value from 1.0.1 to 2.0.1 ([#2640](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2640)) +- [CVE-2022-0144] Bump shelljs from 0.8.4 to 0.8.5 ([#2511](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2511)) +- [Legacy Maps Plugin] Prevent reverse-tabnabbing ([#2540](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2540)) +- [CVE-2022-0155] Bump follow-redirects to 1.15.2 ([#2653](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2653)) +- [CVE-2022-0536] Bump follow-redirects to 1.15.2 ([#2653](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2653)) +- [CVE-2022-23647] Bump prismjs to 1.29.0 ([#2668](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2668)) +- [CVE-2021-24033] Remove storybook package to fix CVE-2021-42740 and CVE-2021-24033 ([#2660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2660)) +- [CVE-2021-42740] Remove storybook package to fix CVE-2021-42740 and CVE-2021-24033 ([#2660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2660)) +- [CVE-2022-37601] Bump loader-utils to 2.0.3 ([#2707](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2707)) +- [CVE-2022-37599] Bump loader-utils to 2.0.4 ([#2995](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2995)) +- [CVE-2022-37603] Bump loader-utils to 2.0.4 ([#2995](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2995)) ### 📈 Features/Enhancements - [Windows] Facilitate building and running OSD and plugins on Windows platforms ([#2601](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2601)) - [Windows] Add helper functions to work around the differences of platforms ([#2681](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2681)) - [Windows] Add `@osd/cross-platform` package to standardize path handling across platforms ([#2703](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2703)) +- [Optimizer] Increase timeout waiting for the exiting of an optimizer worker ([#3193](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3193)) + ### 🐛 Bug Fixes -* [BUG] Fix suggestion list cutoff issue ([#2607](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2607)) -* Removed Leftover X Pack references ([#2638](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2638)) -* Bumped `del` version to fix MacOS race condition ([#2847](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2873)) +- [BUG] Fix suggestion list cutoff issue ([#2607](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2607)) +- Removed Leftover X Pack references ([#2638](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2638)) +- Bumped `del` version to fix MacOS race condition ([#2847](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2873)) ### 🚞 Infrastructure +- Run the unit tests of the CI workflow in band ([#1306](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1306)) +- Capture and report code coverage metrics in workflows ([#1478](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1478)) +- Add verification workflow for release builds ([#1502](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1502)) - Add CHANGELOG.md and related workflows ([#2414](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2414)) - Update backport custom branch name to utilize head template ([#2766](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2766)) - Add automatic selection of the appropriate version of chrome driver to run functional tests ([#2990](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2990)) - Add Windows CI workflows ([#2966](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2966)) +- Record functional test artifacts in case of failure ([#3190](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3190)) +- Improve yarn's performance in workflows by caching yarn's cache folder ([#3194](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3194)) +- Lock workflow tests to Chrome and ChromeDriver 107 as the last combination that run on Node.js v10 ([#xxxx](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3194)) ### 📝 Documentation -* Corrected README and help command of osd-plugin-helpers ([#2810](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2810)) -* Add the release runbook to RELEASING.md ([#2533](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2533)) +- Corrected README and help command of osd-plugin-helpers ([#2810](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2810)) +- Add the release runbook to RELEASING.md ([#2533](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2533)) ### 🛠 Maintenance -* Remove storybook package and related code ([#2660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2660)) + +- Add `target` folders of `test_utils` and `core` to the `osd clean` patterns ([#1442](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1442)) +- Remove storybook package and related code ([#2660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2660)) ### 🪛 Refactoring ### 🔩 Tests -* bump chromedriver to 106 to fix function test fail issue ([#2514](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2514)) +- Fix test failures due to them ending before their duration is captured ([#1338](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1338)) +- Add retrying flaky jest tests ([#2967](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2967)) +- Prevent `AbortError` from breaking unit tests for ExecutionContract ([#xxxx](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3194)) ## [1.x] ### 💥 Breaking Changes @@ -64,7 +76,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### 🐛 Bug Fixes -* Plugin helpers fix related to fs promises module ([#2486](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2486)) +- Plugin helpers fix related to fs promises module ([#2486](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2486)) ### 🚞 Infrastructure @@ -72,7 +84,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### 🛠 Maintenance -* [Version] Increment to 1.4 ([#1341](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1341)) +- [Version] Increment to 1.4 ([#1341](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/1341)) ### 🪛 Refactoring diff --git a/config/opensearch_dashboards.yml b/config/opensearch_dashboards.yml index 69f1f5d3afcc..d357c4a3c8ea 100644 --- a/config/opensearch_dashboards.yml +++ b/config/opensearch_dashboards.yml @@ -1,10 +1,10 @@ # OpenSearch Dashboards is served by a back end server. This setting specifies the port to use. -#server.port: 5601 +server.port: 80 # Specifies the address to which the OpenSearch Dashboards server will bind. IP addresses and host names are both valid values. # The default is 'localhost', which usually means remote machines will not be able to connect. # To allow connections from remote users, set this parameter to a non-loopback address. -#server.host: "localhost" +server.host: "0.0.0.0" # Enables you to specify a path to mount OpenSearch Dashboards at if you are running behind a proxy. # Use the `server.rewriteBasePath` setting to tell OpenSearch Dashboards if it should remove the basePath @@ -23,7 +23,7 @@ #server.name: "your-hostname" # The URLs of the OpenSearch instances to use for all your queries. -#opensearch.hosts: ["http://localhost:9200"] +opensearch.hosts: ["https://miki-os.aka.corp.amazon.com:9200"] # OpenSearch Dashboards uses an index in OpenSearch to store saved searches, visualizations and # dashboards. OpenSearch Dashboards creates a new index if the index doesn't already exist. @@ -35,22 +35,19 @@ # Setting for an optimized healthcheck that only uses the local OpenSearch node to do Dashboards healthcheck. # This settings should be used for large clusters or for clusters with ingest heavy nodes. # It allows Dashboards to only healthcheck using the local OpenSearch node rather than fan out requests across all nodes. -# +# # It requires the user to create an OpenSearch node attribute with the same name as the value used in the setting # This node attribute should assign all nodes of the same cluster an integer value that increments with each new cluster that is spun up -# e.g. in opensearch.yml file you would set the value to a setting using node.attr.cluster_id: +# e.g. in opensearch.yml file you would set the value to a setting using node.attr.cluster_id: # Should only be enabled if there is a corresponding node attribute created in your OpenSearch config that matches the value here -#opensearch.optimizedHealthcheck.id: "cluster_id" -#opensearch.optimizedHealthcheck.filters: { -# attribute_key: "attribute_value", -#} +#opensearch.optimizedHealthcheckId: "cluster_id" # If your OpenSearch is protected with basic authentication, these settings provide # the username and password that the OpenSearch Dashboards server uses to perform maintenance on the OpenSearch Dashboards # index at startup. Your OpenSearch Dashboards users still need to authenticate with OpenSearch, which # is proxied through the OpenSearch Dashboards server. -#opensearch.username: "opensearch_dashboards_system" -#opensearch.password: "pass" +opensearch.username: "miki" +opensearch.password: "baharema" # Enables SSL and paths to the PEM-format SSL certificate and SSL key files, respectively. # These settings enable SSL for outgoing requests from the OpenSearch Dashboards server to the browser. @@ -69,102 +66,113 @@ #opensearch.ssl.certificateAuthorities: [ "/path/to/your/CA.pem" ] # To disregard the validity of SSL certificates, change this setting's value to 'none'. -#opensearch.ssl.verificationMode: full - -# Time in milliseconds to wait for OpenSearch to respond to pings. Defaults to the value of -# the opensearch.requestTimeout setting. -#opensearch.pingTimeout: 1500 - -# Time in milliseconds to wait for responses from the back end or OpenSearch. This value -# must be a positive integer. -#opensearch.requestTimeout: 30000 - -# List of OpenSearch Dashboards client-side headers to send to OpenSearch. To send *no* client-side -# headers, set this value to [] (an empty list). -#opensearch.requestHeadersWhitelist: [ authorization ] - -# Header names and values that are sent to OpenSearch. Any custom headers cannot be overwritten -# by client-side headers, regardless of the opensearch.requestHeadersWhitelist configuration. -#opensearch.customHeaders: {} - -# Time in milliseconds for OpenSearch to wait for responses from shards. Set to 0 to disable. -#opensearch.shardTimeout: 30000 - -# Logs queries sent to OpenSearch. Requires logging.verbose set to true. -#opensearch.logQueries: false - -# Specifies the path where OpenSearch Dashboards creates the process ID file. -#pid.file: /var/run/opensearchDashboards.pid - -# Enables you to specify a file where OpenSearch Dashboards stores log output. -#logging.dest: stdout - -# Set the value of this setting to true to suppress all logging output. -#logging.silent: false - -# Set the value of this setting to true to suppress all logging output other than error messages. -#logging.quiet: false - -# Set the value of this setting to true to log all events, including system usage information -# and all requests. -#logging.verbose: false - -# Set the interval in milliseconds to sample system and process performance -# metrics. Minimum is 100ms. Defaults to 5000. -#ops.interval: 5000 - -# Specifies locale to be used for all localizable strings, dates and number formats. -# Supported languages are the following: English - en , by default , Chinese - zh-CN . -#i18n.locale: "en" - -# Set the allowlist to check input graphite Url. Allowlist is the default check list. -#vis_type_timeline.graphiteAllowedUrls: ['https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite'] - -# Set the blocklist to check input graphite Url. Blocklist is an IP list. -# Below is an example for reference -# vis_type_timeline.graphiteBlockedIPs: [ -# //Loopback -# '127.0.0.0/8', -# '::1/128', -# //Link-local Address for IPv6 -# 'fe80::/10', -# //Private IP address for IPv4 -# '10.0.0.0/8', -# '172.16.0.0/12', -# '192.168.0.0/16', -# //Unique local address (ULA) -# 'fc00::/7', -# //Reserved IP address -# '0.0.0.0/8', -# '100.64.0.0/10', -# '192.0.0.0/24', -# '192.0.2.0/24', -# '198.18.0.0/15', -# '192.88.99.0/24', -# '198.51.100.0/24', -# '203.0.113.0/24', -# '224.0.0.0/4', -# '240.0.0.0/4', -# '255.255.255.255/32', -# '::/128', -# '2001:db8::/32', -# 'ff00::/8', -# ] -#vis_type_timeline.graphiteBlockedIPs: [] - -# opensearchDashboards.branding: - # logo: - # defaultUrl: "" - # darkModeUrl: "" - # mark: - # defaultUrl: "" - # darkModeUrl: "" - # loadingLogo: - # defaultUrl: "" - # darkModeUrl: "" - # faviconUrl: "" - # applicationTitle: "" - -# Set the value of this setting to true to capture region blocked warnings and errors +opensearch.ssl.verificationMode: none + + # Time in milliseconds to wait for OpenSearch to respond to pings. Defaults to the value of + # the opensearch.requestTimeout setting. + #opensearch.pingTimeout: 1500 + + # Time in milliseconds to wait for responses from the back end or OpenSearch. This value + # must be a positive integer. + #opensearch.requestTimeout: 30000 + + # List of OpenSearch Dashboards client-side headers to send to OpenSearch. To send *no* client-side + # headers, set this value to [] (an empty list). + #opensearch.requestHeadersWhitelist: [ authorization ] + + # Header names and values that are sent to OpenSearch. Any custom headers cannot be overwritten + # by client-side headers, regardless of the opensearch.requestHeadersWhitelist configuration. + #opensearch.customHeaders: {} + + # Time in milliseconds for OpenSearch to wait for responses from shards. Set to 0 to disable. + #opensearch.shardTimeout: 30000 + + # Logs queries sent to OpenSearch. Requires logging.verbose set to true. + #opensearch.logQueries: false + + # Specifies the path where OpenSearch Dashboards creates the process ID file. + #pid.file: /var/run/opensearchDashboards.pid + + # Enables you to specify a file where OpenSearch Dashboards stores log output. + #logging.dest: stdout + + # Set the value of this setting to true to suppress all logging output. + #logging.silent: false + + # Set the value of this setting to true to suppress all logging output other than error messages. + #logging.quiet: false + + # Set the value of this setting to true to log all events, including system usage information + # and all requests. + #logging.verbose: false + + # Set the interval in milliseconds to sample system and process performance + # metrics. Minimum is 100ms. Defaults to 5000. + #ops.interval: 5000 + + # Specifies locale to be used for all localizable strings, dates and number formats. + # Supported languages are the following: English - en , by default , Chinese - zh-CN . + #i18n.locale: "en" + + # Set the allowlist to check input graphite Url. Allowlist is the default check list. + #vis_type_timeline.graphiteAllowedUrls: ['https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite'] + + # Set the blocklist to check input graphite Url. Blocklist is an IP list. + # Below is an example for reference + # vis_type_timeline.graphiteBlockedIPs: [ + # //Loopback + # '127.0.0.0/8', + # '::1/128', + # //Link-local Address for IPv6 + # 'fe80::/10', + # //Private IP address for IPv4 + # '10.0.0.0/8', + # '172.16.0.0/12', + # '192.168.0.0/16', + # //Unique local address (ULA) + # 'fc00::/7', + # //Reserved IP address + # '0.0.0.0/8', + # '100.64.0.0/10', + # '192.0.0.0/24', + # '192.0.2.0/24', + # '198.18.0.0/15', + # '192.88.99.0/24', + # '198.51.100.0/24', + # '203.0.113.0/24', + # '224.0.0.0/4', + # '240.0.0.0/4', + # '255.255.255.255/32', + # '::/128', + # '2001:db8::/32', + # 'ff00::/8', + # ] + #vis_type_timeline.graphiteBlockedIPs: [] + + # opensearchDashboards.branding: + # logo: + # defaultUrl: "" + # darkModeUrl: "" + # mark: + # defaultUrl: "" + # darkModeUrl: "" + # loadingLogo: + # defaultUrl: "" + # darkModeUrl: "" + # faviconUrl: "" +# applicationTitle: "" +# useExpandedHeader: false + +#opensearch.ignoreVersionMismatch: true + +# Set the value of this setting to true to capture region blocked warnings and errors # for your map rendering services. -# map.showRegionBlockedWarning: false \ No newline at end of file +# map.showRegionBlockedWarning: false + +opensearch.requestHeadersAllowlist: [ authorization,securitytenant ] +opensearch_security.multitenancy.enabled: true +opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"] +opensearch_security.readonly_mode.roles: ["kibana_read_only"] + +# Use this setting if you are running opensearch-dashboards without https +opensearch_security.cookie.secure: false diff --git a/package.json b/package.json index f8acbfb3bf49..e5afbbf9481d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,9 @@ "built_assets", ".eslintcache", ".node_binaries", - "src/plugins/*/target" + "src/plugins/*/target", + "src/core/target", + "src/test_utils/target" ] } }, @@ -43,13 +45,16 @@ "test": "grunt test", "test:bwc": "./scripts/bwctest_osd.sh", "test:jest": "node scripts/jest", + "test:jest:coverage": "node scripts/jest --coverage", + "test:jest:ci": "node scripts/jest --ci --colors --runInBand", + "test:jest:ci:coverage": "node scripts/jest --ci --colors --runInBand --coverage", "test:jest_integration": "node scripts/jest_integration", + "test:jest_integration:ci": "node scripts/jest_integration --ci --colors --max-old-space-size=5120", "test:mocha": "node scripts/mocha", - "test:mocha:coverage": "grunt test:mochaCoverage", + "test:mocha:coverage": "yarn nyc --reporter=text-summary --reporter=lcov --report-dir=./target/opensearch-dashboards-coverage/mocha node scripts/mocha", "test:ftr": "node scripts/functional_tests", "test:ftr:server": "node scripts/functional_tests_server", "test:ftr:runner": "node scripts/functional_test_runner", - "test:coverage": "grunt test:coverage", "checkLicenses": "node scripts/check_licenses --dev", "build-platform": "node scripts/build", "build": "node scripts/build --all-platforms", @@ -79,7 +84,8 @@ "**/@types/node": ">=10.17.17 <10.20.0", "**/@types/react": "^16.14.23", "**/ansi-regex": "^5.0.1", - "**/axios": "^0.21.4", + "!chromedriver/**/axios": "^0.21.4", + "chromedriver/**/axios": "^0.27.2", "**/ejs": "^3.1.6", "**/follow-redirects": "^1.15.2", "**/front-matter": "^4.0.2", @@ -107,6 +113,8 @@ "**/url-parse": "^1.5.8", "**/shelljs": "0.8.5", "**/unset-value": "^2.0.1", + "**/jest-config": "npm:@amoo-miki/jest-config@26.4.2-rc.1", + "**/jest-jasmine2": "npm:@amoo-miki/jest-jasmine2@26.4.2-rc.1", "**/minimatch": "^3.0.5" }, "workspaces": { @@ -367,7 +375,7 @@ "chai": "3.5.0", "chance": "1.0.18", "cheerio": "0.22.0", - "chromedriver": "^91.0.1", + "chromedriver": "107.0.1", "classnames": "2.2.6", "compare-versions": "3.5.1", "d3": "3.5.17", diff --git a/packages/osd-optimizer/src/worker/run_worker.ts b/packages/osd-optimizer/src/worker/run_worker.ts index ac5b940a78ae..a0ee246c6a5c 100644 --- a/packages/osd-optimizer/src/worker/run_worker.ts +++ b/packages/osd-optimizer/src/worker/run_worker.ts @@ -80,11 +80,13 @@ const exit = (code: number) => { setTimeout(() => { send( workerMsgs.error( - new Error('process did not automatically exit within 5 seconds, forcing exit') + new Error( + `process did not automatically exit within 15 seconds (previous code: ${code}); forcing exit...` + ) ) ); process.exit(1); - }, 5000).unref(); + }, 15000).unref(); }; // check for connected parent on an unref'd timer rather than listening diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 759addb21f48..4e3891f94a6b 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -51,16 +51,6 @@ export default { '/src/test_utils', '/test/functional/services/remote', ], - collectCoverageFrom: [ - 'src/plugins/**/*.{ts,tsx}', - '!src/plugins/**/*.d.ts', - 'packages/osd-ui-framework/src/components/**/*.js', - '!packages/osd-ui-framework/src/components/index.js', - '!packages/osd-ui-framework/src/components/**/*/index.js', - 'packages/osd-ui-framework/src/services/**/*.js', - '!packages/osd-ui-framework/src/services/index.js', - '!packages/osd-ui-framework/src/services/**/*/index.js', - ], moduleNameMapper: { '@elastic/eui$': '/node_modules/@elastic/eui/test-env', '@elastic/eui/lib/(.*)?': '/node_modules/@elastic/eui/test-env/$1', @@ -84,7 +74,8 @@ export default { '/src/dev/jest/setup/react_testing_library.js', ], coverageDirectory: '/target/opensearch-dashboards-coverage/jest', - coverageReporters: ['html', 'text'], + coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'], + coverageReporters: ['lcov', 'text-summary'], moduleFileExtensions: ['js', 'mjs', 'json', 'ts', 'tsx', 'node'], modulePathIgnorePatterns: [ '__fixtures__/', diff --git a/src/dev/jest/integration_tests/__fixtures__/test.js b/src/dev/jest/integration_tests/__fixtures__/test.js index 4010846a5b71..cec71e2c38f3 100644 --- a/src/dev/jest/integration_tests/__fixtures__/test.js +++ b/src/dev/jest/integration_tests/__fixtures__/test.js @@ -30,6 +30,9 @@ * GitHub history for details. */ -it('fails', () => { +it('fails', (done) => { + setTimeout(() => { + done(); + }, 200); throw new Error('failure'); }); diff --git a/src/plugins/expressions/common/execution/execution_contract.test.ts b/src/plugins/expressions/common/execution/execution_contract.test.ts index 23bd83024611..ad93b0daabb6 100644 --- a/src/plugins/expressions/common/execution/execution_contract.test.ts +++ b/src/plugins/expressions/common/execution/execution_contract.test.ts @@ -72,7 +72,7 @@ describe('ExecutionContract', () => { test('can cancel execution', () => { const execution = createExecution('foo bar=123'); - const spy = jest.spyOn(execution, 'cancel'); + const spy = jest.spyOn(execution, 'cancel').mockImplementation(() => {}); const contract = new ExecutionContract(execution); expect(spy).toHaveBeenCalledTimes(0); diff --git a/yarn.lock b/yarn.lock index aa3232c49ea6..09222dbf5448 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2386,10 +2386,10 @@ dependencies: defer-to-connect "^2.0.0" -"@testim/chrome-version@^1.0.7": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@testim/chrome-version/-/chrome-version-1.0.7.tgz#0cd915785ec4190f08a3a6acc9b61fc38fb5f1a9" - integrity sha512-8UT/J+xqCYfn3fKtOznAibsHpiuDshCb0fwgWxRazTT19Igp9ovoXMPhXyLD6m3CKQGTMHgqoxaFfMWaL40Rnw== +"@testim/chrome-version@^1.1.3": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@testim/chrome-version/-/chrome-version-1.1.3.tgz#fbb68696899d7b8c1b9b891eded9c04fe2cd5529" + integrity sha512-g697J3WxV/Zytemz8aTuKjTGYtta9+02kva3C1xc7KXB8GdbfE1akGJIsZLyY/FSh2QrnE+fiB7vmWU3XNcb6A== "@testing-library/dom@^7.24.2": version "7.24.2" @@ -4712,6 +4712,14 @@ axios@^0.21.1, axios@^0.21.4: dependencies: follow-redirects "^1.14.0" +axios@^0.27.2: + version "0.27.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" + integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== + dependencies: + follow-redirects "^1.14.9" + form-data "^4.0.0" + axobject-query@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.0.2.tgz#ea187abe5b9002b377f925d8bf7d1c561adf38f9" @@ -5966,16 +5974,17 @@ chrome-trace-event@^1.0.2: dependencies: tslib "^1.9.0" -chromedriver@^91.0.1: - version "91.0.1" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-91.0.1.tgz#4d70a569901e356c978a41de3019c464f2a8ebd0" - integrity sha512-9LktpHiUxM4UWUsr+jI1K1YKx2GENt6BKKJ2mibPj1Wc6ODzX/3fFIlr8CZ4Ftuyga+dHTTbAyPWKwKvybEbKA== +chromedriver@107.0.1: + version "107.0.1" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-107.0.1.tgz#13e4f20a6a1c00ed5c9734db2356dc737bbfa96d" + integrity sha512-oIBZHystVpbUaPwypJTnqe4UWar0rIPGLPPe9RLSZ+cgbOVns/q9naoXQj+n+VzcbTtdfs9N3VXnVFvG/vKA6Q== dependencies: - "@testim/chrome-version" "^1.0.7" - axios "^0.21.1" - del "^6.0.0" + "@testim/chrome-version" "^1.1.3" + axios "^0.27.2" + compare-versions "^5.0.1" + del "^6.1.1" extract-zip "^2.0.1" - https-proxy-agent "^5.0.0" + https-proxy-agent "^5.0.1" proxy-from-env "^1.1.0" tcp-port-used "^1.0.1" @@ -6362,7 +6371,7 @@ colorspace@1.1.x: color "3.0.x" text-hex "1.0.x" -combined-stream@^1.0.6, combined-stream@~1.0.6: +combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== @@ -6409,6 +6418,11 @@ compare-versions@3.5.1: resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.5.1.tgz#26e1f5cf0d48a77eced5046b9f67b6b61075a393" integrity sha512-9fGPIB7C6AyM18CJJBHt5EnCZDG3oiTJYy0NjfIAGjKpzv0tkxWko7TNQHF5ymqm7IH03tqmeuBxtvD+Izh6mg== +compare-versions@^5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-5.0.3.tgz#a9b34fea217472650ef4a2651d905f42c28ebfd7" + integrity sha512-4UZlZP8Z99MGEY+Ovg/uJxJuvoXuN4M6B3hKaiackiHrgzQFEe3diJi1mf1PNHbFujM7FvLrK2bpgIaImbtZ1A== + component-emitter@^1.2.0, component-emitter@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -9685,7 +9699,7 @@ focus-trap@^2.0.1: dependencies: tabbable "^1.0.3" -follow-redirects@1.12.1, follow-redirects@^1.0.0, follow-redirects@^1.14.0, follow-redirects@^1.15.2: +follow-redirects@1.12.1, follow-redirects@^1.0.0, follow-redirects@^1.14.0, follow-redirects@^1.14.9, follow-redirects@^1.15.2: version "1.15.2" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== @@ -9746,6 +9760,15 @@ form-data@^2.3.1, form-data@^2.5.0: combined-stream "^1.0.6" mime-types "^2.1.12" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" @@ -11362,6 +11385,14 @@ https-proxy-agent@^4.0.0: agent-base "5" debug "4" +https-proxy-agent@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" + integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== + dependencies: + agent-base "6" + debug "4" + human-signals@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" @@ -12737,10 +12768,10 @@ jest-cli@^26.4.2: prompts "^2.0.1" yargs "^15.3.1" -jest-config@^26.4.2: - version "26.4.2" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-26.4.2.tgz#da0cbb7dc2c131ffe831f0f7f2a36256e6086558" - integrity sha512-QBf7YGLuToiM8PmTnJEdRxyYy3mHWLh24LJZKVdXZ2PNdizSe1B/E8bVm+HYcjbEzGuVXDv/di+EzdO/6Gq80A== +jest-config@^26.4.2, "jest-config@npm:@amoo-miki/jest-config@26.4.2-rc.1": + version "26.4.2-rc.1" + resolved "https://registry.yarnpkg.com/@amoo-miki/jest-config/-/jest-config-26.4.2-rc.1.tgz#5ccf4380d509b2007d6cc0cf91c421654f1a48c8" + integrity sha512-u8OAz4FqORcTIGc5F8/GGb4J/qObMHQ20869Vq7r7TIi93nYhx18M6wRtoVQo4IUNOwvG0rND1Ew8xFoE2OXYg== dependencies: "@babel/core" "^7.1.0" "@jest/test-sequencer" "^26.4.2" @@ -12864,10 +12895,10 @@ jest-haste-map@^26.3.0: optionalDependencies: fsevents "^2.1.2" -jest-jasmine2@^26.4.2: - version "26.4.2" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-26.4.2.tgz#18a9d5bec30904267ac5e9797570932aec1e2257" - integrity sha512-z7H4EpCldHN1J8fNgsja58QftxBSL+JcwZmaXIvV9WKIM+x49F4GLHu/+BQh2kzRKHAgaN/E82od+8rTOBPyPA== +jest-jasmine2@^26.4.2, "jest-jasmine2@npm:@amoo-miki/jest-jasmine2@26.4.2-rc.1": + version "26.4.2-rc.1" + resolved "https://registry.yarnpkg.com/@amoo-miki/jest-jasmine2/-/jest-jasmine2-26.4.2-rc.1.tgz#86162f9acd802038ec72a049b183f20e4e0a89f4" + integrity sha512-qi0Uo38OhygDK5zxiDPTiD+wqSJbwesk0D6hesM1TVOEeAkskX0mZN3PMqLIS//+Lgij26+lXyXfPuxbpVLdeQ== dependencies: "@babel/traverse" "^7.1.0" "@jest/environment" "^26.3.0"