Java Code Examples for org.springframework.boot.actuate.health.Health#getDetails()

The following examples show how to use org.springframework.boot.actuate.health.Health#getDetails() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeodeCacheServerHealthIndicatorAutoConfigurationIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Test
public void mockCacheServerHealthCheckWithServerLoadDetails() {

	Health health = this.healthIndicator.health();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.cache.server.count", 1);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.port", 48484);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.load.connection-load", 0.65f);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.load.load-per-connection", 0.35f);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.load.load-per-subscription-connection", 0.75f);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.load.subscription-connection-load", 0.55f);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.metrics.client-count", 21);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.metrics.max-connection-count", 800);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.metrics.open-connection-count", 400);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.metrics.subscription-connection-count", 200);
}
 
Example 2
Source File: GeodeGatewayReceiversHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	GatewayReceiver mockGatewayReceiverOne = GatewayMockObjects.mockGatewayReceiver("10.101.112.1",
		8192, "CardboardBox", "Mailbox", false, 15000,
		4096, true, null, 16384, 1024);

	GatewayReceiver mockGatewayReceiverTwo = GatewayMockObjects.mockGatewayReceiver("10.101.112.4",
		8192, "Skullbox", "PostOfficeBox", true, 5000,
		8192, false, null, 65536, 1024);

	Set<GatewayReceiver> mockGatewayReceivers =
		new TreeSet<>(Comparator.comparing(GatewayReceiver::getBindAddress));

	mockGatewayReceivers.addAll(asSet(mockGatewayReceiverOne, mockGatewayReceiverTwo));

	when(this.mockCache.getGatewayReceivers()).thenReturn(mockGatewayReceivers);

	Health.Builder builder = new Health.Builder();

	this.gatewayReceiversHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.count", mockGatewayReceivers.size());
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.bind-address", "10.101.112.1");
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.end-port", 8192);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.host", "CardboardBox");
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.max-time-between-pings", 15000);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.port", 4096);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.running", "Yes");
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.socket-buffer-size", 16384);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.0.start-port", 1024);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.bind-address", "10.101.112.4");
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.end-port", 8192);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.host", "Skullbox");
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.max-time-between-pings",5000);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.port", 8192);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.running", "No");
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.socket-buffer-size", 65536);
	assertThat(healthDetails).containsEntry("geode.gateway-receiver.1.start-port", 1024);

	verify(this.mockCache, times(1)).getGatewayReceivers();
}
 
Example 3
Source File: GeodeCacheServersHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	List<CacheServer> mockCacheServers = new ArrayList<>();

	ServerLoadProbe mockServerLoadProbe = mock(ServerLoadProbe.class);

	mockCacheServers.add(CacheServerMockObjects.mockCacheServer("10.11.111.1", null,
		"Mailbox", 15000L, mockServerLoadProbe, 100, 500,
		8, 20000, 30000, 41414, true, 16384,
		true));

	mockCacheServers.add(CacheServerMockObjects.mockCacheServer("10.12.120.2", null,
		"Skullbox", 10000L, mockServerLoadProbe, 250, 50,
		16, 5000, 15000, 42424, false, 8192,
		false));

	when(this.mockCache.getCacheServers()).thenReturn(mockCacheServers);

	Health.Builder builder = new Health.Builder();

	this.cacheServersHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.cache.server.count", 2);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.bind-address", "10.11.111.1");
	assertThat(healthDetails).containsEntry("geode.cache.server.0.hostname-for-clients", "Mailbox");
	assertThat(healthDetails).containsEntry("geode.cache.server.0.load-poll-interval", 15000L);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.max-connections", 100);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.max-message-count", 500);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.max-threads", 8);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.max-time-between-pings", 20000);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.message-time-to-live", 30000);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.port", 41414);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.running", "Yes");
	assertThat(healthDetails).containsEntry("geode.cache.server.0.socket-buffer-size", 16384);
	assertThat(healthDetails).containsEntry("geode.cache.server.0.tcp-no-delay", "Yes");
	assertThat(healthDetails).doesNotContainKeys("geode.cache.server.0.client-subscription-config",
		"geode.cache.server.0.metrics.client-count", "geode.cache.server.0.load.connection-load");
	assertThat(healthDetails).containsEntry("geode.cache.server.1.bind-address", "10.12.120.2");
	assertThat(healthDetails).containsEntry("geode.cache.server.1.hostname-for-clients", "Skullbox");
	assertThat(healthDetails).containsEntry("geode.cache.server.1.load-poll-interval", 10000L);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.max-connections", 250);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.max-message-count", 50);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.max-threads", 16);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.max-time-between-pings", 5000);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.message-time-to-live", 15000);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.port", 42424);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.running", "No");
	assertThat(healthDetails).containsEntry("geode.cache.server.1.socket-buffer-size", 8192);
	assertThat(healthDetails).containsEntry("geode.cache.server.1.tcp-no-delay", "No");
	assertThat(healthDetails).doesNotContainKeys("geode.cache.server.1.client-subscription-config",
		"geode.cache.server.1.metrics.client-count", "geode.cache.server.1.load.connection-load");

	verify(this.mockCache, times(1)).getCacheServers();
}
 
