How to setup a tobiko workstation

This guide should help contributors to configure their workstation, so it would be easier for them to write tobiko test cases.

Configuring local test running and debugging

Clone the tobiko repository:

git clone https://opendev.org/x/tobiko.git

Create a tobiko.conf inside the tobiko directory, which will have:

[DEFAULT]

debug = true

Inside the Tobiko directory, run:

tox -e py3

Copy the path you see in the first line (it should contain something similar to tobiko/.tox/py3)

On Pycharm:
  • Create a new (pycharm) project with Location = <the tobiko path>

  • In interpreter options tab, choose “New environment using Virtualenv”, with Location = <tobiko-path>/.pycharm, and then click on “Create -> Create from Existing Sources”.

  • Enter preferences (ctrl+alt+s in Linux)

  • In Project Interpreter tab:
    • Click * -> Add

    • Choose “Existing Environment

    • In the Interpreter field, paste the path you copied after running the tox command, and add the “/bin/python3” suffix.

      Example: the path ~/tobiko/.tox/py3/bin/python3 might be used, as tox provides the directory ~/tobiko/.tox/py3, and we add /bin/python3

    • In Python Integrated Tools tab, under Testing section, set the Default test runner to be “pytest

Now verify your environment has the configuration options mentioned above by doing the following: Find tobiko/tests/unit/test_config.py in the left project window -> right click -> Run pytest in test config.

All tests should pass. You could also debug tests by setting a breakpoint.

Configuring proxy jump

Make sure you can ssh to your remote host without a password:

Define the below SSH variables to later connect to your SSH server:

SSH_HOST=<your-ssh-proxy-address>
SSH_USERNAME=<your-ssh-proxy-user>

For example:

SSH_HOST=seal100.your.domain
SSH_USERNAME=root

Copy your SSH public key to your remote server:

ssh-copy-id -i .ssh/id "${SSH_USERNAME}@${SSH_HOST}"

Make sure the SSH key pair is working:

ssh -i .ssh/id "${SSH_USERNAME}@${SSH_HOST}" hostname

Now let’s make sure Tobiko test cases will use the SSH key pair to connect to your SSH remote host. Add the following lines to tobiko.conf file:

[ssh]
proxy_jump = SSH_USERNAME@SSH_HOST

For example:

[ssh]
proxy_jump = root@seal100.your.domain
#proxy_jump = root@seal99.your.domain
#proxy_jump = root@seal98.your.domain

Tip

You could have multiple hosts in your tobiko.conf [ssh] section, where the ones you are not currently using are commented (as appear above). Moving your tobiko tests from one host to another will be as easy as commenting the host you are stop using and uncommenting the one you are start using (remember to copy your SSH key to your other remote hosts as well).

And that’s it!