accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject git commit: ACCUMULO-1030 Shared mini for integration tests, fix plugin package
Date Wed, 17 Jul 2013 02:09:06 GMT
Updated Branches:
  refs/heads/master db39c354e -> af06b1629


ACCUMULO-1030 Shared mini for integration tests, fix plugin package


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/af06b162
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/af06b162
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/af06b162

Branch: refs/heads/master
Commit: af06b162919fd10d9caca907c84e58c2a0a13247
Parents: db39c35
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Mon Jul 15 20:28:21 2013 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Mon Jul 15 20:28:21 2013 -0400

----------------------------------------------------------------------
 .../maven/plugin/AbstractAccumuloMojo.java      | 42 ----------
 .../org/accumulo/maven/plugin/StartMojo.java    | 67 ---------------
 .../org/accumulo/maven/plugin/StopMojo.java     | 45 ----------
 .../maven/plugin/AbstractAccumuloMojo.java      | 49 +++++++++++
 .../apache/accumulo/maven/plugin/StartMojo.java | 88 ++++++++++++++++++++
 .../apache/accumulo/maven/plugin/StopMojo.java  | 45 ++++++++++
 pom.xml                                         |  5 ++
 test/pom.xml                                    | 59 +++++++++++++
 8 files changed, 246 insertions(+), 154 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/maven-plugin/src/main/java/org/accumulo/maven/plugin/AbstractAccumuloMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugin/src/main/java/org/accumulo/maven/plugin/AbstractAccumuloMojo.java
