accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [2/3] accumulo git commit: ACCUMULO-3948 Prevent test jar from being deployed
Date Fri, 26 Aug 2016 18:24:19 GMT
ACCUMULO-3948 Prevent test jar from being deployed

Use maven-assembly-plugin to create test jar instead of
maven-jar-plugin, which attaches the jar for deployment.

Moves creation of the plugin to earlier phase of the build
(ACCUMULO-4058).

Prefer the use of the maven build directory over the system temp
directory for temporary files.


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

Branch: refs/heads/master
Commit: b08c4b9116f201148af22f69e7c3022c0c597e4b
Parents: d7c50d1
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Fri Aug 26 14:20:45 2016 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Fri Aug 26 14:20:45 2016 -0400

----------------------------------------------------------------------
 test/pom.xml                                    | 40 ++++++-------
 .../org/apache/accumulo/test/ShellServerIT.java | 14 +++--
 .../test/functional/ScannerContextIT.java       | 59 +++++++-------------
 test/src/main/test-jars/Iterators.xml           | 36 ++++++++++++
 4 files changed, 84 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/b08c4b91/test/pom.xml
----------------------------------------------------------------------
diff --git a/test/pom.xml b/test/pom.xml
index 92aeeaf..422543a 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -239,26 +239,6 @@
             </systemPropertyVariables>
           </configuration>
         </plugin>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-jar-plugin</artifactId>
-          <executions>
-            <execution>
-              <id>create-iterator-test-jar</id>
-              <goals>
-                <goal>test-jar</goal>
-              </goals>
-              <phase>pre-integration-test</phase>
-              <configuration>
-                <finalName>TestIterators</finalName>
-                <classifier />
-                <includes>
-                  <include>org/apache/accumulo/test/functional/ValueReversingIterator.class</include>
-                </includes>
-              </configuration>
-            </execution>
-          </executions>
-        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>
@@ -282,6 +262,26 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>create-iterator-test-jar</id>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <attach>false</attach>
+              <finalName>TestJar</finalName>
+              <descriptors>
+                <descriptor>src/main/test-jars/Iterators.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   <profiles>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/b08c4b91/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
index 8db0185..6746198 100644
--- a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
@@ -64,8 +64,8 @@ import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.format.Formatter;
 import org.apache.accumulo.core.util.format.FormatterConfig;
-import org.apache.accumulo.harness.SharedMiniClusterBase;
 import org.apache.accumulo.harness.MiniClusterConfigurationCallback;
+import org.apache.accumulo.harness.SharedMiniClusterBase;
 import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.shell.Shell;
 import org.apache.accumulo.test.functional.SlowIterator;
@@ -1790,22 +1790,24 @@ public class ShellServerIT extends SharedMiniClusterBase {
   }
 
   private static final String FAKE_CONTEXT = "FAKE";
-  private static final String FAKE_CONTEXT_CLASSPATH = "file:///tmp/ShellServerIT-iterators.jar";
+  private static final String FAKE_CONTEXT_CLASSPATH = "file://" + System.getProperty("user.dir")
+ "/target/" + ShellServerIT.class.getSimpleName()
+      + "-fake-iterators.jar";
   private static final String REAL_CONTEXT = "REAL";
