Skip to content

Commit

Permalink
Add cigroup matrix for parallel runs
Browse files Browse the repository at this point in the history
Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
  • Loading branch information
manasvinibs committed Mar 5, 2024
1 parent 4efdc14 commit bc074a1
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 46 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/cypress_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Run cypress tests

# trigger on every PR for all branches
on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]
paths-ignore:
Expand Down Expand Up @@ -47,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9]
group: [1, 2, 10, 11]
container:
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
options: --user 1001
Expand Down Expand Up @@ -81,8 +83,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: ${{ env.SOURCE_REPO }}
ref: '${{ env.SOURCE_BRANCH }}'
repository: ${{ env.SOURCE_REPO || github.repository}}
ref: '${{ env.SOURCE_BRANCH || github.base_ref}}'

- name: Setup Node
uses: actions/setup-node@v2
Expand All @@ -102,6 +104,7 @@ jobs:
run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 12

- name: Checkout
if: ${{ matrix.group != 10 && matrix.group != 11 }}
uses: actions/checkout@v2
with:
path: ${{ env.FTR_PATH }}
Expand All @@ -114,7 +117,7 @@ jobs:
echo "SPEC=${{ inputs.specs }}" >> $GITHUB_ENV
- name: Setup spec files
if: ${{ inputs.specs == '' }}
if: ${{ inputs.specs == '' && matrix.group != 10 && matrix.group != 11 }}
working-directory: ${{ env.FTR_PATH }}
shell: bash
run: |
Expand All @@ -124,6 +127,20 @@ jobs:
FORMATTED_SPEC+="cypress/integration/core-opensearch-dashboards/opensearch-dashboards/${i},"
done
echo "SPEC=${FORMATTED_SPEC}" >> $GITHUB_ENV
echo "SPEC=${FORMATTED_SPEC}"
- name: Setup spec files for Dashboards tests
if: ${{ inputs.specs == '' && matrix.group == 10 || matrix.group == 11 }}
shell: bash
run: |
IFS="," read -a SPEC_ARRAY <<< $(yarn --silent osd:ciGroup${{ matrix.group }})
ADDITIONAL_SPEC=''
for i in "${SPEC_ARRAY[@]}"; do
ADDITIONAL_SPEC+="cypress/integration/core_opensearch_dashboards/${i},"
done
SPEC=${ADDITIONAL_SPEC}
echo "SPEC=${ADDITIONAL_SPEC}" >> $GITHUB_ENV
echo "SPEC: $SPEC"
- name: Get Cypress version
id: cypress_version
Expand All @@ -142,13 +159,23 @@ jobs:
- run: npx cypress cache path

- name: Run tests
if: ${{ matrix.group != 10 && matrix.group != 11 }}
uses: cypress-io/github-action@v2
with:
working-directory: ${{ env.FTR_PATH }}
start: ${{ env.OPENSEARCH_SNAPSHOT_CMD }}, ${{ env.START_CMD }}
wait-on: 'http://localhost:9200, http://localhost:5601'
command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.SPEC }}

