use of org.apache.geode.management.internal.cli.commands.ExportLogsCommand in project geode by apache.
the class ExportLogsCommandTest method sizeOKOnMember_sizeChecksEnabled_doesNotThrow.
@Test
public void sizeOKOnMember_sizeChecksEnabled_doesNotThrow() throws Exception {
final Cache mockCache = mock(Cache.class);
final DistributedMember mockDistributedMember = mock(DistributedMember.class);
final Execution mockFunctionExecutor = mock(Execution.class);
final ExportLogsCommand cmd = createExportLogsCommand(mockCache, mockDistributedMember, mockFunctionExecutor);
cmd.checkIfExportLogsOverflowsDisk("clusterMember", 10 * MEGABYTE, MEGABYTE - 1024, MEGABYTE);
}
use of org.apache.geode.management.internal.cli.commands.ExportLogsCommand in project geode by apache.
the class ExportLogsCommandTest method sizeFromAllMembers_greaterThanLocalDiskAvailable_shouldReturnErrorResult.
@Test
public void sizeFromAllMembers_greaterThanLocalDiskAvailable_shouldReturnErrorResult() throws Exception {
final InternalCache mockCache = mock(InternalCache.class);
final ExportLogsCommand realCmd = new ExportLogsCommand();
ExportLogsCommand spyCmd = spy(realCmd);
String start = null;
String end = null;
String logLevel = null;
boolean onlyLogLevel = false;
boolean logsOnly = false;
boolean statsOnly = false;
InternalDistributedMember member1 = new InternalDistributedMember("member1", 12345);
InternalDistributedMember member2 = new InternalDistributedMember("member2", 98765);
member1.getNetMember().setName("member1");
member2.getNetMember().setName("member2");
Set<DistributedMember> testMembers = new HashSet<>();
testMembers.add(member1);
testMembers.add(member2);
ResultCollector testResults1 = new CustomCollector();
testResults1.addResult(member1, Arrays.asList(75 * MEGABYTE));
ResultCollector testResults2 = new CustomCollector();
testResults2.addResult(member2, Arrays.asList(60 * MEGABYTE));
doReturn(mockCache).when(spyCmd).getCache();
doReturn(testMembers).when(spyCmd).getMembers(null, null);
doReturn(testResults1).when(spyCmd).estimateLogSize(Matchers.any(SizeExportLogsFunction.Args.class), eq(member1));
doReturn(testResults2).when(spyCmd).estimateLogSize(Matchers.any(SizeExportLogsFunction.Args.class), eq(member2));
doReturn(125 * MEGABYTE).when(spyCmd).getLocalDiskAvailable();
doReturn(GIGABYTE).when(spyCmd).getLocalDiskSize();
Result res = spyCmd.exportLogs("working dir", null, null, logLevel, onlyLogLevel, false, start, end, logsOnly, statsOnly, "125m");
assertThat(res.getStatus()).isEqualTo(Result.Status.ERROR);
}
use of org.apache.geode.management.internal.cli.commands.ExportLogsCommand in project geode by apache.
the class ExportLogsCommandTest method sizeTooBigOnMember_sizeChecksDisabled_returnsFalse.
@Test
public void sizeTooBigOnMember_sizeChecksDisabled_returnsFalse() throws Exception {
final Cache mockCache = mock(Cache.class);
final DistributedMember mockDistributedMember = mock(DistributedMember.class);
final Execution mockFunctionExecutor = mock(Execution.class);
final ExportLogsCommand cmd = createExportLogsCommand(mockCache, mockDistributedMember, mockFunctionExecutor);
cmd.checkIfExportLogsOverflowsDisk("clusterMember", 0, MEGABYTE + 1024, MEGABYTE);
}
use of org.apache.geode.management.internal.cli.commands.ExportLogsCommand in project geode by apache.
the class ExportLogsCommandTest method sizeTooBigOnMember_sizeChecksEnabled_shouldThrow.
@Test
public void sizeTooBigOnMember_sizeChecksEnabled_shouldThrow() throws Exception {
final Cache mockCache = mock(Cache.class);
final DistributedMember mockDistributedMember = mock(DistributedMember.class);
final Execution mockFunctionExecutor = mock(Execution.class);
final ExportLogsCommand cmd = createExportLogsCommand(mockCache, mockDistributedMember, mockFunctionExecutor);
assertThatThrownBy(() -> cmd.checkIfExportLogsOverflowsDisk("clusterMember", 10 * MEGABYTE, MEGABYTE + 1024, MEGABYTE)).isInstanceOf(ManagementException.class);
}
Aggregations