huage1994 commented on code in PR #4308: URL: https://github.com/apache/zeppelin/pull/4308#discussion_r842599337
########## 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: Yes, you are right, actually `sleep` is not needed in in zeppelin Github CI. Currently I use MockStorageOperator to mock OSSOperator to run `OSSNotebookRepoTest` in zeppelin Github CI. But `sleep` is needed when someone use `OSSOperator` instead of `MockStorageOperator` to run the test `OSSNotebookRepoTest` in local environment. It is the reason I want to reserve it. > I don't understand. With the TempDir approach, each test should get its own TempDir. Also, the deletion of the files is a synchronous operation. Which component deletes asynchronously here? TempDir approach is used in `MockStorageOperator` but not in real OSSOperator. OSSOperator use only one bucket. However, when i use `OSSOperator` instead of `MockStorageOperator` to run the test `OSSNotebookRepoTest` in my local environment. It would throw `OSSException` `the bucket already exists` if there is no `Thread.sleep(1000);` when the setup of second test case. -- 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-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org