<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-parent</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <artifactId>mdsal-it-parent</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
+++ /dev/null
-/*
- * Copyright (C) 2015 Red Hat, Inc. and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.ovsdb.openstack.netvirt.it;
-
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
-
-import com.google.common.collect.ObjectArrays;
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.util.Calendar;
-import javax.management.InstanceNotFoundException;
-import org.junit.Rule;
-import org.junit.internal.AssumptionViolatedException;
-import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.opendaylight.controller.config.api.ConfigRegistry;
-import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
-import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
-import org.ops4j.pax.exam.options.MavenUrlReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-//import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
-
-/**
- * @author Sam Hague (shague@redhat.com)
- */
-public abstract class AbstractConfigTestBase {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigTestBase.class);
-
- /*
- * Wait up to 10s for our configured module to come up
- */
- private static final int MODULE_TIMEOUT = 10000;
- private static int configTimes = 0;
-
- public abstract String getModuleName();
-
- public abstract String getInstanceName();
-
- public abstract MavenUrlReference getFeatureRepo();
-
- public abstract String getFeatureName();
-
- public Option[] getLoggingOptions() {
- Option[] options = new Option[] {
- editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- logConfiguration(AbstractConfigTestBase.class),
- LogLevel.INFO.name())
- };
- return options;
- }
-
- public String logConfiguration(Class<?> klazz) {
- return "log4j.logger." + klazz.getPackage().getName();
- }
-
- public Option[] getFeaturesOptions() {
- return new Option[]{};
- }
-
- public Option[] getPropertiesOptions() {
- return new Option[]{};
- }
-
- public MavenArtifactUrlReference getKarafDistro() {
- MavenArtifactUrlReference karafUrl;
- /*karafUrl = maven()
- .groupId("org.opendaylight.controller")
- .artifactId("opendaylight-karaf-empty")
- .version("1.5.0-SNAPSHOT")
- .type("zip");*/
-
- karafUrl = maven()
- .groupId("org.opendaylight.ovsdb")
- .artifactId("karaf")
- .versionAsInProject()
- .type("zip");
-
- return karafUrl;
- }
-
- @Configuration
- public Option[] config() {
- LOG.info("Calling config, configTimes: {}", configTimes);
- configTimes++;
- Option[] options = new Option[] {
- //KarafDistributionOption.debugConfiguration("5005", true),
- karafDistributionConfiguration()
- .frameworkUrl(getKarafDistro())
- .unpackDirectory(new File("target/exam"))
- .useDeployFolder(false),
- keepRuntimeFolder(),
- //features(getFeatureRepo() , getFeatureName())
- };
- options = ObjectArrays.concat(options, getFeaturesOptions(), Option.class);
- options = ObjectArrays.concat(options, getLoggingOptions(), Option.class);
- options = ObjectArrays.concat(options, getPropertiesOptions(), Option.class);
- return options;
- }
-
- public void setup() throws Exception {
- LOG.info("Module: {} Instance: {} attempting to configure.",
- getModuleName(),getInstanceName());
- Calendar start = Calendar.getInstance();
- ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory
- .getPlatformMBeanServer());
- for (int timer = 0;timer < MODULE_TIMEOUT;timer++) {
- try {
- configRegistryClient.lookupConfigBean(getModuleName(), getInstanceName());
- Thread.sleep(100);
- } catch (InstanceNotFoundException e) {
- if (timer >= MODULE_TIMEOUT) {
- throw e;
- }
- } catch (InterruptedException e) {
- LOG.error("Exception: ",e);
- }
- }
- Calendar stop = Calendar.getInstance();
- LOG.info("Module: {} Instance: {} configured after {} ms",
- getModuleName(),getInstanceName(),
- stop.getTimeInMillis() - start.getTimeInMillis());
- }
-
- @Rule
- public TestRule watcher = new TestWatcher() {
- @Override
- protected void starting(Description description) {
- LOG.info("TestWatcher: Starting test:\n{}", description.getDisplayName());
- }
-
- @Override
- protected void finished(Description description) {
- LOG.info("TestWatcher: Finished test:\n{}", description.getDisplayName());
- }
-
- @Override
- protected void succeeded(Description description) {
- LOG.info("TestWatcher: Test succeeded:\n{}", description.getDisplayName());
- }
-
- @Override
- protected void failed(Throwable ex, Description description) {
- LOG.info("TestWatcher: Test failed:\n{} ", description.getDisplayName(), ex);
- }
-
- @Override
- protected void skipped(AssumptionViolatedException ex, Description description) {
- LOG.info("TestWatcher: Test skipped:\n{} ", description.getDisplayName(), ex);
- }
- };
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Red Hat, Inc. and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.ovsdb.openstack.netvirt.it;
-
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-
-import com.google.common.collect.ObjectArrays;
-import java.util.Calendar;
-import javax.inject.Inject;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
-import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase implements BindingAwareProvider {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractMdsalTestBase.class);
- private static final int REGISTRATION_TIMEOUT = 10000;
- @Inject @Filter(timeout = 120000)
- private BindingAwareBroker broker;
- private ProviderContext session = null;
-
- public ProviderContext getSession() {
- return session;
- }
-
- @Override
- public void onSessionInitiated(ProviderContext session) {
- LOG.info("Session Initiated: {}",session);
- this.session = session;
- }
-
- @Override
- public void setup() throws Exception {
- super.setup();
- Calendar start = Calendar.getInstance();
- broker.registerProvider(this);
- for (int timer = 0;timer < REGISTRATION_TIMEOUT;timer++) {
- if (session != null) {
- Calendar stop = Calendar.getInstance();
- LOG.info("Registered with the MD-SAL after {} ms",
- stop.getTimeInMillis() - start.getTimeInMillis());
- return;
- } else {
- Thread.sleep(1);
- }
- }
- throw new RuntimeException("Session not initiated after " + REGISTRATION_TIMEOUT + " ms");
- }
-
- @Override
- public Option[] getLoggingOptions() {
- Option[] options = new Option[] {
- editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- logConfiguration(AbstractMdsalTestBase.class),
- LogLevel.INFO.name()),
- };
- options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);
- return options;
- }
-
-}
package org.opendaylight.ovsdb.openstack.netvirt.it;
import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Lists;
import com.google.common.collect.ObjectArrays;
+
+import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import org.junit.runner.RunWith;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.MavenUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
private static final String NETVIRT = "org.opendaylight.ovsdb.openstack.net-virt";
private static final String NETVIRTPROVIDERS = "org.opendaylight.ovsdb.openstack.net-virt-providers";
+ // TODO Constants copied frmo AbstractConfigTestBase, need to be removed (see TODO below)
+ private static final String PAX_EXAM_UNPACK_DIRECTORY = "target/exam";
+ private static final String KARAF_DEBUG_PORT = "5005";
+ private static final String KARAF_DEBUG_PROP = "karaf.debug";
+ private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack";
+
@Inject
private BundleContext bundleContext;
@Configuration
public Option[] config() {
- return super.config();
+ // TODO Figure out how to use the parent Karaf setup, then just use super.config()
+ Option[] options = new Option[] {
+ when(Boolean.getBoolean(KARAF_DEBUG_PROP))
+ .useOptions(KarafDistributionOption.debugConfiguration(KARAF_DEBUG_PORT, true)),
+ karafDistributionConfiguration().frameworkUrl(getKarafDistro())
+ .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY))
+ .useDeployFolder(false),
+ when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
+ // Works only if we don't specify the feature repo and name
+ getLoggingOption()};
+ Option[] propertyOptions = getPropertiesOptions();
+ Option[] combinedOptions = new Option[options.length + propertyOptions.length];
+ System.arraycopy(options, 0, combinedOptions, 0, options.length);
+ System.arraycopy(propertyOptions, 0, combinedOptions, options.length, propertyOptions.length);
+ return combinedOptions;
+ }
+
+ @Override
+ public String getKarafDistro() {
+ return maven()
+ .groupId("org.opendaylight.ovsdb")
+ .artifactId("karaf")
+ .versionAsInProject()
+ .type("zip")
+ .getURL();
}
@Override
}
@Override
- public Option[] getFeaturesOptions() {
- return new Option[]{};
- }
-
- @Override
- public Option[] getLoggingOptions() {
- Option[] options;
-
- options = new Option[] {
- editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- "log4j.logger.org.opendaylight.ovsdb",
- LogLevelOption.LogLevel.DEBUG.name()),
- editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- "log4j.logger.org.opendaylight.ovsdb.lib",
- LogLevelOption.LogLevel.INFO.name()),
+ public Option getLoggingOption() {
+ return composite(
+ editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
+ "log4j.logger.org.opendaylight.ovsdb",
+ LogLevelOption.LogLevel.DEBUG.name()),
+ editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
+ "log4j.logger.org.opendaylight.ovsdb.lib",
+ LogLevelOption.LogLevel.INFO.name()),
+ super.getLoggingOption());
/*editConfigurationFilePut(NetvirtITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
"log4j.logger.org.opendaylight.ovsdb.openstack.net-virt",
LogLevelOption.LogLevel.DEBUG.name())*/
- };
-
- options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);
- return options;
}
- @Override
- public Option[] getPropertiesOptions() {
+ private Option[] getPropertiesOptions() {
Properties props = new Properties(System.getProperties());
String addressStr = props.getProperty(NetvirtITConstants.SERVER_IPADDRESS,
NetvirtITConstants.DEFAULT_SERVER_IPADDRESS);
}
@Before
- public void setUp() throws InterruptedException {
+ @Override
+ public void setup() throws InterruptedException {
if (setup.get()) {
LOG.info("Skipping setUp, already initialized");
return;
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-parent</artifactId>
- <version>0.4.0-SNAPSHOT</version>
+ <artifactId>mdsal-it-parent</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.ovsdb.southbound.it;
-
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
-
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.util.Calendar;
-
-import javax.management.InstanceNotFoundException;
-
-import org.junit.Rule;
-import org.junit.internal.AssumptionViolatedException;
-import org.junit.rules.TestRule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.opendaylight.controller.config.api.ConfigRegistry;
-import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
-import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
-import org.ops4j.pax.exam.options.MavenUrlReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ObjectArrays;
-
-public abstract class AbstractConfigTestBase {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigTestBase.class);
-
- /*
- * Wait up to 10s for our configured module to come up
- */
- private static final int MODULE_TIMEOUT = 10000;
- private static int configTimes = 0;
-
- public abstract String getModuleName();
-
- public abstract String getInstanceName();
-
- public abstract MavenUrlReference getFeatureRepo();
-
- public abstract String getFeatureName();
-
- public Option[] getLoggingOptions() {
- Option[] options = new Option[] {
- editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- logConfiguration(AbstractConfigTestBase.class),
- LogLevel.INFO.name())
- };
- return options;
- }
-
- public String logConfiguration(Class<?> klazz) {
- return "log4j.logger." + klazz.getPackage().getName();
- }
-
- public Option[] getFeaturesOptions() {
- return new Option[]{};
- }
-
- public Option[] getPropertiesOptions() {
- return new Option[]{};
- }
-
- public MavenArtifactUrlReference getKarafDistro() {
- MavenArtifactUrlReference karafUrl;
- karafUrl = maven()
- // karaf-empty is busted
- //.groupId("org.opendaylight.controller")
- //.artifactId("opendaylight-karaf-empty")
- //.version("1.5.0-SNAPSHOT")
- .groupId("org.opendaylight.ovsdb")
- .artifactId("southbound-karaf")
- .versionAsInProject()
- .type("zip");
- return karafUrl;
- }
-
- @Configuration
- public Option[] config() {
- LOG.info("Calling config, configTimes: {}", configTimes);
- configTimes++;
- Option[] options = new Option[] {
- //KarafDistributionOption.debugConfiguration("5005", true),
- karafDistributionConfiguration()
- .frameworkUrl(getKarafDistro())
- .unpackDirectory(new File("target/exam"))
- .useDeployFolder(false),
- keepRuntimeFolder(),
- //debugConfiguration("5005", true),
- //features(getFeatureRepo() , getFeatureName())
- };
- options = ObjectArrays.concat(options, getFeaturesOptions(), Option.class);
- options = ObjectArrays.concat(options, getLoggingOptions(), Option.class);
- options = ObjectArrays.concat(options, getPropertiesOptions(), Option.class);
- return options;
- }
-
- public void setup() throws Exception {
- LOG.info("Module: {} Instance: {} attempting to configure.",
- getModuleName(),getInstanceName());
- Calendar start = Calendar.getInstance();
- ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory
- .getPlatformMBeanServer());
- for (int timer = 0;timer < MODULE_TIMEOUT;timer++) {
- try {
- configRegistryClient.lookupConfigBean(getModuleName(), getInstanceName());
- Thread.sleep(1);
- } catch (InstanceNotFoundException e) {
- if (timer >= MODULE_TIMEOUT) {
- throw e;
- }
- } catch (InterruptedException e) {
- LOG.error("Exception: ",e);
- }
- }
- Calendar stop = Calendar.getInstance();
- LOG.info("Module: {} Instance: {} configured after {} ms",
- getModuleName(),getInstanceName(),
- stop.getTimeInMillis() - start.getTimeInMillis());
- }
-
- @Rule
- public TestRule watcher = new TestWatcher() {
- @Override
- protected void starting(Description description) {
- LOG.info("TestWatcher: Starting test:\n{}", description.getDisplayName());
- }
-
- @Override
- protected void finished(Description description) {
- LOG.info("TestWatcher: Finished test:\n{}", description.getDisplayName());
- }
-
- @Override
- protected void succeeded(Description description) {
- LOG.info("TestWatcher: Test succeeded:\n{}", description.getDisplayName());
- }
-
- @Override
- protected void failed(Throwable ex, Description description) {
- LOG.info("TestWatcher: Test failed:\n{} ", description.getDisplayName(), ex);
- }
-
- @Override
- protected void skipped(AssumptionViolatedException ex, Description description) {
- LOG.info("TestWatcher: Test skipped:\n{} ", description.getDisplayName(), ex);
- }
- };
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.ovsdb.southbound.it;
-
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-
-import java.util.Calendar;
-
-import javax.inject.Inject;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
-import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ObjectArrays;
-
-public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase implements BindingAwareProvider {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractMdsalTestBase.class);
- private static final int REGISTRATION_TIMEOUT = 10000;
- @Inject @Filter(timeout = 60000)
- private BindingAwareBroker broker;
- private ProviderContext session = null;
-
- public ProviderContext getSession() {
- return session;
- }
-
- @Override
- public void onSessionInitiated(ProviderContext session) {
- LOG.info("Session Initiated: {}",session);
- this.session = session;
- }
-
- @Override
- public void setup() throws Exception {
- super.setup();
- Calendar start = Calendar.getInstance();
- broker.registerProvider(this);
- for (int timer = 0;timer < REGISTRATION_TIMEOUT;timer++) {
- if (session != null) {
- Calendar stop = Calendar.getInstance();
- LOG.info("Registered with the MD-SAL after {} ms",
- stop.getTimeInMillis() - start.getTimeInMillis());
- return;
- } else {
- Thread.sleep(1);
- }
- }
- throw new RuntimeException("Session not initiated after " + REGISTRATION_TIMEOUT + " ms");
- }
-
- @Override
- public Option[] getLoggingOptions() {
- Option[] options = new Option[] {
- editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
- logConfiguration(AbstractMdsalTestBase.class),
- LogLevel.INFO.name()),
- };
- options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);
- return options;
- }
-
-}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import com.google.common.collect.ObjectArrays;
import com.google.common.collect.Sets;
+import java.io.File;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import org.junit.runner.RunWith;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.ovsdb.southbound.SouthboundProvider;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.MavenUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
private static Boolean setup = false;
private static MdsalUtils mdsalUtils = null;
+ // TODO Constants copied frmo AbstractConfigTestBase, need to be removed (see TODO below)
+ private static final String PAX_EXAM_UNPACK_DIRECTORY = "target/exam";
+ private static final String KARAF_DEBUG_PORT = "5005";
+ private static final String KARAF_DEBUG_PROP = "karaf.debug";
+ private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack";
+
@Inject
private BundleContext bundleContext;
@Configuration
public Option[] config() {
- return super.config();
+ // TODO Figure out how to use the parent Karaf setup, then just use super.config()
+ Option[] options = new Option[] {
+ when(Boolean.getBoolean(KARAF_DEBUG_PROP))
+ .useOptions(KarafDistributionOption.debugConfiguration(KARAF_DEBUG_PORT, true)),
+ karafDistributionConfiguration().frameworkUrl(getKarafDistro())
+ .unpackDirectory(new File(PAX_EXAM_UNPACK_DIRECTORY))
+ .useDeployFolder(false),
+ when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
+ // Works only if we don't specify the feature repo and name
+ getLoggingOption()};
+ Option[] propertyOptions = getPropertiesOptions();
+ Option[] combinedOptions = new Option[options.length + propertyOptions.length];
+ System.arraycopy(options, 0, combinedOptions, 0, options.length);
+ System.arraycopy(propertyOptions, 0, combinedOptions, options.length, propertyOptions.length);
+ return combinedOptions;
+ }
+
+ @Override
+ public String getKarafDistro() {
+ return maven()
+ .groupId("org.opendaylight.ovsdb")
+ .artifactId("southbound-karaf")
+ .versionAsInProject()
+ .type("zip")
+ .getURL();
}
@Override
}
@Override
- public Option[] getFeaturesOptions() {
- return new Option[]{};
- }
-
- @Override
- public Option[] getLoggingOptions() {
- Option[] options = new Option[] {
+ public Option getLoggingOption() {
+ return composite(
editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
"log4j.logger.org.opendaylight.ovsdb",
- LogLevelOption.LogLevel.TRACE.name())
- };
-
- options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);
- return options;
+ LogLevelOption.LogLevel.TRACE.name()),
+ super.getLoggingOption());
}
- @Override
- public Option[] getPropertiesOptions() {
+ private Option[] getPropertiesOptions() {
Properties props = new Properties(System.getProperties());
String addressStr = props.getProperty(SouthboundITConstants.SERVER_IPADDRESS,
SouthboundITConstants.DEFAULT_SERVER_IPADDRESS);
}
@Before
- public void setUp() throws InterruptedException {
- if (setup == true) {
+ @Override
+ public void setup() throws InterruptedException {
+ if (setup) {
LOG.info("Skipping setUp, already initialized");
return;
}