2 * Copyright (C) 2015 Red Hat, Inc. and others
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.ovsdb.openstack.netvirt.it;
10 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
12 import com.google.common.collect.ObjectArrays;
13 import java.util.Calendar;
14 import javax.inject.Inject;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
18 import org.ops4j.pax.exam.Option;
19 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
20 import org.ops4j.pax.exam.util.Filter;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase implements BindingAwareProvider {
26 private static final Logger LOG = LoggerFactory.getLogger(AbstractMdsalTestBase.class);
27 private static final int REGISTRATION_TIMEOUT = 10000;
28 @Inject @Filter(timeout = 120000)
29 private BindingAwareBroker broker;
30 private ProviderContext session = null;
32 public ProviderContext getSession() {
37 public void onSessionInitiated(ProviderContext session) {
38 LOG.info("Session Initiated: {}",session);
39 this.session = session;
43 public void setup() throws Exception {
45 Calendar start = Calendar.getInstance();
46 broker.registerProvider(this);
47 for (int timer = 0;timer < REGISTRATION_TIMEOUT;timer++) {
48 if (session != null) {
49 Calendar stop = Calendar.getInstance();
50 LOG.info("Registered with the MD-SAL after {} ms",
51 stop.getTimeInMillis() - start.getTimeInMillis());
57 throw new RuntimeException("Session not initiated after " + REGISTRATION_TIMEOUT + " ms");
61 public Option[] getLoggingOptions() {
62 Option[] options = new Option[] {
63 editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
64 logConfiguration(AbstractMdsalTestBase.class),
65 LogLevel.INFO.name()),
67 options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);