-  private static final String REAL_CONTEXT_CLASSPATH = "file:///tmp/TestIterators-tests.jar";
+  private static final String REAL_CONTEXT_CLASSPATH = "file://" + System.getProperty("user.dir")
+ "/target/" + ShellServerIT.class.getSimpleName()
+      + "-real-iterators.jar";
 
   private void setupRealContextPath() throws Exception {
-    // Copy the TestIterators jar to tmp
+    // Copy the test iterators jar to tmp
     Path baseDir = new Path(System.getProperty("user.dir"));
     Path targetDir = new Path(baseDir, "target");
-    Path jarPath = new Path(targetDir, "TestIterators-tests.jar");
+    Path jarPath = new Path(targetDir, "TestJar-Iterators.jar");
     Path dstPath = new Path(REAL_CONTEXT_CLASSPATH);
     FileSystem fs = SharedMiniClusterBase.getCluster().getFileSystem();
     fs.copyFromLocalFile(jarPath, dstPath);
   }
 
   private void setupFakeContextPath() throws Exception {
-    // Copy the TestIterators jar to tmp
+    // Copy the test iterators jar to tmp
     Path baseDir = new Path(System.getProperty("user.dir"));
     Path targetDir = new Path(baseDir, "target");
     Path classesDir = new Path(targetDir, "classes");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/b08c4b91/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
index 91c066f..579881e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map.Entry;
@@ -52,7 +53,7 @@ public class ScannerContextIT extends AccumuloClusterHarness {
 
   private static final String CONTEXT = ScannerContextIT.class.getSimpleName();
   private static final String CONTEXT_PROPERTY = Property.VFS_CONTEXT_CLASSPATH_PROPERTY
+ CONTEXT;
-  private static final String CONTEXT_DIR = "file:///tmp";
+  private static final String CONTEXT_DIR = "file://" + System.getProperty("user.dir") +
"/target";
   private static final String CONTEXT_CLASSPATH = CONTEXT_DIR + "/Test.jar";
   private static int ITERATIONS = 10;
   private static final long WAIT = 7000;
@@ -71,20 +72,24 @@ public class ScannerContextIT extends AccumuloClusterHarness {
     fs = FileSystem.get(CachedConfiguration.getInstance());
   }
 
-  @Test
-  public void test() throws Exception {
-    // Copy the TestIterators jar to tmp
+  private Path copyTestIteratorsJarToTmp() throws IOException {
+    // Copy the test iterators jar to tmp
     Path baseDir = new Path(System.getProperty("user.dir"));
     Path targetDir = new Path(baseDir, "target");
-    Path jarPath = new Path(targetDir, "TestIterators-tests.jar");
+    Path jarPath = new Path(targetDir, "TestJar-Iterators.jar");
     Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
     fs.copyFromLocalFile(jarPath, dstPath);
     // Sleep to ensure jar change gets picked up
     UtilWaitThread.sleep(WAIT);
+    return dstPath;
+  }
 
+  @Test
+  public void test() throws Exception {
+    Path dstPath = copyTestIteratorsJarToTmp();
     try {
       Connector c = getConnector();
-      // Set the classloader context property on the table to point to the TestIterators
jar file.
+      // Set the classloader context property on the table to point to the test iterators
jar file.
       c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
 
       // Insert rows with the word "Test" in the value.
@@ -101,7 +106,7 @@ public class ScannerContextIT extends AccumuloClusterHarness {
       scanCheck(c, tableName, null, null, "Test");
       batchCheck(c, tableName, null, null, "Test");
 
-      // This iterator is in the TestIterators jar file
+      // This iterator is in the test iterators jar file
       IteratorSetting cfg = new IteratorSetting(21, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
 
       // Check that ValueReversingIterator is not already on the classpath by not setting
the context. This should fail.
@@ -129,22 +134,14 @@ public class ScannerContextIT extends AccumuloClusterHarness {
 
   @Test
   public void testScanContextOverridesTableContext() throws Exception {
-    // Copy the TestIterators jar to tmp
-    Path baseDir = new Path(System.getProperty("user.dir"));
-    Path targetDir = new Path(baseDir, "target");
-    Path jarPath = new Path(targetDir, "TestIterators-tests.jar");
-    Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
-    fs.copyFromLocalFile(jarPath, dstPath);
-    // Sleep to ensure jar change gets picked up
-    UtilWaitThread.sleep(WAIT);
-
+    Path dstPath = copyTestIteratorsJarToTmp();
     try {
       Connector c = getConnector();
       // Create two contexts FOO and ScanContextIT. The FOO context will point to a classpath
-      // that contains nothing. The ScanContextIT context will point to the TestIterators.jar
+      // that contains nothing. The ScanContextIT context will point to the test iterators
jar
       String tableContext = "FOO";
       String tableContextProperty = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + tableContext;
-      String tableContextDir = "file:///tmp";
+      String tableContextDir = "file://" + System.getProperty("user.dir") + "/target";
       String tableContextClasspath = tableContextDir + "/TestFoo.jar";
       // Define both contexts
       c.instanceOperations().setProperty(tableContextProperty, tableContextClasspath);
@@ -163,7 +160,7 @@ public class ScannerContextIT extends AccumuloClusterHarness {
       bw.close();
       scanCheck(c, tableName, null, null, "Test");
       batchCheck(c, tableName, null, null, "Test");
-      // This iterator is in the TestIterators jar file
+      // This iterator is in the test iterators jar file
       IteratorSetting cfg = new IteratorSetting(21, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
 
       // Check that ValueReversingIterator is not already on the classpath by not setting
the context. This should fail.
@@ -192,18 +189,10 @@ public class ScannerContextIT extends AccumuloClusterHarness {
 
   @Test
   public void testOneScannerDoesntInterfereWithAnother() throws Exception {
-    // Copy the TestIterators jar to tmp
-    Path baseDir = new Path(System.getProperty("user.dir"));
-    Path targetDir = new Path(baseDir, "target");
-    Path jarPath = new Path(targetDir, "TestIterators-tests.jar");
-    Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
-    fs.copyFromLocalFile(jarPath, dstPath);
-    // Sleep to ensure jar change gets picked up
-    UtilWaitThread.sleep(WAIT);
-
+    Path dstPath = copyTestIteratorsJarToTmp();
     try {
       Connector c = getConnector();
-      // Set the classloader context property on the table to point to the TestIterators
jar file.
+      // Set the classloader context property on the table to point to the test iterators
jar file.
       c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
 
       // Insert rows with the word "Test" in the value.
@@ -247,18 +236,10 @@ public class ScannerContextIT extends AccumuloClusterHarness {
 
   @Test
   public void testClearContext() throws Exception {
-    // Copy the TestIterators jar to tmp
-    Path baseDir = new Path(System.getProperty("user.dir"));
-    Path targetDir = new Path(baseDir, "target");
-    Path jarPath = new Path(targetDir, "TestIterators-tests.jar");
-    Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
-    fs.copyFromLocalFile(jarPath, dstPath);
-    // Sleep to ensure jar change gets picked up
-    UtilWaitThread.sleep(WAIT);
-
+    Path dstPath = copyTestIteratorsJarToTmp();
     try {
       Connector c = getConnector();
-      // Set the classloader context property on the table to point to the TestIterators
jar file.
+      // Set the classloader context property on the table to point to the test iterators
jar file.
       c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
 
       // Insert rows with the word "Test" in the value.

http://git-wip-us.apache.org/repos/asf/accumulo/blob/b08c4b91/test/src/main/test-jars/Iterators.xml
----------------------------------------------------------------------
diff --git a/test/src/main/test-jars/Iterators.xml b/test/src/main/test-jars/Iterators.xml
new file mode 100644
index 0000000..f074720
--- /dev/null
+++ b/test/src/main/test-jars/Iterators.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>Iterators</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.directory}/test-classes</directory>
+      <outputDirectory>./</outputDirectory>
+      <directoryMode>0755</directoryMode>
+      <fileMode>0644</fileMode>
+      <includes>
+        <include>**/ValueReversingIterator.class</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>


Mime
View raw message