sijie commented on a change in pull request #889: BP-14 Implementation of WriteFlag.DEFERRED_SYNC on Journal URL: https://github.com/apache/bookkeeper/pull/889#discussion_r158180713
########## File path: bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalForceTest.java ########## @@ -0,0 +1,166 @@ +/* + * + * 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.bookkeeper.bookie; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.powermock.api.support.membermodification.MemberMatcher.method; +import static org.powermock.api.support.membermodification.MemberModifier.replace; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.io.File; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import lombok.extern.slf4j.Slf4j; + +import org.apache.bookkeeper.conf.ServerConfiguration; +import org.apache.bookkeeper.conf.TestBKConfiguration; +import org.apache.bookkeeper.net.BookieSocketAddress; +import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * Test the bookie journal. + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({JournalChannel.class}) +@Slf4j +public class BookieJournalForceTest { + + private static final ByteBuf DATA = Unpooled.wrappedBuffer(new byte[]{}); + + @Rule + public TemporaryFolder tempDir = new TemporaryFolder(); + + @Test + public void testAckBeforeSync() throws Exception { Review comment: the logic in testAckBeforeSync and testAckAfterSync does sounds good to me. I think for: - for testAckBeforeSync, you need to ensure callback come before sync and eventually sync will still advance the file and the log marker - for testAckAfterSync, you need to ensure callback come back only after sync and the log markers are advanced after that. One solution for this: - you need to be able to control force write thread, e.g. suspend forcewrite thread and make sure callbacks can trigger even forcewrite thread is suspended and verify the forcewrite request enqueued to forcewrite queue contains null items. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
