Skip to content

Commit f69589f

Browse files
committed
Fix stopping w/ signal tests "leaking" signals on Windows.
Earlier these tests send a signal to the execution console on Windows and that caused problems on our new CI. Hopefully this solution works better. Also some cleanup to tests (incl. tidy) and removed ProcessManager.py library that was already mostly unused.
1 parent e5cd42f commit f69589f

File tree

3 files changed

+48
-119
lines changed

3 files changed

+48
-119
lines changed

atest/robot/running/ProcessManager.py

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
try:
2+
from ctypes import windll
3+
4+
windll.kernel32.SetConsoleCtrlHandler(None, False)
5+
6+
except ImportError:
7+
pass

atest/robot/running/stopping_with_signal.robot

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,75 @@
11
*** 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
48

59
*** Variables ***
6-
${TEST FILE} %{TEMPDIR}${/}signal-tests.txt
10+
${TEST FILE} %{TEMPDIR}${/}signal-tests.txt
711

812
*** Test Cases ***
913
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
1215
Check Test Cases Have Failed Correctly
1316

1417
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
1820
Check Test Cases Have Failed Correctly
1921

2022
Execution Is Stopped Even If Keyword Swallows Exception
2123
[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
2425
Check Test Cases Have Failed Correctly
2526

2627
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
2929
Check Test Cases Have Failed Correctly
3030

3131
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
3433
Check Test Cases Have Failed Correctly
3534

3635
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
3937
Check Test Cases Have Failed Correctly
4038

4139
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
4341
Check Tests Have Been Forced To Shutdown
4442

4543
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
4846
Check Tests Have Been Forced To Shutdown
4947

5048
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
5250
Check Tests Have Been Forced To Shutdown
5351

5452
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
5654
Check Tests Have Been Forced To Shutdown
5755

5856
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
6058
Check Tests Have Been Forced To Shutdown
6159

6260
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
6562
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
7066

7167
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
7469
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}
8073

8174
*** Keywords ***
8275
Start And Send Signal
@@ -85,7 +78,9 @@ Start And Send Signal
8578
Start Run ${datasource} ${sleep} @{extra options}
8679
Wait Until Created ${TESTFILE} timeout=45s
8780
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}
8984

9085
Start Run
9186
[Arguments] ${datasource} ${sleep} @{extra options}
@@ -94,28 +89,29 @@ Start Run
9489
... --output ${OUTFILE} --report NONE --log NONE
9590
... --variable TESTSIGNALFILE:${TEST FILE}
9691
... --variable TEARDOWNSLEEP:${sleep}
92+
... --variablefile ${CURDIR}${/}enable_ctrl_c_event.py
9793
... @{extra options}
9894
... ${DATADIR}${/}running${/}stopping_with_signal${/}${datasource}
9995
Log Many @{command}
100-
ProcessManager.start process @{command}
96+
Start Process @{command}
10197

10298
Check Test Cases Have Failed Correctly
99+
Process Output ${OUTFILE}
103100
Check Test Tags Test
104101
Check Test Tags Test2 robot:exit
105102

106103
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
113105

114106
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}
116112

117113
One SIGTERM
118-
Send Terminate SIGTERM
114+
Send Signal To Process SIGTERM
119115

120116
Two SIGINTs
121117
One SIGINT

0 commit comments

Comments
 (0)