- name: Run tests within Dashboards repo
if: ${{ matrix.group == 10 || matrix.group == 11 }}
run: |
echo "CWD: $(pwd)"
node scripts/opensearch snapshot -E cluster.routing.allocation.disk.threshold_enabled=false
node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true
source scripts/cypress_tests.sh
run_cypress
# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v3
if: failure()
Expand Down
63 changes: 30 additions & 33 deletions .github/workflows/dashboards_cypress_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Orchestrator cypress workflow
run-name: dashboards_cypress_workflow ${{ inputs.UNIQUE_ID != '' && inputs.UNIQUE_ID || '' }} # Unique id number appended to the workflow run-name to reference the run within the orchestrator.
# Trigger on dispatch event sent from FT repo orchestrator
on:
push:
branches: [ '**' ]
workflow_dispatch:
inputs:
test_repo:
Expand Down Expand Up @@ -41,25 +43,32 @@ env:
TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || github.repository }}
TEST_BRANCH: "${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }}"
OSD_PATH: 'osd'
CYPRESS_BROWSER: 'chromium'
CYPRESS_BROWSER: 'electron'
JOB_ID: ${{ inputs.UNIQUE_ID}}
OPENSEARCH: ${{ inputs.OS_URL != '' && inputs.OS_URL || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$VERSION/latest/linux/x64/tar/dist/opensearch/opensearch-$VERSION-linux-x64.tar.gz' }}
DASHBOARDS: ${{ inputs.OSD_URL != '' && inputs.OSD_URL || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/$VERSION/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-$VERSION-linux-x64.tar.gz' }}
OPENSEARCH_DIR: 'cypress/opensearch'
DASHBOARDS_DIR: 'cypress/opensearch-dashboards'
SECURITY_ENABLED: ${{ inputs.SECURITY_ENABLED != '' && inputs.SECURITY_ENABLED || 'false' }}
SPEC: 'cypress/integration/core_opensearch_dashboards/*'

jobs:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch-dashboards

cypress-tests:
needs: Get-CI-Image-Tag
runs-on: ubuntu-latest
strategy:
matrix:
spec_group:
[1, 2, 3, 4] # Add more spec files as needed
spec_group: [10, 11] # Add more spec files as needed
container:
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
options: --user 1001
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root
env:
# prevents extra Cypress installation progress messages
CI: 1
Expand All @@ -70,14 +79,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
with:
path: ./${{ env.OSD_PATH }}
repository: ${{ env.TEST_REPO }}
ref: '${{ env.TEST_BRANCH }}'

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './${{ env.OSD_PATH }}/.nvmrc'
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Setup Yarn
Expand All @@ -88,73 +96,62 @@ jobs:
- name: Setup spec files
if: ${{ inputs.specs == '' }}
working-directory: ${{ env.OSD_PATH }}
shell: bash
run: |
IFS="," read -a SPEC_ARRAY <<< $(yarn --silent osd:ciGroup${{ matrix.spec_group }})
FORMATTED_SPEC=''
for i in "${SPEC_ARRAY[@]}"; do
FORMATTED_SPEC+="cypress/integration/core-opensearch-dashboards/${i},"
FORMATTED_SPEC+="cypress/integration/core_opensearch_dashboards/${i},"
done
echo "SPEC=${FORMATTED_SPEC}" >> $GITHUB_ENV
echo "SPec found: $SPEC"
SPEC=${FORMATTED_SPEC} # Set SPEC to FORMATTED_SPEC
echo "SPEC=${SPEC}" >> $GITHUB_ENV
echo "SPEC found: $SPEC"
- name: Get Cypress version
id: cypress_version
run: |
echo "name=cypress_version::$(cat ./${{ env.OSD_PATH }}/package.json | jq '.devDependencies.cypress' | tr -d '"')" >> $GITHUB_OUTPUT
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v1
with:
path: ~/.cache/Cypress
key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }}
env:
CYPRESS_INSTALL_BINARY: ${{ steps.cypress_version.outputs.cypress_version }}
- run: npx cypress cache list
- run: npx cypress cache path
echo "name=cypress_version::$(cat package.json | jq '.devDependencies.cypress' | tr -d '"')" >> $GITHUB_OUTPUT
- name: Get package version (Linux)
run: |
cd ${{ env.OSD_PATH }}
echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
- name: Run bootstrap
run: |
cd ${{ env.OSD_PATH }}
yarn osd bootstrap
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
yarn osd bootstrap"
- name: Download and extract Opensearch artifacts
run: |
CWD=$(pwd)
mkdir -p $CWD/${{ env.OPENSEARCH_DIR }}
source ${{ env.OSD_PATH }}/scripts/common/utils.sh
source scripts/common/utils.sh
open_artifact $CWD/${{ env.OPENSEARCH_DIR }} ${{ env.OPENSEARCH }}
- name: Download and extract Opensearch Dashboards artifacts
run: |
CWD=$(pwd)
mkdir -p $CWD/${{ env.DASHBOARDS_DIR }}
source ${{ env.OSD_PATH }}/scripts/common/utils.sh
source scripts/common/utils.sh
open_artifact $CWD/${{ env.DASHBOARDS_DIR }} ${{ env.DASHBOARDS }}
- name: Run Cypress tests
run: |
source ${{ env.OSD_PATH }}/scripts/cypress_tests.sh
run_dashboards_cypress_tests
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "source scripts/cypress_tests.sh && run_dashboards_cypress_tests"
# Screenshots are only captured on failures
- uses: actions/upload-artifact@v3
if: failure()
with:
name: osd-cypress-screenshots
path: ${{ env.OSD_PATH }}/cypress/screenshots
path: cypress/screenshots
retention-days: 1

- uses: actions/upload-artifact@v3
if: always()
with:
name: osd-cypress-videos
path: ${{ env.OSD_PATH }}/cypress/videos
path: cypress/videos
retention-days: 1
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@
"pkg-version": "scripts/use_node -e \"console.log(require('./package.json').version)\"",
"cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false",
"cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500",
"osd:ciGroup1": "echo \"\"",
"osd:ciGroup2": "echo \"\"",
"osd:ciGroup3": "echo \"\"",
"osd:ciGroup4": "echo \"dashboard_sanity_test_spec.js\""
"osd:ciGroup10": "echo \"dashboard_sanity_test_spec.js\"",
"osd:ciGroup11": "echo \"dashboard_sanity_test_spec.js\""
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions scripts/common/opensearch_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function setup_opensearch() {
cd "$OPENSEARCH_DIR"
echo "network.host: 0.0.0.0" >> config/opensearch.yml
echo "discovery.type: single-node" >> config/opensearch.yml
echo "cluster.routing.allocation.disk.threshold_enabled: false" >> config/opensearch.yml
[ $SECURITY_ENABLED == "false" ] && [ -d "plugins/opensearch-security" ] && echo "plugins.security.disabled: true" >> config/opensearch.yml
# Required for IM
[ -d "plugins/opensearch-index-management" ] && echo "path.repo: [/tmp]" >> config/opensearch.yml
Expand Down
12 changes: 7 additions & 5 deletions scripts/cypress_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

set -e

. $OSD_PATH/scripts/common/utils.sh
. $OSD_PATH/scripts/common/opensearch_service.sh
. $OSD_PATH/scripts/common/opensearch_dashboards_service.sh
. scripts/common/utils.sh
. scripts/common/opensearch_service.sh
. scripts/common/opensearch_dashboards_service.sh

CWD=$(pwd)
CREDENTIAL="admin:myStrongPassword123!"
Expand Down Expand Up @@ -67,10 +67,12 @@ function check_status() {

# Starts OpenSearch Dashboards and run tests in the cypress folder
function run_dashboards_cypress_tests() {
run_opensearch
cd $CWD
echo "[ OpenSearch Dashboards setup before it starts... ]"
setup_dashboards >> /dev/null 2>&1 &
sleep 100
cd "$DASHBOARDS_DIR"
cd $CWD/"$DASHBOARDS_DIR"
if [ -x "./bin/opensearch-dashboards" ]; then
spawn_process_and_save_PID "./bin/opensearch-dashboards &"
else
Expand All @@ -79,11 +81,11 @@ function run_dashboards_cypress_tests() {
fi
check_status $DASHBOARDS_URL $DASHBOARDS_MSG
# Run cypress tests
cd "$CWD"/osd
run_cypress
}

function run_cypress() {
cd "$CWD"/osd
echo "SPEC found: $SPEC"
if [ $SECURITY_ENABLED = "true" ]; then
echo "run security enabled tests"
Expand Down

0 comments on commit bc074a1

Please sign in to comment.