@@ -79,11 +79,10 @@ def graph(count: int):
7979 }
8080
8181 topic = f"test.metadata.{ os .getpid ()} "
82- _precreate_topic (topic )
8382 subKey = "foo"
8483 pubKey = ["mapped_a" , "mapped_b" , "mapped_c" ]
8584
86- c = csp .count (csp .timer (timedelta (seconds = 0.1 )))
85+ c = csp .count (csp .timer (timedelta (seconds = 0.5 )))
8786 t = csp .sample (c , csp .const ("foo" ))
8887
8988 pubStruct = MetaPubData .collectts (
@@ -104,22 +103,23 @@ def graph(count: int):
104103 )
105104
106105 csp .add_graph_output ("sub_data" , sub_data )
107- # csp.print('sub', sub_data)
106+ csp .print ('sub' , sub_data )
108107 # Wait for at least count ticks and until we get a live tick
109- done_flag = csp .count (sub_data ) >= count
110- done_flag = csp .and_ (done_flag , sub_data .mapped_live is True )
108+ done_flag = csp .and_ (csp .count (sub_data ) >= count , sub_data .mapped_live == True ) # noqa: E712
111109 stop = csp .filter (done_flag , done_flag )
112110 csp .stop_engine (stop )
113111
114- count = 5
115- results = csp .run (graph , count , starttime = datetime .utcnow (), endtime = timedelta (seconds = 30 ), realtime = True )
112+ results = csp .run (graph , 5 , starttime = datetime .utcnow (), endtime = timedelta (seconds = 10 ), realtime = True )
116113 assert len (results ["sub_data" ]) >= 5
117114 print (results )
118115 for result in results ["sub_data" ]:
119116 assert result [1 ].mapped_partition >= 0
120117 assert result [1 ].mapped_offset >= 0
121118 assert result [1 ].mapped_live is not None
122119 assert result [1 ].mapped_timestamp < datetime .utcnow ()
120+ # first record should be non live
121+ assert results ["sub_data" ][0 ][1 ].mapped_live is False
122+ # last record should be live
123123 assert results ["sub_data" ][- 1 ][1 ].mapped_live
124124
125125 @pytest .mark .skipif (not os .environ .get ("CSP_TEST_KAFKA" ), reason = "Skipping kafka adapter tests" )
@@ -186,7 +186,7 @@ def graph(symbols: list, count: int):
186186 symbols = ["AAPL" , "MSFT" ]
187187 count = 100
188188 results = csp .run (
189- graph , symbols , count , starttime = datetime .utcnow (), endtime = timedelta (seconds = 30 ), realtime = True
189+ graph , symbols , count , starttime = datetime .utcnow (), endtime = timedelta (seconds = 10 ), realtime = True
190190 )
191191 for symbol in symbols :
192192 pub = results [f"pall_{ symbol } " ]
@@ -212,7 +212,7 @@ def pub_graph():
212212 csp .stop_engine (stop )
213213 # csp.print('pub', struct)
214214
215- csp .run (pub_graph , starttime = datetime .utcnow (), endtime = timedelta (seconds = 30 ), realtime = True )
215+ csp .run (pub_graph , starttime = datetime .utcnow (), endtime = timedelta (seconds = 10 ), realtime = True )
216216
217217 # grab start/end times
218218 def get_times_graph ():
@@ -232,7 +232,7 @@ def get_times_graph():
232232 # csp.print('sub', data)
233233 # csp.print('status', kafkaadapter.status())
234234
235- all_data = csp .run (get_times_graph , starttime = datetime .utcnow (), endtime = timedelta (seconds = 30 ), realtime = True )[
235+ all_data = csp .run (get_times_graph , starttime = datetime .utcnow (), endtime = timedelta (seconds = 10 ), realtime = True )[
236236 "data"
237237 ]
238238 min_time = all_data [0 ][1 ].dt
@@ -258,7 +258,7 @@ def get_data(start_offset, expected_count):
258258 KafkaStartOffset .EARLIEST ,
259259 10 ,
260260 starttime = datetime .utcnow (),
261- endtime = timedelta (seconds = 30 ),
261+ endtime = timedelta (seconds = 10 ),
262262 realtime = True ,
263263 )["data" ]
264264 # print(res)
@@ -276,7 +276,7 @@ def get_data(start_offset, expected_count):
276276 assert len (res ) == 0
277277
278278 res = csp .run (
279- get_data , KafkaStartOffset .START_TIME , 10 , starttime = min_time , endtime = timedelta (seconds = 30 ), realtime = True
279+ get_data , KafkaStartOffset .START_TIME , 10 , starttime = min_time , endtime = timedelta (seconds = 10 ), realtime = True
280280 )["data" ]
281281 assert len (res ) == 10
282282
@@ -287,12 +287,12 @@ def get_data(start_offset, expected_count):
287287 stime = all_data [2 ][1 ].dt + timedelta (milliseconds = 1 )
288288 expected = [x for x in all_data if x [1 ].dt >= stime ]
289289 res = csp .run (
290- get_data , stime , len (expected ), starttime = datetime .utcnow (), endtime = timedelta (seconds = 30 ), realtime = True
290+ get_data , stime , len (expected ), starttime = datetime .utcnow (), endtime = timedelta (seconds = 10 ), realtime = True
291291 )["data" ]
292292 assert len (res ) == len (expected )
293293
294294 res = csp .run (
295- get_data , timedelta (seconds = 0 ), len (expected ), starttime = stime , endtime = timedelta (seconds = 30 ), realtime = True
295+ get_data , timedelta (seconds = 0 ), len (expected ), starttime = stime , endtime = timedelta (seconds = 10 ), realtime = True
296296 )["data" ]
297297 assert len (res ) == len (expected )
298298
@@ -359,7 +359,7 @@ def graph(symbols: list, count: int):
359359 symbols = ["AAPL" , "MSFT" ]
360360 count = 10
361361 results = csp .run (
362- graph , symbols , count , starttime = datetime .utcnow (), endtime = timedelta (seconds = 30 ), realtime = True
362+ graph , symbols , count , starttime = datetime .utcnow (), endtime = timedelta (seconds = 10 ), realtime = True
363363 )
364364 # print(results)
365365 for symbol in symbols :
0 commit comments