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 br...@apache.org on 2018/11/21 19:06:40 UTC
[26/50] [abbrv] hadoop git commit: HDDS-164. Add unit test for
HddsDatanodeService. Contributed by Yiqun Lin.
HDDS-164. Add unit test for HddsDatanodeService. Contributed by Yiqun Lin.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/0123e519
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/0123e519
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/0123e519
Branch: refs/heads/HDFS-13891
Commit: 0123e5197b4e355dd4a5d97962ec64d3768a8479
Parents: 4ecdcc9
Author: Márton Elek <el...@apache.org>
Authored: Tue Nov 20 15:49:16 2018 +0100
Committer: Márton Elek <el...@apache.org>
Committed: Tue Nov 20 15:49:48 2018 +0100
----------------------------------------------------------------------
.../hadoop/ozone/TestHddsDatanodeService.java | 95 ++++++++++++++++++++
1 file changed, 95 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/0123e519/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/TestHddsDatanodeService.java
----------------------------------------------------------------------
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/TestHddsDatanodeService.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/TestHddsDatanodeService.java
new file mode 100644
index 0000000..18cd00c
--- /dev/null
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/TestHddsDatanodeService.java
@@ -0,0 +1,95 @@
+/**
+ * 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.ozone;
+
+import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ENABLED;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.hdds.HddsConfigKeys;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.ServicePlugin;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test class for {@link HddsDatanodeService}.
+ */
+public class TestHddsDatanodeService {
+ private File testDir;
+ private Configuration conf;
+ private HddsDatanodeService service;
+
+ @Before
+ public void setUp() {
+ testDir = GenericTestUtils.getRandomizedTestDir();
+ conf = new OzoneConfiguration();
+ conf.setBoolean(OZONE_ENABLED, true);
+ conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getPath());
+ conf.setClass(OzoneConfigKeys.HDDS_DATANODE_PLUGINS_KEY, MockService.class,
+ ServicePlugin.class);
+
+ String volumeDir = testDir + "/disk1";
+ conf.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, volumeDir);
+ }
+
+ @After
+ public void tearDown() {
+ FileUtil.fullyDelete(testDir);
+ }
+
+ @Test
+ public void testStartup() throws IOException {
+ service = HddsDatanodeService.createHddsDatanodeService(conf);
+ service.start(null);
+ service.join();
+
+ assertNotNull(service.getDatanodeDetails());
+ assertNotNull(service.getDatanodeDetails().getHostName());
+ assertFalse(service.getDatanodeStateMachine().isDaemonStopped());
+
+ service.stop();
+ service.close();
+ }
+
+ static class MockService implements ServicePlugin {
+
+ @Override
+ public void close() throws IOException {
+ // Do nothing
+ }
+
+ @Override
+ public void start(Object arg0) {
+ // Do nothing
+ }
+
+ @Override
+ public void stop() {
+ // Do nothing
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org