Skip to content

Commit

Permalink
Add functional test for UI Metric
Browse files Browse the repository at this point in the history
Signed-off-by: Suchit Sahoo <suchsah@amazon.com>
  • Loading branch information
LDrago27 committed May 3, 2024
1 parent 79d98ca commit ce568c8
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cypress-workflow-bundle-snapshot-based.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
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'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
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'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true

tests-without-security:
uses: ./.github/workflows/release-e2e-workflow-template.yml
with:
test-name: Core Dashboards using Bundle Snapshot
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'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true
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'
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true --ml_commons_dashboards.enabled=true --usageCollection.uiMetric.enabled=true
security-enabled: false
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"WAIT_FOR_LOADER_BUFFER_MS": 0,
"DASHBOARDS_ASSISTANT_ENABLED": false,
"WORKSPACE_ENABLED": false,
"UIMETRIC_ENABLED": false,
"SAVED_OBJECTS_PERMISSION_ENABLED": false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../../../utils/commands';

const miscUtils = new MiscUtils(cy);
describe('dev_console_ui_metric', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
miscUtils.visitPage('app/dev_tools#/console');

cy.get('[data-test-subj="help-close-button"]', { timeout: 30000 }).then(
($btn) => {
if ($btn.is(':visible')) {
cy.wrap($btn).click({ force: true });
} else {
cy.get('[type="button"]').contains('Console').click({ force: true });
}
}
);

cy.intercept('POST', 'api/ui_metric/report').as('reportreq');

cy.wait(5000); // Intentional wait
});
if (Cypress.env('UIMETRIC_ENABLED')) {
it('check UI Metric are being recorded', function () {
miscUtils.visitPage('app/home#/');

cy.wait('@reportreq', { timeout: 100000 })
.its('response.statusCode')
.should('equal', 200);

// Now verify the response of api/stat

cy.request(
'GET',
`${
Cypress.config().baseUrl
}/api/stats?extended=true&legacy=true&exclude_usage=false`
).then((res) => {
expect(res.status).to.eq(200);
expect(res.body)
.to.have.property('usage')
.that.has.property('application_usage')
.that.has.property('dev_tools');
expect(res.body)
.to.have.property('usage')
.that.has.property('ui_metric')
.that.has.property('console')
.that.has.property('length')
.that.is.gt(0);
});
});
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"osd:ciGroup1": "echo \"apps/vis_builder/*.js\"",
"osd:ciGroup2": "echo \"apps/vis_type_table/*.js\"",
"osd:ciGroup3": "echo \"apps/vis-augmenter/*.js\"",
"osd:ciGroup4": "echo \"dashboard_sample_data_with_datasource_spec.js,dashboard_sanity_test_spec.js\"",
"osd:ciGroup4": "echo \"dashboard_sample_data_with_datasource_spec.js,dashboard_sanity_test_spec.js,apps/telemetry/*.js\"",
"osd:ciGroup5": "echo \"datasource-management-plugin/*.js\"",
"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\"",
"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\"",
Expand Down

0 comments on commit ce568c8

Please sign in to comment.