Example 4
Source File: GeodeCacheHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	DistributedMember mockDistributedMember =
		CacheMockObjects.mockDistributedMember("TestMember", "TestGroup", "MockGroup");

	when(mockDistributedMember.getHost()).thenReturn("Skullbox");
	when(mockDistributedMember.getProcessId()).thenReturn(12345);

	DistributedSystem mockDistributedSystem = CacheMockObjects.mockDistributedSystem(mockDistributedMember);

	when(mockDistributedSystem.getAllOtherMembers()).thenAnswer(invocation -> mockDistributedMembers(8));
	when(mockDistributedSystem.isConnected()).thenReturn(true);
	when(mockDistributedSystem.isReconnecting()).thenReturn(false);

	ResourceManager mockResourceManager = CacheMockObjects.mockResourceManager(0.9f,
		0.95f, 0.85f, 0.9f);

	GemFireCache mockGemFireCache = CacheMockObjects.mockGemFireCache(this.mockGemFireCache,
		"MockGemFireCache", mockDistributedSystem, mockResourceManager);

	CancelCriterion mockCancelCriterion = mock(CancelCriterion.class);

	when(mockCancelCriterion.isCancelInProgress()).thenReturn(false);
	when(mockGemFireCache.getCancelCriterion()).thenReturn(mockCancelCriterion);
	when(mockGemFireCache.isClosed()).thenReturn(false);

	Health.Builder builder = new Health.Builder();

	this.cacheHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.cache.name", "MockGemFireCache");
	assertThat(healthDetails).containsEntry("geode.cache.closed", "No");
	assertThat(healthDetails).containsEntry("geode.cache.cancel-in-progress", "No");
	assertThat(healthDetails).containsKey("geode.distributed-member.id");
	assertThat(String.valueOf(healthDetails.get("geode.distributed-member.id"))).isNotEqualToIgnoringCase("null");
	assertThat(healthDetails).containsEntry("geode.distributed-member.name", "TestMember");
	assertThat(healthDetails).containsEntry("geode.distributed-member.groups", Arrays.asList("TestGroup", "MockGroup"));
	assertThat(healthDetails).containsEntry("geode.distributed-member.host", "Skullbox");
	assertThat(healthDetails).containsEntry("geode.distributed-member.process-id", 12345);
	assertThat(healthDetails).containsEntry("geode.distributed-system.member-count", 9);
	assertThat(healthDetails).containsEntry("geode.distributed-system.connection", "Connected");
	assertThat(healthDetails).containsEntry("geode.distributed-system.reconnecting", "No");
	//assertThat(healthDetails).containsKey("geode.distributed-member.properties-location");
	//assertThat(healthDetails).containsKey("geode.distributed-member.security-properties-location");
	assertThat(healthDetails).containsEntry("geode.resource-manager.critical-heap-percentage", 0.9f);
	assertThat(healthDetails).containsEntry("geode.resource-manager.critical-off-heap-percentage", 0.95f);
	assertThat(healthDetails).containsEntry("geode.resource-manager.eviction-heap-percentage", 0.85f);
	assertThat(healthDetails).containsEntry("geode.resource-manager.eviction-off-heap-percentage", 0.9f);

	verify(this.mockGemFireCache, times(1)).getCancelCriterion();
	verify(this.mockGemFireCache, times(2)).getDistributedSystem();
	verify(this.mockGemFireCache, times(1)).getResourceManager();
	verify(mockDistributedSystem, times(1)).getDistributedMember();
}
 
