deniskuzZ commented on code in PR #14236:
URL: https://github.com/apache/iceberg/pull/14236#discussion_r2437350143
##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java:
##########
@@ -504,6 +507,52 @@ public void testChangeLockWithAlterTable() throws
Exception {
.hasSameClassAs(initialLock);
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testFirstHiveCommitWithLockSetting(boolean lockEnabled) {
+ String tableName = lockEnabled ? "new_table_with_lock" :
"new_table_with_no_lock";
+ TableIdentifier newTableIdentifier = TableIdentifier.of(DB_NAME,
tableName);
+
+ try {
+ HiveTableOperations ops =
+ new HiveTableOperations(
+ catalog.getConf(),
+ catalog.clientPool(),
+ catalog.newTableOps(newTableIdentifier).io(),
+ catalog.name(),
+ newTableIdentifier.namespace().level(0),
+ newTableIdentifier.name());
+
+ AtomicReference<HiveLock> lockRef = new AtomicReference<>();
+ HiveTableOperations spyOps = spy(ops);
+ TableMetadata metadata =
+ TableMetadata.newTableMetadata(
+ SCHEMA,
+ PartitionSpec.unpartitioned(),
+ catalog.defaultWarehouseLocation(newTableIdentifier),
+ lockEnabled ? ImmutableMap.of() :
ImmutableMap.of(HIVE_LOCK_ENABLED, "false"));
+ doAnswer(
+ i -> {
+ lockRef.set(ops.lockObject(i.getArgument(0)));
+ return lockRef.get();
+ })
+ .when(spyOps)
+ .lockObject(eq(metadata));
+
+ // Commit with base = null (new table creation)
+ spyOps.commit(null, metadata);
+
+ Class<? extends HiveLock> expectedLockClass =
+ lockEnabled ? MetastoreLock.class : NoLock.class;
+ assertThat(lockRef).as("Lock not captured by the
stub").doesNotHaveNullValue();
+ assertThat(lockRef.get())
+ .as("Lock mechanism should use (%s)",
expectedLockClass.getSimpleName())
+ .isInstanceOf(expectedLockClass);
+ } finally {
+ catalog.dropTable(newTableIdentifier, true);
Review Comment:
why do you need to drop, when there is no table create here?
--
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]