FrankChen021 commented on a change in pull request #9898:
URL: https://github.com/apache/druid/pull/9898#discussion_r448148488



##########
File path: 
extensions-contrib/aliyun-oss-extensions/src/test/java/org/apache/druid/storage/aliyun/OssDataSegmentMoverTest.java
##########
@@ -0,0 +1,266 @@
+/*
+ * 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.druid.storage.aliyun;
+
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.OSSException;
+import com.aliyun.oss.model.CopyObjectRequest;
+import com.aliyun.oss.model.CopyObjectResult;
+import com.aliyun.oss.model.ListObjectsRequest;
+import com.aliyun.oss.model.OSSObjectSummary;
+import com.aliyun.oss.model.ObjectListing;
+import com.aliyun.oss.model.PutObjectResult;
+import com.aliyun.oss.model.StorageClass;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.java.util.common.MapUtils;
+import org.apache.druid.segment.loading.SegmentLoadingException;
+import org.apache.druid.timeline.DataSegment;
+import org.apache.druid.timeline.partition.NoneShardSpec;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class OssDataSegmentMoverTest
+{
+  private static final DataSegment SOURCE_SEGMENT = new DataSegment(
+      "test",
+      Intervals.of("2013-01-01/2013-01-02"),
+      "1",
+      ImmutableMap.of(
+          "key",
+          
"baseKey/test/2013-01-01T00:00:00.000Z_2013-01-02T00:00:00.000Z/1/0/index.zip",
+          "bucket",
+          "main"
+      ),
+      ImmutableList.of("dim1", "dim1"),
+      ImmutableList.of("metric1", "metric2"),
+      NoneShardSpec.instance(),
+      0,
+      1
+  );
+
+  @Test
+  public void testMove() throws Exception
+  {
+    MockClient mockClient = new MockClient();
+    OssDataSegmentMover mover = new OssDataSegmentMover(mockClient, new 
OssStorageConfig());
+
+    mockClient.putObject(
+        "main",
+        
"baseKey/test/2013-01-01T00:00:00.000Z_2013-01-02T00:00:00.000Z/1/0/index.zip"
+    );
+
+    DataSegment movedSegment = mover.move(
+        SOURCE_SEGMENT,
+        ImmutableMap.of("baseKey", "targetBaseKey", "bucket", "archive")
+    );
+
+    Map<String, Object> targetLoadSpec = movedSegment.getLoadSpec();
+    Assert.assertEquals(
+        
"targetBaseKey/test/2013-01-01T00:00:00.000Z_2013-01-02T00:00:00.000Z/1/0/index.zip",
+        MapUtils.getString(targetLoadSpec, "key")
+    );
+    Assert.assertEquals("archive", MapUtils.getString(targetLoadSpec, 
"bucket"));
+    Assert.assertTrue(mockClient.didMove());
+  }
+
+  @Test
+  public void testMoveNoop() throws Exception
+  {
+    MockClient mockS3Client = new MockClient();

Review comment:
       all `s3` in  this extension have been fixed




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to