@@ -232,7 +232,8 @@ module NetworkGeneration
232232 task0 . out_port . connect_to ( task1 . in_port )
233233
234234 @dynamics . should_receive ( :policy_for )
235- . with ( task0 , "out" , "in" , task1 , nil )
235+ . with ( task0 , "out" , "in" , task1 , nil ,
236+ explicit_policy : { } )
236237 . and_return ( type : :buffer , size : 42 )
237238 policy_graph = @dynamics . compute_connection_policies
238239
@@ -252,7 +253,8 @@ module NetworkGeneration
252253 task0 . out_port . connect_to ( task1 . in_port )
253254
254255 @dynamics . should_receive ( :policy_for )
255- . with ( task0 , "out" , "in" , task1 , nil )
256+ . with ( task0 , "out" , "in" , task1 , nil ,
257+ explicit_policy : { } )
256258 . and_return ( type : :buffer , size : 42 , init : true )
257259 policy_graph = @dynamics . compute_connection_policies
258260
@@ -272,7 +274,8 @@ module NetworkGeneration
272274 task0 . out_port . connect_to ( task1 . in_port )
273275
274276 @dynamics . should_receive ( :policy_for )
275- . with ( task0 , "out" , "in" , task1 , nil )
277+ . with ( task0 , "out" , "in" , task1 , nil ,
278+ explicit_policy : { } )
276279 . and_return ( type : :buffer , size : 42 , init : false )
277280 policy_graph = @dynamics . compute_connection_policies
278281
@@ -290,7 +293,8 @@ module NetworkGeneration
290293 cmp . c_child . out_port . connect_to ( task . in_port )
291294
292295 @dynamics . should_receive ( :policy_for )
293- . with ( cmp . c_child , "out" , "in" , task , nil )
296+ . with ( cmp . c_child , "out" , "in" , task , nil ,
297+ explicit_policy : { } )
294298 . and_return ( type : :buffer , size : 42 )
295299 policy_graph = @dynamics . compute_connection_policies
296300
@@ -308,7 +312,7 @@ module NetworkGeneration
308312 task0 . out_port . connect_to ( task1 . in_port , type : :buffer , size : 42 )
309313
310314 @dynamics
311- . should_receive ( :policy_for )
315+ . should_receive ( :policy_compute_data_element )
312316 . with ( task0 , "out" , "in" , task1 , nil )
313317 . and_return ( type : :buffer , size : 10 , init : nil )
314318 policy_graph = @dynamics . compute_connection_policies
@@ -329,12 +333,13 @@ module NetworkGeneration
329333 )
330334
331335 @dynamics . should_receive ( :policy_for )
332- . with ( task0 , "out" , "in" , task1 , { type : :data } )
333- . and_return ( type : :buffer , size : 42 )
336+ . with ( task0 , "out" , "in" , task1 , { type : :data } ,
337+ explicit_policy : { } )
338+ . and_return ( type : :buffer , size : 42 , init : nil )
334339
335340 policy_graph = @dynamics . compute_connection_policies
336341
337- assert_equal ( { type : :buffer , size : 42 } ,
342+ assert_equal ( { type : :buffer , size : 42 , init : nil } ,
338343 policy_graph [ [ task0 , task1 ] ] [ %w[ out in ] ] )
339344 end
340345
@@ -351,9 +356,11 @@ module NetworkGeneration
351356 fallback_policy : { type : :data }
352357 )
353358
354- @dynamics . should_receive ( :policy_for ) . never
359+ @dynamics . should_receive ( :policy_compute_data_element )
360+ . with ( task0 , "out" , "in" , task1 , { type : :data } )
361+ . and_return ( { type : :buffer , size : 42 } )
355362 policy_graph = @dynamics . compute_connection_policies
356- assert_equal ( { type : :buffer , size : 42 } ,
363+ assert_equal ( { type : :buffer , size : 42 , init : nil } ,
357364 policy_graph [ [ task0 , task1 ] ] [ %w[ out in ] ] )
358365 end
359366
@@ -374,12 +381,31 @@ module NetworkGeneration
374381 task0 . out_port . connect_to task1 . in_port , type : :data
375382
376383 flexmock ( @dynamics )
377- . should_receive ( :policy_for )
378- . with ( task0 , "out" , "in" , task1 , nil )
379- . and_return ( type : :buffer , size : 10 , init : true )
384+ . should_receive ( :policy_compute_data_element )
385+ . never
386+
387+ policy_graph = @dynamics . compute_connection_policies
388+ expected_policy = { type : :data , init : nil }
389+ assert_equal ( expected_policy ,
390+ policy_graph [ [ task0 , task1 ] ] [ %w[ out in ] ] )
391+ end
392+
393+ it "makes sure the size is not overridden when explicit policy " \
394+ "sets the type to :buffer" do
395+ plan . add ( task0 = @task_m . new )
396+ plan . add ( task1 = @task_m . new )
397+
398+ add_agents ( tasks = [ task0 , task1 ] )
399+ flexmock ( @dynamics ) . should_receive ( :propagate ) . with ( tasks )
400+
401+ task0 . out_port . connect_to task1 . in_port , type : :buffer , size : 42
402+
403+ flexmock ( @dynamics )
404+ . should_receive ( :policy_compute_data_element )
405+ . never
380406
381407 policy_graph = @dynamics . compute_connection_policies
382- expected_policy = { type : :data , init : true }
408+ expected_policy = { type : :buffer , size : 42 , init : nil }
383409 assert_equal ( expected_policy ,
384410 policy_graph [ [ task0 , task1 ] ] [ %w[ out in ] ] )
385411 end
@@ -568,20 +594,29 @@ module NetworkGeneration
568594 "the sink port is marked as needs_reliable_connection" do
569595 @sink_task_m . in_port . needs_reliable_connection
570596 fallback_policy = flexmock
571- expected_policy = flexmock
597+ connection_policy = flexmock
598+ computed_policy = flexmock
599+ merged_policy = flexmock
572600
573- expected_policy
574- . should_receive ( :merge )
575- . and_return ( expected_policy )
601+ flexmock ( @dynamics )
602+ . should_receive ( :merge_policy )
603+ . with ( { } , computed_policy )
604+ . and_return ( merged_policy )
605+
606+ flexmock ( @dynamics )
607+ . should_receive ( :policy_default_init_flag )
608+ . with ( connection_policy , @source_t . out_port . model )
609+ . once . and_return ( computed_policy )
576610
577611 flexmock ( @dynamics )
578612 . should_receive ( :compute_reliable_connection_policy )
579613 . with ( @source_t . out_port , @sink_t . in_port , fallback_policy )
580- . once . and_return ( expected_policy )
614+ . once . and_return ( connection_policy )
615+
581616 policy = @dynamics . policy_for (
582617 @source_t , "out" , "in" , @sink_t , fallback_policy
583618 )
584- assert_equal expected_policy , policy
619+ assert_equal merged_policy , policy
585620 end
586621
587622 it "merges init policy when sink requires reliable connection" do
0 commit comments