juliomax commented on code in PR #2894:
URL: 
https://github.com/apache/datafusion-ballista/pull/2894#discussion_r4645644048


##########
ballista/executor/src/executor_process.rs:
##########
@@ -1570,6 +1635,371 @@ mod tests {
         drop(listener);
     }
 
+    #[test]
+    fn resolve_vcores_zero_uses_available_parallelism() {
+        let config = ExecutorProcessConfig {
+            vcores: 0,
+            ..ExecutorProcessConfig::default()
+        };
+
+        assert_eq!(
+            super::resolve_vcores(&config),
+            std::thread::available_parallelism().unwrap().get()
+        );
+    }
+
+    #[test]
+    fn resolve_vcores_explicit_is_kept() {
+        let config = ExecutorProcessConfig {
+            vcores: 3,
+            ..ExecutorProcessConfig::default()
+        };
+
+        assert_eq!(super::resolve_vcores(&config), 3);
+    }
+
+    #[tokio::test]
+    async fn shuffle_cleaner_removes_expired_job_dirs_and_stops_on_shutdown() {
+        let work_dir = TempDir::new().unwrap();
+        let job_dir = work_dir.path().join("job_id");
+        fs::create_dir(&job_dir).unwrap();
+        File::create(job_dir.join("tmp.csv"))
+            .expect("creating temp file")
+            .write_all(b"data")
+            .expect("writing data");
+
+        let mut notifier = ShutdownNotifier::new();
+        super::spawn_shuffle_cleaner(&notifier, 
work_dir.path().to_str().unwrap(), 1, 1);
+
+        tokio::time::timeout(Duration::from_secs(10), async {
+            while job_dir.exists() {
+                tokio::time::sleep(Duration::from_millis(100)).await;
+            }
+        })
+        .await
+        .expect("expired job dir was never cleaned");
+
+        // The cleaner holds a completion sender until it sees the shutdown
+        // signal, so the receiver only completes once the cleaner has stopped.
+        let _ = notifier.notify_shutdown.send(());
+        drop(notifier.shutdown_complete_tx);
+        tokio::time::timeout(
+            Duration::from_secs(5),
+            notifier.shutdown_complete_rx.recv(),
+        )
+        .await
+        .expect("shuffle cleaner did not stop on shutdown");
+    }
+
+    #[tokio::test]
+    async fn stop_request_ends_the_wait_without_notifying_the_scheduler() {
+        let mut handlers = FuturesUnordered::new();
+        handlers.push(tokio::spawn(async {
+            std::future::pending::<Result<(), BallistaError>>().await
+        }));
+        let (stop_send, mut stop_recv) = 
tokio::sync::mpsc::channel::<bool>(10);
+        stop_send.send(true).await.unwrap();
+
+        let outcome = tokio::time::timeout(
+            Duration::from_secs(5),
+            super::run_until_shutdown(&mut handlers, &mut stop_recv),
+        )
+        .await
+        .expect("a stop request did not end the wait");
+
+        assert_eq!(outcome, (false, String::new()));
+    }
+
+    #[tokio::test]
+    async fn failed_service_ends_the_wait_and_notifies_the_scheduler() {
+        let mut handlers = FuturesUnordered::new();
+        handlers.push(tokio::spawn(async {
+            Err::<(), 
BallistaError>(BallistaError::General("boom".to_string()))
+        }));
+        let (_stop_send, mut stop_recv) = 
tokio::sync::mpsc::channel::<bool>(10);
+
+        let (notify_scheduler, reason) = tokio::time::timeout(
+            Duration::from_secs(5),
+            super::run_until_shutdown(&mut handlers, &mut stop_recv),
+        )
+        .await
+        .expect("a failed service did not end the wait");
+
+        assert!(notify_scheduler);
+        assert!(
+            reason.starts_with("executor services stopped with reason Err("),
+            "unexpected reason: {reason}"
+        );
+        assert!(reason.contains("boom"), "unexpected reason: {reason}");
+    }
+
+    /// Reserves a local port and releases it, so nothing listens there.
+    fn unused_local_port() -> u16 {

Review Comment:
   Done in 1f41fc70



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to