📜 ⬆️ ⬇️

Running OpenStack Keystone tests in a Docker container on Mac

The following describes how to run Keystone tests in the Docker container on OS X and why I needed it.



I sometimes write small patches in Openstack, mostly in Keystone. I do this on my laptop with OS X. In 2009, I switched from Linux to Mac, because at the last it was no less convenient to develop, and doing everything else was much more convenient. Unfortunately, the last time the first statement often turns out to be false. For example, Apple began to very slowly update the system's open source libraries, from which Keystone tests suffered - first because of the old OpenSSL, and then python-ldap. About this, for example, writes Keystone PTL Morgan Fainberg. He starts optimistic
')
NOTICE: Keystone will likely be deprecated

You can deal with this, but the pleasure is not the same.

At first I moved to a VM with Ubuntu, which removed all the problems with running tests, but setting up and maintaining another development environment is a task that I would like to avoid. Run the same VM only because of the tests - waste. In addition, the minor differences between Mac and Lunux (shell, MacVim) were a bit annoying. That's why I decided to continue development on a Mac, running tests in a docker container in the same iTerm2. Next step by step instructions.

First create a project
$ mkdir ../docker $ cd ../docker $ vim Dockerfile 


Writing Dockerfile
 FROM ubuntu:14.04 MAINTAINER XXX "xxx@gmail.com" RUN apt-get update RUN apt-get install -y python RUN apt-get install -y git RUN apt-get install -y python-setuptools RUN apt-get install -y python-pip RUN pip install virtualenv RUN apt-get install -y gettext RUN apt-get install -y python-dev python3-dev libxml2-dev libxslt1-dev RUN apt-get install -y libsasl2-dev libsqlite3-dev libssl-dev libldap2-dev libffi-dev RUN pip install tox RUN apt-get install -y python-tox 


Create a container:
 $ docker build -t="hashmap/keystone-dev" . 


We get:
 Sending build context to Docker daemon 2.048 kB Sending build context to Docker daemon Step 0 : FROM ubuntu:14.04 ---> 63e3c10217b8 ... Unpacking python-tox (1.6.0-1ubuntu1) ... Setting up libjs-jquery (1.7.2+dfsg-2ubuntu1) ... Setting up libjs-underscore (1.4.4-2ubuntu1) ... Setting up libjs-sphinxdoc (1.2.2+dfsg-1ubuntu1.1) ... Setting up python-py (1.4.20-1) ... Setting up python-virtualenv (1.11.4-1) ... Setting up python-tox (1.6.0-1ubuntu1) ... ---> 41f003afb987 Removing intermediate container 52fa1fca6272 Successfully built 41f003afb987 


Now we get the source keystone
 $ mkdir -p ~/projects/openstack/ $ cd ~/projects/openstack/ $ git clone https://github.com/openstack/keystone.git 


We start the container
 $ docker run -it -v ~/projects/openstack/keystone/:/keystone hashmap/keystone-dev 


Get the session inside the container:
 root@ecc4228056af:/# cd /keystone 


Once we need to configure venv
 $ python tools/install_venv.py $ source .venv/bin/activate $ python -c "import keystone" 


If there are no errors, everything is set. You can still update the database:
 $ root@e29e21a501f0:/keystone# ./.venv/bin/keystone-manage db_sync 


Now we run the test
 $ tox -e py27 ... - Passed: 4254 - Skipped: 1234 - Expected Fail: 0 - Unexpected Success: 0 - Failed: 0 ... py27: commands succeeded congratulations :) 

Now you can run the test container from time to time. I didn’t measure it, but it’s noticeable that the tests are performed more slowly, on the other hand, I gave them exactly half of the laptop’s resources.

As a result, we have a development environment on a Mac with working tests, a luxury in the current situation!

PS If you like KDPV - let me know, our company's docker-girl will appear in the following posts.

Source: https://habr.com/ru/post/264365/


All Articles