xiangfu0 commented on code in PR #19863:
URL: https://github.com/apache/pinot/pull/19863#discussion_r4289857545


##########
pinot-spi/src/test/java/org/apache/pinot/spi/filesystem/PinotFSPaginatedListTest.java:
##########
@@ -108,6 +108,21 @@ public void testNoClosePinotFSDelegatesToUnderlyingFS() 
throws IOException {
     verify(mockDelegate).listFilesWithMetadata(TEST_URI, true, filter, 5);
   }
 
+  /// PinotFSFactory hands out NoClosePinotFS, so without forwarding a sorted 
store would look unsorted.
+  @Test
+  public void testNoClosePinotFSDelegatesListingAfter() throws IOException {

Review Comment:
   The new SPI defaults aren't directly tested here. This case stubs the 
delegate so it only proves `NoClosePinotFS` forwards. Consider one small test 
with `thenCallRealMethod()` asserting that `supportsListingAfter()` returns 
false and `listFilesWithMetadataAfter()` throws `UnsupportedOperationException` 
by default, so a regression flipping either default would be caught.



##########
pinot-plugins/pinot-file-system/pinot-gcs/src/test/java/org/apache/pinot/plugin/filesystem/GcsPinotFSListingAfterTest.java:
##########
@@ -0,0 +1,139 @@
+/**
+ * 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.pinot.plugin.filesystem;
+
+import com.google.api.gax.paging.Page;
+import com.google.cloud.storage.Blob;
+import com.google.cloud.storage.Storage;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.pinot.spi.filesystem.FileMetadata;
+import org.mockito.ArgumentCaptor;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+
+public class GcsPinotFSListingAfterTest {
+  private static final URI DIR = URI.create("gs://bucket/data/");
+
+  private Storage _storage;
+  private GcsPinotFS _gcsPinotFS;
+
+  @BeforeMethod
+  public void setUp()
+      throws Exception {
+    _storage = mock(Storage.class);
+    _gcsPinotFS = new GcsPinotFS();
+    // Same injection as GcsPinotFSPaginatedListTest: GcsPinotFS has no 
constructor taking a Storage.
+    final Field storageField = GcsPinotFS.class.getDeclaredField("_storage");
+    storageField.setAccessible(true);
+    storageField.set(_gcsPinotFS, _storage);
+  }
+
+  /// Paths are URI-escaped object names; the start path is decoded back to 
the name, and the inclusive startOffset
+  /// match is dropped.
+  @Test
+  public void testStartsAfterTheObjectTheEscapedPathNames()
+      throws IOException {
+    stubList(page(null, "data/a b", "data/a c/", "data/b c"));
+
+    final List<FileMetadata> files = 
_gcsPinotFS.listFilesWithMetadataAfter(DIR, "gs://bucket/data/a%20b", 10);

Review Comment:
   This round-trip is the core GCS subtlety, but only a space (`%20`) is 
exercised here. The escaping genuinely differs per character: a literal `%` 
becomes `%25`, a `+` must survive un-decoded in a path, and unicode is 
percent-escaped as UTF-8. A data-provider covering those (e.g. `a%b`, `a+b`, a 
unicode name) would guard the decode side against regressions that `%20` alone 
can't catch.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to