Skip to content

Commit 5efcadf

Browse files
deshsiddansjcy
authored andcommitted
Query grouping dashboard changes and extensive tests (opensearch-project#33)
* Revert "remove records with grouping (opensearch-project#26)" This reverts commit 9efdbaf. Signed-off-by: Siddhant Deshmukh <[email protected]> * Query grouping dashboard changes and extensive tests Signed-off-by: Siddhant Deshmukh <[email protected]> * Fix tests and linting Signed-off-by: Siddhant Deshmukh <[email protected]> * Address review comments Signed-off-by: Siddhant Deshmukh <[email protected]> * Address review comments and update tests Signed-off-by: Siddhant Deshmukh <[email protected]> * Update cypress tests, hashcode to id, refactoring Signed-off-by: Siddhant Deshmukh <[email protected]> * Lint Signed-off-by: Siddhant Deshmukh <[email protected]> --------- Signed-off-by: Siddhant Deshmukh <[email protected]>
1 parent 1632706 commit 5efcadf

26 files changed

+1879
-256
lines changed

.github/workflows/cypress-tests.yml

Lines changed: 154 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,154 @@
1-
name: Cypress e2e integration tests workflow
2-
on:
3-
pull_request:
4-
branches:
5-
- "*"
6-
push:
7-
branches:
8-
- "*"
9-
env:
10-
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
11-
QUERY_INSIGHTS_BRANCH: '2.x'
12-
GRADLE_VERSION: '7.6.1'
13-
jobs:
14-
tests:
15-
name: Run Cypress E2E tests
16-
strategy:
17-
matrix:
18-
os: [ubuntu-latest, windows-latest]
19-
include:
20-
- os: windows-latest
21-
cypress_cache_folder: ~/AppData/Local/Cypress/Cache
22-
- os: ubuntu-latest
23-
cypress_cache_folder: ~/.cache/Cypress
24-
runs-on: ${{ matrix.os }}
25-
env:
26-
# prevents extra Cypress installation progress messages
27-
CI: 1
28-
# avoid warnings like "tput: No value for $TERM and no -T specified"
29-
TERM: xterm
30-
steps:
31-
- name: Set up JDK
32-
uses: actions/setup-java@v1
33-
with:
34-
java-version: 21
35-
36-
- name: Enable longer filenames
37-
if: ${{ matrix.os == 'windows-latest' }}
38-
run: git config --system core.longpaths true
39-
40-
- name: Checkout Query Insights
41-
uses: actions/checkout@v2
42-
with:
43-
path: query-insights
44-
repository: opensearch-project/query-insights
45-
ref: ${{ env.QUERY_INSIGHTS_BRANCH }}
46-
47-
- name: Set up Gradle
48-
uses: gradle/gradle-build-action@v2
49-
with:
50-
gradle-version: ${{ env.GRADLE_VERSION }}
51-
52-
- name: Run OpenSearch with Query Insights plugin
53-
run: |
54-
cd query-insights
55-
./gradlew run &
56-
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
57-
shell: bash
58-
59-
- name: Checkout OpenSearch-Dashboards
60-
uses: actions/checkout@v2
61-
with:
62-
repository: opensearch-project/OpenSearch-Dashboards
63-
path: OpenSearch-Dashboards
64-
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
65-
66-
- name: Checkout Query Insights Dashboards plugin
67-
uses: actions/checkout@v2
68-
with:
69-
path: OpenSearch-Dashboards/plugins/query-insights-dashboards
70-
71-
- name: Setup Node
72-
uses: actions/setup-node@v3
73-
with:
74-
node-version-file: './OpenSearch-Dashboards/.nvmrc'
75-
registry-url: 'https://registry.npmjs.org'
76-
77-
- name: Install Yarn
78-
# Need to use bash to avoid having a windows/linux specific step
79-
shell: bash
80-
run: |
81-
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
82-
echo "Installing yarn@$YARN_VERSION"
83-
npm i -g yarn@$YARN_VERSION
84-
- run: node -v
85-
- run: yarn -v
86-
87-
- name: Bootstrap plugin/OpenSearch-Dashboards
88-
run: |
89-
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
90-
yarn osd bootstrap --single-version=loose
91-
92-
- name: Run OpenSearch-Dashboards server
93-
run: |
94-
cd OpenSearch-Dashboards
95-
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
96-
shell: bash
97-
98-
# Window is slow so wait longer
99-
- name: Sleep until OSD server starts - windows
100-
if: ${{ matrix.os == 'windows-latest' }}
101-
run: Start-Sleep -s 600
102-
shell: powershell
103-
104-
- name: Sleep until OSD server starts - non-windows
105-
if: ${{ matrix.os != 'windows-latest' }}
106-
run: sleep 500
107-
shell: bash
108-
109-
- name: Install Cypress
110-
run: |
111-
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
112-
# This will install Cypress in case the binary is missing which can happen on Windows and Mac
113-
# If the binary exists, this will exit quickly so it should not be an expensive operation
114-
npx cypress install
115-
shell: bash
116-
117-
- name: Get Cypress version
118-
id: cypress_version
119-
run: |
120-
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
121-
echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
122-
123-
- name: Cache Cypress
124-
id: cache-cypress
125-
uses: actions/cache@v2
126-
with:
127-
path: ${{ matrix.cypress_cache_folder }}
128-
key: cypress-cache-v2-${{ matrix.os }}-${{ hashFiles('OpenSearch-Dashboards/plugins/query-insights-dashboards/package.json') }}
129-
130-
# for now just chrome, use matrix to do all browsers later
131-
- name: Cypress tests
132-
uses: cypress-io/github-action@v5
133-
with:
134-
working-directory: OpenSearch-Dashboards/plugins/query-insights-dashboards
135-
command: yarn run cypress run
136-
wait-on: 'http://localhost:5601'
137-
wait-on-timeout: 600
138-
browser: chrome
139-
env:
140-
CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}
141-
142-
# Screenshots are only captured on failure, will change this once we do visual regression tests
143-
- uses: actions/upload-artifact@v4
144-
if: failure()
145-
with:
146-
name: cypress-screenshots-${{ matrix.os }}
147-
path: OpenSearch-Dashboards/plugins/query-insights-dashboards/cypress/screenshots
148-
149-
# Test run video was always captured, so this action uses "always()" condition
150-
- uses: actions/upload-artifact@v4
151-
if: always()
152-
with:
153-
name: cypress-videos-${{ matrix.os }}
154-
path: OpenSearch-Dashboards/plugins/query-insights-dashboards/cypress/videos
1+
name: Cypress e2e integration tests workflow
2+
on:
3+
pull_request:
4+
branches:
5+
- "*"
6+
push:
7+
branches:
8+
- "*"
9+
env:
10+
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
11+
QUERY_INSIGHTS_BRANCH: '2.x'
12+
GRADLE_VERSION: '7.6.1'
13+
jobs:
14+
tests:
15+
name: Run Cypress E2E tests
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
include:
20+
- os: windows-latest
21+
cypress_cache_folder: ~/AppData/Local/Cypress/Cache
22+
- os: ubuntu-latest
23+
cypress_cache_folder: ~/.cache/Cypress
24+
runs-on: ${{ matrix.os }}
25+
env:
26+
# prevents extra Cypress installation progress messages
27+
CI: 1
28+
# avoid warnings like "tput: No value for $TERM and no -T specified"
29+
TERM: xterm
30+
steps:
31+
- name: Set up JDK
32+
uses: actions/setup-java@v1
33+
with:
34+
java-version: 21
35+
36+
- name: Enable longer filenames
37+
if: ${{ matrix.os == 'windows-latest' }}
38+
run: git config --system core.longpaths true
39+
40+
- name: Checkout Query Insights
41+
uses: actions/checkout@v2
42+
with:
43+
path: query-insights
44+
repository: opensearch-project/query-insights
45+
ref: ${{ env.QUERY_INSIGHTS_BRANCH }}
46+
47+
- name: Set up Gradle
48+
uses: gradle/gradle-build-action@v2
49+
with:
50+
gradle-version: ${{ env.GRADLE_VERSION }}
51+
52+
- name: Run OpenSearch with Query Insights plugin
53+
run: |
54+
cd query-insights
55+
./gradlew run &
56+
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
57+
shell: bash
58+
59+
- name: Checkout OpenSearch-Dashboards
60+
uses: actions/checkout@v2
61+
with:
62+
repository: opensearch-project/OpenSearch-Dashboards
63+
path: OpenSearch-Dashboards
64+
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
65+
66+
- name: Checkout Query Insights Dashboards plugin
67+
uses: actions/checkout@v2
68+
with:
69+
path: OpenSearch-Dashboards/plugins/query-insights-dashboards
70+
71+
- name: Setup Node
72+
uses: actions/setup-node@v3
73+
with:
74+
node-version-file: './OpenSearch-Dashboards/.nvmrc'
75+
registry-url: 'https://registry.npmjs.org'
76+
77+
- name: Install Yarn
78+
# Need to use bash to avoid having a windows/linux specific step
79+
shell: bash
80+
run: |
81+
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
82+
echo "Installing yarn@$YARN_VERSION"
83+
npm i -g yarn@$YARN_VERSION
84+
- run: node -v
85+
- run: yarn -v
86+
87+
- name: Bootstrap plugin/OpenSearch-Dashboards
88+
run: |
89+
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
90+
yarn osd bootstrap --single-version=loose
91+
92+
- name: Run OpenSearch-Dashboards server
93+
run: |
94+
cd OpenSearch-Dashboards
95+
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
96+
shell: bash
97+
98+
# Window is slow so wait longer
99+
- name: Sleep until OSD server starts - windows
100+
if: ${{ matrix.os == 'windows-latest' }}
101+
run: Start-Sleep -s 600
102+
shell: powershell
103+
104+
- name: Sleep until OSD server starts - non-windows
105+
if: ${{ matrix.os != 'windows-latest' }}
106+
run: sleep 500
107+
shell: bash
108+
109+
- name: Install Cypress
110+
run: |
111+
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
112+
# This will install Cypress in case the binary is missing which can happen on Windows and Mac
113+
# If the binary exists, this will exit quickly so it should not be an expensive operation
114+
npx cypress install
115+
shell: bash
116+
117+
- name: Get Cypress version
118+
id: cypress_version
119+
run: |
120+
cd OpenSearch-Dashboards/plugins/query-insights-dashboards
121+
echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
122+
123+
- name: Cache Cypress
124+
id: cache-cypress
125+
uses: actions/cache@v2
126+
with:
127+
path: ${{ matrix.cypress_cache_folder }}
128+
key: cypress-cache-v2-${{ matrix.os }}-${{ hashFiles('OpenSearch-Dashboards/plugins/query-insights-dashboards/package.json') }}
129+
130+
# for now just chrome, use matrix to do all browsers later
131+
- name: Cypress tests
132+
uses: cypress-io/github-action@v5
133+
with:
134+
working-directory: OpenSearch-Dashboards/plugins/query-insights-dashboards
135+
command: yarn run cypress run
136+
wait-on: 'http://localhost:5601'
137+
wait-on-timeout: 600
138+
browser: chrome
139+
env:
140+
CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}
141+
142+
# Screenshots are only captured on failure, will change this once we do visual regression tests
143+
- uses: actions/upload-artifact@v4
144+
if: failure()
145+
with:
146+
name: cypress-screenshots-${{ matrix.os }}
147+
path: OpenSearch-Dashboards/plugins/query-insights-dashboards/cypress/screenshots
148+
149+
# Test run video was always captured, so this action uses "always()" condition
150+
- uses: actions/upload-artifact@v4
151+
if: always()
152+
with:
153+
name: cypress-videos-${{ matrix.os }}
154+
path: OpenSearch-Dashboards/plugins/query-insights-dashboards/cypress/videos

