RussellSpitzer commented on a change in pull request #2328:
URL: https://github.com/apache/iceberg/pull/2328#discussion_r593561965



##########
File path: 
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java
##########
@@ -66,4 +75,220 @@ public void testSuppressUnlockExceptions() throws 
TException, InterruptedExcepti
     // the commit must succeed
     Assert.assertEquals(1, ops.current().schema().columns().size());
   }
+
+  @Test
+  public void testThriftExceptionFailureOnCommit() throws TException, 
InterruptedException {
+    Table table = catalog.loadTable(TABLE_IDENTIFIER);
+    HiveTableOperations ops = (HiveTableOperations) ((HasTableOperations) 
table).operations();
+
+    TableMetadata metadataV1 = ops.current();
+
+    table.updateSchema()
+        .addColumn("n", Types.IntegerType.get())
+        .commit();
+
+    ops.refresh();
+
+    TableMetadata metadataV2 = ops.current();
+
+    Assert.assertEquals(2, ops.current().schema().columns().size());
+
+    HiveTableOperations spyOps = spy(ops);
+
+    failCommitAndThrowException(spyOps);
+
+    AssertHelpers.assertThrows("We should rethrow generic runtime errors if 
the " +
+        "commit actually doesn't succeed", RuntimeException.class, "Metastore 
operation failed",
+        () -> spyOps.commit(metadataV2, metadataV1));
+
+    ops.refresh();
+    Assert.assertEquals("Current metadata should not have changed", 
metadataV2, ops.current());
+    Assert.assertTrue("Current metadata should still exist", 
metadataFileExists(metadataV2));
+    Assert.assertEquals("No new metadata files should exist", 2, 
metadataFileCount(ops.current()));
+  }
+
+  @Test
+  public void testThriftExceptionSuccessOnCommit() throws TException, 
InterruptedException {

Review comment:
       Pretends we throw an error while persisting that actually does commit




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



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

Reply via email to