Comments (12)
a=aexpect.ShellSession("TERM=xterm bash") a.sendline("docker run -t -i fedora bash") a.sendline('\x10\x11') print a.read_nonblocking() a.sendline("echo $HOSTNAME") print a.read_nonblocking()
doesn't work either. (still inside the docker). There is an odor of decay in the kingdom of python/docker.
from autotest-docker.
Another update, I'm still unable to interact properly with docker, but I tested ctrl+a d
to detach from screen
, and then screen -x
to attach back. When the session is screen
the process dies (which makes sense), but when I use aexpect.ShellSession("TERM=xterm bash")
and then execute screen -x
, ctrl+a d
I'm back in the original bash and can again attach by screen -x
.
So it should be possible, just docker handles the ctrl-sequences differently.
from autotest-docker.
Ha, apparently python was just too quick. This works:
a=aexpect.ShellSession("TERM=xterm bash") a.sendline("docker run -t -i fedora bash") time.sleep(1) a.sendline("echo $HOSTNAME") print a.read_nonblocking() a.send('\x10') time.sleep(1) a.send('\x11') time.sleep(1) a.sendline("echo $HOSTNAME") print a.read_nonblocking()
So I can take care of this test...
from autotest-docker.
The time.sleep() is not needed. Only the ctrl+p and ctrl+q has to be sent in separate command:
a.send('\x10\x11')
- does not work
a.send('\x10'); a.send('\x11')
- works fine
Which is funny, because screen understands booth versions...
from autotest-docker.
@ldoktor Since we don't really care about testing kernels, and specific shell tty/pty layers, I think you'll need to take a more direct approach: pty.fork()
+ pty.spawn()
(in the child) https://docs.python.org/release/2.6.8/library/pty.html#module-pty
Alternatively, you could use os.openpty()
and subprocess.popen
(with shell=False). Either way, you'll then be able to use the tty
and termios
modules to setup and exercise exactly the aspects you want to test. Otherwise there's a billion uncontrolled middle-layers that will lead to a very environment and hardware-dependant test.
Make no mistake, this is complicated stuff, however you probably only need to figure it out once 😄 For some hints, check out docker's own CLI and integration tests. There are a few which take the approach I mentioned above, and could provide some hints on how to do it in python.
from autotest-docker.
@ldoktor is this issue still relevant? IIRC I saw these included in a test somewhere, I could be wrong though.
from autotest-docker.
Hi Chris, yes, this test still doesn't exist (only in dexpect demonstration). But once we include dexpect, I'll develop this test instantaneously. 😄
from autotest-docker.
@ldoktor Oh right, thanks for the reminder, that's where I saw the code. Okay, bumping out to 0.7.5 then.
from autotest-docker.
@ldoktor Can this test be done to incorporate dexpect in the subtest module so it doesn't create dependencies on the dockertest API, and gives us way to demo/tweak dexpect before moving it into the core?
from autotest-docker.
Better-yet, stick only the bare-minimum needed to get this test written simply and cleanly. It's more important we test this feature now than test it much later in possibly a more abstract way. In other words, keep code reuse problems confined to the scope of this test, don't worry about how other future tests could reuse something.
from autotest-docker.
Moving to "future version" to follow pull-requests, then get moved into the 0.8.x series somewhere when ready.
from autotest-docker.
(3) (CI) Test docker console detach/attach
from autotest-docker.
Related Issues (20)
- info test fails
- commit subtest check_commit_default fail HOT 5
- New test: Pull latest also pulls cooresponding tagged image HOT 1
- cp test fails
- Docs: Add sub-section about subtest documentation
- docker_cli/logs/basic test fails w/ unhelpful exception message
- docker_cli/dockerimport/truncated is unreliable
- New test: iptables / firewalld is working. (Docker 1.7.0) HOT 1
- docker_cli/run_volumes cleanup() in base class is not general purpose
- Pre-check wether image exists before container uses it HOT 2
- Improve conf.py's compability for Sphinx v1.3.1 HOT 2
- new test: Exercise --icc=false w/ docker rm --link HOT 1
- Docs: Update development-env. requirements
- Quick Fix: Make image name parsing regex pretty
- Quick Fix: Default omit_empty=True in get_as_list() HOT 1
- Reimplement some dockertest/docker_daemon.py functions HOT 3
- redhat/packaging test fails on Atomic Host HOT 8
- run_cgroups/memory_no_cgroup : fix handling of 0
- Dockercmd module documentation
- Add support for Ubuntu HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autotest-docker.