@@ -331,7 +331,7 @@ public void stopCollectingGauges_invalidGaugeCollectionFrequency_appInForeground
331
331
}
332
332
333
333
@ Test
334
- public void testGaugeCounterStartsAJobToConsumeTheGeneratedMetrics () {
334
+ public void testGaugeCounterStartsAJobToConsumeTheGeneratedMetrics () throws InterruptedException {
335
335
PerfSession fakeSession = createTestSession (1 );
336
336
testGaugeManager .setApplicationProcessState (ApplicationProcessState .FOREGROUND );
337
337
testGaugeManager .startCollectingGauges (fakeSession );
@@ -504,23 +504,17 @@ public void testStopCollectingGaugesCreatesOneLastJobToConsumeAnyPendingMetrics(
504
504
testGaugeManager .stopCollectingGauges ();
505
505
assertThat (fakeScheduledExecutorService .isEmpty ()).isFalse ();
506
506
507
- CpuMetricReading fakeCpuMetricReading = createFakeCpuMetricReading (200 , 100 );
508
- fakeCpuGaugeCollector .cpuMetricReadings .add (fakeCpuMetricReading );
509
-
510
- AndroidMemoryReading fakeMemoryMetricReading =
511
- createFakeAndroidMetricReading (/* currentUsedAppJavaHeapMemoryKb= */ 23454678 );
512
- fakeMemoryGaugeCollector .memoryMetricReadings .add (fakeMemoryMetricReading );
507
+ generateMetricsAndIncrementCounter (2 );
513
508
514
509
assertThat (fakeScheduledExecutorService .getDelayToNextTask (TimeUnit .MILLISECONDS ))
515
510
.isEqualTo (TIME_TO_WAIT_BEFORE_FLUSHING_GAUGES_QUEUE_MS );
516
511
517
512
fakeScheduledExecutorService .simulateSleepExecutingAtMostOneTask ();
518
513
GaugeMetric recordedGaugeMetric =
519
514
getLastRecordedGaugeMetric (ApplicationProcessState .FOREGROUND );
520
- assertThatCpuGaugeMetricWasSentToTransport (
521
- testSessionId (1 ), recordedGaugeMetric , fakeCpuMetricReading );
522
- assertThatMemoryGaugeMetricWasSentToTransport (
523
- testSessionId (1 ), recordedGaugeMetric , fakeMemoryMetricReading );
515
+ assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (testSessionId (1 ));
516
+
517
+ assertThat (GaugeCounter .INSTANCE .count ()).isEqualTo (0 );
524
518
}
525
519
526
520
@ Test
@@ -587,6 +581,7 @@ public void testLogGaugeMetadataLogsAfterApplicationContextIsSet() {
587
581
GaugeMetadata recordedGaugeMetadata = recordedGaugeMetric .getGaugeMetadata ();
588
582
589
583
assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (testSessionId (1 ));
584
+ assertThat (recordedGaugeMetadata ).isNotEqualTo (GaugeMetadata .getDefaultInstance ());
590
585
}
591
586
592
587
@ Test
@@ -655,20 +650,4 @@ private GaugeMetric getLastRecordedGaugeMetric(
655
650
when (mockTransportManager .isInitialized ()).thenReturn (true );
656
651
return argMetric .getValue ();
657
652
}
658
-
659
- private void assertThatCpuGaugeMetricWasSentToTransport (
660
- String sessionId , GaugeMetric recordedGaugeMetric , CpuMetricReading ... cpuMetricReadings ) {
661
- assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (sessionId );
662
- assertThat (recordedGaugeMetric .getCpuMetricReadingsList ())
663
- .containsAtLeastElementsIn (cpuMetricReadings );
664
- }
665
-
666
- private void assertThatMemoryGaugeMetricWasSentToTransport (
667
- String sessionId ,
668
- GaugeMetric recordedGaugeMetric ,
669
- AndroidMemoryReading ... androidMetricReadings ) {
670
- assertThat (recordedGaugeMetric .getSessionId ()).isEqualTo (sessionId );
671
- assertThat (recordedGaugeMetric .getAndroidMemoryReadingsList ())
672
- .containsAtLeastElementsIn (androidMetricReadings );
673
- }
674
653
}
0 commit comments