Github user karanmehta93 commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/397#discussion_r228699968
  
    --- Diff: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java
 ---
    @@ -191,31 +192,52 @@ private void upsertData(PreparedStatement stmt, 
String field1, String field2, in
         stmt.execute();
       }
     
    -  public void upsertAndSnapshot(String tableName) throws Exception {
    +  private void upsertAndSnapshot(String tableName, boolean shouldSplit) 
throws Exception {
         upsertData(tableName);
     
    +    TableName hbaseTableName = TableName.valueOf(tableName);
         Connection conn = DriverManager.getConnection(getUrl());
         Admin admin = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
    -    admin.snapshot(SNAPSHOT_NAME, TableName.valueOf(tableName));
    -    // call flush to create new files in the region
    -    admin.flush(TableName.valueOf(tableName));
    +
    +    if (shouldSplit) {
    +      splitTableSync(admin, hbaseTableName, "BBBB".getBytes(), 2);
    +    }
    +
    +    admin.snapshot(SNAPSHOT_NAME, hbaseTableName);
     
         List<SnapshotDescription> snapshots = admin.listSnapshots();
         Assert.assertEquals(tableName, snapshots.get(0).getTable());
     
    +    // Capture the snapshot timestamp to use as SCN while reading the 
table later
    +    // Assigning the timestamp value here will make tests less flaky
    +    timestamp = System.currentTimeMillis();
    +
         // upsert data after snapshot
         PreparedStatement stmt = conn.prepareStatement(String.format(UPSERT, 
tableName));
    -    upsertData(stmt, "DDDD", "SNFB", 0004);
    +    upsertData(stmt, "DDDD", "SNFB", 45);
         conn.commit();
       }
     
    -    public void deleteSnapshot(String tableName) throws Exception {
    +  private void splitTableSync(Admin admin, TableName hbaseTableName,
    --- End diff --
    
    Didn't use the method provided in BaseTest.java since enabling/disabling 
the table causes the snapshot manifest file to not contain the offline regions. 
    The bug is caused because the snapshot manifest file on a regular 
production table can contain information about regions that are split or 
offline, which should ideally be ignored when restoring snapshot.


---

Reply via email to