add debug flag to tcup
Change-Id: I79a2019b47d2f138cd7fd3a4f26d137ab2f31c40 Change-Id: Id4ae3b8b904cd4a0f2b78a0631f2b7b958974ff1
This commit is contained in:
parent
f49642de75
commit
3f4311be67
40
doc/tcup.md
40
doc/tcup.md
@ -9,7 +9,13 @@ The following instructions are designs run Refstack/Tempest in a container with
|
||||
|
||||
1. Install Docker using [[https://www.docker.io/gettingstarted/#h_installation]]
|
||||
1. Note: if you are in an environment with a proxy, make sure you configure `/etc/default/docker` to leverage the proxy too!
|
||||
1. You may want to prep-the environment using
|
||||
1. You may want to prep-the environment using `sudo docker pull ubuntu:13.10`
|
||||
|
||||
1. Setup Docker to run without sudo
|
||||
1. permanently (recommended):
|
||||
1. `sudo usermod -a -G docker <your-user>`
|
||||
1. you will need to reboot after this change
|
||||
1. short term: `sudo chmod 666 /var/run/docker.sock`
|
||||
|
||||
1. Get the code: `wget https://raw.githubusercontent.com/stackforge/refstack/master/scripts/tcup.py`
|
||||
1. note: you can also get the code by cloning the Refstack and running the code in `/scripts/tcup.py`
|
||||
@ -17,37 +23,33 @@ The following instructions are designs run Refstack/Tempest in a container with
|
||||
1. Set your environment variables to access the test target cloud
|
||||
1. generally, you will `source openrc.sh` to load the cloud credentials and URLs
|
||||
|
||||
1. Run TCUP: `sudo python tcup.py`
|
||||
1. if you want to work on the code from Refstack, use `sudo python scripts/tcup.py'
|
||||
1. Run TCUP: `python tcup.py`
|
||||
1. if you want to work on the code from Refstack, use `scripts/tcup.py'
|
||||
|
||||
|
||||
## Trouble Shooting TCUP
|
||||
## Troubleshooting TCUP
|
||||
|
||||
There are several ways to trouble shoot, TCUP.
|
||||
|
||||
1. Enter your docker container using `run -i -t [image id from tcup.py] /bin/bash `
|
||||
1. Check your environment variables include the OS_* values using `export`
|
||||
1. Make sure you can access Keystone using `curl $OS_AUTH_URL`
|
||||
1. Make sure your credentials are working using `keystone catalog`
|
||||
1. `Export DEBUG=true` to turn on additional logging and force TCUP into manual run mode
|
||||
1. Run TCUP using the debug flag: `tcup.py --debug`
|
||||
1. Attach to the container as instructed at the end of the TCUP script
|
||||
1. Inside the container:
|
||||
1. Check your environment variables include the OS_* values using `export`
|
||||
1. Make sure you can access Keystone using `curl $OS_AUTH_URL`
|
||||
1. Make sure your credentials are working using `keystone catalog`
|
||||
|
||||
## Docker Tips
|
||||
1. You can run Docker without sudo!
|
||||
1. `sudo usermod -a -G docker <your-user>` (to permanently run Docker
|
||||
without sudo)
|
||||
1. you will need to reboot after this change (but you can wait until we tell you to reboot later)
|
||||
1. if you don't want this to be permanent or active before the reboot use, `sudo chmod 666 /var/run/docker.sock`
|
||||
|
||||
1. You can inspect which containers are running!
|
||||
1. `sudo docker ps` shows the running containers
|
||||
1. `sudo docker attach` allows you to connect to a container (may have to press enter)
|
||||
1. `docker ps` shows the running containers
|
||||
1. `docker attach` allows you to connect to a container (may have to press enter)
|
||||
1. exit from inside the container with `Ctrl-p` + `Ctrl-q`
|
||||
1. Orphaned Containers: Over time, you may end up with [orphaned contaniers](http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html), use the following to clean them up
|
||||
1. `sudo docker rm $(docker ps -a -q)`
|
||||
1. `sudo docker rmi $(docker images | grep "^<none>" | awk "{print $3}")`
|
||||
1. `docker rm $(docker ps -a -q)`
|
||||
1. `docker rmi $(docker images | grep "^<none>" | awk "{print $3}")`
|
||||
|
||||
## For Developers
|
||||
|
||||
If you run TCUP in debug mode (`export DEBUG=true`) then TCUP will automatically mount your PWD as /dev.
|
||||
If you run TCUP in debug mode (`export DEBUG=true` or using `--debug` parameter) then TCUP will automatically mount your PWD as /dev.
|
||||
If you run TCUP from your Refstack clone, then you can work directly in Refstack code from inside
|
||||
a TCUP container from the /dev directory.
|
@ -20,6 +20,7 @@ import commands
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -32,14 +33,19 @@ if __name__ == "__main__":
|
||||
"LESSCLOSE", "SSH_CONNECTION"}
|
||||
REQUIRED_ENV_VARS = {'OS_PASSWORD', 'OS_USERNAME', 'OS_AUTH_URL'}
|
||||
|
||||
# debugging?
|
||||
debug = ((len(sys.argv) > 1 and sys.argv[1] == "--debug")
|
||||
or os.environ.get("DEBUG"))
|
||||
|
||||
# Setup the logger
|
||||
LOG_FORMAT = "%(asctime)s %(name)s %(levelname)s %(message)s"
|
||||
logger = logging.getLogger("TCUP")
|
||||
console_log_handle = logging.StreamHandler()
|
||||
console_log_handle.setFormatter(logging.Formatter(LOG_FORMAT))
|
||||
logger.addHandler(console_log_handle)
|
||||
if os.environ.get("DEBUG"):
|
||||
if debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.info("Starting in DEBUG mode.")
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
@ -84,19 +90,19 @@ if __name__ == "__main__":
|
||||
docker_run = "docker run -d -i"
|
||||
for env_var in user_env_vars:
|
||||
docker_run += ' -e "%s=%s"' % (env_var, user_env_vars[env_var])
|
||||
if "DEBUG" in user_env_vars:
|
||||
if debug:
|
||||
docker_run += " -v `pwd`:/dev"
|
||||
docker_run += ' -t %s' % (image)
|
||||
if "DEBUG" in user_env_vars:
|
||||
if debug:
|
||||
docker_run += " /bin/bash"
|
||||
logger.info("""Debug mode does not start tests!
|
||||
You must run `refstack/tools/execute_test.py \
|
||||
--tempest-home /tempest` to complete processing""")
|
||||
logger.info("Debug mode does not start tests! \
|
||||
You must run `refstack/refstack/tools/execute_test.py \
|
||||
--tempest-home /tempest` to complete processing")
|
||||
else:
|
||||
docker_run += " cd refstack; refstack/tools/execute_test.py" \
|
||||
" --tempest-home /tempest" \
|
||||
" --callback ${api_addr} ${test_id}"
|
||||
if "DEBUG" in user_env_vars:
|
||||
if debug:
|
||||
docker_run_log_output = docker_run
|
||||
else:
|
||||
# normally we redact the password
|
||||
@ -109,6 +115,6 @@ if __name__ == "__main__":
|
||||
docker_output = commands.getoutput(docker_run)
|
||||
logger.debug(docker_output)
|
||||
logger.info("""You can monitor the TCUP results using the command
|
||||
'sudo docker attach %s'
|
||||
'docker attach %s'
|
||||
(hint: you may need to press [enter])"""
|
||||
% docker_output[0:12])
|
||||
|
Loading…
Reference in New Issue
Block a user