You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@rocketmq.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/09/22 02:46:01 UTC

[jira] [Commented] (ROCKETMQ-249) Attempt to clear disk even if disk store path is found

    [ https://issues.apache.org/jira/browse/ROCKETMQ-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16175815#comment-16175815 ] 

ASF GitHub Bot commented on ROCKETMQ-249:
-----------------------------------------

Github user dongeforever commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/133#discussion_r140402297
  
    --- Diff: store/src/test/java/org/apache/rocketmq/store/CleanCommitLogServiceTest.java ---
    @@ -0,0 +1,115 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.rocketmq.store;
    +
    +import java.lang.reflect.Field;
    +import java.lang.reflect.Method;
    +import org.apache.rocketmq.common.BrokerConfig;
    +import org.apache.rocketmq.store.config.MessageStoreConfig;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import static org.mockito.Mockito.spy;
    +import static org.mockito.Mockito.when;
    +
    +/**
    + * Tests for CleanCommitLogService.
    + */
    +public class CleanCommitLogServiceTest {
    +    DefaultMessageStore messageStore;
    +    DefaultMessageStore.CleanCommitLogService cleanCommitLogService;
    +
    +    // CleanCommitLogService class.
    +    Class<?> clazz;
    +
    +    @Before
    +    public void setUp() throws Exception {
    +        clazz = Class.forName("org.apache.rocketmq.store.DefaultMessageStore$CleanCommitLogService");
    +
    +        MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
    +        messageStore = new DefaultMessageStore(
    +            messageStoreConfig, null, null, new BrokerConfig());
    +
    +        Field cleanCommitLogServiceField = messageStore.getClass().getDeclaredField("cleanCommitLogService");
    +        cleanCommitLogServiceField.setAccessible(true);
    +
    +        cleanCommitLogService = spy((DefaultMessageStore.CleanCommitLogService) (cleanCommitLogServiceField.get(messageStore)));
    +    }
    +
    +    @After
    +    public void tearDown() throws Exception {
    +    }
    +
    +    @Test
    +    public void isSpaceToDeleteNoCommitLog() throws Exception {
    +        Method m = clazz.getDeclaredMethod("isSpaceToDelete");
    +        m.setAccessible(true);
    +
    +        Assert.assertFalse((boolean) m.invoke(cleanCommitLogService));
    +    }
    +
    +    @Test
    +    public void isSpaceToDeleteWithCommitLogNoQueue() throws Exception {
    +        try {
    +            messageStore.start();
    +            messageStore.load();
    +
    +            Method m = clazz.getDeclaredMethod("isSpaceToDelete");
    +            m.setAccessible(true);
    +
    +            Assert.assertFalse((boolean) m.invoke(cleanCommitLogService));
    +        } finally {
    +            messageStore.shutdown();
    --- End diff --
    
    How about putting the finally block into teardown() ?
    The test framework will handle it.


> Attempt to clear disk even if disk store path is found
> ------------------------------------------------------
>
>                 Key: ROCKETMQ-249
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-249
>             Project: Apache RocketMQ
>          Issue Type: Bug
>            Reporter: Roman Shtykh
>            Assignee: Roman Shtykh
>
> If disk usage estimates fail because the disk store path is not found (doesn't exist), message store falsely decides the disk is full and tries to delete.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)