-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Migrate reporting FTRs from the Stats Usage API
#151808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import expect from '@kbn/expect'; | ||
| import { createPdfV2Params, createPngV2Params } from '..'; | ||
| import { FtrProviderContext } from '../../ftr_provider_context'; | ||
| import { UsageStatsPayloadTestFriendly } from '../../../api_integration/services/usage_api'; | ||
|
|
||
| // eslint-disable-next-line import/no-default-export | ||
| export default function ({ getService }: FtrProviderContext) { | ||
|
|
@@ -35,10 +36,11 @@ export default function ({ getService }: FtrProviderContext) { | |
| describe('server', function () { | ||
| this.tags('skipCloud'); | ||
| it('configuration settings of the tests_server', async () => { | ||
| const usage = await usageAPI.getUsageStats(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this will help resolve #134517
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried unskipping it, but it was still flaky. I can try to debug it on a follow up PR. I wouldn't like to delay this one further because it's blocking a community PR 🧡 |
||
| expect(usage.kibana_config_usage.xpack_reporting_capture_max_attempts).to.be(1); | ||
| expect(usage.kibana_config_usage.xpack_reporting_csv_max_size_bytes).to.be(6000); | ||
| expect(usage.kibana_config_usage.xpack_reporting_roles_enabled).to.be(false); | ||
| const [{ stats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
| const usage = stats.stack_stats.kibana.plugins; | ||
| expect(usage.kibana_config_usage['xpack.reporting.capture.maxAttempts']).to.be(1); | ||
| expect(usage.kibana_config_usage['xpack.reporting.csv.maxSizeBytes']).to.be(6000); | ||
| expect(usage.kibana_config_usage['xpack.reporting.roles.enabled']).to.be(false); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -52,12 +54,12 @@ export default function ({ getService }: FtrProviderContext) { | |
| DIAG_SCREENSHOT = '/api/reporting/diagnose/screenshot', | ||
| } | ||
|
|
||
| let initialStats: any; | ||
| let stats: any; | ||
| let initialStats: UsageStatsPayloadTestFriendly; | ||
| let stats: UsageStatsPayloadTestFriendly; | ||
| const CALL_COUNT = 3; | ||
|
|
||
| before('call APIs', async () => { | ||
| initialStats = await usageAPI.getUsageStats(); | ||
| [{ stats: initialStats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
|
|
||
| await Promise.all( | ||
| Object.keys(paths).map(async (key) => { | ||
|
|
@@ -73,30 +75,36 @@ export default function ({ getService }: FtrProviderContext) { | |
| await waitOnAggregation(); | ||
|
|
||
| // determine the result usage count | ||
| stats = await usageAPI.getUsageStats(); | ||
| [{ stats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
| }); | ||
|
|
||
| it('job listing', async () => { | ||
| expect(getUsageCount(initialStats, `get ${paths.LIST}`)).to.be(0); | ||
| expect(getUsageCount(stats, `get ${paths.LIST}`)).to.be(CALL_COUNT); | ||
| const initialCount = getUsageCount(initialStats, `get ${paths.LIST}`); | ||
| expect(getUsageCount(stats, `get ${paths.LIST}`)).to.be(CALL_COUNT + initialCount); | ||
| }); | ||
|
|
||
| it('job count', async () => { | ||
| expect(getUsageCount(initialStats, `get ${paths.COUNT}`)).to.be(0); | ||
| expect(getUsageCount(stats, `get ${paths.COUNT}`)).to.be(CALL_COUNT); | ||
| const initialCount = getUsageCount(initialStats, `get ${paths.COUNT}`); | ||
| expect(getUsageCount(stats, `get ${paths.COUNT}`)).to.be(CALL_COUNT + initialCount); | ||
| }); | ||
|
|
||
| it('job info', async () => { | ||
| expect( | ||
| getUsageCount(initialStats, `get /api/reporting/jobs/info/{docId}:printable_pdf`) | ||
| ).to.be(0); | ||
| const initialCount = getUsageCount( | ||
| initialStats, | ||
| `get /api/reporting/jobs/info/{docId}:printable_pdf` | ||
| ); | ||
| expect(getUsageCount(stats, `get /api/reporting/jobs/info/{docId}:printable_pdf`)).to.be( | ||
| CALL_COUNT | ||
| CALL_COUNT + initialCount | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('downloading and deleting', () => { | ||
| let initialStats: UsageStatsPayloadTestFriendly; | ||
| before('gather initial stats', async () => { | ||
| [{ stats: initialStats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
| }); | ||
|
|
||
| it('downloading', async () => { | ||
| try { | ||
| await Promise.all([ | ||
|
|
@@ -119,12 +127,14 @@ export default function ({ getService }: FtrProviderContext) { | |
| log.info(`waiting on aggregation completed.`); | ||
|
|
||
| log.info(`calling getUsageStats...`); | ||
| const [{ stats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
| const initialCount = getUsageCount( | ||
| initialStats, | ||
| `get /api/reporting/jobs/download/{docId}:printable_pdf` | ||
| ); | ||
| expect( | ||
| getUsageCount( | ||
| await usageAPI.getUsageStats(), | ||
| `get /api/reporting/jobs/download/{docId}:printable_pdf` | ||
| ) | ||
| ).to.be(3); | ||
| getUsageCount(stats, `get /api/reporting/jobs/download/{docId}:printable_pdf`) | ||
| ).to.be(3 + initialCount); | ||
| }); | ||
|
|
||
| it('deleting', async () => { | ||
|
|
@@ -145,17 +155,19 @@ export default function ({ getService }: FtrProviderContext) { | |
| log.info(`waiting on aggregation completed.`); | ||
|
|
||
| log.info(`calling getUsageStats...`); | ||
| const [{ stats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
| const initialCount = getUsageCount( | ||
| initialStats, | ||
| `delete /api/reporting/jobs/delete/{docId}:csv_searchsource` | ||
| ); | ||
| expect( | ||
| getUsageCount( | ||
| await usageAPI.getUsageStats(), | ||
| `delete /api/reporting/jobs/delete/{docId}:csv_searchsource` | ||
| ) | ||
| ).to.be(1); | ||
| getUsageCount(stats, `delete /api/reporting/jobs/delete/{docId}:csv_searchsource`) | ||
| ).to.be(1 + initialCount); | ||
| }); | ||
| }); | ||
|
|
||
| describe('API counters: job generation', () => { | ||
| let stats: any; | ||
| let stats: UsageStatsPayloadTestFriendly; | ||
|
|
||
| before(async () => { | ||
| // call generation APIs | ||
|
|
@@ -172,7 +184,7 @@ export default function ({ getService }: FtrProviderContext) { | |
|
|
||
| await waitOnAggregation(); | ||
|
|
||
| stats = await usageAPI.getUsageStats(); | ||
| [{ stats }] = await usageAPI.getTelemetryStats({ unencrypted: true }); | ||
| }); | ||
|
|
||
| it('PNG', async () => { | ||
|
|
@@ -201,10 +213,13 @@ export default function ({ getService }: FtrProviderContext) { | |
| }); | ||
| }; | ||
|
|
||
| const getUsageCount = (checkUsage: any, counterName: string): number => { | ||
| const getUsageCount = ( | ||
| checkUsage: UsageStatsPayloadTestFriendly, | ||
| counterName: string | ||
| ): number => { | ||
| return ( | ||
| checkUsage.usage_counters.daily_events.find( | ||
| (item: any) => item.counter_name === counterName | ||
| checkUsage.stack_stats.kibana.plugins.usage_counters.dailyEvents.find( | ||
| (item: any) => item.counterName === counterName | ||
| )?.total || 0 | ||
| ); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the API as it not recommended for its use to fetch usage.