use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testExecute.
@Test
public void testExecute() throws Throwable {
final UUID diskStoreId = UUID.randomUUID();
final String diskStoreName = "mockDiskStore";
final String memberId = "mockMemberId";
final String memberName = "mockMemberName";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final InternalDistributedMember mockMember = mockContext.mock(InternalDistributedMember.class, "DistributedMember");
final DiskStore mockDiskStore = createMockDiskStore(diskStoreId, diskStoreName, true, false, 75, 8192l, 500, 120l, 10240, createFileArray("/export/disk/backup", "/export/disk/overflow", "/export/disk/persistence"), createIntArray(10240, 204800, 4096000), 50, 75);
final FunctionContext mockFunctionContext = mockContext.mock(FunctionContext.class, "testExecute$FunctionContext");
final TestResultSender testResultSender = new TestResultSender();
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getMyId();
will(returnValue(mockMember));
oneOf(mockCache).findDiskStore(diskStoreName);
will(returnValue(mockDiskStore));
oneOf(mockCache).getPdxPersistent();
will(returnValue(true));
oneOf(mockCache).getPdxDiskStore();
will(returnValue("memoryStore"));
oneOf(mockMember).getId();
will(returnValue(memberId));
oneOf(mockMember).getName();
will(returnValue(memberName));
oneOf(mockFunctionContext).getArguments();
will(returnValue(diskStoreName));
oneOf(mockFunctionContext).getResultSender();
will(returnValue(testResultSender));
}
});
final Set<DiskStoreDetails.RegionDetails> expectedRegionDetails = setupRegionsForTestExecute(mockCache, diskStoreName);
final Set<DiskStoreDetails.GatewayDetails> expectedGatewayDetails = setupGatewaysForTestExecute(mockCache, diskStoreName);
final Set<DiskStoreDetails.CacheServerDetails> expectedCacheServerDetails = setupCacheServersForTestExecute(mockCache, diskStoreName);
final Set<DiskStoreDetails.AsyncEventQueueDetails> expectedAsyncEventQueueDetails = setupAsyncEventQueuesForTestExecute(mockCache, diskStoreName);
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
function.execute(mockFunctionContext);
final List<?> results = testResultSender.getResults();
assertNotNull(results);
assertEquals(1, results.size());
final DiskStoreDetails diskStoreDetails = (DiskStoreDetails) results.get(0);
assertNotNull(diskStoreDetails);
assertEquals(diskStoreId, diskStoreDetails.getId());
assertEquals(diskStoreName, diskStoreDetails.getName());
assertEquals(memberId, diskStoreDetails.getMemberId());
assertEquals(memberName, diskStoreDetails.getMemberName());
assertTrue(diskStoreDetails.getAllowForceCompaction());
assertFalse(diskStoreDetails.getAutoCompact());
assertEquals(75, diskStoreDetails.getCompactionThreshold().intValue());
assertEquals(8192l, diskStoreDetails.getMaxOplogSize().longValue());
assertFalse(diskStoreDetails.isPdxSerializationMetaDataStored());
assertEquals(500, diskStoreDetails.getQueueSize().intValue());
assertEquals(120l, diskStoreDetails.getTimeInterval().longValue());
assertEquals(10240, diskStoreDetails.getWriteBufferSize().intValue());
assertEquals(50.0f, diskStoreDetails.getDiskUsageWarningPercentage().floatValue(), 0.0f);
assertEquals(75.0f, diskStoreDetails.getDiskUsageCriticalPercentage().floatValue(), 0.0f);
final List<String> expectedDiskDirs = Arrays.asList(new File("/export/disk/backup").getAbsolutePath(), new File("/export/disk/overflow").getAbsolutePath(), new File("/export/disk/persistence").getAbsolutePath());
final List<Integer> expectdDiskDirSizes = Arrays.asList(10240, 204800, 4096000);
int count = 0;
for (final DiskStoreDetails.DiskDirDetails diskDirDetails : diskStoreDetails) {
assertTrue(expectedDiskDirs.contains(diskDirDetails.getAbsolutePath()));
assertTrue(expectdDiskDirSizes.contains(diskDirDetails.getSize()));
count++;
}
assertEquals(expectedDiskDirs.size(), count);
assertRegionDetails(expectedRegionDetails, diskStoreDetails);
assertCacheServerDetails(expectedCacheServerDetails, diskStoreDetails);
assertGatewayDetails(expectedGatewayDetails, diskStoreDetails);
assertAsyncEventQueueDetails(expectedAsyncEventQueueDetails, diskStoreDetails);
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testSetCacheServerDetails.
@Test
public void testSetCacheServerDetails() {
final String diskStoreName = "testDiskStore";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final CacheServer mockCacheServer1 = mockContext.mock(CacheServer.class, "CacheServer1");
final CacheServer mockCacheServer2 = mockContext.mock(CacheServer.class, "CacheServer2");
final CacheServer mockCacheServer3 = mockContext.mock(CacheServer.class, "CacheServer3");
final ClientSubscriptionConfig mockCacheServer1ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer1ClientSubscriptionConfig");
final ClientSubscriptionConfig mockCacheServer2ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer2ClientSubscriptionConfig");
final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getCacheServers();
will(returnValue(Arrays.asList(mockCacheServer1, mockCacheServer2, mockCacheServer3)));
exactly(2).of(mockCacheServer1).getClientSubscriptionConfig();
will(returnValue(mockCacheServer1ClientSubscriptionConfig));
oneOf(mockCacheServer1ClientSubscriptionConfig).getDiskStoreName();
will(returnValue(diskStoreName));
oneOf(mockCacheServer1).getBindAddress();
will(returnValue("10.127.255.1"));
oneOf(mockCacheServer1).getPort();
will(returnValue(65536));
oneOf(mockCacheServer1).getHostnameForClients();
will(returnValue("gemini"));
exactly(2).of(mockCacheServer2).getClientSubscriptionConfig();
will(returnValue(mockCacheServer2ClientSubscriptionConfig));
oneOf(mockCacheServer2ClientSubscriptionConfig).getDiskStoreName();
will(returnValue(" "));
oneOf(mockCacheServer3).getClientSubscriptionConfig();
will(returnValue(null));
exactly(3).of(mockDiskStore).getName();
will(returnValue(diskStoreName));
}
});
final Set<DiskStoreDetails.CacheServerDetails> expectedCacheServerDetails = CollectionUtils.asSet(createCacheServerDetails("10.127.255.1", 65536, "gemini"));
final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
function.setCacheServerDetails(mockCache, mockDiskStore, diskStoreDetails);
assertCacheServerDetails(expectedCacheServerDetails, diskStoreDetails);
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class ListDiskStoresFunctionJUnitTest method testExecuteOnMemberHavingNoDiskStores.
@Test
@SuppressWarnings("unchecked")
public void testExecuteOnMemberHavingNoDiskStores() throws Throwable {
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final InternalDistributedMember mockMember = mockContext.mock(InternalDistributedMember.class, "DistributedMember");
final FunctionContext mockFunctionContext = mockContext.mock(FunctionContext.class, "FunctionContext");
final TestResultSender testResultSender = new TestResultSender();
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getMyId();
will(returnValue(mockMember));
oneOf(mockCache).listDiskStoresIncludingRegionOwned();
will(returnValue(Collections.emptyList()));
oneOf(mockFunctionContext).getResultSender();
will(returnValue(testResultSender));
}
});
final ListDiskStoresFunction function = createListDiskStoresFunction(mockCache);
function.execute(mockFunctionContext);
final List<?> results = testResultSender.getResults();
assertNotNull(results);
assertEquals(1, results.size());
final Set<DiskStoreDetails> diskStoreDetails = (Set<DiskStoreDetails>) results.get(0);
assertNotNull(diskStoreDetails);
assertTrue(diskStoreDetails.isEmpty());
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class ListDiskStoresFunctionJUnitTest method testExecute.
@Test
@SuppressWarnings("unchecked")
public void testExecute() throws Throwable {
final UUID mockDiskStoreOneId = UUID.randomUUID();
final UUID mockDiskStoreTwoId = UUID.randomUUID();
final UUID mockDiskStoreThreeId = UUID.randomUUID();
final String memberId = "mockMemberId";
final String memberName = "mockMemberName";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final InternalDistributedMember mockMember = mockContext.mock(InternalDistributedMember.class, "DistributedMember");
final DiskStoreImpl mockDiskStoreOne = mockContext.mock(DiskStoreImpl.class, "DiskStoreOne");
final DiskStoreImpl mockDiskStoreTwo = mockContext.mock(DiskStoreImpl.class, "DiskStoreTwo");
final DiskStoreImpl mockDiskStoreThree = mockContext.mock(DiskStoreImpl.class, "DiskStoreThree");
final Collection<DiskStoreImpl> mockDiskStores = new ArrayList<DiskStoreImpl>();
mockDiskStores.add(mockDiskStoreOne);
mockDiskStores.add(mockDiskStoreTwo);
mockDiskStores.add(mockDiskStoreThree);
final FunctionContext mockFunctionContext = mockContext.mock(FunctionContext.class, "FunctionContext");
final TestResultSender testResultSender = new TestResultSender();
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getMyId();
will(returnValue(mockMember));
oneOf(mockCache).listDiskStoresIncludingRegionOwned();
will(returnValue(mockDiskStores));
exactly(3).of(mockMember).getId();
will(returnValue(memberId));
exactly(3).of(mockMember).getName();
will(returnValue(memberName));
oneOf(mockDiskStoreOne).getDiskStoreUUID();
will(returnValue(mockDiskStoreOneId));
oneOf(mockDiskStoreOne).getName();
will(returnValue("ds-backup"));
oneOf(mockDiskStoreTwo).getDiskStoreUUID();
will(returnValue(mockDiskStoreTwoId));
oneOf(mockDiskStoreTwo).getName();
will(returnValue("ds-overflow"));
oneOf(mockDiskStoreThree).getDiskStoreUUID();
will(returnValue(mockDiskStoreThreeId));
oneOf(mockDiskStoreThree).getName();
will(returnValue("ds-persistence"));
oneOf(mockFunctionContext).getResultSender();
will(returnValue(testResultSender));
}
});
final ListDiskStoresFunction function = createListDiskStoresFunction(mockCache);
function.execute(mockFunctionContext);
final List<?> results = testResultSender.getResults();
assertNotNull(results);
assertEquals(1, results.size());
final Set<DiskStoreDetails> diskStoreDetails = (Set<DiskStoreDetails>) results.get(0);
assertNotNull(diskStoreDetails);
assertEquals(3, diskStoreDetails.size());
diskStoreDetails.containsAll(Arrays.asList(createDiskStoreDetails(mockDiskStoreOneId, "ds-backup", memberId, memberName), createDiskStoreDetails(mockDiskStoreTwoId, "ds-overflow", memberId, memberName), createDiskStoreDetails(mockDiskStoreThreeId, "ds-persistence", memberId, memberName)));
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class ListDiskStoresFunctionJUnitTest method testExecuteOnMemberWithANonGemFireCache.
@Test
@SuppressWarnings("unchecked")
public void testExecuteOnMemberWithANonGemFireCache() throws Throwable {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final FunctionContext mockFunctionContext = mockContext.mock(FunctionContext.class, "FunctionContext");
final TestResultSender testResultSender = new TestResultSender();
mockContext.checking(new Expectations() {
{
oneOf(mockFunctionContext).getResultSender();
will(returnValue(testResultSender));
}
});
final ListDiskStoresFunction function = createListDiskStoresFunction(mockCache);
function.execute(mockFunctionContext);
final List<?> results = testResultSender.getResults();
assertNotNull(results);
assertEquals(1, results.size());
final Set<DiskStoreDetails> diskStoreDetails = (Set<DiskStoreDetails>) results.get(0);
assertNotNull(diskStoreDetails);
assertTrue(diskStoreDetails.isEmpty());
}
Aggregations