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
21 public class DataBrokerTestModuleTest {
24 public void ensureDataBrokerTestModuleWorksWithoutException() {
25 assertThat(DataBrokerTestModule.dataBroker()).isNotNull();
29 @Ignore // This test is flaky on build server VMs (although fine locally)
30 public void slowYangLoadingShouldOnlyHappenOnceAndNotDelayEachDataBroker() {
31 // TODO Write a lil' Timer utility class to make this kind of timing test code more readable
32 long startAtMs = System.currentTimeMillis();
33 DataBrokerTestModule.dataBroker();
34 long firstDataBrokerAtMs = System.currentTimeMillis();
35 long firstDataBrokerDurationMs = firstDataBrokerAtMs - startAtMs;
36 DataBrokerTestModule.dataBroker();
37 long secondDataBrokerDurationMs = System.currentTimeMillis() - firstDataBrokerAtMs;
38 assertThat(Math.abs(secondDataBrokerDurationMs - firstDataBrokerDurationMs))
39 .isLessThan(firstDataBrokerDurationMs / 4);