@@ -39,9 +39,9 @@ const userKey = 'nicolas@split.io';
3939const secondUserKey = 'marcio@split.io' ;
4040
4141const baseUrls = {
42- sdk : 'https://sdk.push-fallbacking /api' ,
43- events : 'https://events.push-fallbacking /api' ,
44- auth : 'https://auth.push-fallbacking /api'
42+ sdk : 'https://sdk.push-fallback /api' ,
43+ events : 'https://events.push-fallback /api' ,
44+ auth : 'https://auth.push-fallback /api'
4545} ;
4646const config = {
4747 core : {
@@ -51,11 +51,14 @@ const config = {
5151 scheduler : {
5252 featuresRefreshRate : 0.2 ,
5353 segmentsRefreshRate : 0.25 ,
54+ largeSegmentsRefreshRate : 0.25 ,
5455 impressionsRefreshRate : 3000
5556 } ,
5657 urls : baseUrls ,
5758 streamingEnabled : true ,
58- // debug: true,
59+ sync : {
60+ largeSegmentsEnabled : true
61+ }
5962} ;
6063const settings = settingsFactory ( config ) ;
6164
@@ -79,30 +82,31 @@ const MILLIS_DESTROY = MILLIS_STREAMING_DISABLED_CONTROL + settings.scheduler.fe
7982
8083/**
8184 * Sequence of calls:
82- * 0.0 secs: initial SyncAll (/splitChanges, /mySegments/* ), auth, SSE connection
83- * 0.1 secs: SSE connection opened -> syncAll (/splitChanges, /mySegments /nicolas)
84- * 0.2 secs: Streaming down (OCCUPANCY event) -> fetch due to fallback to polling (/splitChanges, /mySegments /nicolas)
85+ * 0.0 secs: initial SyncAll (/splitChanges, /my(Large)Segments/nicolas ), auth, SSE connection
86+ * 0.1 secs: SSE connection opened -> syncAll (/splitChanges, /my(Large)Segments /nicolas)
87+ * 0.2 secs: Streaming down (OCCUPANCY event) -> fetch due to fallback to polling (/splitChanges, /my(Large)Segments /nicolas)
8588 * 0.3 secs: SPLIT_UPDATE event ignored
8689 * 0.4 secs: periodic fetch due to polling (/splitChanges)
87- * 0.45 secs: periodic fetch due to polling (/mySegments /*)
88- * 0.5 secs: Streaming up (OCCUPANCY event) -> syncAll (/splitChanges, /mySegments /nicolas)
89- * 0.55 secs: create a new client while streaming -> initial fetch (/mySegments /marcio), auth, SSE connection and syncAll (/splitChanges, /mySegments /nicolas, /mySegments /marcio)
90+ * 0.45 secs: periodic fetch due to polling (/my(Large)Segments /*)
91+ * 0.5 secs: Streaming up (OCCUPANCY event) -> syncAll (/splitChanges, /my(Large)Segments /nicolas)
92+ * 0.55 secs: create a new client while streaming -> initial fetch (/my(Large)Segments /marcio), auth, SSE connection and syncAll (/splitChanges, /my(Large)Segments /nicolas, /my(Large)Segments /marcio)
9093 * 0.6 secs: SPLIT_UPDATE event -> /splitChanges
91- * 0.7 secs: Streaming down (CONTROL event) -> fetch due to fallback to polling (/splitChanges, /mySegments /nicolas, /mySegments /marcio)
94+ * 0.7 secs: Streaming down (CONTROL event) -> fetch due to fallback to polling (/splitChanges, /my(Large)Segments /nicolas, /my(Large)Segments /marcio)
9295 * 0.8 secs: MY_SEGMENTS_UPDATE event ignored
9396 * 0.9 secs: periodic fetch due to polling (/splitChanges)
94- * 0.95 secs: periodic fetch due to polling (/mySegments /nicolas, /mySegments /marcio, /mySegments /facundo)
95- * 1.0 secs: Streaming up (CONTROL event) -> syncAll (/splitChanges, /mySegments /nicolas, /mySegments /marcio, /mySegments /facundo)
97+ * 0.95 secs: periodic fetch due to polling (/my(Large)Segments /nicolas, /my(Large)Segments /marcio, /my(Large)Segments /facundo)
98+ * 1.0 secs: Streaming up (CONTROL event) -> syncAll (/splitChanges, /my(Large)Segments /nicolas, /my(Large)Segments /marcio, /my(Large)Segments /facundo)
9699 * 1.1 secs: MY_SEGMENTS_UPDATE event -> /mySegments/nicolas
97- * 1.2 secs: Streaming down (CONTROL event) -> fetch due to fallback to polling (/splitChanges, /mySegments /nicolas, /mySegments /marcio, /mySegments /facundo)
100+ * 1.2 secs: Streaming down (CONTROL event) -> fetch due to fallback to polling (/splitChanges, /my(Large)Segments /nicolas, /my(Large)Segments /marcio, /my(Large)Segments /facundo)
98101 * 1.3 secs: STREAMING_RESET control event -> auth, SSE connection, syncAll and stop polling
99102 * 1.5 secs: STREAMING_RESET control event -> auth, SSE connection, syncAll
100103 * 1.6 secs: Streaming closed (CONTROL STREAMING_DISABLED event) -> fetch due to fallback to polling (/splitChanges, /mySegments/nicolas, /mySegments/marcio, /mySegments/facundo)
101- * 1.8 secs: periodic fetch due to polling (/splitChanges): due to update without segments, mySegments are not fetched
104+ * 1.8 secs: periodic fetch due to polling (/splitChanges)
105+ * 1.85 secs: periodic fetch due to polling (/myLargeSegments/*). /mySegments/* are not fetched due to update without segments
102106 * 2.0 secs: periodic fetch due to polling (/splitChanges)
103107 * 2.1 secs: destroy client
104108 */
105- export function testFallbacking ( fetchMock , assert ) {
109+ export function testFallback ( fetchMock , assert ) {
106110 assert . plan ( 20 ) ;
107111 fetchMock . reset ( ) ;
108112
@@ -213,6 +217,10 @@ export function testFallbacking(fetchMock, assert) {
213217 return { status : 200 , body : authPushEnabledNicolas } ;
214218 } ) ;
215219
220+ // MyLargeSegments are fetched one more time than MySegments due to smart pausing of MySegments sync at the end of the test
221+ fetchMock . get ( { url : url ( settings , '/myLargeSegments/nicolas%40split.io' ) , repeat : 14 } , { status : 200 , body : { myLargeSegments : [ ] } } ) ;
222+ fetchMock . get ( { url : url ( settings , '/myLargeSegments/marcio%40split.io' ) , repeat : 10 } , { status : 200 , body : { myLargeSegments : [ ] } } ) ;
223+
216224 // initial split and mySegment sync
217225 fetchMock . getOnce ( url ( settings , '/splitChanges?s=1.1&since=-1' ) , { status : 200 , body : splitChangesMock1 } ) ;
218226 fetchMock . getOnce ( url ( settings , '/mySegments/nicolas%40split.io' ) , { status : 200 , body : mySegmentsNicolasMock1 } ) ;
0 commit comments