GithubHelp home page GithubHelp logo

Comments (12)

ldoktor avatar ldoktor commented on August 24, 2024
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.

ldoktor avatar ldoktor commented on August 24, 2024

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.

ldoktor avatar ldoktor commented on August 24, 2024

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.

ldoktor avatar ldoktor commented on August 24, 2024

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.

cevich avatar cevich commented on August 24, 2024

@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.

cevich avatar cevich commented on August 24, 2024

@ldoktor is this issue still relevant? IIRC I saw these included in a test somewhere, I could be wrong though.

from autotest-docker.

ldoktor avatar ldoktor commented on August 24, 2024

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.

cevich avatar cevich commented on August 24, 2024

@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.

cevich avatar cevich commented on August 24, 2024

@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.

cevich avatar cevich commented on August 24, 2024

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.

cevich avatar cevich commented on August 24, 2024

Moving to "future version" to follow pull-requests, then get moved into the 0.8.x series somewhere when ready.

from autotest-docker.

cevich avatar cevich commented on August 24, 2024

(3) (CI) Test docker console detach/attach

from autotest-docker.

Related Issues (20)

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.