@@ -36,7 +36,6 @@ import com.netflix.metacat.common.server.events.MetacatEventBus
36
36
import com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent
37
37
import com.netflix.metacat.common.server.events.MetacatUpdateTablePreEvent
38
38
import com.netflix.metacat.common.server.model.ChildInfo
39
- import com.netflix.metacat.common.server.model.ParentInfo
40
39
import com.netflix.metacat.common.server.properties.Config
41
40
import com.netflix.metacat.common.server.spi.MetacatCatalogConfig
42
41
import com.netflix.metacat.common.server.usermetadata.DefaultAuthorizationService
@@ -292,6 +291,23 @@ class TableServiceImplSpec extends Specification {
292
291
definitionMetadata : outerNode,
293
292
serde : new StorageDto (uri : ' s3:/clone/clone/c' )
294
293
)
294
+ // mock case where create Table Fail as parent table does not exist
295
+ when :
296
+ service. create(childTableName, createTableDto)
297
+ then :
298
+ 1 * config. isParentChildCreateEnabled() >> true
299
+ 1 * ownerValidationService. extractPotentialOwners(_) >> [" cloneClient" ]
300
+ 1 * ownerValidationService. isUserValid(_) >> true
301
+ 1 * ownerValidationService. extractPotentialOwnerGroups(_) >> [" cloneClientGroup" ]
302
+ 1 * ownerValidationService. isGroupValid(_) >> true
303
+ 1 * connectorTableServiceProxy. exists(_) >> false
304
+
305
+ 0 * parentChildRelSvc. createParentChildRelation(parentTableName, " p_uuid" , childTableName, " child_uuid" , " CLONE" )
306
+ 0 * connectorTableServiceProxy. create(_, _) >> {throw new RuntimeException (" Fail to create" )}
307
+ 0 * parentChildRelSvc. deleteParentChildRelation(parentTableName, " p_uuid" , childTableName, " child_uuid" , " CLONE" )
308
+ def e = thrown(RuntimeException )
309
+ assert e. message. contains(" does not exist" )
310
+
295
311
// mock case where create Table Fail and revert function is triggerred
296
312
when :
297
313
service. create(childTableName, createTableDto)
@@ -301,6 +317,7 @@ class TableServiceImplSpec extends Specification {
301
317
1 * ownerValidationService. isUserValid(_) >> true
302
318
1 * ownerValidationService. extractPotentialOwnerGroups(_) >> [" cloneClientGroup" ]
303
319
1 * ownerValidationService. isGroupValid(_) >> true
320
+ 1 * connectorTableServiceProxy. exists(_) >> true
304
321
305
322
1 * parentChildRelSvc. createParentChildRelation(parentTableName, " p_uuid" , childTableName, " child_uuid" , " CLONE" )
306
323
1 * connectorTableServiceProxy. create(_, _) >> {throw new RuntimeException (" Fail to create" )}
@@ -317,10 +334,11 @@ class TableServiceImplSpec extends Specification {
317
334
1 * ownerValidationService. isUserValid(_) >> true
318
335
1 * ownerValidationService. extractPotentialOwnerGroups(_) >> [" cloneClientGroup" ]
319
336
1 * ownerValidationService. isGroupValid(_) >> true
337
+ 0 * connectorTableServiceProxy. exists(_)
320
338
321
339
0 * parentChildRelSvc. createParentChildRelation(parentTableName, " p_uuid" , childTableName, " child_uuid" , " CLONE" )
322
340
0 * connectorTableServiceProxy. create(_, _)
323
- def e = thrown(RuntimeException )
341
+ e = thrown(RuntimeException )
324
342
assert e. message. contains(" is currently disabled" )
325
343
326
344
// mock successful case
@@ -332,6 +350,7 @@ class TableServiceImplSpec extends Specification {
332
350
1 * ownerValidationService. isUserValid(_) >> true
333
351
1 * ownerValidationService. extractPotentialOwnerGroups(_) >> [" cloneClientGroup" ]
334
352
1 * ownerValidationService. isGroupValid(_) >> true
353
+ 1 * connectorTableServiceProxy. exists(_) >> true
335
354
336
355
1 * parentChildRelSvc. createParentChildRelation(parentTableName, " p_uuid" , childTableName, " child_uuid" , " CLONE" )
337
356
1 * connectorTableServiceProxy. create(_, _)
@@ -417,7 +436,8 @@ class TableServiceImplSpec extends Specification {
417
436
1 * config. isParentChildGetEnabled() >> true
418
437
1 * config. isParentChildDropEnabled() >> true
419
438
1 * parentChildRelSvc. getParents(name) >> {[] as Set }
420
- 2 * parentChildRelSvc. getChildren(name) >> {[new ChildInfo (" child" , " clone" , " child_uuid" )] as Set }
439
+ 1 * parentChildRelSvc. isParentTable(name) >> true
440
+ 1 * parentChildRelSvc. getChildren(name) >> {[new ChildInfo (" child" , " clone" , " child_uuid" )] as Set }
421
441
1 * config. getNoTableDeleteOnTags() >> []
422
442
def e = thrown(RuntimeException )
423
443
assert e. message. contains(" because it still has" )
@@ -429,7 +449,8 @@ class TableServiceImplSpec extends Specification {
429
449
1 * config. isParentChildGetEnabled() >> true
430
450
1 * config. isParentChildDropEnabled() >> true
431
451
1 * parentChildRelSvc. getParents(name)
432
- 2 * parentChildRelSvc. getChildren(name)
452
+ 1 * parentChildRelSvc. isParentTable(name) >> true
453
+ 1 * parentChildRelSvc. getChildren(name)
433
454
1 * config. getNoTableDeleteOnTags() >> []
434
455
1 * connectorTableServiceProxy. delete(_) >> {throw new RuntimeException (" Fail to drop" )}
435
456
0 * parentChildRelSvc. drop(_)
@@ -442,9 +463,9 @@ class TableServiceImplSpec extends Specification {
442
463
1 * config. isParentChildGetEnabled() >> true
443
464
1 * config. isParentChildDropEnabled() >> false
444
465
1 * parentChildRelSvc. isChildTable(name) >> true
445
- 0 * parentChildRelSvc. isParentTable(name)
466
+ 1 * parentChildRelSvc. isParentTable(name) >> false
446
467
1 * parentChildRelSvc. getParents(name)
447
- 1 * parentChildRelSvc. getChildren(name)
468
+ 0 * parentChildRelSvc. getChildren(name)
448
469
1 * config. getNoTableDeleteOnTags() >> []
449
470
0 * connectorTableServiceProxy. delete(_)
450
471
0 * parentChildRelSvc. drop(_)
@@ -458,9 +479,9 @@ class TableServiceImplSpec extends Specification {
458
479
1 * config. isParentChildGetEnabled() >> true
459
480
1 * config. isParentChildDropEnabled() >> false
460
481
1 * parentChildRelSvc. isChildTable(name) >> false
461
- 1 * parentChildRelSvc. isParentTable(name) >> true
482
+ 2 * parentChildRelSvc. isParentTable(name) >> true
462
483
1 * parentChildRelSvc. getParents(name)
463
- 1 * parentChildRelSvc. getChildren(name)
484
+ 0 * parentChildRelSvc. getChildren(name)
464
485
1 * config. getNoTableDeleteOnTags() >> []
465
486
0 * connectorTableServiceProxy. delete(_)
466
487
0 * parentChildRelSvc. drop(_)
@@ -475,9 +496,9 @@ class TableServiceImplSpec extends Specification {
475
496
1 * config. isParentChildGetEnabled() >> true
476
497
1 * config. isParentChildDropEnabled() >> false
477
498
1 * parentChildRelSvc. isChildTable(name) >> false
478
- 1 * parentChildRelSvc. isParentTable(name) >> false
499
+ 2 * parentChildRelSvc. isParentTable(name) >> false
479
500
1 * parentChildRelSvc. getParents(name) >> {[] as Set }
480
- 2 * parentChildRelSvc. getChildren(name) >> {[] as Set }
501
+ 1 * parentChildRelSvc. getChildren(name) >> {[] as Set }
481
502
1 * config. getNoTableDeleteOnTags() >> []
482
503
1 * connectorTableServiceProxy. delete(_)
483
504
1 * parentChildRelSvc. drop(_)
@@ -491,9 +512,9 @@ class TableServiceImplSpec extends Specification {
491
512
1 * config. isParentChildGetEnabled() >> true
492
513
1 * config. isParentChildDropEnabled() >> true
493
514
0 * parentChildRelSvc. isChildTable(name)
494
- 0 * parentChildRelSvc. isParentTable(name)
515
+ 1 * parentChildRelSvc. isParentTable(name)
495
516
1 * parentChildRelSvc. getParents(name) >> {[] as Set }
496
- 2 * parentChildRelSvc. getChildren(name) >> {[] as Set }
517
+ 1 * parentChildRelSvc. getChildren(name) >> {[] as Set }
497
518
1 * config. getNoTableDeleteOnTags() >> []
498
519
1 * connectorTableServiceProxy. delete(_)
499
520
1 * parentChildRelSvc. drop(_)
0 commit comments