-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Suchit Sahoo <suchsah@amazon.com>
- Loading branch information
Showing
6 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cypress/fixtures/dashboard/opensearch_dashboards/telemetry/uiReport.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"report":{"reportVersion":1,"uiStatsMetrics":{"console-count-GET_cat.indices":{"key":"console-count-GET_cat.indices","appName":"console","eventName":"GET_cat.indices","type":"count","stats":{"min":0,"max":1,"avg":0.5,"sum":21}}}}} |
103 changes: 103 additions & 0 deletions
103
...ntegration/core-opensearch-dashboards/opensearch-dashboards/apps/telemetry/server.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CURRENT_TENANT } from '../../../../../utils/commands'; | ||
import report from '../../../../../fixtures/dashboard/opensearch_dashboards/telemetry/uiReport.json'; | ||
|
||
describe('server', () => { | ||
before(() => { | ||
CURRENT_TENANT.newTenant = 'global'; | ||
}); | ||
|
||
if (Cypress.env('UIMETRIC_ENABLED')) { | ||
it('test server side batching', function () { | ||
// verify we don't have any entries for ui metric | ||
cy.request( | ||
'GET', | ||
`${ | ||
Cypress.config().baseUrl | ||
}/api/stats?extended=true&legacy=true&exclude_usage=false` | ||
).then((res) => { | ||
expect(res.status).to.eq(200); | ||
const usage = res.body.usage; | ||
expect(usage.ui_metric).to.deep.equal({}); | ||
}); | ||
|
||
// Send the first UI metric report | ||
cy.request({ | ||
method: 'POST', | ||
url: `${Cypress.config().baseUrl}/api/ui_metric/report`, | ||
headers: { | ||
'Osd-Xsrf': 'osd-fetch', | ||
}, | ||
body: report, | ||
}).then((res) => { | ||
expect(res.status).to.eq(200); | ||
}); | ||
|
||
// Verify that the above report has been written | ||
cy.request( | ||
'GET', | ||
`${ | ||
Cypress.config().baseUrl | ||
}/api/stats?extended=true&legacy=true&exclude_usage=false` | ||
).then((res) => { | ||
expect(res.status).to.eq(200); | ||
const usage = res.body.usage; | ||
expect(usage.ui_metric.console[0].value).to.equal(21); | ||
}); | ||
|
||
// Send the second UI metric report | ||
cy.request({ | ||
method: 'POST', | ||
url: `${Cypress.config().baseUrl}/api/ui_metric/report`, | ||
headers: { | ||
'Osd-Xsrf': 'osd-fetch', | ||
}, | ||
body: report, | ||
}).then((res) => { | ||
expect(res.status).to.eq(200); | ||
}); | ||
|
||
// Verify that the above report has not been written and count is same as before | ||
cy.request( | ||
'GET', | ||
`${ | ||
Cypress.config().baseUrl | ||
}/api/stats?extended=true&legacy=true&exclude_usage=false` | ||
).then((res) => { | ||
expect(res.status).to.eq(200); | ||
const usage = res.body.usage; | ||
expect(usage.ui_metric.console[0].value).to.equal(21); | ||
}); | ||
|
||
cy.wait(60000); // Intentional wait to exceed batvhing interval | ||
|
||
// Send the third UI metric report, since the time interval is greater than batching interval it will write this and previous report | ||
cy.request({ | ||
method: 'POST', | ||
url: `${Cypress.config().baseUrl}/api/ui_metric/report`, | ||
headers: { | ||
'Osd-Xsrf': 'osd-fetch', | ||
}, | ||
body: report, | ||
}).then((res) => { | ||
expect(res.status).to.eq(200); | ||
}); | ||
|
||
// Verify all the 3 Ui metric report have been written | ||
cy.request( | ||
'GET', | ||
`${ | ||
Cypress.config().baseUrl | ||
}/api/stats?extended=true&legacy=true&exclude_usage=false` | ||
).then((res) => { | ||
expect(res.status).to.eq(200); | ||
const usage = res.body.usage; | ||
expect(usage.ui_metric.console[0].value).to.equal(63); | ||
}); | ||
}); | ||
} | ||
}); |
59 changes: 59 additions & 0 deletions
59
...gration/core-opensearch-dashboards/opensearch-dashboards/apps/telemetry/ui_metric.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters