Skip to content

Commit 5575576

Browse files
committed
Add functional test for UI Metric
Signed-off-by: Suchit Sahoo <suchsah@amazon.com>
1 parent 6e3cc01 commit 5575576

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

.github/workflows/cypress-workflow-bundle-snapshot-based.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ jobs:
2525
uses: ./.github/workflows/release-e2e-workflow-template.yml
2626
with:
2727
test-name: Core Dashboards using Bundle Snapshot
28-
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
29-
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
28+
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_UIMETRIC_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
29+
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true
3030

3131
tests-without-security:
3232
needs: changes
3333
if: ${{ needs.changes.outputs.tests == 'true' }}
3434
uses: ./.github/workflows/release-e2e-workflow-template.yml
3535
with:
3636
test-name: Core Dashboards using Bundle Snapshot
37-
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
38-
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
37+
test-command: env CYPRESS_NO_COMMAND_LOG=1 CYPRESS_ML_COMMONS_DASHBOARDS_ENABLED=true CYPRESS_VISBUILDER_ENABLED=true CYPRESS_UIMETRIC_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
38+
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true
3939
security-enabled: false

cypress.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"ML_COMMONS_DASHBOARDS_ENABLED": true,
2323
"WAIT_FOR_LOADER_BUFFER_MS": 0,
2424
"DASHBOARDS_ASSISTANT_ENABLED": false,
25-
"WORKSPACE_ENABLED": false
25+
"WORKSPACE_ENABLED": false,
26+
"UIMETRIC_ENABLED": false
2627
}
2728
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
7+
import { CURRENT_TENANT } from '../../../../../utils/commands';
8+
9+
const miscUtils = new MiscUtils(cy);
10+
describe('dev_console_ui_metric', () => {
11+
before(() => {
12+
CURRENT_TENANT.newTenant = 'global';
13+
miscUtils.visitPage('app/dev_tools#/console');
14+
15+
cy.get('[data-test-subj="help-close-button"]', { timeout: 30000 }).then(
16+
($btn) => {
17+
if ($btn.is(':visible')) {
18+
cy.wrap($btn).click({ force: true });
19+
} else {
20+
cy.get('[type="button"]').contains('Console').click({ force: true });
21+
}
22+
}
23+
);
24+
25+
cy.intercept('POST', 'api/ui_metric/report').as('reportreq');
26+
27+
cy.wait(5000); // Intentional wait
28+
});
29+
if (Cypress.env('UIMETRIC_ENABLED')) {
30+
it('check UI Metric are being recorded', function () {
31+
miscUtils.visitPage('app/home#/');
32+
33+
cy.wait('@reportreq', { timeout: 100000 })
34+
.its('response.statusCode')
35+
.should('equal', 200);
36+
37+
// Now verify the response of api/stat
38+
39+
cy.request(
40+
'GET',
41+
`${
42+
Cypress.config().baseUrl
43+
}/api/stats?extended=true&legacy=true&exclude_usage=false`
44+
).then((res) => {
45+
expect(res.status).to.eq(200);
46+
expect(res.body)
47+
.to.have.property('usage')
48+
.that.has.property('application_usage')
49+
.that.has.property('dev_tools');
50+
expect(res.body)
51+
.to.have.property('usage')
52+
.that.has.property('ui_metric')
53+
.that.has.property('console')
54+
.that.has.property('length')
55+
.that.is.gt(0);
56+
});
57+
});
58+
}
59+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"osd:ciGroup1": "echo \"apps/vis_builder/*.js\"",
2929
"osd:ciGroup2": "echo \"apps/vis_type_table/*.js\"",
3030
"osd:ciGroup3": "echo \"apps/vis-augmenter/*.js\"",
31-
"osd:ciGroup4": "echo \"dashboard_sample_data_with_datasource_spec.js,dashboard_sanity_test_spec.js\"",
31+
"osd:ciGroup4": "echo \"dashboard_sample_data_with_datasource_spec.js,dashboard_sanity_test_spec.js,apps/telemetry/*.js\"",
3232
"osd:ciGroup5": "echo \"datasource-management-plugin/*.js\"",
3333
"osd:ciGroup6": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/data_source_selector.spec.js,apps/data_explorer/date_nanos_mixed.spec.js,apps/data_explorer/date_nanos.spec.js,apps/data_explorer/discover_histogram.spec.js,apps/data_explorer/discover.spec.js,apps/data_explorer/zzz_after.spec.js\"",
3434
"osd:ciGroup7": "echo \"apps/data_explorer/aaa_before.spec.js,apps/data_explorer/doc_navigation.spec.js,apps/data_explorer/doc_table.spec.js,apps/data_explorer/errors.spec.js,apps/data_explorer/field_data.spec.js,apps/data_explorer/zzz_after.spec.js\"",

0 commit comments

Comments
 (0)