use of com.microsoft.applicationinsights.serviceprofilerapi.config.ServiceProfilerConfigMonitorService in project ApplicationInsights-Java by microsoft.
the class ServiceProfilerConfigMonitorServiceTest method pullsConfig.
@Test
void pullsConfig() throws IOException, URISyntaxException {
AtomicReference<Runnable> job = new AtomicReference<>();
ScheduledExecutorService executorService = mockScheduledExecutorService(job::set);
ServiceProfilerClientV2 serviceProfilerClient = mockServiceProfilerClient();
ServiceProfilerConfigMonitorService serviceMonitor = new ServiceProfilerConfigMonitorService(executorService, 100, serviceProfilerClient);
AtomicReference<ProfilerConfiguration> config = new AtomicReference<>();
serviceMonitor.initialize(Collections.singletonList(config::set));
assertThat(job.get()).isNotNull();
job.get().run();
Mockito.verify(serviceProfilerClient, times(1)).getSettings(any(Date.class));
assertThat(config.get()).isNotNull();
assertThat(config.get().getCollectionPlan()).isEqualTo("--single --mode immediate --immediate-profiling-duration 120 --expiration 5249157885138288517 --settings-moniker a-settings-moniker");
assertThat(config.get().getCpuTriggerConfiguration()).isEqualTo("--cpu-trigger-enabled true --cpu-threshold 80 --cpu-trigger-profilingDuration 30 --cpu-trigger-cooldown 14400");
assertThat(config.get().getDefaultConfiguration()).isEqualTo("--sampling-enabled true --sampling-rate 5 --sampling-profiling-duration 120");
assertThat(config.get().getMemoryTriggerConfiguration()).isEqualTo("--memory-trigger-enabled true --memory-threshold 20 --memory-trigger-profilingDuration 120 --memory-trigger-cooldown 14400");
}
Aggregations