2 * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.binding.test.tests;
10 import static com.google.common.truth.Truth.assertThat;
12 import org.junit.Ignore;
13 import org.junit.Test;
14 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
17 * Integration tests the DataBrokerTestModule.
19 * @author Michael Vorburger
22 public class DataBrokerTestModuleTest {
25 public void ensureDataBrokerTestModuleWorksWithoutException() {
26 assertThat(DataBrokerTestModule.dataBroker()).isNotNull();
30 @Ignore // This test is flaky on build server VMs (although fine locally)
31 public void slowYangLoadingShouldOnlyHappenOnceAndNotDelayEachDataBroker() {
32 // TODO Write a lil' Timer utility class to make this kind of timing test code more readable
33 long startAtMs = System.currentTimeMillis();
34 DataBrokerTestModule.dataBroker();
35 long firstDataBrokerAtMs = System.currentTimeMillis();
36 long firstDataBrokerDurationMs = firstDataBrokerAtMs - startAtMs;
37 DataBrokerTestModule.dataBroker();
38 long secondDataBrokerDurationMs = System.currentTimeMillis() - firstDataBrokerAtMs;
39 assertThat(Math.abs(secondDataBrokerDurationMs - firstDataBrokerDurationMs))
40 .isLessThan(firstDataBrokerDurationMs / 4);