kerneltime commented on pull request #2509:
URL: https://github.com/apache/ozone/pull/2509#issuecomment-914743987


   I would recommend something like this to better explain all the variations 
and possible outcomes.
   
   ``` 
   // CopyIfTimestampTestCase captures all the possibilities for the time 
stamps 
     // that can be passed into the multipart copy with copy-if flags for 
     // timestamps. Only some of the cases are valid others should raise an 
     // exception.
     // Time stamps can be, 
     // 1. after the timestamp on the object but still a valid time stamp 
     // (in regard to wall clock time on server)
     // 2. before the timestamp on the object
     // 3. In the Future beyond the wall clock time on the server
     // 4. Null
     // 5. Unparsable 
     // 
     public enum CopyIfTimestampTestCase {
       
MODIFIED_SINCE_FUTURE_TS_UNMODIFIED_SINCE_FUTURE_TS(afterSourceKeyModificationTimeStr,
 afterSourceKeyModificationTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_FUTURE_TS_UNMODIFIED_SINCE_PAST_TS(afterSourceKeyModificationTimeStr,
 beforeSourceKeyModificationTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_FUTURE_TS_UNMODIFIED_SINCE_NULL(afterSourceKeyModificationTimeStr,
 null, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_FUTURE_TS_UNMODIFIED_SINCE_ABSOLUTE_FUTURE(afterSourceKeyModificationTimeStr,
 futureTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_FUTURE_TS_UNMODIFIED_SINCE_UNPARSABLE_TS(afterSourceKeyModificationTimeStr,
 UNPARSABLE_TIME_STR, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_PAST_TS_UNMODIFIED_SINCE_FUTURE_TS(beforeSourceKeyModificationTimeStr,
 afterSourceKeyModificationTimeStr, null),
       
MODIFIED_SINCE_PAST_TS_UNMODIFIED_SINCE_PAST_TS(beforeSourceKeyModificationTimeStr,
 beforeSourceKeyModificationTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_PAST_TS_UNMODIFIED_SINCE_NULL(beforeSourceKeyModificationTimeStr,
 null, null),
       
MODIFIED_SINCE_PAST_TS_UNMOFIFIED_SINCE_ABSOLUTE_FUTURE(beforeSourceKeyModificationTimeStr,futureTimeStr,
 null),
       
MODIFIED_SINCE_PAST_TS_UNMODIFIED_SINCE_UNPARSABLE_TS(beforeSourceKeyModificationTimeStr,
 UNPARSABLE_TIME_STR, null),
       MODIFIED_SINCE_NULL_TS_UNMODIFIED_SINCE_FUTURE_TS(null, 
afterSourceKeyModificationTimeStr, null),
       MODIFIED_SINCE_NULL_TS_UNMODIFIED_SINCE_PAST_TS(null, 
beforeSourceKeyModificationTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       MODIFIED_SINCE_NULL_TS_UNMODIFIED_SINCE_NULL_TS(null, null, null),
       MODIFIED_SINCE_NULL_TS_UNMODIFIED_SINCE_ABSOLUTE_TS(null, futureTimeStr, 
null),
       MODIFIED_SINCE_NULL_TS_UNMODIFIED_SINCE_UNPARSABLE_TS(null, 
UNPARSABLE_TIME_STR, null),
       
MODIFIED_SINCE_UNPARSABLE_TS_UNMODIFIED_SINCE_FUTURE_TS(UNPARSABLE_TIME_STR, 
afterSourceKeyModificationTimeStr, null),
       
MODIFIED_SINCE_UNPARSABLE_TS_UNMODIFIED_SINCE_PAST_TS(UNPARSABLE_TIME_STR, 
beforeSourceKeyModificationTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       
MODIFIED_SINCE_UNPARSABLE_TS_UNMODIFIED_SINCE_NULL_TS(UNPARSABLE_TIME_STR, 
null, null),
       
MODIFIED_SINCE_UNPARSABLE_TS_UNMODIFIED_SINCE_ABSOLUTE_TS(UNPARSABLE_TIME_STR, 
futureTimeStr, null),
       
MODIFIED_SINCE_UNPARSABLE_TS_UNMODIFIED_SINCE_UNPARSABLE_TS(UNPARSABLE_TIME_STR,
 UNPARSABLE_TIME_STR, null),
       MODIFIED_SINCE_ABS_FUTURE_TS_UNMODIFIED_SINCE_FUTURE_TS(futureTimeStr, 
afterSourceKeyModificationTimeStr, null),
       MODIFIED_SINCE_ABS_FUTURE_TS_UNMODIFIED_SINCE_PAST_TS(futureTimeStr, 
beforeSourceKeyModificationTimeStr, S3ErrorTable.PRECOND_FAILED.getCode()),
       MODIFIED_SINCE_ABS_FUTURE_TS_UNMODIFIED_SINCE_NULL_TS(futureTimeStr, 
null, null),
       MODIFIED_SINCE_ABS_FUTURE_TS_UNMODIFIED_SINCE_ABSOLUTE_TS(futureTimeStr, 
futureTimeStr, null),
       
MODIFIED_SINCE_ABS_FUTURE_TS_UNMODIFIED_SINCE_UNPARSABLE_TS(futureTimeStr, 
UNPARSABLE_TIME_STR, null);
       private String modifiedTimestamp;
       private String unmodifiedTimestamp;
       private String errorCode;
       CopyIfTimestampTestCase(String modifiedTimestamp, String 
unmodifiedTimestamp, String errorCode) {
         this.modifiedTimestamp = modifiedTimestamp;
         this.unmodifiedTimestamp = unmodifiedTimestamp;
         this.errorCode = errorCode;
       }
   
       @Override
       public String toString() {
         return " Modified:" + this.modifiedTimestamp
             + " Unmodified:" + this.unmodifiedTimestamp
             + " ErrorCode:" + this.errorCode;
       }
     }
     @Test
     public void testMultipartTSHeaders() throws Exception {
       for (CopyIfTimestampTestCase t : CopyIfTimestampTestCase.values() ) {
         try {
           uploadPartWithCopy(t.modifiedTimestamp, t.unmodifiedTimestamp);
           if (t.errorCode != null) {
             fail("Fail test:" + t);
           }
         } catch (OS3Exception ex) {
           if (t.errorCode == null) {
             fail("Failed test:" + t );
           }
         }
       }
     }
   ```


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