Example 5
Source File: GeodeGatewaySendersHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	GatewaySender mockGatewaySenderOne = GatewayMockObjects.mockGatewaySender("MockGatewaySenderOne",
		100, true, 250, 30000, "TestDiskStore",
		true, 8, 16384, 24,
		GatewaySender.OrderPolicy.THREAD, true, true, 123,
		true, 32768, 15000);

	GatewaySender mockGatewaySenderTwo = GatewayMockObjects.mockGatewaySender("MockGatewaySenderTwo",
		99, false, 500, 20000, null,
		false, 16, 8192, 32,
		GatewaySender.OrderPolicy.KEY, false, false, 789,
		false, 65536, 20000);

	Set<GatewaySender> mockGatewaySenders =
		new TreeSet<>(Comparator.comparing(GatewaySender::getId));

	mockGatewaySenders.addAll(asSet(mockGatewaySenderOne, mockGatewaySenderTwo));

	when(this.mockCache.getGatewaySenders()).thenReturn(mockGatewaySenders);

	Health.Builder builder = new Health.Builder();

	this.gatewaySendersHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.gateway-sender.count", mockGatewaySenders.size());
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.alert-threshold", 100);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.batch-conflation-enabled", "Yes");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.batch-size", 250);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.batch-time-interval", 30000);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.disk-store-name", "TestDiskStore");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.disk-synchronous", "Yes");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.dispatcher-threads", 8);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.max-queue-memory", 16384);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.max-parallelism-for-replicated-region", 24);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.order-policy", GatewaySender.OrderPolicy.THREAD);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.parallel", "Yes");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.persistent", "Yes");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.remote-distributed-system-id", 123);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.running", "Yes");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.socket-buffer-size", 32768);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderOne.socket-read-timeout", 15000);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.alert-threshold", 99);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.batch-conflation-enabled", "No");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.batch-size", 500);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.batch-time-interval", 20000);
	assertThat(healthDetails).containsKey("geode.gateway-sender.MockGatewaySenderTwo.disk-store-name");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.disk-synchronous", "No");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.dispatcher-threads", 16);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.max-queue-memory", 8192);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.max-parallelism-for-replicated-region", 32);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.order-policy", GatewaySender.OrderPolicy.KEY);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.parallel", "No");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.persistent", "No");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.remote-distributed-system-id", 789);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.running", "No");
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.socket-buffer-size", 65536);
	assertThat(healthDetails).containsEntry("geode.gateway-sender.MockGatewaySenderTwo.socket-read-timeout", 20000);

	verify(this.mockCache, times(1)).getGatewaySenders();
}
 
