You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2022/04/05 07:31:25 UTC

[GitHub] [zeppelin] Reamer commented on a diff in pull request #4308: [Zeppelin-5655] OSSNotebookRepo support version control.

Reamer commented on code in PR #4308:
URL: https://github.com/apache/zeppelin/pull/4308#discussion_r842451911


##########
zeppelin-plugins/notebookrepo/oss/src/test/java/org/apache/zeppelin/notebook/repo/OSSNotebookRepoTest.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.zeppelin.notebook.repo;
+
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.apache.zeppelin.notebook.Note;
+import org.apache.zeppelin.notebook.NoteInfo;
+import org.apache.zeppelin.notebook.Paragraph;
+import org.apache.zeppelin.notebook.repo.storage.MockStorageOperator;
+import org.apache.zeppelin.notebook.repo.storage.RemoteStorageOperator;
+import org.apache.zeppelin.scheduler.Job;
+import org.apache.zeppelin.user.AuthenticationInfo;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class OSSNotebookRepoTest {
+
+  private AuthenticationInfo anonymous = AuthenticationInfo.ANONYMOUS;
+  private OSSNotebookRepo notebookRepo;
+  private RemoteStorageOperator ossOperator;
+  private String bucket;
+  private static int OSS_VERSION_MAX = 30;
+
+
+
+  @Before
+  public void setUp() throws IOException {
+    bucket = "zeppelin-test-bucket";
+    String endpoint = "yourEndpoint";
+    String accessKeyId = "yourAccessKeyId";
+    String accessKeySecret = "yourAccessKeySecret";
+    ossOperator = new MockStorageOperator();
+    ossOperator.createBucket(bucket);
+    notebookRepo = new OSSNotebookRepo();
+    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
+    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_OSS_ENDPOINT.getVarName(),
+            endpoint);
+    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_OSS_BUCKET.getVarName(),
+            bucket);
+    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_OSS_ACCESSKEYID.getVarName(),
+            accessKeyId);
+    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_OSS_ACCESSKEYSECRET.getVarName(),
+            accessKeySecret);
+    System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_OSS_VERSION_MAX.getVarName(),
+            OSS_VERSION_MAX + "");
+    notebookRepo.init(conf);
+    notebookRepo.setOssOperator(ossOperator);
+  }
+
+  @After
+  public void tearDown() throws InterruptedException, IOException {
+    if (notebookRepo != null) {
+      notebookRepo.close();
+    }
+    ossOperator.deleteDir(bucket, "");
+    ossOperator.deleteBucket(bucket);
+    Thread.sleep(1000);

Review Comment:
   Why a `sleep`?



##########
zeppelin-plugins/notebookrepo/oss/src/main/java/org/apache/zeppelin/notebook/repo/storage/MockStorageOperator.java:
##########
@@ -0,0 +1,99 @@
+package org.apache.zeppelin.notebook.repo.storage;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+

Review Comment:
   `MockStorageOperator.java` should be moved to the test folder.



##########
zeppelin-plugins/notebookrepo/oss/src/main/java/org/apache/zeppelin/notebook/repo/OSSNotebookRepo.java:
##########
@@ -214,4 +190,89 @@ public void updateSettings(Map<String, String> settings, AuthenticationInfo subj
     LOGGER.warn("Method not implemented");
   }
 
+
+  String buildRevisionsDirName(String noteId, String notePath) throws IOException {

Review Comment:
   Please add access specifiers and possible `static` at this point.



##########
zeppelin-plugins/notebookrepo/oss/src/main/java/org/apache/zeppelin/notebook/repo/storage/MockStorageOperator.java:
##########
@@ -0,0 +1,99 @@
+package org.apache.zeppelin.notebook.repo.storage;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class MockStorageOperator implements RemoteStorageOperator {
+
+  private String mockRootFolder = "mock-storage-dir/";

Review Comment:
   I would prefer [Files.createTempDirectory(...) ](https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createTempDirectory(java.nio.file.Path,%20java.lang.String,%20java.nio.file.attribute.FileAttribute...)), because it is not clear where the test folder is created. New files outside the `target` folder are not welcome during tests.



-- 
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: dev-unsubscribe@zeppelin.apache.org

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