Search in sources :

Example 1 with ExportLogsCommand

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);
}
Also used : Execution(org.apache.geode.cache.execute.Execution) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) ExportLogsCommand(org.apache.geode.management.internal.cli.commands.ExportLogsCommand) InternalCache(org.apache.geode.internal.cache.InternalCache) Cache(org.apache.geode.cache.Cache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 2 with ExportLogsCommand

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);
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) ExportLogsCommand(org.apache.geode.management.internal.cli.commands.ExportLogsCommand) ResultCollector(org.apache.geode.cache.execute.ResultCollector) HashSet(java.util.HashSet) Result(org.apache.geode.management.cli.Result) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 3 with ExportLogsCommand

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);
}
Also used : Execution(org.apache.geode.cache.execute.Execution) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) ExportLogsCommand(org.apache.geode.management.internal.cli.commands.ExportLogsCommand) InternalCache(org.apache.geode.internal.cache.InternalCache) Cache(org.apache.geode.cache.Cache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 4 with ExportLogsCommand

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);
}
Also used : Execution(org.apache.geode.cache.execute.Execution) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) ExportLogsCommand(org.apache.geode.management.internal.cli.commands.ExportLogsCommand) InternalCache(org.apache.geode.internal.cache.InternalCache) Cache(org.apache.geode.cache.Cache) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DistributedMember (org.apache.geode.distributed.DistributedMember)4 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 InternalCache (org.apache.geode.internal.cache.InternalCache)4 ExportLogsCommand (org.apache.geode.management.internal.cli.commands.ExportLogsCommand)4 UnitTest (org.apache.geode.test.junit.categories.UnitTest)4 Test (org.junit.Test)4 Cache (org.apache.geode.cache.Cache)3 Execution (org.apache.geode.cache.execute.Execution)3 HashSet (java.util.HashSet)1 ResultCollector (org.apache.geode.cache.execute.ResultCollector)1 Result (org.apache.geode.management.cli.Result)1