Example 6
Source File: GeodeAsyncEventQueuesHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	Set<AsyncEventQueue> mockAsyncEventQueues = new HashSet<>();

	mockAsyncEventQueues.add(AsyncEventQueueMockObjects.mockAsyncEventQueue("aeqOne", true,
		250, 10000, "testDiskStoreOne", true, 16,
		true, 65536, GatewaySender.OrderPolicy.THREAD, true,
		true, true, 1024));

	mockAsyncEventQueues.add(AsyncEventQueueMockObjects.mockAsyncEventQueue("aeqTwo", false,
		100, 1000, "testDiskStoreTwo", false, 8,
		false, 32768, GatewaySender.OrderPolicy.KEY, false,
		true, false, 8192));

	when(this.mockCache.getAsyncEventQueues()).thenReturn(mockAsyncEventQueues);

	Health.Builder builder = new Health.Builder();

	this.asyncEventQueuesHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.async-event-queue.count", mockAsyncEventQueues.size());
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.batch-conflation-enabled", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.batch-size", 250);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.batch-time-interval", 10000);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.disk-store-name", "testDiskStoreOne");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.disk-synchronous", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.dispatcher-threads", 16);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.forward-expiration-destroy", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.max-queue-memory", 65536);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.order-policy", GatewaySender.OrderPolicy.THREAD);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.parallel", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.persistent", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.primary", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.size", 1024);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.batch-conflation-enabled", "No");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.batch-size", 100);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.batch-time-interval", 1000);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.disk-store-name", "testDiskStoreTwo");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.disk-synchronous", "No");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.dispatcher-threads", 8);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.forward-expiration-destroy", "No");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.max-queue-memory", 32768);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.order-policy", GatewaySender.OrderPolicy.KEY);
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.parallel", "No");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.persistent", "Yes");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.primary", "No");
	assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.size", 8192);

	verify(this.mockCache, times(1)).getAsyncEventQueues();
}
 
Example 7
Source File: GeodeContinuousQueriesHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	CqQuery mockContinuousQuery = mock(CqQuery.class, "MockContinuousQuery");

	when(mockContinuousQuery.getName()).thenReturn("MockContinuousQuery");
	when(mockContinuousQuery.getQueryString()).thenReturn("SELECT * FROM /Example WHERE status = 'RUNNING'");
	when(mockContinuousQuery.isClosed()).thenReturn(false);
	when(mockContinuousQuery.isDurable()).thenReturn(true);
	when(mockContinuousQuery.isRunning()).thenReturn(true);
	when(mockContinuousQuery.isStopped()).thenReturn(false);

	CqState mockContinuousQueryState = mock(CqState.class);

	when(mockContinuousQueryState.isClosing()).thenReturn(false);
	when(mockContinuousQuery.getState()).thenReturn(mockContinuousQueryState);

	CqStatistics mockContinuousQueryStatistics = mock(CqStatistics.class);

	when(mockContinuousQueryStatistics.numDeletes()).thenReturn(1024L);
	when(mockContinuousQueryStatistics.numEvents()).thenReturn(4096000L);
	when(mockContinuousQueryStatistics.numInserts()).thenReturn(8192L);
	when(mockContinuousQueryStatistics.numUpdates()).thenReturn(1638400L);
	when(mockContinuousQuery.getStatistics()).thenReturn(mockContinuousQueryStatistics);

	Query mockQuery = mock(Query.class);

	QueryStatistics mockQueryStatistics = mock(QueryStatistics.class);

	when(mockQueryStatistics.getNumExecutions()).thenReturn(1024L);
	when(mockQueryStatistics.getTotalExecutionTime()).thenReturn(123456789L);
	when(mockQuery.getStatistics()).thenReturn(mockQueryStatistics);
	when(mockContinuousQuery.getQuery()).thenReturn(mockQuery);

	CqQuery[] mockContinuousQueries = { mockContinuousQuery };

	when(this.mockQueryService.getCqs()).thenReturn(mockContinuousQueries);

	CqServiceStatistics mockContinuousQueryServiceStatistics = mock(CqServiceStatistics.class);

	when(mockContinuousQueryServiceStatistics.numCqsActive()).thenReturn(42L);
	when(mockContinuousQueryServiceStatistics.numCqsClosed()).thenReturn(8L);
	when(mockContinuousQueryServiceStatistics.numCqsCreated()).thenReturn(51L);
	when(mockContinuousQueryServiceStatistics.numCqsStopped()).thenReturn(16L);
	when(mockContinuousQueryServiceStatistics.numCqsOnClient()).thenReturn(64L);
	when(this.mockQueryService.getCqStatistics()).thenReturn(mockContinuousQueryServiceStatistics);

	Health.Builder builder = new Health.Builder();

	this.continuousQueriesHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.continuous-query.count", mockContinuousQueries.length);
	assertThat(healthDetails).containsEntry("geode.continuous-query.number-of-active", 42L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.number-of-closed", 8L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.number-of-created", 51L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.number-of-stopped", 16L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.number-on-client", 64L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.oql-query-string", "SELECT * FROM /Example WHERE status = 'RUNNING'");
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.closed", "No");
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.closing", "No");
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.durable", "Yes");
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.running", "Yes");
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.stopped", "No");
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.query.number-of-executions", 1024L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.query.total-execution-time", 123456789L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.statistics.number-of-deletes", 1024L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.statistics.number-of-events", 4096000L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.statistics.number-of-inserts", 8192L);
	assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.statistics.number-of-updates", 1638400L);

	verify(this.mockQueryService, times(1)).getCqs();
}
 
