This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Kill using -g instead of -s * Add integration test for kill-process! * feedback from dpo * feedback from shams
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
waiter/integration/waiter/shell_scheduler_integration_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(ns waiter.shell-scheduler-integration-test | ||
(:require [clojure.java.shell :as sh] | ||
[clojure.string :as str] | ||
[clojure.test :refer :all] | ||
[waiter.shell-scheduler :refer :all] | ||
[waiter.test-helpers :refer :all] | ||
[waiter.utils :as utils]) | ||
(:import (java.nio.file Files | ||
Paths) | ||
java.nio.file.attribute.FileAttribute)) | ||
|
||
(deftest ^:parallel ^:integration-fast test-kill-process | ||
(let [working-dir (Files/createTempDirectory nil | ||
(make-array FileAttribute 0)) | ||
test-cmd (-> (Paths/get "test-files/test-command.sh" (make-array String 0)) | ||
.toAbsolutePath | ||
.toString) | ||
port->reservation-atom (atom {}) | ||
{:keys [shell-scheduler/pid] :as instance} (launch-instance "abc" working-dir test-cmd "http" {} 1 | ||
port->reservation-atom [40000 50000])] | ||
; There are 4 processes spawned by the instance: | ||
; 1. The wrapper process launched by the scheduler | ||
; 2. The `test-command.sh` script | ||
; 3/4 sleep commands forked by `test-command.sh` | ||
(is (wait-for #(= 4 (count (str/split (:out (sh/sh "pgrep" "-g" (str pid))) | ||
#"\n"))) | ||
:interval 1 :timeout 10)) | ||
(kill-process! instance port->reservation-atom 100) | ||
(is (wait-for #(= "" (:out (sh/sh "pgrep" "-g" (str pid)))) | ||
:interval 1 :timeout 10)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sleep 120 & | ||
sleep 120 & | ||
wait |