Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions .github/workflows/cypress-tests-qi-wlm-interaction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
name: Cypress e2e integration tests workflow for QI-WLM interaction
on:
pull_request:
branches:
- "*"
push:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: 'main'
QUERY_INSIGHTS_BRANCH: 'main'
GRADLE_VERSION: '7.6.1'
CYPRESS_VIDEO: true
CYPRESS_SCREENSHOT_ON_RUN_FAILURE: true

jobs:
tests:
name: Run Cypress E2E tests for QI-WLM interaction
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
cypress_cache_folder: ~/.cache/Cypress
runs-on: ${{ matrix.os }}
env:
CI: 1
TERM: xterm
steps:

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Checkout Query Insights
uses: actions/checkout@v4
with:
path: query-insights
repository: opensearch-project/query-insights
ref: ${{ env.QUERY_INSIGHTS_BRANCH }}

- name: Checkout OpenSearch
uses: actions/checkout@v4
with:
path: OpenSearch
repository: opensearch-project/OpenSearch
ref: ${{ env.OPENSEARCH_BRANCH }}

- name: Fetch OpenSearch version from build.gradle
run: |
cd query-insights
opensearch_version=$(node -e "
const fs = require('fs');
const gradleFile = fs.readFileSync('build.gradle', 'utf-8');
const match = gradleFile.match(/opensearch_version\\s*=\\s*System\\.getProperty\\(['\"][^'\"]+['\"],\\s*['\"]([^'\"]+)['\"]\\)/);
console.log(match ? match[1] : 'No version found');
")
echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$opensearch_version" >> $GITHUB_ENV
shell: bash

- name: Build Required Plugins
run: |
cd OpenSearch
./gradlew :modules:autotagging-commons:assemble
./gradlew :plugins:workload-management:assemble

- name: Copy Plugins to Query Insights
run: |
mkdir -p query-insights/plugins
find OpenSearch/modules/autotagging-commons/build/distributions/ -name "*.zip" -exec cp {} query-insights/plugins/ \;
find OpenSearch/plugins/workload-management/build/distributions/ -name "*.zip" -exec cp {} query-insights/plugins/ \;

- name: Set up Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: ${{ env.GRADLE_VERSION }}

- name: Run OpenSearch with Query Insights plugin
run: |
cd query-insights
./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} &

echo "Waiting for OpenSearch to start..."
for i in {1..60}; do
if curl -s http://localhost:9200/_cluster/health > /dev/null 2>&1; then
echo "OpenSearch is ready!"
break
fi
echo "Attempt $i/60: OpenSearch not ready yet, waiting 10 seconds..."
sleep 10
done

curl -s http://localhost:9200/_cluster/health || (echo "OpenSearch failed to start" && exit 1)

echo -e "\nEnabling WLM mode:"
curl -X PUT "http://localhost:9200/_cluster/settings" \
-H 'Content-Type: application/json' \
-d '{"persistent":{"wlm.workload_group.mode":"enabled"}}' | jq '.'
shell: bash

- name: Checkout OpenSearch-Dashboards
uses: actions/checkout@v4
with:
repository: opensearch-project/OpenSearch-Dashboards
path: OpenSearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}

- name: Checkout Query Insights Dashboards plugin
uses: actions/checkout@v4
with:
path: OpenSearch-Dashboards/plugins/query-insights-dashboards

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './OpenSearch-Dashboards/.nvmrc'
registry-url: 'https://registry.npmjs.org'

- name: Install Yarn
shell: bash
run: |
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
npm i -g yarn@$YARN_VERSION

- name: Bootstrap plugin/OpenSearch-Dashboards
run: |
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
yarn osd bootstrap --single-version=loose

- name: Run OpenSearch-Dashboards server
run: |
cd OpenSearch-Dashboards
export NODE_OPTIONS="--max-old-space-size=6144 --dns-result-order=ipv4first"
nohup yarn start --no-base-path --no-watch --server.host="0.0.0.0" > dashboards.log 2>&1 &
sleep 10
shell: bash

- name: Wait for OpenSearch-Dashboards to be ready
run: |
echo "Waiting for OpenSearch-Dashboards to start..."
max_attempts=150
attempt=0
while [ $attempt -lt $max_attempts ]; do
if curl -s -f http://localhost:5601/api/status > /dev/null 2>&1; then
echo "OpenSearch-Dashboards is ready!"
sleep 45
break
fi
attempt=$((attempt + 1))
echo "Attempt $attempt/$max_attempts: waiting 10 seconds..."
sleep 10
done
shell: bash

- name: Install Cypress
run: |
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
npx cypress install
shell: bash

- name: Cache Cypress
uses: actions/cache@v4
with:
path: ${{ matrix.cypress_cache_folder }}
key: cypress-cache-v2-${{ matrix.os }}-${{ hashFiles('OpenSearch-Dashboards/plugins/query-insights-dashboards/package.json') }}

- name: Create WLM workload groups
run: |
curl -s -H 'Content-Type: application/json' \
-X PUT 'http://localhost:9200/_wlm/workload_group' \
-d '{"name":"analytics_group","resiliency_mode":"soft","resource_limits":{"cpu":0.3,"memory":0.3}}'

curl -s -H 'Content-Type: application/json' \
-X PUT 'http://localhost:9200/_wlm/workload_group' \
-d '{"name":"search_group","resiliency_mode":"soft","resource_limits":{"cpu":0.2,"memory":0.2}}'

- name: Cypress tests
uses: cypress-io/github-action@v5
with:
working-directory: OpenSearch-Dashboards/plugins/query-insights-dashboards
command: yarn run cypress run --config defaultCommandTimeout=120000,requestTimeout=120000,responseTimeout=120000,pageLoadTimeout=180000,taskTimeout=120000,execTimeout=120000 --spec cypress/e2e/qi-wlm-interaction/**/*
wait-on: 'http://localhost:5601'
wait-on-timeout: 1200
browser: chrome
env:
CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}
CI: true
timeout-minutes: 120

- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-qi-wlm-interaction-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/query-insights-dashboards/cypress/screenshots

- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-videos-qi-wlm-interaction-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/query-insights-dashboards/cypress/videos
Loading
Loading