ConstantSchemaAbstractDataBrokerTest, faster than AbstractDataBrokerTest
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / test / tests / DataBrokerTestModuleTest.java
1 /*
2  * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.binding.test.tests;
9
10 import static com.google.common.truth.Truth.assertThat;
11
12 import org.junit.Ignore;
13 import org.junit.Test;
14 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
15
16 /**
17  * Integration tests the DataBrokerTestModule.
18  *
19  * @author Michael Vorburger
20  */
21 public class DataBrokerTestModuleTest {
22
23     @Test
24     public void ensureDataBrokerTestModuleWorksWithoutException() {
25         assertThat(DataBrokerTestModule.dataBroker()).isNotNull();
26     }
27
28     @Test
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);
40     }
41 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.