From: Ed Warnicke Date: Wed, 11 Mar 2015 00:31:03 +0000 (-0700) Subject: Base projects and parents for IT tests. X-Git-Tag: release/beryllium~396 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=bc99ff03ddcba2ceff83fd1ebba68731f39c864b Base projects and parents for IT tests. This provides a very very simple working basis for IT tests. Change-Id: I16fae750c32ffe6fce356c8036b6d74988aa4f99 Signed-off-by: Ed Warnicke Signed-off-by: Ed Warnicke --- diff --git a/.gitignore b/.gitignore index b304ffce87..ead1f8ee02 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,4 @@ maven-eclipse.xml .metadata opendaylight/md-sal/sal-distributed-datastore/journal !opendaylight/distribution/opendaylight-karaf-resources/src/main/resources/bin - - +.checkstyle diff --git a/opendaylight/config/config-it-base/pom.xml b/opendaylight/config/config-it-base/pom.xml new file mode 100644 index 0000000000..def8cd3fd3 --- /dev/null +++ b/opendaylight/config/config-it-base/pom.xml @@ -0,0 +1,85 @@ + + + + + + org.opendaylight.controller + config-parent + 0.4.0-SNAPSHOT + + + 4.0.0 + config-it-base + bundle + + + + org.opendaylight.controller + config-artifacts + ${project.version} + pom + import + + + + + + org.opendaylight.controller + config-util + + + + org.ops4j.pax.exam + pax-exam-container-karaf + compile + + + org.ops4j.pax.exam + pax-exam-junit4 + compile + + + org.ops4j.pax.exam + pax-exam + compile + + + org.ops4j.pax.url + pax-url-aether + compile + + + javax.inject + javax.inject + 1 + compile + + + org.apache.karaf.features + org.apache.karaf.features.core + ${karaf.version} + compile + + + org.osgi + org.osgi.core + compile + + + junit + junit + compile + + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + + + diff --git a/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java b/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java new file mode 100644 index 0000000000..e581e50247 --- /dev/null +++ b/opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java @@ -0,0 +1,173 @@ +package org.opendaylight.controller.config.it.base; + +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.base.Stopwatch; + +import java.io.File; +import java.lang.management.ManagementFactory; +import java.util.concurrent.TimeUnit; + +import javax.management.ObjectName; + +import org.junit.Before; +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.KarafDistributionOption; +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; + +public abstract class AbstractConfigTestBase { + + 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"; + private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigTestBase.class); + public static final String ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg"; + + /* + * Default values for karaf distro version, type, groupId, and artifactId + */ + private static final String KARAF_DISTRO_VERSION = "3.0.2"; + private static final String KARAF_DISTRO_TYPE = "zip"; + private static final String KARAF_DISTRO_ARTIFACTID = "apache-karaf"; + private static final String KARAF_DISTRO_GROUPID = "org.apache.karaf"; + + /* + * Property names to override defaults for karaf distro artifactId, groupId, version, and type + */ + private static final String KARAF_DISTRO_VERSION_PROP = "karaf.distro.version"; + private static final String KARAF_DISTRO_TYPE_PROP = "karaf.distro.type"; + private static final String KARAF_DISTRO_ARTIFACTID_PROP = "karaf.distro.artifactId"; + private static final String KARAF_DISTRO_GROUPID_PROP = "karaf.distro.groupId"; + + /* + * Wait up to 10s for our configured module to come up + */ + private static final int MODULE_TIMEOUT_MILLIS = 60000; + + public abstract String getModuleName(); + + public abstract String getInstanceName(); + + public abstract MavenUrlReference getFeatureRepo(); + + public abstract String getFeatureName(); + + public Option getLoggingOption() { + Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG, + logConfiguration(AbstractConfigTestBase.class), + LogLevel.INFO.name()); + return option; + } + + public String logConfiguration(Class klazz) { + return "log4j.logger." + klazz.getPackage().getName(); + } + + public String getKarafDistro() { + String groupId = System.getProperty(KARAF_DISTRO_GROUPID_PROP,KARAF_DISTRO_GROUPID); + String artifactId = System.getProperty(KARAF_DISTRO_ARTIFACTID_PROP,KARAF_DISTRO_ARTIFACTID); + String version = System.getProperty(KARAF_DISTRO_VERSION_PROP,KARAF_DISTRO_VERSION); + String type = System.getProperty(KARAF_DISTRO_TYPE_PROP,KARAF_DISTRO_TYPE); + MavenArtifactUrlReference karafUrl = maven() + .groupId(groupId) + .artifactId(artifactId) + .version(version) + .type(type); + return karafUrl.getURL(); + } + + @Configuration + public Option[] 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()), + features(getFeatureRepo(), getFeatureName()), + getLoggingOption()}; + return options; + } + + @Before + public void setup() throws Exception { + LOG.info("Module: {} Instance: {} attempting to configure.", + getModuleName(),getInstanceName()); + Stopwatch stopWatch = Stopwatch.createStarted(); + ObjectName objectName = null; + for(int i = 0;iconfig-artifacts config-parent + config-it-base diff --git a/opendaylight/md-sal/mdsal-it-base/pom.xml b/opendaylight/md-sal/mdsal-it-base/pom.xml new file mode 100644 index 0000000000..50d054ff8c --- /dev/null +++ b/opendaylight/md-sal/mdsal-it-base/pom.xml @@ -0,0 +1,95 @@ + + + + + + org.opendaylight.controller + config-parent + 0.4.0-SNAPSHOT + + + 4.0.0 + mdsal-it-base + 1.3.0-SNAPSHOT + bundle + + 0.4.0-SNAPSHOT + + + + + ${project.groupId} + mdsal-artifacts + ${project.version} + pom + import + + + + + + ${project.groupId} + config-it-base + ${config.version} + compile + + + ${project.groupId} + sal-binding-api + + + + org.ops4j.pax.exam + pax-exam-container-karaf + compile + + + org.ops4j.pax.exam + pax-exam-junit4 + compile + + + org.ops4j.pax.exam + pax-exam + compile + + + org.ops4j.pax.url + pax-url-aether + compile + + + javax.inject + javax.inject + 1 + compile + + + org.apache.karaf.features + org.apache.karaf.features.core + ${karaf.version} + compile + + + org.osgi + org.osgi.core + compile + + + junit + junit + compile + + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + + + diff --git a/opendaylight/md-sal/mdsal-it-base/src/main/java/org/opendaylight/controller/mdsal/it/base/AbstractMdsalTestBase.java b/opendaylight/md-sal/mdsal-it-base/src/main/java/org/opendaylight/controller/mdsal/it/base/AbstractMdsalTestBase.java new file mode 100644 index 0000000000..34728a99fb --- /dev/null +++ b/opendaylight/md-sal/mdsal-it-base/src/main/java/org/opendaylight/controller/mdsal/it/base/AbstractMdsalTestBase.java @@ -0,0 +1,75 @@ +package org.opendaylight.controller.mdsal.it.base; + +import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; +import static org.ops4j.pax.exam.CoreOptions.composite; + +import java.util.Calendar; + +import javax.inject.Inject; + +import org.junit.Before; +import org.opendaylight.controller.config.it.base.AbstractConfigTestBase; +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.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +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 = 70000; + @Inject @Filter(timeout=60000) + private BundleContext context; + private ProviderContext session = null; + + public ProviderContext getSession() { + return session; + } + + @Override + public void onSessionInitiated(ProviderContext session) { + LOG.info("Session Initiated: {}",session); + this.session = session; + } + + @Override + @Before + public void setup() throws Exception { + super.setup(); + Calendar start = Calendar.getInstance(); + ServiceReference serviceReference = context.getServiceReference(BindingAwareBroker.class); + if(serviceReference == null) { + throw new RuntimeException("BindingAwareBroker not found"); + } + BindingAwareBroker broker = context.getService(serviceReference); + broker.registerProvider(this); + for(int i=0;i + + + + + org.opendaylight.controller + config-parent + 0.4.0-SNAPSHOT + + + 4.0.0 + mdsal-it-parent + 1.3.0-SNAPSHOT + pom + + org.opendaylight.controller + opendaylight-karaf-empty + 1.6.0-SNAPSHOT + zip + false + + + + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + pom + import + + + + + + + org.opendaylight.controller + mdsal-it-base + ${mdsal.version} + + + + + org.ops4j.pax.exam + pax-exam-container-karaf + + + org.ops4j.pax.exam + pax-exam-junit4 + + + org.ops4j.pax.exam + pax-exam + + + org.ops4j.pax.url + pax-url-aether + + + javax.inject + javax.inject + 1 + + + org.apache.karaf.features + org.apache.karaf.features.core + ${karaf.version} + + + org.osgi + org.osgi.core + + + junit + junit + + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + + + + + junit + junit + test + + + + org.mockito + mockito-all + test + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + karaf.distro.groupId + ${karaf.distro.groupId} + + + karaf.distro.artifactId + ${karaf.distro.artifactId} + + + karaf.distro.version + ${karaf.distro.version} + + + karaf.distro.type + ${karaf.distro.type} + + + karaf.keep.unpack + ${karaf.keep.unpack} + + + ${project.build.directory}/surefire-reports + + + + + + + org.apache.servicemix.tooling + depends-maven-plugin + + + generate-depends-file + + generate-depends-file + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-karaf-resources + + unpack-dependencies + + process-test-resources + + ${project.build.directory}/test-classes + org.opendaylight.controller + config-it-base,mdsal-it-base + META-INF\/** + false + + + + + + + diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 9834008b0b..2a363bac8d 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -91,6 +91,11 @@ sal-binding-it sal-binding-dom-it + + + mdsal-it-base + mdsal-it-parent +