File tree Expand file tree Collapse file tree 4 files changed +17
-6
lines changed Expand file tree Collapse file tree 4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1- PYTEST_FLAGS =-W error::SyntaxWarning
1+ PYTEST_FLAGS =-W error::SyntaxWarning -s
22
33TEMP_TEST_OUTPUT =/tmp/contract-test-service.log
44
@@ -28,12 +28,12 @@ install:
2828.PHONY : test
2929test : # ! Run unit tests
3030test : install
31- @LD_SKIP_DATABASE_TESTS=1 poetry run pytest $(PYTEST_FLAGS )
31+ @LD_SKIP_DATABASE_TESTS=1 poetry run pytest $(PYTEST_FLAGS ) ldclient/testing/impl/datasystem/test_fdv2_datasystem.py::test_two_phase_init
3232
3333.PHONY : test-all
3434test-all : # ! Run unit tests (including database integrations)
3535test-all : install
36- @poetry run pytest $(PYTEST_FLAGS )
36+ @poetry run pytest $(PYTEST_FLAGS ) ldclient/testing/impl/datasystem/test_fdv2_datasystem.py::test_two_phase_init
3737
3838.PHONY : lint
3939lint : # ! Run type analysis and linting checks
Original file line number Diff line number Diff line change @@ -307,6 +307,7 @@ def _run_initializers(self, set_on_ready: Event):
307307 log .info ("Attempting to initialize via %s" , initializer .name )
308308
309309 basis_result = initializer .fetch (self ._store )
310+ print ("@@@@@@" , "init" , basis_result , "\n " )
310311
311312 if isinstance (basis_result , _Fail ):
312313 log .warning ("Initializer %s failed: %s" , initializer .name , basis_result .error )
@@ -446,6 +447,7 @@ def _consume_synchronizer_results(
446447 def reader (self : 'FDv2' ):
447448 try :
448449 for update in synchronizer .sync (self ._store ):
450+ print ("@@@@@@" , "update is at" , update , "\n " )
449451 action_queue .put (update )
450452 finally :
451453 action_queue .put ("quit" )
Original file line number Diff line number Diff line change @@ -296,9 +296,12 @@ def _set_basis(
296296 # Take snapshot for change detection if we have flag listeners
297297 old_data : Optional [Collections ] = None
298298 if self ._flag_change_listeners .has_listeners ():
299+ print ("@@@@" , "we have flag listeners\n " )
299300 old_data = {}
300301 for kind in [FEATURES , SEGMENTS ]:
301302 old_data [kind ] = self ._memory_store .all (kind , lambda x : x )
303+ else :
304+ print ("@@@@" , "we don't have flag listeners\n " )
302305
303306 ok = self ._memory_store .set_basis (collections )
304307 if ok is False :
@@ -323,6 +326,7 @@ def _set_basis(
323326 affected_items = self ._compute_changed_items_for_full_data_set (
324327 old_data , collections
325328 )
329+ print ("@@@@@ affected items are" , affected_items , "\n " )
326330 self ._send_change_events (affected_items )
327331
328332 def _apply_delta (
Original file line number Diff line number Diff line change @@ -27,25 +27,30 @@ def test_two_phase_init():
2727 set_on_ready = Event ()
2828 fdv2 = FDv2 (Config (sdk_key = "dummy" ), data_system_config )
2929
30- changed = Event ()
30+ initialized = Event ()
31+ modified = Event ()
3132 changes : List [FlagChange ] = []
3233 count = 0
3334
3435 def listener (flag_change : FlagChange ):
3536 nonlocal count , changes
3637 count += 1
38+ print ("@@@@@ count" , count , "\n " )
3739 changes .append (flag_change )
3840
41+ if count == 1 :
42+ initialized .set ()
3943 if count == 2 :
40- changed .set ()
44+ modified .set ()
4145
4246 fdv2 .flag_tracker .add_listener (listener )
4347
4448 fdv2 .start (set_on_ready )
4549 assert set_on_ready .wait (1 ), "Data system did not become ready in time"
50+ assert initialized .wait (1 ), "Data system did not read from both initialization and synchronizer yet"
4651
4752 td_synchronizer .update (td_synchronizer .flag ("feature-flag" ).on (False ))
48- assert changed .wait (1 ), "Flag change listener was not called in time "
53+ assert modified .wait (1 ), "Data system did not read update from synchronizer "
4954 assert len (changes ) == 2
5055 assert changes [0 ].key == "feature-flag"
5156 assert changes [1 ].key == "feature-flag"
You can’t perform that action at this time.
0 commit comments