eolivelli commented on a change in pull request #932: ISSUE #931,#907: Add option to track task execution time URL: https://github.com/apache/bookkeeper/pull/932#discussion_r159473039
########## File path: bookkeeper-server/src/test/java/org/apache/bookkeeper/test/OpStatTest.java ########## @@ -0,0 +1,125 @@ +/* + * + * 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.test; + +import static org.apache.bookkeeper.bookie.BookKeeperServerStats.SERVER_SCOPE; +import static org.junit.Assert.assertTrue; + +import java.util.function.BiConsumer; +import org.apache.bookkeeper.client.BookKeeper; +import org.apache.bookkeeper.client.LedgerHandle; +import org.apache.bookkeeper.util.MathUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Basic tests to verify that stats are being updated as expected. + */ +public class OpStatTest extends BookKeeperClusterTestCase { + private LedgerHandle lh; + + public OpStatTest() { + super(1); + } + + @Before + @Override + public void setUp() throws Exception { + super.setUp(); + lh = bkc.createLedger(1, 1, BookKeeper.DigestType.CRC32, "".getBytes()); + resetBookieOpLoggers(); + } + + @After + @Override + public void tearDown() throws Exception { + lh.close(); + lh = null; + super.tearDown(); + } + + private void validateOpStat(TestStatsProvider stats, String path, BiConsumer<Long, Double> f) { + assertTrue(stats != null); + TestStatsProvider.TestOpStatsLogger logger = stats.getOpStatsLogger(path); + assertTrue(logger != null); + f.accept(logger.getSuccessCount(), logger.getSuccessAverage()); + } + + private void validateOpStat(TestStatsProvider stats, String paths[], BiConsumer<Long, Double> f) { + for (String path : paths) { + validateOpStat(stats, path, f); + } + } + + @Test(timeout = 6000) Review comment: Nit: Drop timeouts we have now in surefire config ---------------------------------------------------------------- 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
