QA/Execution/Web Testing/Automation/Screen Tutorial: Difference between revisions

Jump to navigation Jump to search
(Created page with "= Screen Tutorial = == Quick Guide == "screen" - start a new screen session. The -S <name> flag names the session. The default name (when flag is omitted) is an ID number. "s...")
 
Line 7: Line 7:
"screen -ls" - see a list of the active/detached screen sessions.
"screen -ls" - see a list of the active/detached screen sessions.


"screen -r <name>" - Reattach screen session with name <name>, as seen in "screen -ls"
"screen -r <name>" - Reattach screen session with name <name>, as seen in "screen -ls". Use the -x flag if there are multiple people trying to reattach to the same screen session.


Control+A => D - detach from current screen session
Control+A => D - detach from current screen session
Line 19: Line 19:
For an indepth guide on screen and its features, go to [http://www.linuxjournal.com/article/6340].
For an indepth guide on screen and its features, go to [http://www.linuxjournal.com/article/6340].


=== What is Screen? ===


Here's a quick rundown:
Screen is a UNIX tool that essentially allows you to use multiple terminals / processes with a single SSH session / terminal. Think of it as being analogous to having multiple tabs open, each with their own process running. Screen allows you to see and control all of these tabs through a single SSH session (or terminal window).


Using screen will mean that we can start and stop RCs/etc using an SSH session rather than having to VNC into a machine and physically closing / restarting a Terminal tab. Furthermore, we will no longer have to keep terminal windows open on the machines. RCs will run in the background.
=== Why Screen? ===
 
Screen is used by many server administrators because often times, you do not have direct access to a server. It is very easy to SSH into a server, and so it is much cleaner to have a single SSH session to manage all of the individual processes than to have a bunch of different SSH sessions. Furthermore, it is difficult to have a process run in the background, end your SSH session, and to rejoin the process at a later time. Screen solves all of these problems.
 
The biggest benefit for screen is that it allows remote employees (especially those for whom VNCing into the Selenium machines may not be possible due to slow internet).
 
=== How Screen Applies to Us ===
 
We will be running all of the processes on the OSX machines in screen sessions now. This means that all RCs (with the exception of Windows VM RCs), the Grid Hub, and the Hudson server will all be run via screen. In practice, this is not much different than we do it now - instead of having many tabs with each process being in its own tab, we will now have multiple screen sessions. Depending on feedback, we can keep the tabs open on the machines themselves (with each tab reattached to a screen session), or we don't. Leaving the screen sessions in tabs is beneficial because users of the physical machine (and VNC) can see the console output without having to worry about screen. However, not having these tabs open (and thus letting the user reattach the screen session they want when they want), we maintain a cleaner desktop with fewer visible programs running.  
 
=== Walkthrough ===


To start a new screen session, type "screen" in terminal. I suggest giving it a name so that when you look at the active sessions, it makes sense. This can be done with the -S flag, so something like "screen -S selenium_grid" would be good.
To start a new screen session, type "screen" in terminal. I suggest giving it a name so that when you look at the active sessions, it makes sense. This can be done with the -S flag, so something like "screen -S selenium_grid" would be good.
Line 30: Line 41:
When done starting the RCs, press control+a (this indicates you want to send a command to SCREEN rather than to the terminal window you're in), and then hit d - this will "detach" the screen session and leave it running in the background.
When done starting the RCs, press control+a (this indicates you want to send a command to SCREEN rather than to the terminal window you're in), and then hit d - this will "detach" the screen session and leave it running in the background.


Detached screen sessions can be seen by typing "screen -ls".  
Detached screen sessions can be seen by typing "screen -ls" in the parent terminal session.  


To bring back detached screen sessions, type "screen -r <session_name>" and it will bring you back to the terminal window as you left it when you detached.  
To bring back detached screen sessions, type "screen -r <session_name>" and it will bring you back to the terminal window as you left it when you detached. If you receive errors about the screen already being reattached to a different session (this will occur if multiple users try to reattach simultaneously), use the -x flag after the -r flag in the command.


You can have multiple screen sessions running (just remember to detach before starting a new one), so this is perfect for running multiple RCs.  
You can have multiple screen sessions running (just remember to detach before starting a new one), so this is perfect for running multiple RCs.  


To kill a session, reattach it and use Control+A, then K.
To kill a session (this will end any process that is running within it), reattach it and use Control+A, then K.
46

edits

Navigation menu