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 08:23:14 UTC

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

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


##########
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`?
   
   The delete operations on OSS Service above has a delay.
   It's ok when test with `MockStorageOperator` but it would affect setup of next test case if we do not wait for them to end when test with `OSSOperator`.
   



-- 
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