@@ -524,77 +524,6 @@ describe("controllers/stream", () => {
524
524
expect ( server . db . stream . addDefaultFields ( document ) ) . toEqual ( stream ) ;
525
525
} ) ;
526
526
527
- it ( "should lock pull for a new stream" , async ( ) => {
528
- // Create stream pull
529
- const now = Date . now ( ) ;
530
- const res = await client . put ( "/stream/pull" , postMockPullStream ) ;
531
- expect ( res . status ) . toBe ( 201 ) ;
532
- const stream = await res . json ( ) ;
533
-
534
- // Request pull lock
535
- const resLockPull = await client . post ( `/stream/${ stream . id } /lockPull` ) ;
536
- expect ( resLockPull . status ) . toBe ( 204 ) ;
537
-
538
- // Check that the pullLockedAt is marked with the correct date
539
- const res2 = await client . get ( `/stream/${ stream . id } ` ) ;
540
- expect ( res2 . status ) . toBe ( 200 ) ;
541
- const stream2 = await res2 . json ( ) ;
542
- expect ( stream2 . pullLockedAt ) . toBeGreaterThan ( now ) ;
543
- } ) ;
544
-
545
- it ( "should not lock pull for an active stream" , async ( ) => {
546
- // Create stream pull
547
- const res = await client . put ( "/stream/pull" , postMockPullStream ) ;
548
- expect ( res . status ) . toBe ( 201 ) ;
549
- const stream = await res . json ( ) ;
550
-
551
- // Mark stream as active
552
- await db . stream . update ( stream . id , { isActive : true } ) ;
553
-
554
- // Requesting pull lock should fail, because the stream is active (so it should be replicated instead of being pulled)
555
- const reslockPull = await client . post ( `/stream/${ stream . id } /lockPull` ) ;
556
- expect ( reslockPull . status ) . toBe ( 423 ) ;
557
- } ) ;
558
-
559
- it ( "should not lock pull for already locked pull" , async ( ) => {
560
- // Create stream pull
561
- const res = await client . put ( "/stream/pull" , postMockPullStream ) ;
562
- expect ( res . status ) . toBe ( 201 ) ;
563
- const stream = await res . json ( ) ;
564
-
565
- // Request pull lock by many processes at the same time, only one should acquire a lock
566
- const promises = [ ] ;
567
- for ( let i = 0 ; i < 10 ; i ++ ) {
568
- promises . push ( client . post ( `/stream/${ stream . id } /lockPull` ) ) ;
569
- }
570
- const resPulls = await Promise . all ( promises ) ;
571
- expect ( resPulls . filter ( ( r ) => r . status === 204 ) . length ) . toBe ( 1 ) ;
572
- expect ( resPulls . filter ( ( r ) => r . status === 423 ) . length ) . toBe ( 9 ) ;
573
- } ) ;
574
-
575
- it ( "should lock pull for already locked pull if lease has expired" , async ( ) => {
576
- // Create stream pull
577
- const res = await client . put ( "/stream/pull" , postMockPullStream ) ;
578
- expect ( res . status ) . toBe ( 201 ) ;
579
- const stream = await res . json ( ) ;
580
-
581
- // Request pull lock
582
- const resLockPull = await client . post ( `/stream/${ stream . id } /lockPull` , {
583
- leaseTimeout : 1 ,
584
- } ) ;
585
- expect ( resLockPull . status ) . toBe ( 204 ) ;
586
-
587
- // Wait until lease has expired
588
- await sleep ( 1 ) ;
589
-
590
- // Request pull lock should succeed, because the lock lease has expired (so we assume the stream is not being pulled at the moment)
591
- const resLockPull2 = await client . post (
592
- `/stream/${ stream . id } /lockPull` ,
593
- { leaseTimeout : 1 }
594
- ) ;
595
- expect ( resLockPull2 . status ) . toBe ( 204 ) ;
596
- } ) ;
597
-
598
527
it ( "should update a stream if it has the same pull source" , async ( ) => {
599
528
let res = await client . put ( "/stream/pull" , postMockPullStream ) ;
600
529
expect ( res . status ) . toBe ( 201 ) ;
@@ -831,18 +760,6 @@ describe("controllers/stream", () => {
831
760
expect ( updatedStream . lastSeen ) . toBeGreaterThan ( timeBeforeBump ) ;
832
761
} ) ;
833
762
834
- it ( "start pull should update lastPullAt" , async ( ) => {
835
- const stream = await createAndActivateStream ( ) ;
836
- const timeBeforeBump = Date . now ( ) ;
837
- expect ( stream . lastSeen ) . toBeLessThan ( timeBeforeBump ) ;
838
-
839
- const res = await client . post ( `/stream/${ stream . id } /heartbeat` ) ;
840
-
841
- expect ( res . status ) . toBe ( 204 ) ;
842
- const updatedStream = await server . db . stream . get ( stream . id ) ;
843
- expect ( updatedStream . lastSeen ) . toBeGreaterThan ( timeBeforeBump ) ;
844
- } ) ;
845
-
846
763
it ( "should allow changing the mist host as well" , async ( ) => {
847
764
const stream = await createAndActivateStream ( ) ;
848
765
0 commit comments