gaoyunhaii commented on code in PR #21736:
URL: https://github.com/apache/flink/pull/21736#discussion_r1181141053


##########
flink-fs-tests/src/test/java/org/apache/flink/hdfstests/ContinuousFileProcessingMigrationTest.java:
##########
@@ -309,17 +288,34 @@ public void testMonitoringSourceRestore() throws 
Exception {
 
         testHarness.setup();
 
-        testHarness.initializeState(
-                OperatorSnapshotUtil.getResourceFilename(
-                        "monitoring-function-migration-test-"
-                                + expectedModTime
-                                + "-flink"
-                                + testMigrateVersion
-                                + "-snapshot"));
+        // Get the exact filename
+        Tuple2<String, Long> fileNameAndModTime = 
getResourceFilename(testMigrateVersion);
+
+        testHarness.initializeState(fileNameAndModTime.f0);
 
         testHarness.open();
 
-        Assert.assertEquals((long) expectedModTime, 
monitoringFunction.getGlobalModificationTime());
+        Assert.assertEquals(
+                fileNameAndModTime.f1.longValue(), 
monitoringFunction.getGlobalModificationTime());
+    }
+
+    private Tuple2<String, Long> getResourceFilename(FlinkVersion version) 
throws IOException {
+        String resourceDirectory = 
OperatorSnapshotUtil.getResourceFilename("");
+        Pattern fileNamePattern =
+                Pattern.compile(
+                        "monitoring-function-migration-test-(\\d+)-flink"

Review Comment:
   Since there is a check at the last of `testMonitoringSourceRestore`:
   
   ```java
   Assert.assertEquals(
                   fileNameAndModTime.f1.longValue(), 
monitoringFunction.getGlobalModificationTime());
   ```
   
   Thus the modification time might still be required. 
   
   But there might be another option that we do not store the modification time 
in the filename, instead we read it directly from the file's meta during tests. 
If it works then we could get rid of the mod time in the filename. 
   
   Do you think it is ok for us to file a separate issue to further optimize 
this test?  
   
   



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

Reply via email to