Skip to content

Commit 67fd811

Browse files
authored
Query grouping dashboard changes and extensive tests (#33)
* Revert "remove records with grouping (#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 c2519b8 commit 67fd811

26 files changed

+1880
-257
lines changed

.github/workflows/cypress-tests.yml

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

common/constants.ts

+7
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

+3-3
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

+2-2
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)