You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2015/06/01 19:37:45 UTC
[2/4] accumulo git commit: ACCUMULO-3871 added a small m/r job that
can read tests from a file, and execute them
ACCUMULO-3871 added a small m/r job that can read tests from a file, and execute them
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/93cc4a1d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/93cc4a1d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/93cc4a1d
Branch: refs/heads/master
Commit: 93cc4a1dff255ed196efc8ed100f327e77226221
Parents: e97709a
Author: Eric C. Newton <er...@gmail.com>
Authored: Fri May 29 17:19:50 2015 -0400
Committer: Eric C. Newton <er...@gmail.com>
Committed: Fri May 29 17:19:50 2015 -0400
----------------------------------------------------------------------
assemble/pom.xml | 11 ++
test/pom.xml | 24 ++++
.../accumulo/test/IntegrationTestMapReduce.java | 113 +++++++++++++++++++
.../test/functional/ConfigurableMacIT.java | 4 +-
4 files changed, 151 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/93cc4a1d/assemble/pom.xml
----------------------------------------------------------------------
diff --git a/assemble/pom.xml b/assemble/pom.xml
index b965fe6..525b443 100644
--- a/assemble/pom.xml
+++ b/assemble/pom.xml
@@ -223,6 +223,17 @@
</build>
<profiles>
<profile>
+ <id>test-jar</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.accumulo</groupId>
+ <artifactId>accumulo-test</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
<id>apache-release</id>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/93cc4a1d/test/pom.xml
----------------------------------------------------------------------
diff --git a/test/pom.xml b/test/pom.xml
index f943eed..516461b 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -183,6 +183,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
@@ -235,6 +240,25 @@
</build>
<profiles>
<profile>
+ <id>test-jar</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-test-jar</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>shared-mini-for-it</id>
<!--
<activation>
http://git-wip-us.apache.org/repos/asf/accumulo/blob/93cc4a1d/test/src/test/java/org/apache/accumulo/test/IntegrationTestMapReduce.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/IntegrationTestMapReduce.java b/test/src/test/java/org/apache/accumulo/test/IntegrationTestMapReduce.java
new file mode 100644
index 0000000..6b9e82e
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/IntegrationTestMapReduce.java
@@ -0,0 +1,113 @@
+/*
+ * 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.test;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.Reducer;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.input.NLineInputFormat;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IntegrationTestMapReduce extends Configured implements Tool {
+
+ private static final Logger log = LoggerFactory.getLogger(IntegrationTestMapReduce.class);
+
+ public static class TestMapper extends Mapper<LongWritable,Text,IntWritable,Text> {
+
+ @Override
+ protected void map(LongWritable key, Text value, Mapper<LongWritable,Text,IntWritable,Text>.Context context) throws IOException, InterruptedException {
+ String className = value.toString();
+ Class<? extends Object> test = null;
+ try {
+ test = Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ log.debug("Error finding class {}", className, e);
+ context.write(new IntWritable(-1), new Text(e.toString()));
+ }
+ JUnitCore core = new JUnitCore();
+ log.info("Running test {}", className);
+ Result result = core.run(test);
+ if (result.wasSuccessful()) {
+ log.info("{} was successful", className);
+ context.write(new IntWritable(0), value);
+ } else {
+ log.info("{} failed", className);
+ context.write(new IntWritable(1), value);
+ }
+ }
+ }
+
+ public static class TestReducer extends Reducer<IntWritable,Text,IntWritable,Text> {
+
+ @Override
+ protected void reduce(IntWritable code, Iterable<Text> tests, Reducer<IntWritable,Text,IntWritable,Text>.Context context) throws IOException,
+ InterruptedException {
+ StringBuffer result = new StringBuffer();
+ for (Text test : tests) {
+ result.append(test);
+ result.append("\n");
+ }
+ context.write(code, new Text(result.toString()));
+ }
+ }
+
+ @Override
+ public int run(String[] args) throws Exception {
+ // read a list of tests from the input, and print out the results
+ if (args.length != 2) {
+ System.err.println("Wrong number of args: <input> <output>");
+ }
+ Configuration conf = getConf();
+ Job job = Job.getInstance(conf, "accumulo integration test runner");
+ // read one line at a time
+ job.setInputFormatClass(NLineInputFormat.class);
+ conf.setInt(NLineInputFormat.LINES_PER_MAP, 1);
+
+ // run the test
+ job.setJarByClass(IntegrationTestMapReduce.class);
+ job.setMapperClass(TestMapper.class);
+
+ // group test by result code
+ job.setReducerClass(TestReducer.class);
+ job.setOutputKeyClass(IntWritable.class);
+ job.setOutputValueClass(Text.class);
+
+ FileInputFormat.addInputPath(job, new Path(args[0]));
+ FileOutputFormat.setOutputPath(job, new Path(args[1]));
+ return job.waitForCompletion(true) ? 0 : 1;
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.exit(ToolRunner.run(new IntegrationTestMapReduce(), args));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/93cc4a1d/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableMacIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableMacIT.java b/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableMacIT.java
index 53eb8e4..a738d1f 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableMacIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/ConfigurableMacIT.java
@@ -127,7 +127,9 @@ public class ConfigurableMacIT extends AccumuloIT {
// createTestDir will give us a empty directory, we don't need to clean it up ourselves
File baseDir = createTestDir(this.getClass().getName() + "_" + this.testName.getMethodName());
MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(baseDir, ROOT_PASSWORD);
- cfg.setNativeLibPaths(NativeMapIT.nativeMapLocation().getAbsolutePath());
+ String nativePathInDevTree = NativeMapIT.nativeMapLocation().getAbsolutePath();
+ String nativePathInMapReduce = new File(System.getProperty("user.dir")).toString();
+ cfg.setNativeLibPaths(nativePathInDevTree, nativePathInMapReduce);
cfg.setProperty(Property.GC_FILE_ARCHIVE, Boolean.TRUE.toString());
Configuration coreSite = new Configuration(false);
configure(cfg, coreSite);