@@ -3457,18 +3457,19 @@ func TestStaleEdgeMerge(t *testing.T) {
3457
3457
})
3458
3458
defer s .Close ()
3459
3459
3460
+ depV0 := vtxConst (1 , vtxOpt {name : "depV0" })
3461
+ depV1 := vtxConst (1 , vtxOpt {name : "depV1" })
3462
+ depV2 := vtxConst (1 , vtxOpt {name : "depV2" })
3463
+
3460
3464
// These should all end up edge merged
3461
3465
v0 := vtxAdd (2 , vtxOpt {name : "v0" , inputs : []Edge {
3462
- {Vertex : vtxConst (3 , vtxOpt {})},
3463
- {Vertex : vtxConst (4 , vtxOpt {})},
3466
+ {Vertex : depV0 },
3464
3467
}})
3465
3468
v1 := vtxAdd (2 , vtxOpt {name : "v1" , inputs : []Edge {
3466
- {Vertex : vtxConst (3 , vtxOpt {})},
3467
- {Vertex : vtxConst (4 , vtxOpt {})},
3469
+ {Vertex : depV1 },
3468
3470
}})
3469
3471
v2 := vtxAdd (2 , vtxOpt {name : "v2" , inputs : []Edge {
3470
- {Vertex : vtxConst (3 , vtxOpt {})},
3471
- {Vertex : vtxConst (4 , vtxOpt {})},
3472
+ {Vertex : depV2 },
3472
3473
}})
3473
3474
3474
3475
j0 , err := s .NewJob ("job0" )
@@ -3478,6 +3479,11 @@ func TestStaleEdgeMerge(t *testing.T) {
3478
3479
require .NoError (t , err )
3479
3480
require .NotNil (t , res )
3480
3481
3482
+ require .Contains (t , s .actives , v0 .Digest ())
3483
+ require .Contains (t , s .actives [v0 .Digest ()].jobs , j0 )
3484
+ require .Contains (t , s .actives , depV0 .Digest ())
3485
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j0 )
3486
+
3481
3487
// this edge should be merged with the one from j0
3482
3488
j1 , err := s .NewJob ("job1" )
3483
3489
require .NoError (t , err )
@@ -3486,14 +3492,37 @@ func TestStaleEdgeMerge(t *testing.T) {
3486
3492
require .NoError (t , err )
3487
3493
require .NotNil (t , res )
3488
3494
3495
+ require .Contains (t , s .actives , v0 .Digest ())
3496
+ require .Contains (t , s .actives [v0 .Digest ()].jobs , j0 )
3497
+ require .Contains (t , s .actives [v0 .Digest ()].jobs , j1 )
3498
+ require .Contains (t , s .actives , depV0 .Digest ())
3499
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j0 )
3500
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j1 )
3501
+
3502
+ require .Contains (t , s .actives , v1 .Digest ())
3503
+ require .NotContains (t , s .actives [v1 .Digest ()].jobs , j0 )
3504
+ require .Contains (t , s .actives [v1 .Digest ()].jobs , j1 )
3505
+ require .Contains (t , s .actives , depV1 .Digest ())
3506
+ require .NotContains (t , s .actives [depV1 .Digest ()].jobs , j0 )
3507
+ require .Contains (t , s .actives [depV1 .Digest ()].jobs , j1 )
3508
+
3489
3509
// discard j0, verify that v0 is still active and it's state contains j1 since j1's
3490
3510
// edge was merged to v0's state
3491
3511
require .NoError (t , j0 .Discard ())
3512
+
3492
3513
require .Contains (t , s .actives , v0 .Digest ())
3493
- require .Contains (t , s .actives , v1 .Digest ())
3494
3514
require .NotContains (t , s .actives [v0 .Digest ()].jobs , j0 )
3495
3515
require .Contains (t , s .actives [v0 .Digest ()].jobs , j1 )
3516
+ require .Contains (t , s .actives , depV0 .Digest ())
3517
+ require .NotContains (t , s .actives [depV0 .Digest ()].jobs , j0 )
3518
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j1 )
3519
+
3520
+ require .Contains (t , s .actives , v1 .Digest ())
3521
+ require .NotContains (t , s .actives [v1 .Digest ()].jobs , j0 )
3496
3522
require .Contains (t , s .actives [v1 .Digest ()].jobs , j1 )
3523
+ require .Contains (t , s .actives , depV1 .Digest ())
3524
+ require .NotContains (t , s .actives [depV1 .Digest ()].jobs , j0 )
3525
+ require .Contains (t , s .actives [depV1 .Digest ()].jobs , j1 )
3497
3526
3498
3527
// verify another job can still merge
3499
3528
j2 , err := s .NewJob ("job2" )
@@ -3504,29 +3533,52 @@ func TestStaleEdgeMerge(t *testing.T) {
3504
3533
require .NotNil (t , res )
3505
3534
3506
3535
require .Contains (t , s .actives , v0 .Digest ())
3507
- require .Contains (t , s .actives , v1 .Digest ())
3508
- require .Contains (t , s .actives , v2 .Digest ())
3509
- require .NotContains (t , s .actives [v0 .Digest ()].jobs , j0 )
3510
3536
require .Contains (t , s .actives [v0 .Digest ()].jobs , j1 )
3511
3537
require .Contains (t , s .actives [v0 .Digest ()].jobs , j2 )
3538
+ require .Contains (t , s .actives , depV0 .Digest ())
3539
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j1 )
3540
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j2 )
3541
+
3542
+ require .Contains (t , s .actives , v1 .Digest ())
3512
3543
require .Contains (t , s .actives [v1 .Digest ()].jobs , j1 )
3544
+ require .NotContains (t , s .actives [v1 .Digest ()].jobs , j2 )
3545
+ require .Contains (t , s .actives , depV1 .Digest ())
3546
+ require .Contains (t , s .actives [depV1 .Digest ()].jobs , j1 )
3547
+ require .NotContains (t , s .actives [depV1 .Digest ()].jobs , j2 )
3548
+
3549
+ require .Contains (t , s .actives , v2 .Digest ())
3550
+ require .NotContains (t , s .actives [v2 .Digest ()].jobs , j1 )
3513
3551
require .Contains (t , s .actives [v2 .Digest ()].jobs , j2 )
3552
+ require .Contains (t , s .actives , depV2 .Digest ())
3553
+ require .NotContains (t , s .actives [depV2 .Digest ()].jobs , j1 )
3554
+ require .Contains (t , s .actives [depV2 .Digest ()].jobs , j2 )
3514
3555
3515
3556
// discard j1, verify only referenced edges still exist
3516
3557
require .NoError (t , j1 .Discard ())
3558
+
3517
3559
require .Contains (t , s .actives , v0 .Digest ())
3518
- require .NotContains (t , s .actives , v1 .Digest ())
3519
- require .Contains (t , s .actives , v2 .Digest ())
3520
- require .NotContains (t , s .actives [v0 .Digest ()].jobs , j0 )
3521
3560
require .NotContains (t , s .actives [v0 .Digest ()].jobs , j1 )
3522
3561
require .Contains (t , s .actives [v0 .Digest ()].jobs , j2 )
3562
+ require .Contains (t , s .actives , depV0 .Digest ())
3563
+ require .NotContains (t , s .actives [depV0 .Digest ()].jobs , j1 )
3564
+ require .Contains (t , s .actives [depV0 .Digest ()].jobs , j2 )
3565
+
3566
+ require .NotContains (t , s .actives , v1 .Digest ())
3567
+ require .NotContains (t , s .actives , depV1 .Digest ())
3568
+
3569
+ require .Contains (t , s .actives , v2 .Digest ())
3523
3570
require .Contains (t , s .actives [v2 .Digest ()].jobs , j2 )
3571
+ require .Contains (t , s .actives , depV2 .Digest ())
3572
+ require .Contains (t , s .actives [depV2 .Digest ()].jobs , j2 )
3524
3573
3525
3574
// discard the last job and verify everything was removed now
3526
3575
require .NoError (t , j2 .Discard ())
3527
3576
require .NotContains (t , s .actives , v0 .Digest ())
3528
3577
require .NotContains (t , s .actives , v1 .Digest ())
3529
3578
require .NotContains (t , s .actives , v2 .Digest ())
3579
+ require .NotContains (t , s .actives , depV0 .Digest ())
3580
+ require .NotContains (t , s .actives , depV1 .Digest ())
3581
+ require .NotContains (t , s .actives , depV2 .Digest ())
3530
3582
}
3531
3583
3532
3584
func generateSubGraph (nodes int ) (Edge , int ) {
0 commit comments