Skip to content

Commit a581a77

Browse files
committed
fix broken tests and add early harvest test for blobs
1 parent 4cfbb5f commit a581a77

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

tests/assets/harvest-early-block-internal.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@
88
<title>RUM Unit Test</title>
99
{init} {config}
1010
<script>
11-
NREUM.init.harvest.interval = 30
11+
NREUM.init.harvest.interval = 30;
1212
NREUM.init.ajax.block_internal = true; // Enable blocking of internal AJAX requests
1313
</script>
1414
{loader}
1515
</head>
16-
<body>Instrumented
16+
<body>
1717
<script>
18-
// make all events harvest early by setting a jsAttributes size that exceeds the ideal payload size
19-
newrelic.setCustomAttribute('foo', 'bar'.repeat(16000))
18+
// make all compatible events harvest early by setting a jsAttributes size that exceeds the ideal payload size
19+
newrelic.setCustomAttribute("foo", "bar".repeat(16000));
20+
newrelic.addPageAction("test");
21+
newrelic.log("test");
22+
document.addEventListener("click", function () {
23+
fetch("https://pokeapi.co/api/v2/pokemon/moltres");
24+
});
2025

21-
newrelic.addPageAction('test')
22-
newrelic.log('test')
23-
document.addEventListener('click', function () {
24-
fetch('https://pokeapi.co/api/v2/pokemon/moltres')
25-
})
26+
// This will create a trace node with a long name, which should be harvested early
27+
newrelic.addToTrace({ name: "foo".repeat(16000), start: Date.now() });
2628
</script>
2729
</body>
2830
</html>

tests/specs/harvesting/harvest-early.e2e.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { testAjaxEventsRequest, testInsRequest, testInteractionEventsRequest, testLogsRequest } from '../../../tools/testing-server/utils/expect-tests'
1+
import { testAjaxEventsRequest, testInsRequest, testInteractionEventsRequest, testLogsRequest, testBlobTraceRequest } from '../../../tools/testing-server/utils/expect-tests'
22

33
describe('should harvest early', () => {
44
let ajaxEventsCapture
55
let insightsCapture
66
let interactionEventsCapture
77
let loggingEventsCapture
8+
let testBlobTraceCapture
89

910
beforeEach(async () => {
10-
[ajaxEventsCapture, insightsCapture, interactionEventsCapture, loggingEventsCapture] = await browser.testHandle.createNetworkCaptures('bamServer', [
11+
;[ajaxEventsCapture, insightsCapture, interactionEventsCapture, loggingEventsCapture, testBlobTraceCapture] = await browser.testHandle.createNetworkCaptures('bamServer', [
1112
{ test: testAjaxEventsRequest },
1213
{ test: testInsRequest },
1314
{ test: testInteractionEventsRequest },
14-
{ test: testLogsRequest }
15+
{ test: testLogsRequest },
16+
{ test: testBlobTraceRequest }
1517
])
1618
})
1719

@@ -24,6 +26,7 @@ describe('should harvest early', () => {
2426
insightsCapture.waitForResult({ totalCount: 1 }),
2527
interactionEventsCapture.waitForResult({ totalCount: 1 }),
2628
loggingEventsCapture.waitForResult({ totalCount: 1 }),
29+
testBlobTraceCapture.waitForResult({ totalCount: 2 }), // the initial trace ALWAYS harvests immediately, but the second one should be tested for early harvest
2730
browser.execute(function () {
2831
document.querySelector('body').click()
2932
})

tests/specs/session-trace/trace-nodes.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('Trace nodes', () => {
2626
const [sessionTraceHarvests] = await Promise.all([
2727
sessionTraceCapture.waitForResult({ timeout: 10000 }),
2828
browser.execute(function () {
29-
const storedEvents = Object.values(newrelic.initializedAgents)[0].features.session_trace.featAggregate.events.prevStoredEvents
29+
const storedEvents = Object.values(newrelic.initializedAgents)[0].features.session_trace.featAggregate.traceStorage.prevStoredEvents
3030
for (let i = 0; i < 10; i++) storedEvents.add(i) // artificially add "events" since the counter is otherwise unreliable
3131
}).then(() =>
3232
$('#btn1').click() // since the agent has multiple listeners on vischange, this is a good example of often duplicated event

0 commit comments

Comments
 (0)