GithubHelp home page GithubHelp logo

not-raspberry / spawn_and_check Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 27 KB

Spawn a process and wait until it's ready. Stop the OS-level race condition pain in your tests.

Python 100.00%
process-instrumentation unix

spawn_and_check's People

Contributors

not-raspberry avatar

Stargazers

 avatar

Watchers

 avatar  avatar

spawn_and_check's Issues

Wait for pre-checks the same way as we do with post-checks

Running a service with execute and at least one check may fail if the previous service didn't terminate on time:

  1. Process X₁ is ran with the executor.
  2. SIGTERM is sent to the process X₁ but the service takes some time to tear down
  3. Process X₂ is ran with the executor - pre-checks fail because they see the previous service.
  4. X₁ terminates after some time but it's too late - X₂'s executor failed.

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.

Research when exactly a UDP connection can fail

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.

Narrow down test durations a little

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.