common/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44
*/
55

66
export const TIMESTAMP = 'Timestamp';
7+
export const TYPE = 'Type';
8+
export const ID = 'Id';
9+
export const QUERY_COUNT = 'Query Count';
710
export const LATENCY = 'Latency';
811
export const CPU_TIME = 'CPU Time';
912
export const MEMORY_USAGE = 'Memory Usage';
1013
export const INDICES = 'Indices';
1114
export const SEARCH_TYPE = 'Search Type';
1215
export const NODE_ID = 'Coordinator Node ID';
1316
export const TOTAL_SHARDS = 'Total Shards';
17+
export const GROUP_BY = 'Group by';
18+
export const AVERAGE_LATENCY = 'Average Latency';
19+
export const AVERAGE_CPU_TIME = 'Average CPU Time';
20+
export const AVERAGE_MEMORY_USAGE = 'Average Memory Usage';

cypress/e2e/2_query_details.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('Top Queries Details Page', () => {
2828
// waiting for the query insights queue to drain
2929
cy.wait(10000);
3030
cy.navigateToOverview();
31-
cy.get('.euiTableRow').first().find('button').click(); // Navigate to details
31+
cy.get('.euiTableRow').first().find('button').first().click(); // Navigate to details
3232
});
3333

3434
it('should display correct details on the query details page', () => {
@@ -80,7 +80,7 @@ describe('Top Queries Details Page', () => {
8080
.parent()
8181
.next()
8282
.invoke('text')
83-
.should('match', /^\d+ ms$/);
83+
.should('match', /^\d+(\.\d{1,2})? ms$/);
8484
// Validate CPU Time
8585
cy.contains('h4', 'CPU Time')
8686
.parent()
@@ -92,7 +92,7 @@ describe('Top Queries Details Page', () => {
9292
.parent()
9393
.next()
9494
.invoke('text')
95-
.should('match', /^\d+ B$/);
95+
.should('match', /^\d+(\.\d+)? B$/);
9696
// Validate Indices
9797
cy.contains('h4', 'Indices').parent().next().invoke('text').should('not.be.empty');
9898
// Validate Search Type

cypress/e2e/3_configurations.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Query Insights Configurations Page', () => {
2929
cy.contains('button', 'Top N queries').should('be.visible');
3030
cy.contains('button', 'Configuration').should('have.class', 'euiTab-isSelected');
3131
// Validate the panels
32-
cy.get('.euiPanel').should('have.length', 2); // Two panels: configuration settings and statuses
32+
cy.get('.euiPanel').should('have.length', 4); // Two panels: configuration settings and statuses
3333
});
3434

3535
/**
@@ -125,7 +125,7 @@ describe('Query Insights Configurations Page', () => {
125125
it('should display statuses for configuration metrics', () => {
126126
// Validate the status panel header
127127
cy.get('.euiPanel')
128-
.last()
128+
.eq(1) // Selects the second panel (index 1)
129129
.within(() => {
130130
cy.get('h2').contains('Statuses for configuration metrics').should('be.visible');
131131
});

0 commit comments

Comments
 (0)