|
| 1 | +import { testRumRequest, testMetricsRequest } from '../../../tools/testing-server/utils/expect-tests' |
| 2 | + |
| 3 | +describe('basic pve capturing', () => { |
| 4 | + let rumCapture |
| 5 | + let metricsCapture |
| 6 | + |
| 7 | + beforeEach(async () => { |
| 8 | + [rumCapture, metricsCapture] = await browser.testHandle.createNetworkCaptures('bamServer', [ |
| 9 | + { test: testRumRequest }, |
| 10 | + { test: testMetricsRequest } |
| 11 | + ]) |
| 12 | + }) |
| 13 | + |
| 14 | + it('should report SMs when RUM call fails to browser connect service', async () => { |
| 15 | + // will reply with http status 500 to fake error response from browser connect service |
| 16 | + await browser.testHandle.scheduleReply('bamServer', { |
| 17 | + test: testRumRequest, |
| 18 | + statusCode: 500 |
| 19 | + }) |
| 20 | + |
| 21 | + // visit the webpage, not waiting for agent load since we don't expect the rum feature to load properly |
| 22 | + await browser.url(await browser.testHandle.assetURL('instrumented.html')) |
| 23 | + |
| 24 | + // wait for rum response harvest |
| 25 | + const rumHarvest = await rumCapture.waitForResult({ totalCount: 1 }) |
| 26 | + |
| 27 | + // RUM harvest should have the expected http status code from the bam server |
| 28 | + expect(rumHarvest[0].reply.statusCode).toBe(500) |
| 29 | + |
| 30 | + // wait for supportability metrics harvest |
| 31 | + const smHarvest = await metricsCapture.waitForResult({ totalCount: 1 }) |
| 32 | + |
| 33 | + // check for expected properties on status code supportability metric |
| 34 | + const smHarvestStatusCode = smHarvest[0].request.body.sm.find(sm => sm.params.name === 'Browser/Supportability/BCS/Error/StatusCode') |
| 35 | + expect(smHarvestStatusCode).toBeDefined() |
| 36 | + expect(smHarvestStatusCode.stats).toBeDefined() |
| 37 | + expect(smHarvestStatusCode.stats.c).toBe(1) |
| 38 | + expect(smHarvestStatusCode.stats.t).toBe(500) |
| 39 | + |
| 40 | + // check for expected properties on dropped bytes supportability metric |
| 41 | + const smHarvestDroppedBytes = smHarvest[0].request.body.sm.find(sm => sm.params.name === 'Browser/Supportability/BCS/Error/Dropped/Bytes') |
| 42 | + expect(smHarvestDroppedBytes).toBeDefined() |
| 43 | + expect(smHarvestDroppedBytes.stats).toBeDefined() |
| 44 | + expect(smHarvestDroppedBytes.stats.c).toBe(1) |
| 45 | + expect(smHarvestDroppedBytes.stats.t).toBeGreaterThan(0) |
| 46 | + |
| 47 | + // check for expected properties on response time supportability metric |
| 48 | + const smHarvestResponseTime = smHarvest[0].request.body.sm.find(sm => sm.params.name === 'Browser/Supportability/BCS/Error/Duration/Ms') |
| 49 | + expect(smHarvestResponseTime).toBeDefined() |
| 50 | + expect(smHarvestResponseTime.stats).toBeDefined() |
| 51 | + expect(smHarvestResponseTime.stats.c).toBe(1) |
| 52 | + expect(smHarvestResponseTime.stats.t).toBeGreaterThan(0) |
| 53 | + }) |
| 54 | +}) |
0 commit comments