You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/03/08 19:43:35 UTC

[2/2] git commit: ACCUMULO-2442 A basic IT that ensures that we write to all filesystems

ACCUMULO-2442 A basic IT that ensures that we write to all filesystems


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

Branch: refs/heads/ACCUMULO-2442
Commit: 2c41acd96525841d3cf897905b2155ca05cf1173
Parents: 073bbee
Author: Josh Elser <el...@apache.org>
Authored: Sat Mar 8 13:41:35 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Sat Mar 8 13:43:15 2014 -0500

----------------------------------------------------------------------
 .../accumulo/test/functional/MultiVolumeIT.java | 112 +++++++++++++++++++
 .../test/functional/MultiVolumeMacIT.java       |  91 +++++++++++++++
 2 files changed, 203 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2c41acd9/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeIT.java b/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeIT.java
new file mode 100644
index 0000000..adfe32f
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeIT.java
@@ -0,0 +1,112 @@
+/*
+ * 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.functional;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.admin.TableOperations;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class MultiVolumeIT extends MultiVolumeMacIT {
+
+  @Override
+  public int getNumFileSystems() {
+    return 2;
+  }
+
+  @Test
+  public void testCreateWriteDeleteLocalFs() throws Exception {
+    Connector c = getConnector();
+    TableOperations tops = c.tableOperations();
+
+    // This should be statistically significant (<5%) to ensure that all have files
+    for (int i = 0; i < 25; i++) {
+      final String tableName = testName.getMethodName() + i;
+      tops.create(tableName);
+      
+      BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+      for (int row = 0; row < 500; row++) {
+        // rows
+        Mutation m = new Mutation(Integer.toString(row));
+        for (int col = 0; col < 50; col++) {
+          m.put(Integer.toString(col), "", Integer.toString(row) + col);
+        }
+        
+        bw.addMutation(m);
+      }
+      
+      bw.close();
+      tops.compact(tableName, null, null, true, true);
+    }
+
+    File dir = cluster.getConfig().getDir();
+    File accumuloDir = new File(dir, "accumulo");
+    String[] volumeDirs = accumuloDir.list();
+    Assert.assertEquals(2, volumeDirs.length);
+    
+    for (String volume : volumeDirs) {
+      File volumeDir = new File(accumuloDir, volume);
+      Collection<File> rfiles = FileUtils.listFiles(volumeDir, new IOFileFilter() {
+
+        @Override
+        public boolean accept(File file) {
+          if (file.isFile()) {
+            return file.getName().endsWith(".rf");
+          } else {
+            return true;
+          }
+        }
+
+        @Override
+        public boolean accept(File dir, String name) {
+          return name.endsWith(".rf");
+        }
+        
+      }, new IOFileFilter() {
+
+        @Override
+        public boolean accept(File file) {
+          return true;
+        }
+
+        @Override
+        public boolean accept(File dir, String name) {
+          return true;
+        }
+        
+      });
+      
+      Assert.assertTrue("Found no rfiles in " + volumeDir, rfiles.size() > 0);
+    }
+    
+    for (int i = 0; i < 6; i++) {
+      tops.delete(testName.getMethodName() + i);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2c41acd9/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeMacIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeMacIT.java b/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeMacIT.java
new file mode 100644
index 0000000..b510d2f
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/functional/MultiVolumeMacIT.java
@@ -0,0 +1,91 @@
+/*
+ * 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.functional;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.minicluster.impl.MultiVolumeMiniAccumuloClusterImpl;
+import org.apache.hadoop.conf.Configuration;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * 
+ */
+public class MultiVolumeMacIT extends AbstractMacIT {
+  
+  public MultiVolumeMiniAccumuloClusterImpl cluster;
+  
+  public int getNumFileSystems() {
+    return 2;
+  }
+  
+  public boolean useMiniDfs() {
+    return false;
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    MiniAccumuloConfigImpl cfg = new MiniAccumuloConfigImpl(
+        createTestDir(this.getClass().getName() + "_" + this.testName.getMethodName()), ROOT_PASSWORD);
+    cfg.setNativeLibPaths(NativeMapIT.nativeMapLocation().getAbsolutePath());
+    
+    cfg.setNumFilesystems(getNumFileSystems());
+    cfg.useMiniDFS(useMiniDfs());
+    
+    Configuration coreSite = new Configuration(false);
+    cfg.setProperty(Property.TSERV_NATIVEMAP_ENABLED, Boolean.TRUE.toString());
+    
+    cluster = new MultiVolumeMiniAccumuloClusterImpl(cfg);
+    if (coreSite.size() > 0) {
+      File csFile = new File(cluster.getConfig().getConfDir(), "core-site.xml");
+      if (csFile.exists())
+        throw new RuntimeException(csFile + " already exist");
+
+      OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(cluster.getConfig().getConfDir(), "core-site.xml")));
+      coreSite.writeXml(out);
+      out.close();
+    }
+    cluster.start();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (cluster != null)
+      try {
+        cluster.stop();
+      } catch (Exception e) {}
+  }
+  
+  @Override
+  public Connector getConnector() throws AccumuloException, AccumuloSecurityException {
+    return cluster.getConnector("root", ROOT_PASSWORD);
+  }
+
+  @Override
+  public String rootPath() {
+    return cluster.getConfig().getDir().getAbsolutePath();
+  }
+}