Example 8
Source File: GeodeIndexesHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	Region mockRegion = CacheMockObjects.mockRegion("MockRegion", DataPolicy.PARTITION);

	IndexStatistics mockIndexStatistics = IndexMockObjects.mockIndexStatistics(226,
		100000, 6000, 1024000L, 51515L,
		512, 2048L, 4096L);

	Index mockIndex = IndexMockObjects.mockIndex("MockIndex", "/Example",
		"id", "one, two", mockRegion, mockIndexStatistics,
		IndexType.PRIMARY_KEY.getGemfireIndexType());

	Map<String, Index> mockIndexes = Collections.singletonMap("MockIndex", mockIndex);

	when(this.applicationContext.getBeansOfType(eq(Index.class))).thenReturn(mockIndexes);

	Health.Builder builder = new Health.Builder();

	this.indexesHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.index.count", mockIndexes.size());
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.from-clause", "/Example");
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.indexed-expression", "id");
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.projection-attributes", "one, two");
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.region", "/MockRegion");
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.type",
		IndexType.PRIMARY_KEY.getGemfireIndexType().toString());
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.number-of-bucket-indexes", 226);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.number-of-keys", 100000L);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.number-of-map-index-keys", 6000L);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.number-of-values", 1024000L);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.number-of-updates", 51515L);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.read-lock-count", 512);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.total-update-time", 2048L);
	assertThat(healthDetails).containsEntry("geode.index.MockIndex.statistics.total-uses", 4096L);

	verify(this.applicationContext, times(1)).getBeansOfType(eq(Index.class));
}
 
Example 9
Source File: GeodePoolsHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() {

	List<InetSocketAddress> mockLocators =
		Arrays.asList(testSocketAddress("mailbox", 1234),
			testSocketAddress("skullbox", 6789));

	Pool mockPool = PoolMockObjects.mockPool("MockPool", false, 5000,
		60000L, 1000, mockLocators, 500, 50,
		true, mockLocators.subList(0, 1), 75, 15000L,
		true, null, 10000, 2, "TestGroup",
		Collections.emptyList(), 65536, 30000, 5000,
		10000, true, 5000,
		2, 8, false);

	when(this.poolsHealthIndicator.findAllPools()).thenReturn(Collections.singletonMap("MockPool", mockPool));

	Health.Builder builder = new Health.Builder();

	this.poolsHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.pool.count", 1);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.destroyed", "No");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.free-connection-timeout", 5000);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.idle-timeout", 60000L);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.load-conditioning-interval", 1000);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.locators", "mailbox:1234,skullbox:6789");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.max-connections", 500);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.min-connections", 50);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.multi-user-authentication", "Yes");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.online-locators", "mailbox:1234");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.pending-event-count", 75);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.ping-interval", 15000L);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.pr-single-hop-enabled", "Yes");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.read-timeout", 10000);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.retry-attempts", 2);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.server-group", "TestGroup");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.servers", "");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.socket-buffer-size", 65536);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.statistic-interval", 5000);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-ack-interval", 10000);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-enabled", "Yes");
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-message-tracking-timeout", 5000);
	assertThat(healthDetails).containsEntry("geode.pool.MockPool.subscription-redundancy", 2);
	//assertThat(healthDetails).containsEntry("geode.pool.MockPool.thread-local-connections", "No");

	verify(this.poolsHealthIndicator, times(1)).findAllPools();
}
 
