@@ -20,6 +20,7 @@ use std::error::Error;
2020use std:: path:: PathBuf ;
2121
2222use ballista:: prelude:: { SessionConfigExt , SessionContextExt } ;
23+ use ballista_core:: config:: TaskSchedulingPolicy ;
2324use ballista_core:: serde:: {
2425 BallistaCodec , protobuf:: scheduler_grpc_client:: SchedulerGrpcClient ,
2526} ;
@@ -99,25 +100,36 @@ fn get_data_dir(udf_env: &str, submodule_data: &str) -> Result<PathBuf, Box<dyn
99100 }
100101}
101102
102- /// starts a ballista cluster for integration tests
103+ /// starts a ballista cluster for integration tests (pull-staged scheduling).
103104#[ allow( dead_code) ]
104105pub async fn setup_test_cluster ( ) -> ( String , u16 ) {
106+ setup_test_cluster_with_scheduling ( TaskSchedulingPolicy :: PullStaged ) . await
107+ }
108+
109+ /// starts a ballista cluster using the given [`TaskSchedulingPolicy`].
110+ #[ allow( dead_code) ]
111+ pub async fn setup_test_cluster_with_scheduling (
112+ scheduling_policy : TaskSchedulingPolicy ,
113+ ) -> ( String , u16 ) {
105114 let config = SessionConfig :: new_with_ballista ( ) ;
106115 let default_codec = BallistaCodec :: default ( ) ;
107116
108- let addr = ballista_scheduler:: standalone:: new_standalone_scheduler ( )
109- . await
110- . expect ( "scheduler to be created" ) ;
117+ let addr = ballista_scheduler:: standalone:: new_standalone_scheduler_with_scheduling (
118+ scheduling_policy,
119+ )
120+ . await
121+ . expect ( "scheduler to be created" ) ;
111122
112- let host = "localhost " . to_string ( ) ;
123+ let host = "127.0.0.1 " . to_string ( ) ;
113124
114125 let scheduler =
115126 connect_to_scheduler ( format ! ( "http://{}:{}" , host, addr. port( ) ) ) . await ;
116127
117- ballista_executor:: new_standalone_executor (
128+ ballista_executor:: new_standalone_executor_with_scheduling_policy (
118129 scheduler,
119130 config. ballista_standalone_parallelism ( ) ,
120131 default_codec,
132+ scheduling_policy,
121133 )
122134 . await
123135 . expect ( "executor to be created" ) ;
@@ -127,26 +139,48 @@ pub async fn setup_test_cluster() -> (String, u16) {
127139 ( host, addr. port ( ) )
128140}
129141
130- /// starts a ballista cluster for integration tests
142+ /// starts a ballista cluster using push-staged scheduling (default executor policy).
131143#[ allow( dead_code) ]
132- pub async fn setup_test_cluster_with_state ( session_state : SessionState ) -> ( String , u16 ) {
133- let config = SessionConfig :: new_with_ballista ( ) ;
144+ pub async fn setup_test_cluster_push_scheduling ( ) -> ( String , u16 ) {
145+ setup_test_cluster_with_scheduling ( TaskSchedulingPolicy :: PushStaged ) . await
146+ }
134147
135- let addr = ballista_scheduler:: standalone:: new_standalone_scheduler_from_state (
136- & session_state,
148+ /// starts a cluster with [`SessionState`] (pull scheduling).
149+ #[ allow( dead_code) ]
150+ pub async fn setup_test_cluster_with_state ( session_state : SessionState ) -> ( String , u16 ) {
151+ setup_test_cluster_with_state_and_scheduling (
152+ session_state,
153+ TaskSchedulingPolicy :: PullStaged ,
137154 )
138155 . await
139- . expect ( "scheduler to be created" ) ;
156+ }
140157
141- let host = "localhost" . to_string ( ) ;
158+ /// starts a ballista cluster with selectable [`TaskSchedulingPolicy`].
159+ #[ allow( dead_code) ]
160+ pub async fn setup_test_cluster_with_state_and_scheduling (
161+ session_state : SessionState ,
162+ scheduling_policy : TaskSchedulingPolicy ,
163+ ) -> ( String , u16 ) {
164+ let config = SessionConfig :: new_with_ballista ( ) ;
165+
166+ let addr =
167+ ballista_scheduler:: standalone:: new_standalone_scheduler_from_state_with_scheduling_policy (
168+ & session_state,
169+ scheduling_policy,
170+ )
171+ . await
172+ . expect ( "scheduler to be created" ) ;
173+
174+ let host = "127.0.0.1" . to_string ( ) ;
142175
143176 let scheduler =
144177 connect_to_scheduler ( format ! ( "http://{}:{}" , host, addr. port( ) ) ) . await ;
145178
146- ballista_executor:: new_standalone_executor_from_state (
179+ ballista_executor:: new_standalone_executor_from_state_with_scheduling_policy (
147180 scheduler,
148181 config. ballista_standalone_parallelism ( ) ,
149182 & session_state,
183+ scheduling_policy,
150184 )
151185 . await
152186 . expect ( "executor to be created" ) ;
@@ -156,11 +190,39 @@ pub async fn setup_test_cluster_with_state(session_state: SessionState) -> (Stri
156190 ( host, addr. port ( ) )
157191}
158192
193+ /// starts a cluster with push-staged scheduling and a custom session state.
194+ #[ allow( dead_code) ]
195+ pub async fn setup_test_cluster_with_state_push_scheduling (
196+ session_state : SessionState ,
197+ ) -> ( String , u16 ) {
198+ setup_test_cluster_with_state_and_scheduling (
199+ session_state,
200+ TaskSchedulingPolicy :: PushStaged ,
201+ )
202+ . await
203+ }
204+
159205#[ allow( dead_code) ]
160206pub async fn setup_test_cluster_with_builders (
161207 config_producer : ConfigProducer ,
162208 runtime_producer : RuntimeProducer ,
163209 session_builder : SessionBuilder ,
210+ ) -> ( String , u16 ) {
211+ setup_test_cluster_with_builders_and_scheduling (
212+ config_producer,
213+ runtime_producer,
214+ session_builder,
215+ TaskSchedulingPolicy :: PullStaged ,
216+ )
217+ . await
218+ }
219+
220+ #[ allow( dead_code) ]
221+ pub async fn setup_test_cluster_with_builders_and_scheduling (
222+ config_producer : ConfigProducer ,
223+ runtime_producer : RuntimeProducer ,
224+ session_builder : SessionBuilder ,
225+ scheduling_policy : TaskSchedulingPolicy ,
164226) -> ( String , u16 ) {
165227 let config = config_producer ( ) ;
166228
@@ -171,26 +233,29 @@ pub async fn setup_test_cluster_with_builders(
171233 datafusion_proto:: protobuf:: PhysicalPlanNode ,
172234 > = BallistaCodec :: new ( logical, physical) ;
173235
174- let addr = ballista_scheduler:: standalone:: new_standalone_scheduler_with_builder (
175- session_builder,
176- config_producer. clone ( ) ,
177- codec. clone ( ) ,
178- )
179- . await
180- . expect ( "scheduler to be created" ) ;
236+ let addr =
237+ ballista_scheduler:: standalone:: new_standalone_scheduler_with_builder_and_policy (
238+ session_builder,
239+ config_producer. clone ( ) ,
240+ codec. clone ( ) ,
241+ scheduling_policy,
242+ )
243+ . await
244+ . expect ( "scheduler to be created" ) ;
181245
182- let host = "localhost " . to_string ( ) ;
246+ let host = "127.0.0.1 " . to_string ( ) ;
183247
184248 let scheduler =
185249 connect_to_scheduler ( format ! ( "http://{}:{}" , host, addr. port( ) ) ) . await ;
186250
187- ballista_executor:: new_standalone_executor_from_builder (
251+ ballista_executor:: new_standalone_executor_from_builder_with_scheduling_policy (
188252 scheduler,
189253 config. ballista_standalone_parallelism ( ) ,
190254 config_producer,
191255 runtime_producer,
192256 codec,
193257 Default :: default ( ) ,
258+ scheduling_policy,
194259 )
195260 . await
196261 . expect ( "executor to be created" ) ;
@@ -234,6 +299,15 @@ pub async fn remote_context() -> SessionContext {
234299 . unwrap ( )
235300}
236301
302+ /// Remote [`SessionContext`] against a throwaway cluster using push-staged scheduling.
303+ #[ allow( dead_code) ]
304+ pub async fn remote_context_push_scheduling ( ) -> SessionContext {
305+ let ( host, port) = setup_test_cluster_push_scheduling ( ) . await ;
306+ SessionContext :: remote ( & format ! ( "df://{host}:{port}" ) )
307+ . await
308+ . unwrap ( )
309+ }
310+
237311#[ allow( dead_code) ]
238312pub async fn standalone_context_with_state ( ) -> SessionContext {
239313 let config = SessionConfig :: new_with_ballista ( ) ;
@@ -257,6 +331,19 @@ pub async fn remote_context_with_state() -> SessionContext {
257331 . unwrap ( )
258332}
259333
334+ #[ allow( dead_code) ]
335+ pub async fn remote_context_with_state_push_scheduling ( ) -> SessionContext {
336+ let config = SessionConfig :: new_with_ballista ( ) ;
337+ let state = SessionStateBuilder :: new ( )
338+ . with_config ( config)
339+ . with_default_features ( )
340+ . build ( ) ;
341+ let ( host, port) = setup_test_cluster_with_state_push_scheduling ( state. clone ( ) ) . await ;
342+ SessionContext :: remote_with_state ( & format ! ( "df://{host}:{port}" ) , state)
343+ . await
344+ . unwrap ( )
345+ }
346+
260347#[ ctor:: ctor( unsafe ) ]
261348fn init ( ) {
262349 // Enable RUST_LOG logging configuration for test
0 commit comments