Commit Graph

777 Commits

Author SHA1 Message Date
David Wilson b75198396d Fix unit_Test.ClientTest following 108015aa22
Closes #604
2019-07-31 13:18:47 +01:00
David Wilson 28b4d63e49 tests: terraform tweaks 2019-07-31 01:50:37 +01:00
David Wilson 5ed0b93669 tests: update gcloud.py to match terraform config 2019-07-31 01:50:37 +01:00
David Wilson de2e1ec184 tests/ansible/gcloud: terraform conf for load testing 2019-07-31 01:50:37 +01:00
David Wilson 108015aa22 ansible: gracefully handle failure to connect to MuxProcess
It's possible to hit an ugly exception during early CTRL+C
2019-07-31 01:50:37 +01:00
David Wilson a9d3fdf6b7 ansible: fix affinity tests for 5ae45f6612390bbc888b65964fb5c218feed1679 2019-07-31 01:50:37 +01:00
David Wilson ebb4a7ca6a issue #543: dumb fix for file vs. stat :( 2019-07-31 01:14:34 +01:00
David Wilson f3915b5f40 issue #543: disable host key checking 2019-07-31 01:14:34 +01:00
David Wilson 0741876392 issue #543: Hide Mitogen test users from gdm 2019-07-31 01:14:34 +01:00
David Wilson 17d0e1b315 issue #543: skip test that's hard to do on Mac 2019-07-31 00:15:05 +01:00
David Wilson 0e55bb3eb7 image_prep: ensure Mac users can SSH without manual intervention 2019-07-31 00:15:05 +01:00
David Wilson 501cfca82b issue #543: make localhost_ansible_tests run locally 2019-07-31 00:15:05 +01:00
David Wilson 115145555e [linear2] fix another test relying on Connection.parent 2019-07-29 18:07:01 +01:00
David Wilson a39169ff16 [linear2] fix mitogen_shutdown_all service context access 2019-07-29 16:18:23 +01:00
David Wilson 1fca0b7a94 [linear2] fix MuxProcess test fixture and some merge fallout 2019-07-29 16:10:36 +01:00
David Wilson 9035884c77 ansible: abstract worker process model.
Move all details of broker/router setup out of connection.py, instead
deferring it to a WorkerModel class exported by process.py via
get_worker_model(). The running strategy can override the configured
worker model via _get_worker_model().

ClassicWorkerModel is installed by default, which implements the
extension's existing process model.

Add optional support for the third party setproctitle module, so
children have pretty names in ps output.

Add optional support for per-CPU multiplexers to classic runs.
2019-07-29 13:52:30 +01:00
David Wilson 6da991fae9 [stream-refactor] Py3.x test fixes 2019-07-28 15:57:07 +01:00
David Wilson 87440ec6f7 [stream-refactor] Debian Docker container image initctl 2019-07-28 13:58:53 +00:00
David Wilson 0e6de532de [stream-refactor] fix testlib assertion format string 2019-07-28 10:40:59 +00:00
David Wilson 5f7ab220cb [stream-refactor] statically link doas binary using musl
So it can run on CentOS 5
2019-07-28 10:40:59 +00:00
David Wilson 462c4ff59f [stream-refactor] stop writing to /tmp/foo in fd_check.py. 2019-07-28 10:40:59 +00:00
David Wilson cd0a557602 [stream-refactor] yet another 2.4 issue in create_child_test 2019-07-28 10:40:59 +00:00
David Wilson 54987100b2 [stream-refactor] allow up to 30 seconds to connect in unix_test
It reliably fails when running on a (intentionally) heavily loaded
machine
2019-07-28 10:40:59 +00:00
David Wilson db9066fbfb [stream-refactor] mark setns module as requiring Python >2.4 2019-07-28 10:40:59 +00:00
David Wilson 856dfcebcd [stream-refactor] another 2.4 fix for create_child_test 2019-07-28 10:40:59 +00:00
David Wilson bed5931194 [stream-refactor] remove one more getuser() usage 2019-07-28 10:40:59 +00:00
David Wilson 2f950b3bda [stream-refactor] allow doas_test to succeed on CentOS
Unlike on Debian, some environment variables that tickle
getpass.getuser() are being inherited. So use getuid() instead.

Also install the doas binary on CentOS. CI was changed (I believe) to
shrink the configuration matrix, and now these tests run on CentOS too.
2019-07-28 10:40:59 +00:00
David Wilson 2ba3973bc5 Pin idna==2.7 when running on Python<2.7. 2019-07-28 10:40:59 +00:00
David Wilson 07f3179e58 [stream-refactor] Py2.4 compat fix for iter_split_test. 2019-07-28 10:40:59 +00:00
David Wilson f0065d76d8 [stream-refactor] add descriptive task names to _container_prep 2019-07-28 10:40:59 +00:00
David Wilson bd80d4b0af [stream-refactor] avoid os.wait3() for Py2.4. 2019-07-23 17:30:46 +01:00
David Wilson 1aceacf89e [stream-refactor] replace old detach_popen() reference 2019-07-23 14:07:00 +01:00
David Wilson 300f8b2ff9 ansible: fixturize creation of MuxProcess
This relies on the previous commit resetting global variables.

