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 in...@apache.org on 2018/05/03 18:28:07 UTC
[5/5] hadoop git commit: HDFS-13525. RBF: Add unit test
TestStateStoreDisabledNameservice. Contributed by Yiqun Lin.
HDFS-13525. RBF: Add unit test TestStateStoreDisabledNameservice. Contributed by Yiqun Lin.
(cherry picked from commit a3b416f69dc3965f247603f657df33bd74fd723e)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4f75d228
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4f75d228
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4f75d228
Branch: refs/heads/branch-2.9
Commit: 4f75d228e8f446994aded1549630eaf38533e31e
Parents: e5f47da
Author: Inigo Goiri <in...@apache.org>
Authored: Thu May 3 11:24:57 2018 -0700
Committer: Inigo Goiri <in...@apache.org>
Committed: Thu May 3 11:27:10 2018 -0700
----------------------------------------------------------------------
.../TestStateStoreDisabledNameservice.java | 71 ++++++++++++++++++++
1 file changed, 71 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4f75d228/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/TestStateStoreDisabledNameservice.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/TestStateStoreDisabledNameservice.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/TestStateStoreDisabledNameservice.java
new file mode 100644
index 0000000..353510a
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/TestStateStoreDisabledNameservice.java
@@ -0,0 +1,71 @@
+/**
+ * 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.server.federation.store;
+
+import static org.apache.hadoop.hdfs.server.federation.store.FederationStateStoreTestUtils.clearRecords;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.hadoop.hdfs.server.federation.store.records.DisabledNameservice;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test the basic {@link StateStoreService}
+ * {@link DisabledNameserviceStore} functionality.
+ */
+public class TestStateStoreDisabledNameservice extends TestStateStoreBase {
+
+ private static DisabledNameserviceStore disabledStore;
+
+ @Before
+ public void setup() throws IOException, InterruptedException {
+ disabledStore = getStateStore()
+ .getRegisteredRecordStore(DisabledNameserviceStore.class);
+ // Clear disabled nameservice registrations
+ assertTrue(clearRecords(getStateStore(), DisabledNameservice.class));
+ }
+
+ @Test
+ public void testDisableNameservice() throws IOException {
+ // no nameservices disabled firstly
+ Set<String> disabledNameservices = disabledStore.getDisabledNameservices();
+ assertEquals(0, disabledNameservices.size());
+
+ // disable two nameservices
+ disabledStore.disableNameservice("ns0");
+ disabledStore.disableNameservice("ns1");
+ disabledStore.loadCache(true);
+ // verify if the nameservices are disabled
+ disabledNameservices = disabledStore.getDisabledNameservices();
+ assertEquals(2, disabledNameservices.size());
+ assertTrue(disabledNameservices.contains("ns0")
+ && disabledNameservices.contains("ns1"));
+
+ // enable one nameservice
+ disabledStore.enableNameservice("ns0");
+ disabledStore.loadCache(true);
+ // verify the disabled nameservice again
+ disabledNameservices = disabledStore.getDisabledNameservices();
+ assertEquals(1, disabledNameservices.size());
+ assertTrue(disabledNameservices.contains("ns1"));
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org