You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/07/29 07:08:11 UTC

[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #102: [Improvement] Ignore partial failure on initializing local storage in shuffle server side

zuston commented on code in PR #102:
URL: https://github.com/apache/incubator-uniffle/pull/102#discussion_r932932697


##########
server/src/test/java/org/apache/uniffle/server/storage/LocalStorageManagerTest.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.uniffle.server.storage;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.IOException;
+import java.nio.file.Files;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.uniffle.server.ShuffleServerConf;
+import org.apache.uniffle.storage.common.LocalStorage;
+import org.apache.uniffle.storage.util.StorageType;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * The class is to test the {@link LocalStorageManager}
+ */
+public class LocalStorageManagerTest {
+
+  @Test
+  public void testInitializeLocalStorage() throws IOException {
+    String tmpDir1 = Files.createTempDirectory("rss-data1").toString();
+    String tmpDir2 = Files.createTempDirectory("rss-data2").toString();
+
+    // case1: when no candidates, it should throw exception.
+    ShuffleServerConf conf = new ShuffleServerConf();
+    conf.setLong(ShuffleServerConf.FLUSH_COLD_STORAGE_THRESHOLD_SIZE, 2000L);
+    conf.setString(ShuffleServerConf.RSS_STORAGE_BASE_PATH, tmpDir1 + "," + tmpDir2);
+    conf.setLong(ShuffleServerConf.DISK_CAPACITY, 1024L);
+    MockedLocalStorageBuilder.setErrorPath(Arrays.asList(tmpDir1, tmpDir2));
+    conf.setString(ShuffleServerConf.RSS_STORAGE_TYPE, StorageType.MEMORY_LOCALFILE_HDFS.name());
+    try {
+      LocalStorageManager localStorageManager = new LocalStorageManager(conf, new MockedLocalStorageBuilder());
+      fail();
+    } catch (Exception e) {
+      // ignore
+    }
+
+    // case2: when candidates exist, it should initialize successfully.
+    MockedLocalStorageBuilder.setErrorPath(Arrays.asList(tmpDir1));
+    LocalStorageManager localStorageManager = new LocalStorageManager(conf, new MockedLocalStorageBuilder());
+    assertEquals(1, localStorageManager.getStorages().size());
+
+    // case3: all ok
+    MockedLocalStorageBuilder.setErrorPath(Collections.EMPTY_LIST);
+    localStorageManager = new LocalStorageManager(conf, new MockedLocalStorageBuilder());
+    assertEquals(2, localStorageManager.getStorages().size());
+  }
+
+  public static class MockedLocalStorageBuilder extends LocalStorage.Builder {

Review Comment:
   Got it.
   But i can't understand why this mockBuilder is not appropriate.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org