Example 10
Source File: GeodeDiskStoresHealthIndicatorUnitTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Test
public void healthCheckCapturesDetails() throws Exception {

	File mockDirectoryOne = mock(File.class);
	File mockDirectoryTwo = mock(File.class);

	when(mockDirectoryOne.getAbsolutePath()).thenReturn("/ext/gemfire/disk/stores/one");
	when(mockDirectoryTwo.getAbsolutePath()).thenReturn("/ext/gemfire/disk/stores/two");

	int[] diskDirectorySizes = { 1024, 8192 };

	Map<String, DiskStore> mockDiskStores = new HashMap<>();

	mockDiskStores.put("MockDiskStoreOne", DiskStoreMockObjects.mockDiskStore("MockDiskStoreOne",
		true, true, 90,
		ArrayUtils.asArray(mockDirectoryOne, mockDirectoryTwo), diskDirectorySizes, 0.95f,
		0.90f, 1024000L, 16384, 5000L, 32768));

	mockDiskStores.put("MockDiskStoreTwo", DiskStoreMockObjects.mockDiskStore("MockDiskStoreTwo",
		false, true, 50,null, null,
		0.90f,0.80f, 2048000L, 4096,
		15000L, 8192));

	when(this.mockApplicationContext.getBeansOfType(DiskStore.class)).thenReturn(mockDiskStores);

	Health.Builder builder = new Health.Builder();

	this.diskStoresHealthIndicator.doHealthCheck(builder);

	Health health = builder.build();

	assertThat(health).isNotNull();
	assertThat(health.getStatus()).isEqualTo(Status.UP);

	Map<String, Object> healthDetails = health.getDetails();

	assertThat(healthDetails).isNotNull();
	assertThat(healthDetails).isNotEmpty();
	assertThat(healthDetails).containsEntry("geode.disk-store.count", mockDiskStores.size());
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.allow-force-compaction", "Yes");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.auto-compact", "Yes");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.compaction-threshold", 90);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.disk-directories", "[/ext/gemfire/disk/stores/one, /ext/gemfire/disk/stores/two]");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.disk-directory-sizes", "[1024, 8192]");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.disk-usage-critical-percentage", 0.95f);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.disk-usage-warning-percentage", 0.90f);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.max-oplog-size", 1024000L);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.queue-size", 16384);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.time-interval", 5000L);
	assertThat(healthDetails).containsKey("geode.disk-store.MockDiskStoreOne.uuid");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.write-buffer-size", 32768);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.allow-force-compaction", "No");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.auto-compact", "Yes");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.compaction-threshold", 50);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.disk-directories", "[]");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.disk-directory-sizes", "[]");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.disk-usage-critical-percentage", 0.90f);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.disk-usage-warning-percentage", 0.80f);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.max-oplog-size", 2048000L);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.queue-size", 4096);
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.time-interval", 15000L);
	assertThat(healthDetails).containsKey("geode.disk-store.MockDiskStoreOne.uuid");
	assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreTwo.write-buffer-size", 8192);

	verify(this.mockApplicationContext, times(1)).getBeansOfType(eq(DiskStore.class));
}