You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2013/03/31 06:28:04 UTC
svn commit: r1462876 - in
/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol:
./ TestLayoutVersion.java
Author: suresh
Date: Sun Mar 31 04:28:03 2013
New Revision: 1462876
URL: http://svn.apache.org/r1462876
Log:
HDFS-4651. Adding missed files in the previous commit.
Added:
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol/
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol/TestLayoutVersion.java
Added: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol/TestLayoutVersion.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol/TestLayoutVersion.java?rev=1462876&view=auto
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol/TestLayoutVersion.java (added)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/hdfs/protocol/TestLayoutVersion.java Sun Mar 31 04:28:03 2013
@@ -0,0 +1,86 @@
+/**
+ * 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.hadoop.hdfs.protocol;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.EnumSet;
+
+import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature;
+import org.junit.Test;
+
+/**
+ * Test for {@link LayoutVersion}
+ */
+public class TestLayoutVersion {
+
+ /**
+ * Tests to make sure a given layout version supports all the
+ * features from the ancestor
+ */
+ @Test
+ public void testFeaturesFromAncestorSupported() {
+ for (Feature f : Feature.values()) {
+ validateFeatureList(f);
+ }
+ }
+
+ /**
+ * Test to make sure 0.20.203 supports delegation token
+ */
+ @Test
+ public void testRelease203() {
+ assertTrue(LayoutVersion.supports(Feature.DELEGATION_TOKEN,
+ Feature.RESERVED_REL20_203.lv));
+ }
+
+ /**
+ * Test to make sure 0.20.204 supports delegation token
+ */
+ @Test
+ public void testRelease204() {
+ assertTrue(LayoutVersion.supports(Feature.DELEGATION_TOKEN,
+ Feature.RESERVED_REL20_204.lv));
+ }
+
+ /**
+ * Test to make sure release 1.2.0 support CONCAT
+ */
+ @Test
+ public void testRelease1_2_0() {
+ assertTrue(LayoutVersion.supports(Feature.CONCAT,
+ Feature.RESERVED_REL1_2_0.lv));
+ }
+
+ /**
+ * Given feature {@code f}, ensures the layout version of that feature
+ * supports all the features supported by it's ancestor.
+ */
+ private void validateFeatureList(Feature f) {
+ int lv = f.lv;
+ int ancestorLV = f.ancestorLV;
+ EnumSet<Feature> ancestorSet = LayoutVersion.map.get(ancestorLV);
+ assertNotNull(ancestorSet);
+ for (Feature feature : ancestorSet) {
+ assertTrue("LV " + lv + " does nto support " + feature
+ + " supported by the ancestor LV " + f.ancestorLV,
+ LayoutVersion.supports(feature, lv));
+ }
+ }
+}