b/maven-plugin/src/main/java/org/accumulo/maven/plugin/AbstractAccumuloMojo.java
deleted file mode 100644
index 2ffcd29..0000000
--- a/maven-plugin/src/main/java/org/accumulo/maven/plugin/AbstractAccumuloMojo.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.accumulo.maven.plugin;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugins.annotations.Parameter;
-
-public abstract class AbstractAccumuloMojo extends AbstractMojo {
-  
-  @Parameter(defaultValue = "${plugin.artifacts}", readonly = true, required = true)
-  private List<Artifact> pluginArtifacts;
-  
-  void configureMiniClasspath() {
-    for (Artifact artifact : pluginArtifacts) {
-      try {
-        System.setProperty("java.class.path", System.getProperty("java.class.path", "") +
File.pathSeparator + artifact.getFile().toURI().toURL());
-      } catch (MalformedURLException e) {
-        e.printStackTrace();
-      }
-    }
-    
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/maven-plugin/src/main/java/org/accumulo/maven/plugin/StartMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugin/src/main/java/org/accumulo/maven/plugin/StartMojo.java b/maven-plugin/src/main/java/org/accumulo/maven/plugin/StartMojo.java
deleted file mode 100644
index fc0d716..0000000
--- a/maven-plugin/src/main/java/org/accumulo/maven/plugin/StartMojo.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.accumulo.maven.plugin;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.accumulo.minicluster.MiniAccumuloCluster;
-import org.apache.accumulo.minicluster.MiniAccumuloConfig;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-
-/**
- * Goal which starts an instance of {@link MiniAccumuloCluster}.
- */
-@Mojo(name = "start", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution
= ResolutionScope.TEST)
-public class StartMojo extends AbstractAccumuloMojo {
-  
-  @Parameter(defaultValue = "${project.build.directory}", property = "outputDir", required
= true)
-  private File outputDirectory;
-  
-  @Parameter(defaultValue = "testInstance", property = "instanceName", required = true)
-  private String instanceName;
-  
-  @Parameter(defaultValue = "secret", property = "rootPassword", required = true)
-  private String rootPassword = "secret";
-  
-  static Set<MiniAccumuloCluster> runningClusters = Collections.synchronizedSet(new
HashSet<MiniAccumuloCluster>());
-  
-  @Override
-  public void execute() throws MojoExecutionException {
-    File subdir = new File(new File(outputDirectory, "accumulo-maven-plugin"), instanceName);
-    subdir.mkdirs();
-    
-    try {
-      configureMiniClasspath();
-      MiniAccumuloConfig cfg = new MiniAccumuloConfig(subdir, rootPassword);
-      cfg.setInstanceName(instanceName);
-      MiniAccumuloCluster mac = new MiniAccumuloCluster(cfg);
-      System.out.println("Starting MiniAccumuloCluster: " + mac.getInstanceName());
-      mac.start();
-      runningClusters.add(mac);
-    } catch (Exception e) {
-      throw new MojoExecutionException("Unable to start " + MiniAccumuloCluster.class.getSimpleName(),
e);
-    }
-    
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/maven-plugin/src/main/java/org/accumulo/maven/plugin/StopMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugin/src/main/java/org/accumulo/maven/plugin/StopMojo.java b/maven-plugin/src/main/java/org/accumulo/maven/plugin/StopMojo.java
deleted file mode 100644
index 84c2a6c..0000000
--- a/maven-plugin/src/main/java/org/accumulo/maven/plugin/StopMojo.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.accumulo.maven.plugin;
-
-import org.apache.accumulo.minicluster.MiniAccumuloCluster;
-import org.apache.accumulo.minicluster.MiniAccumuloCluster.LogWriter;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-
-/**
- * Goal which stops all instances of {@link MiniAccumuloCluster} started with the start mojo.
- */
-@Mojo(name = "stop", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST, requiresDependencyResolution
= ResolutionScope.TEST)
-public class StopMojo extends AbstractAccumuloMojo {
-  
-  @Override
-  public void execute() throws MojoExecutionException {
-    for (MiniAccumuloCluster mac : StartMojo.runningClusters) {
-      System.out.println("Stopping MiniAccumuloCluster: " + mac.getInstanceName());
-      try {
-        mac.stop();
-        for (LogWriter log : mac.getLogWriters())
-          log.flush();
-      } catch (Exception e) {
-        throw new MojoExecutionException("Unable to start " + MiniAccumuloCluster.class.getSimpleName(),
e);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java
b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java
new file mode 100644
index 0000000..7eb4acb
--- /dev/null
+++ b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/AbstractAccumuloMojo.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.maven.plugin;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+public abstract class AbstractAccumuloMojo extends AbstractMojo {
+  
+  @Parameter(defaultValue = "${plugin.artifacts}", readonly = true, required = true)
+  private List<Artifact> pluginArtifacts;
+  
+  void configureMiniClasspath(String miniClasspath) {
+    String classpath = "";
+    if (miniClasspath == null && pluginArtifacts != null) {
+      String sep = "";
+      for (Artifact artifact : pluginArtifacts) {
+        try {
+          classpath += sep + artifact.getFile().toURI().toURL();
+          sep = File.pathSeparator;
+        } catch (MalformedURLException e) {
+          e.printStackTrace();
+        }
+      }
+    } else if (miniClasspath != null && !miniClasspath.isEmpty()) {
+      classpath = miniClasspath;
+    }
+    System.setProperty("java.class.path", System.getProperty("java.class.path", "") + File.pathSeparator
+ classpath);
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java
new file mode 100644
index 0000000..075ba8e
--- /dev/null
+++ b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StartMojo.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.maven.plugin;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.accumulo.minicluster.MiniAccumuloCluster;
+import org.apache.accumulo.minicluster.MiniAccumuloConfig;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+/**
+ * Goal which starts an instance of {@link MiniAccumuloCluster}.
+ */
+@Mojo(name = "start", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution
= ResolutionScope.TEST)
+public class StartMojo extends AbstractAccumuloMojo {
+  
+  @Parameter(defaultValue = "${project.build.directory}", property = "outputDir", required
= true)
+  private File outputDirectory;
+  
+  @Parameter(defaultValue = "testInstance", property = "instanceName", required = true)
+  private String instanceName;
+  
+  @Parameter(defaultValue = "secret", property = "rootPassword", required = true)
+  private String rootPassword;
+  
+  private String miniClasspath;
+  
+  static Set<MiniAccumuloCluster> runningClusters = Collections.synchronizedSet(new
HashSet<MiniAccumuloCluster>());
+  
+  @Override
+  public void execute() throws MojoExecutionException {
+    File subdir = new File(new File(outputDirectory, "accumulo-maven-plugin"), instanceName);
+    
+    try {
+      subdir = subdir.getCanonicalFile();
+      subdir.mkdirs();
+      configureMiniClasspath(miniClasspath);
+      MiniAccumuloConfig cfg = new MiniAccumuloConfig(subdir, rootPassword);
+      cfg.setInstanceName(instanceName);
+      MiniAccumuloCluster mac = new MiniAccumuloCluster(cfg);
+      System.out.println("Starting MiniAccumuloCluster: " + mac.getInstanceName() + " in
" + mac.getConfig().getDir());
+      mac.start();
+      runningClusters.add(mac);
+    } catch (Exception e) {
+      throw new MojoExecutionException("Unable to start " + MiniAccumuloCluster.class.getSimpleName(),
e);
+    }
+    
+  }
+  
+  public static void main(String[] args) throws MojoExecutionException {
+    int a = 0;
+    for (String arg : args) {
+      if (a < 2) {
+        // skip the first two args
+        a++;
+        continue;
+      }
+      StartMojo starter = new StartMojo();
+      starter.outputDirectory = new File(args[0]);
+      String[] instArgs = arg.split(" ");
+      starter.instanceName = instArgs[0];
+      starter.rootPassword = instArgs[1];
+      starter.miniClasspath = args[1];
+      starter.execute();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java
new file mode 100644
index 0000000..ae1b7c0
--- /dev/null
+++ b/maven-plugin/src/main/java/org/apache/accumulo/maven/plugin/StopMojo.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.maven.plugin;
+
+import org.apache.accumulo.minicluster.MiniAccumuloCluster;
+import org.apache.accumulo.minicluster.MiniAccumuloCluster.LogWriter;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+/**
+ * Goal which stops all instances of {@link MiniAccumuloCluster} started with the start mojo.
+ */
+@Mojo(name = "stop", defaultPhase = LifecyclePhase.POST_INTEGRATION_TEST, requiresDependencyResolution
= ResolutionScope.TEST)
+public class StopMojo extends AbstractAccumuloMojo {
+  
+  @Override
+  public void execute() throws MojoExecutionException {
+    for (MiniAccumuloCluster mac : StartMojo.runningClusters) {
+      System.out.println("Stopping MiniAccumuloCluster: " + mac.getInstanceName());
+      try {
+        mac.stop();
+        for (LogWriter log : mac.getLogWriters())
+          log.flush();
+      } catch (Exception e) {
+        throw new MojoExecutionException("Unable to start " + MiniAccumuloCluster.class.getSimpleName(),
e);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 905e4e7..73f8454 100644
--- a/pom.xml
+++ b/pom.xml
@@ -229,6 +229,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.accumulo</groupId>
+        <artifactId>accumulo-maven-plugin</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.accumulo</groupId>
         <artifactId>accumulo-minicluster</artifactId>
         <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/af06b162/test/pom.xml
----------------------------------------------------------------------
diff --git a/test/pom.xml b/test/pom.xml
index 18ee842..9bf9dcf 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -122,6 +122,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-maven-plugin</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>jetty</artifactId>
       <scope>test</scope>
@@ -145,6 +150,60 @@
   </build>
   <profiles>
     <profile>
+      <id>shared-mini-for-it</id>
+      <activation>
+        <property>
+          <name>!skipITs</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>setup-mini-classpath</id>
+                <goals>
+                  <goal>build-classpath</goal>
+                </goals>
+                <phase>pre-integration-test</phase>
+                <configuration>
+                  <includeScope>test</includeScope>
+                  <outputProperty>accumulo-it-mini-classpath</outputProperty>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>run-mini-for-integration-tests</id>
+                <goals>
+                  <goal>java</goal>
+                </goals>
+                <phase>pre-integration-test</phase>
+                <configuration>
+                  <mainClass>org.apache.accumulo.maven.plugin.StartMojo</mainClass>
+                  <classpathScope>test</classpathScope>
+                  <arguments>
+                    <!-- These first two should stay static -->
+                    <argument>${project.build.directory}</argument>
+                    <argument>${accumulo-it-mini-classpath}</argument>
+                    <!-- InstanceName RootPassword, one pair per MiniAccumuloCluster -->
+                    <argument>testInstance1 rootPassword1</argument>
+                    <argument>testInstance2 rootPassword2</argument>
+                  </arguments>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
       <!-- profile for building against Hadoop 1.0.x
       Activate by not specifying hadoop.profile -->
       <id>hadoop-1.0</id>


Mime
View raw message