Update clean_shutdown() to handle duplicate calls, due to tests
repeatedly installing it.
2019-07-23 14:04:22 +01:00
David Wilson 869e04af10 [stream-refactor] import fd_check.py used by create_child_test 2019-07-22 20:38:14 +01:00
David Wilson 1069ca43d6 [stream-refactor] port mitogen.buildah, added to master since work began 2019-07-22 19:34:08 +01:00
David Wilson f43e24e970 [stream-refactor] repaired rest of create_child_test. 2019-07-22 18:30:51 +01:00
David Wilson f039c81bb0 [stream-refactor] rename Process attrs, fix up more create_child_test 2019-07-22 18:30:51 +01:00
David Wilson cfe337b3c0 [stream-refactor] import incomplete create_child_test 2019-07-22 18:30:51 +01:00
David Wilson 9c38093aa7 issue #482: tests: check for zombie process after test. 2019-07-22 18:30:51 +01:00
David Wilson 3a1125a7bd issue #363: add test. 2019-07-22 18:30:51 +01:00
David Wilson baafc746fe tests: clean up old-style SSH exception catch 2019-07-22 18:30:51 +01:00
David Wilson 4524f03a48 issue #271: add mitogen__permdenied user to Docker image. 2019-07-22 18:30:51 +01:00
David Wilson acade4ce88 ssh: fix issue #271 regression due to refactor, add test. 2019-07-22 18:30:51 +01:00
David Wilson 8d1b01d8ef Refactor Stream, introduce quasi-asynchronous connect, much more
Split Stream into many, many classes

  * mitogen.parent.Connection: Handles connection setup logic only.
    * Maintain references to stdout and stderr streams.
    * Manages TimerList timer to cancel connection attempt after
      deadline
    * Blocking setup code replaced by async equivalents running on the
      broker

  * mitogen.parent.Options: Tracks connection-specific options. This
    keeps the connection class small, but more importantly, it is
    generic to the future desire to build and execute command lines
    without starting a full connection.

  * mitogen.core.Protocol: Handles program behaviour relating to events
    on a stream. Protocol performs no IO of its own, instead deferring
    it to Stream and Side. This makes testing much easier, and means
    libssh can reimplement Stream and Side to reuse MitogenProtocol

  * mitogen.core.MitogenProtocol: Guts of the old Mitogen stream
    implementtion

  * mitogen.core.BufferedWriter: Guts of the old Mitogen buffered
    transmit implementation, made generic

  * mitogen.core.DelineatedProtocol: Guts of the old IoLogger, knows how
    to split up input and pass it on to a
    on_line_received()/on_partial_line_received() callback.

  * mitogen.parent.BootstrapProtocol: Asynchronous equivalent of the old
    blocking connect code. Waits for various prompts (MITO001 etc) and
    writes the bootstrap using a BufferedWriter. On success, switches
    the stream to MitogenProtocol.

  * mitogen.core.Message: move encoding parts of MitogenProtocol out to
    Message (where it belongs) and write a bunch of new tests for
    pickling.

  * The bizarre Stream.construct() is gone now, Option.__init__ is its
    own constructor. Should fix many LGTM errors.

* Update all connection methods:  Every connection method is updated to
  use async logic, defining protocols as required to handle interactive
  prompts like in SSH or su. Add new real integration tests for at least
  doas and su.

* Eliminate manual fd management: File descriptors are trapped in file
  objects at their point of origin, and Side is updated to use file
  objects rather than raw descriptors. This eliminates a whole class of
  bugs where unrelated FDs could be closed by the wrong component. Now
  an FD's open/closed status is fused to it everywhere in the library.

* Halve file descriptor usage: now FD open/close state is tracked by
  its file object, we don't need to duplicate FDs everywhere so that
  receive/transmit side can be closed independently. Instead both sides
  back on to the same file object. Closes #26, Closes #470.

* Remove most uses of dup/dup2: Closes #256. File descriptors are
  trapped in a common file object and shared among classes. The
  remaining few uses for dup/dup2 are as close to minimal as possible.

* Introduce mitogen.parent.Process: uniform interface for subprocesses
  created either via mitogen.fork or the subprocess module. Remove all
  the crap where we steal a pid from subprocess guts. Now we use
  subprocess to manage its processes as it should be. Closes #169 by
  using the new Timers facility to poll for a slow-to-exit subprocess.

* Fix su password race: Closes #363. DelineatedProtocol naturally
  retries partially received lines, preventing the cause of the original
  race.

* Delete old blocking IO utility functions
  iter_read()/write_all()/discard_until().

Closes #26
Closes #147
Closes #169
Closes #256
Closes #363
Closes #419
Closes #470
2019-07-22 18:30:51 +01:00
David Wilson 37beb3a5c5 core: teach iter_split() to break on callback returning False. 2019-07-22 18:30:51 +01:00
David Wilson bf77d4ab1d testlib: have LogCapturer.raw() return unicode on 2.x. 2019-07-22 18:30:51 +01:00
David Wilson fb23ecae01 tests: jail_test fixes. 2019-07-22 18:30:51 +01:00
David Wilson 12569ad70a tests/bench: import ssh-roundtrip.py. 2019-07-22 18:30:51 +01:00
David Wilson bb0c98f451 tests: note location of related tests. 2019-07-22 18:30:51 +01:00
David Wilson eff8179591 tests: add real test for doas. 2019-07-22 18:30:51 +01:00