not-raspberry / spawn_and_check Goto Github PK
View Code? Open in Web Editor NEWSpawn a process and wait until it's ready. Stop the OS-level race condition pain in your tests.
Spawn a process and wait until it's ready. Stop the OS-level race condition pain in your tests.
When killing the process (after post-checks fail), first try to terminate it with SIGTERM, wait for termination for some time and then send SIGKILL.
The waiting can be done similarly to checks polling so having #3 resolved first would definitely help.
Running a service with execute
and at least one check may fail if the previous service didn't terminate on time:
DRY polling - currently there is a simple wait_until
implementation in test.wait
and a polling loop inside the execute
function. There will be another polling for the pre-checks so the rule of three has to be applied.
This will probably require changing the check functions' signature to subprocess.Popen -> bool
.
UDP connecion can fail on ICMP level (The destination host responds with 'Port Unreachable' which gets translated to 'Connection Refused' on UDP level). People are experiencing it (http://stackoverflow.com/questions/16130786/why-am-i-getting-the-error-connection-refused-in-python-sockets) however I was unable to reproduce it locally - which is strange because I have dealt with failing UDP connections in the past.
Provide a code that raises socket.error
with the proper errno from a UDP connection.
Longest test durations:
10.02s call test/unit/test_executor.py::test_execute_pre_checks_fail[5]
10.02s call test/unit/test_executor.py::test_execute_pre_checks_fail[3]
10.02s call test/unit/test_executor.py::test_execute_pre_checks_fail[4]
10.02s call test/unit/test_executor.py::test_execute_pre_checks_fail[2]
10.02s call test/unit/test_executor.py::test_execute_pre_checks_fail[1]
5.17s call test/integration/test_spawn_and_check.py::test_execute_check_http[5]
5.15s call test/integration/test_spawn_and_check.py::test_execute_check_tcp[5]
5.11s call test/integration/test_spawn_and_check.py::test_execute_check_unix[5]
4.09s call test/integration/test_spawn_and_check.py::test_execute_failing_checks
3.26s call test/integration/test_spawn_and_check.py::test_execute_same_service_sequentially
3.16s call test/integration/test_spawn_and_check.py::test_execute_check_tcp[3]
3.15s call test/integration/test_spawn_and_check.py::test_execute_check_http[3]
3.11s call test/integration/test_spawn_and_check.py::test_execute_check_unix[3]
1.14s call test/integration/test_spawn_and_check.py::test_execute_process_killed
Those tests are mostly sleeping. It would be nice to e.g. reduce timeouts for unit tests.
Another, more complicated way is to mock time.sleep
and time.time
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.