1
1
*** Settings ***
2
- Resource atest_resource.robot
3
- Library ProcessManager.py
2
+ Documentation Test that SIGINT and SIGTERM can stop execution gracefully
3
+ ... (one signal) and forcefully (two signals). Windows does not
4
+ ... support these signals so we use CTRL_C_EVENT instead SIGINT
5
+ ... and do not test with SIGTERM.
6
+ Force Tags no-windows-jython
7
+ Resource atest_resource.robot
4
8
5
9
*** Variables ***
6
- ${TEST FILE } %{TEMPDIR }${/ } signal-tests.txt
10
+ ${TEST FILE } %{TEMPDIR }${/ } signal-tests.txt
7
11
8
12
*** Test Cases ***
9
13
SIGINT Signal Should Stop Test Execution Gracefully
10
- Start And Send Signal without_any_timeout.robot One SIGINT
11
- Process Output For Graceful Shutdown
14
+ Start And Send Signal without_any_timeout.robot One SIGINT
12
15
Check Test Cases Have Failed Correctly
13
16
14
17
SIGTERM Signal Should Stop Test Execution Gracefully
15
- [Tags] no-windows
16
- Start And Send Signal without_any_timeout.robot One SIGTERM
17
- Process Output For Graceful Shutdown
18
+ [Tags] no-windows
19
+ Start And Send Signal without_any_timeout.robot One SIGTERM
18
20
Check Test Cases Have Failed Correctly
19
21
20
22
Execution Is Stopped Even If Keyword Swallows Exception
21
23
[Tags] no-ipy no-jython
22
- Start And Send Signal swallow_exception.robot One SIGTERM
23
- Process Output For Graceful Shutdown
24
+ Start And Send Signal swallow_exception.robot One SIGINT
24
25
Check Test Cases Have Failed Correctly
25
26
26
27
One Signal Should Stop Test Execution Gracefully When Run Keyword Is Used
27
- Start And Send Signal run_keyword.robot One SIGTERM
28
- Process Output For Graceful Shutdown
28
+ Start And Send Signal run_keyword.robot One SIGINT
29
29
Check Test Cases Have Failed Correctly
30
30
31
31
One Signal Should Stop Test Execution Gracefully When Test Timeout Is Used
32
- Start And Send Signal test_timeout.robot One SIGTERM
33
- Process Output For Graceful Shutdown
32
+ Start And Send Signal test_timeout.robot One SIGINT
34
33
Check Test Cases Have Failed Correctly
35
34
36
35
One Signal Should Stop Test Execution Gracefully When Keyword Timeout Is Used
37
- Start And Send Signal keyword_timeout.robot One SIGTERM
38
- Process Output For Graceful Shutdown
36
+ Start And Send Signal keyword_timeout.robot One SIGINT
39
37
Check Test Cases Have Failed Correctly
40
38
41
39
Two SIGINT Signals Should Stop Test Execution Forcefully
42
- Start And Send Signal without_any_timeout.robot Two SIGINTs 2s
40
+ Start And Send Signal without_any_timeout.robot Two SIGINTs 2s
43
41
Check Tests Have Been Forced To Shutdown
44
42
45
43
Two SIGTERM Signals Should Stop Test Execution Forcefully
46
- [Tags] no-windows
47
- Start And Send Signal without_any_timeout.robot Two SIGTERMs 2s
44
+ [Tags] no-windows
45
+ Start And Send Signal without_any_timeout.robot Two SIGTERMs 2s
48
46
Check Tests Have Been Forced To Shutdown
49
47
50
48
Two Signals Should Stop Test Execution Forcefully When Run Keyword Is Used
51
- Start And Send Signal run_keyword.robot Two SIGINTs 2s
49
+ Start And Send Signal run_keyword.robot Two SIGINTs 2s
52
50
Check Tests Have Been Forced To Shutdown
53
51
54
52
Two Signals Should Stop Test Execution Forcefully When Test Timeout Is Used
55
- Start And Send Signal test_timeout.robot Two SIGINTs 2s
53
+ Start And Send Signal test_timeout.robot Two SIGINTs 2s
56
54
Check Tests Have Been Forced To Shutdown
57
55
58
56
Two Signals Should Stop Test Execution Forcefully When Keyword Timeout Is Used
59
- Start And Send Signal keyword_timeout.robot Two SIGINTs 2s
57
+ Start And Send Signal keyword_timeout.robot Two SIGINTs 2s
60
58
Check Tests Have Been Forced To Shutdown
61
59
62
60
One Signal Should Stop Test Execution Gracefully And Test Case And Suite Teardowns Should Be Run
63
- Start And Send Signal with_teardown.robot One SIGINT
64
- Process Output For Graceful Shutdown
61
+ Start And Send Signal with_teardown.robot One SIGINT
65
62
Check Test Cases Have Failed Correctly
66
- ${tc } = Get Test Case Test
67
- Check Log Message ${tc.teardown.msgs[0] } Logging Test Case Teardown
68
- ${ts } = Get Test Suite With Teardown
69
- Check Log Message ${ts.teardown.kws[0].msgs[0] } Logging Suite Teardown
63
+ ${tc } = Get Test Case Test
64
+ Check Log Message ${tc.teardown.msgs[0] } Logging Test Case Teardown
65
+ Check Log Message ${SUITE.teardown.kws[0].msgs[0] } Logging Suite Teardown
70
66
71
67
Skip Teardowns After Stopping Gracefully
72
- Start And Send Signal with_teardown.robot One SIGINT 0s --SkipTeardownOnExit
73
- Process Output For Graceful Shutdown
68
+ Start And Send Signal with_teardown.robot One SIGINT 0s --SkipTeardownOnExit
74
69
Check Test Cases Have Failed Correctly
75
- ${tc } = Get Test Case Test
76
- Should Be Equal ${tc.teardown } ${None }
77
- ${ts } = Get Test Suite With Teardown
78
- Should Be Equal ${ts.teardown } ${None }
79
-
70
+ ${tc } = Get Test Case Test
71
+ Should Be Equal ${tc.teardown } ${None }
72
+ Should Be Equal ${SUITE.teardown } ${None }
80
73
81
74
*** Keywords ***
82
75
Start And Send Signal
@@ -85,7 +78,9 @@ Start And Send Signal
85
78
Start Run ${datasource } ${sleep } @{extra options }
86
79
Wait Until Created ${TESTFILE } timeout=45s
87
80
Run Keyword ${signals }
88
- Wait Until Finished
81
+ ${result } = Wait For Process timeout=45s on_timeout=terminate
82
+ Log Many ${result.rc } ${result.stdout } ${result.stderr }
83
+ Set Test Variable $STDERR ${result.stderr }
89
84
90
85
Start Run
91
86
[Arguments] ${datasource } ${sleep } @{extra options }
@@ -94,28 +89,29 @@ Start Run
94
89
... --output ${OUTFILE } --report NONE --log NONE
95
90
... --variable TESTSIGNALFILE:${TEST FILE }
96
91
... --variable TEARDOWNSLEEP:${sleep }
92
+ ... --variablefile ${CURDIR }${/ } enable_ctrl_c_event.py
97
93
... @{extra options }
98
94
... ${DATADIR }${/ } running${/ } stopping_with_signal${/ }${datasource }
99
95
Log Many @{command }
100
- ProcessManager.start process @{command }
96
+ Start Process @{command }
101
97
102
98
Check Test Cases Have Failed Correctly
99
+ Process Output ${OUTFILE }
103
100
Check Test Tags Test
104
101
Check Test Tags Test2 robot:exit
105
102
106
103
Check Tests Have Been Forced To Shutdown
107
- ${stderr } = ProcessManager.Get Stderr
108
- Should Contain ${stderr } Execution forcefully stopped
109
-
110
- Process Output For Graceful Shutdown
111
- Wait Until Created ${OUTFILE } timeout=45s
112
- Process Output ${OUTFILE }
104
+ Should Contain ${STDERR } Execution forcefully stopped
113
105
114
106
One SIGINT
115
- Send Terminate SIGINT
107
+ # Process library doesn't support sending signals on Windows so need to
108
+ # use Call Method instead. Also use CTRL_C_EVENT, not SIGINT, on Windows.
109
+ ${process } = Get Process Object
110
+ ${signal } = Evaluate signal.CTRL_C_EVENT if $INTERPRETER.is_windows else signal.SIGINT
111
+ Call Method ${process } send_signal ${signal }
116
112
117
113
One SIGTERM
118
- Send Terminate SIGTERM
114
+ Send Signal To Process SIGTERM
119
115
120
116
Two SIGINTs
121
117
One SIGINT
0 commit comments