Skip to content

Commit 697e605

Browse files
author
Yingjian Wu
committed
add test
1 parent 6b4fa0b commit 697e605

File tree

1 file changed

+60
-41
lines changed

1 file changed

+60
-41
lines changed

metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MetacatSmokeSpec.groovy

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ class MetacatSmokeSpec extends Specification {
20842084
/*
20852085
Step 4: create another table with the same name different uuid without specifying the parent child relation
20862086
but should fail because the table already exists
2087-
This test the revert should not impact the previous record
2087+
This test the revert during creation should not impact the previous record
20882088
*/
20892089
when:
20902090
child11TableDto = PigDataDtoProvider.getTable(catalogName, databaseName, child11, 'amajumdar', child11Uri)
@@ -2151,36 +2151,7 @@ class MetacatSmokeSpec extends Specification {
21512151
assert e.message.contains("Cannot create a parent table on top of another parent")
21522152
21532153
/*
2154-
Step 7: create another table with the same parent1 name but should fail because the table already exists
2155-
Test the revert should not impact the previous record
2156-
*/
2157-
when:
2158-
api.createTable(catalogName, databaseName, parent1, parent1TableDto)
2159-
then:
2160-
e = thrown(Exception)
2161-
assert e.message.contains("already exists")
2162-
2163-
when:
2164-
parent1Table = api.getTable(catalogName, databaseName, parent1, true, true, false)
2165-
child11Table = api.getTable(catalogName, databaseName, child11, true, true, false)
2166-
then:
2167-
// Test Parent 1 parentChildInfo
2168-
assert parent1Table.definitionMetadata.get("parentChildRelationInfo").get("isParent").booleanValue()
2169-
assert parentChildRelV1.getChildren(catalogName, databaseName, parent1) == [
2170-
new ChildInfoDto("embedded-fast-hive-metastore/iceberg_db/child11", "CLONE", "c11_uuid"),
2171-
new ChildInfoDto("embedded-fast-hive-metastore/iceberg_db/child12", "CLONE", "c12_uuid")
2172-
] as Set
2173-
2174-
// Test Child11 parentChildInfo
2175-
assert !child11Table.definitionMetadata.get("parentChildRelationInfo").has("isParent")
2176-
assert child11Table.definitionMetadata.get("random_key").asText() == "random_value"
2177-
JSONAssert.assertEquals(child11Table.definitionMetadata.get("parentChildRelationInfo").toString(),
2178-
'{"parentInfos":[{"name":"embedded-fast-hive-metastore/iceberg_db/parent1","relationType":"CLONE", "uuid":"p1_uuid"}]}',
2179-
false)
2180-
assert parentChildRelV1.getChildren(catalogName, databaseName, child11).isEmpty()
2181-
2182-
/*
2183-
Step 8: Create one grandChild As a Parent of A child table should fail
2154+
Step 7: Create one grandChild As a Parent of A child table should fail
21842155
*/
21852156
when:
21862157
def grandchild121TableDto = PigDataDtoProvider.getTable(catalogName, databaseName, grandChild121, 'amajumdar', null)
@@ -2192,7 +2163,7 @@ class MetacatSmokeSpec extends Specification {
21922163
assert e.message.contains("Cannot create a child table as parent")
21932164
21942165
/*
2195-
Step 9: Create another parent child that is disconnected with the above
2166+
Step 8: Create another parent child that is disconnected with the above
21962167
*/
21972168
when:
21982169
// Create Parent2
@@ -2220,7 +2191,8 @@ class MetacatSmokeSpec extends Specification {
22202191
assert parentChildRelV1.getChildren(catalogName, databaseName, child21).isEmpty()
22212192
22222193
/*
2223-
Step 10: Create a table newParent1 and attempt to rename parent1 to newParent1 should fail
2194+
Step 9: Create a table newParent1 without any parent child rel info
2195+
and attempt to rename parent1 to newParent1 should fail
22242196
Test the parentChildRelationship record remain the same after the revert
22252197
*/
22262198
when:
@@ -2257,6 +2229,53 @@ class MetacatSmokeSpec extends Specification {
22572229
false)
22582230
assert parentChildRelV1.getChildren(catalogName, databaseName, child12).isEmpty()
22592231
2232+
/*
2233+
Step 10: Attempt to rename parent1 to parent2 should fail
2234+
Test the parentChildRelationship record remain the same after the revert
2235+
*/
2236+
when:
2237+
api.renameTable(catalogName, databaseName, parent1, parent2)
2238+
then:
2239+
e = thrown(Exception)
2240+
assert e.message.contains("already exists in parent child relationship service")
2241+
2242+
when:
2243+
parent1Table = api.getTable(catalogName, databaseName, parent1, true, true, false)
2244+
child11Table = api.getTable(catalogName, databaseName, child11, true, true, false)
2245+
child12Table = api.getTable(catalogName, databaseName, child12, true, true, false)
2246+
parent2Table = api.getTable(catalogName, databaseName, parent2, true, true, false)
2247+
child21Table = api.getTable(catalogName, databaseName, child21, true, true, false)
2248+
then:
2249+
// Test Parent 1 parentChildInfo
2250+
assert parent1Table.definitionMetadata.get("parentChildRelationInfo").get("isParent").booleanValue()
2251+
assert parentChildRelV1.getChildren(catalogName, databaseName, parent1) == [
2252+
new ChildInfoDto("embedded-fast-hive-metastore/iceberg_db/child11", "CLONE", "c11_uuid"),
2253+
new ChildInfoDto("embedded-fast-hive-metastore/iceberg_db/child12", "CLONE", "c12_uuid")
2254+
] as Set
2255+
// Test Child11 parentChildInfo
2256+
assert !child11Table.definitionMetadata.get("parentChildRelationInfo").has("isParent")
2257+
assert child11Table.definitionMetadata.get("random_key").asText() == "random_value"
2258+
JSONAssert.assertEquals(child11Table.definitionMetadata.get("parentChildRelationInfo").toString(),
2259+
'{"parentInfos":[{"name":"embedded-fast-hive-metastore/iceberg_db/parent1","relationType":"CLONE", "uuid":"p1_uuid"}]}',
2260+
false)
2261+
assert parentChildRelV1.getChildren(catalogName, databaseName, child11).isEmpty()
2262+
// Test Child12 parentChildInfo
2263+
assert !child12Table.definitionMetadata.get("parentChildRelationInfo").has("isParent")
2264+
JSONAssert.assertEquals(child12Table.definitionMetadata.get("parentChildRelationInfo").toString(),
2265+
'{"parentInfos":[{"name":"embedded-fast-hive-metastore/iceberg_db/parent1","relationType":"CLONE","uuid":"p1_uuid"}]}',
2266+
false)
2267+
assert parentChildRelV1.getChildren(catalogName, databaseName, child12).isEmpty()
2268+
// Test Parent 2 parentChildInfo
2269+
assert parent2Table.definitionMetadata.get("parentChildRelationInfo").get("isParent").booleanValue()
2270+
assert parentChildRelV1.getChildren(catalogName, databaseName, parent2) == [
2271+
new ChildInfoDto("embedded-fast-hive-metastore/iceberg_db/child21", "CLONE", "c21_uuid")
2272+
] as Set
2273+
// Test Child21 parentChildInfo
2274+
JSONAssert.assertEquals(child21Table.definitionMetadata.get("parentChildRelationInfo").toString(),
2275+
'{"parentInfos":[{"name":"embedded-fast-hive-metastore/iceberg_db/parent2","relationType":"CLONE","uuid":"p2_uuid"}]}',
2276+
false)
2277+
assert parentChildRelV1.getChildren(catalogName, databaseName, child21).isEmpty()
2278+
22602279
22612280
/*
22622281
Step 11: First drop the newParent1 and then Rename parent1 to newParent1 should now succeed
@@ -2386,7 +2405,7 @@ class MetacatSmokeSpec extends Specification {
23862405
23872406
23882407
/*
2389-
Step 13: Drop previous renameChild11 and Rename child11 to renameChild11
2408+
Step 14: Drop previous renameChild11 and Rename child11 to renameChild11
23902409
*/
23912410
when:
23922411
api.deleteTable(catalogName, databaseName, renameChild11)
@@ -2417,7 +2436,7 @@ class MetacatSmokeSpec extends Specification {
24172436
assert e.message.contains("Unable to locate for")
24182437
24192438
/*
2420-
Step 14: Drop parent renameParent1
2439+
Step 15 Drop parent renameParent1
24212440
*/
24222441
when:
24232442
api.deleteTable(catalogName, databaseName, renameParent1)
@@ -2427,7 +2446,7 @@ class MetacatSmokeSpec extends Specification {
24272446
assert e.message.contains("because it still has")
24282447
24292448
/*
2430-
Step 15: Drop renameChild11 should succeed
2449+
Step 16: Drop renameChild11 should succeed
24312450
*/
24322451
when:
24332452
api.deleteTable(catalogName, databaseName, renameChild11)
@@ -2441,7 +2460,7 @@ class MetacatSmokeSpec extends Specification {
24412460
] as Set
24422461
24432462
/*
2444-
Step 16: Create renameChild11 and should expect random_key should appear at it is reattached
2463+
Step 17: Create renameChild11 and should expect random_key should appear at it is reattached
24452464
but parent childInfo should not as it is always coming from the parent child relationship service
24462465
which currently does not have any record
24472466
*/
@@ -2462,7 +2481,7 @@ class MetacatSmokeSpec extends Specification {
24622481
] as Set
24632482
24642483
/*
2465-
Step 17: Drop child12 should succeed
2484+
Step 18: Drop child12 should succeed
24662485
*/
24672486
when:
24682487
api.deleteTable(catalogName, databaseName, child12)
@@ -2472,7 +2491,7 @@ class MetacatSmokeSpec extends Specification {
24722491
assert parentChildRelV1.getChildren(catalogName, databaseName, renameParent1).isEmpty()
24732492
24742493
/*
2475-
Step 18: Drop renameParent1 should succeed as there is no more child under it
2494+
Step 19: Drop renameParent1 should succeed as there is no more child under it
24762495
*/
24772496
when:
24782497
api.deleteTable(catalogName, databaseName, renameParent1)
@@ -2496,7 +2515,7 @@ class MetacatSmokeSpec extends Specification {
24962515
assert parentChildRelV1.getChildren(catalogName, databaseName, child21).isEmpty()
24972516
24982517
/*
2499-
Step 19: update parent2 with random parentChildRelationInfo to test immutability
2518+
Step 20: update parent2 with random parentChildRelationInfo to test immutability
25002519
*/
25012520
when:
25022521
def updateParent2Dto = parent2Table
@@ -2519,7 +2538,7 @@ class MetacatSmokeSpec extends Specification {
25192538
assert parentChildRelV1.getChildren(catalogName, databaseName, child21).isEmpty()
25202539
25212540
/*
2522-
Step 20: update child21 with random parentChildRelationInfo to test immutability
2541+
Step 21: update child21 with random parentChildRelationInfo to test immutability
25232542
*/
25242543
when:
25252544
def updateChild21Dto = child21Table

0 commit comments

Comments
 (0)