@@ -131,6 +131,7 @@ def graph(symbols: list, count: int):
131
131
csp .timer (timedelta (seconds = 0.2 ), True ),
132
132
csp .delay (csp .timer (timedelta (seconds = 0.2 ), False ), timedelta (seconds = 0.1 )),
133
133
)
134
+
134
135
i = csp .count (csp .timer (timedelta (seconds = 0.15 )))
135
136
d = csp .count (csp .timer (timedelta (seconds = 0.2 ))) / 2.0
136
137
s = csp .sample (csp .timer (timedelta (seconds = 0.4 )), csp .const ("STRING" ))
@@ -157,18 +158,13 @@ def graph(symbols: list, count: int):
157
158
)
158
159
csp .add_graph_output (f"pall_{ symbol } " , pub_data )
159
160
160
- # csp.print('status', kafkaadapter.status())
161
-
162
161
sub_data = kafkaadapter .subscribe (
163
162
ts_type = SubData ,
164
163
msg_mapper = msg_mapper ,
165
164
topic = topic ,
166
165
key = symbol ,
167
166
push_mode = csp .PushMode .NON_COLLAPSING ,
168
167
)
169
-
170
- sub_data = csp .firstN (sub_data , count )
171
-
172
168
csp .add_graph_output (f"sall_{ symbol } " , sub_data )
173
169
174
170
done_flag = csp .count (sub_data ) == count
@@ -190,8 +186,12 @@ def graph(symbols: list, count: int):
190
186
pub = results [f"pall_{ symbol } " ]
191
187
sub = results [f"sall_{ symbol } " ]
192
188
189
+ # limit by the last `count`
190
+ sub = sub [- 1 * count :]
191
+ pub = pub [- 1 * count :]
192
+
193
193
assert len (sub ) == count
194
- assert [v [1 ] for v in sub ] == [v [1 ] for v in pub [: count ]]
194
+ assert [v [1 ] for v in sub ] == [v [1 ] for v in pub [- 1 * count : ]]
195
195
196
196
@pytest .mark .skipif (not os .environ .get ("CSP_TEST_KAFKA" ), reason = "Skipping kafka adapter tests" )
197
197
def test_start_offsets (self , kafkaadapter , kafkabroker ):
0 commit comments