|
| 1 | +# Setup a Development Enviroment for openQA and related Tools |
| 2 | + |
| 3 | +These examples use `podman` and |
| 4 | +[`distrobox`](https://en.opensuse.org/Distrobox). You can use similar tools |
| 5 | +like `docker`, `toolbox` etc. to achieve the same. |
| 6 | + |
| 7 | +You will run two containers: |
| 8 | +* A separate postgres container (so you don't have to deal with the database |
| 9 | + when updating your dev container) |
| 10 | +* The openQA environment in a openSUSE Leap or Tumbleweed container, which |
| 11 | + both can use the same postgres container. |
| 12 | + In this example we will be settting up and using the Leap container. |
| 13 | + |
| 14 | +You can run the openQA container with `distrobox`, for example, |
| 15 | +for easy handling (network, home directory, permissions, and graphical |
| 16 | +environment will just work). |
| 17 | + |
| 18 | +Some common settings we are using here: |
| 19 | +* database name: `openqa-local` |
| 20 | +* A directory which contains everything: git repos, openQA config, assets etc. |
| 21 | + * `OPENQA_BASEDIR=$HOME/openqadev.leap` |
| 22 | +* Database user: `geekotest` |
| 23 | +* Database container: `postgres-openqa` |
| 24 | + |
| 25 | +## Creating a bash file with environment variables |
| 26 | + |
| 27 | +Create a file `~/localopenqa.leap.sh` that you can `source` whenever you want to |
| 28 | +work in this environment: |
| 29 | + |
| 30 | +``` |
| 31 | +#!/bin/bash |
| 32 | +
|
| 33 | +# The directory where openQA operates in and which creates everything: |
| 34 | +# * git repos |
| 35 | +# * openQA assets, pool directory, testresults |
| 36 | +# * configuration |
| 37 | +
|
| 38 | +export OPENQA_BASEDIR=$HOME/openqadev.leap |
| 39 | +
|
| 40 | +# The rest of the variables can likely stay like this |
| 41 | +
|
| 42 | +# If you want to import database dumps from elsewhere |
| 43 | +#export SQL_DUMP_DIR=$HOME/sqldumps |
| 44 | +
|
| 45 | +export OPENQA_CONFIG=$OPENQA_BASEDIR/config |
| 46 | +export OPENQA_REPOS="$OPENQA_BASEDIR/git" |
| 47 | +
|
| 48 | +# ----------- CPAN ------------ |
| 49 | +# Whenever necessary, you can install additional modules from CPAN like: |
| 50 | +# cpanm -l $OPENQA_BASEDIR/perl5 Some::[email protected] |
| 51 | +export PERL5LIB=$OPENQA_BASEDIR/perl5/lib/perl5 |
| 52 | +PATH=$OPENQA_BASEDIR/perl5/bin:$PATH |
| 53 | +
|
| 54 | +PATH=$OPENQA_REPOS/openQA/scripts:$PATH |
| 55 | +
|
| 56 | +export OPENQA_KEY=1234567890ABCDEF |
| 57 | +export OPENQA_SECRET=1234567890ABCDEF |
| 58 | +``` |
| 59 | + |
| 60 | +## Create Directories, Clone Git |
| 61 | + |
| 62 | +``` |
| 63 | +source ~/localopenqa.leap.sh |
| 64 | +mkdir $OPENQA_BASEDIR |
| 65 | +mkdir $OPENQA_REPOS |
| 66 | +mkdir $OPENQA_BASEDIR/openqa $OPENQA_BASEDIR/config $OPENQA_BASEDIR/perl5 $OPENQA_BASEDIR/openqa/db |
| 67 | +
|
| 68 | +git clone [email protected]:os-autoinst/openQA $OPENQA_REPOS/openQA |
| 69 | +git clone [email protected]:os-autoinst/os-autoinst $OPENQA_REPOS/os-autoinst |
| 70 | +git clone [email protected]:os-autoinst/scripts $OPENQA_REPOS/scripts |
| 71 | +``` |
| 72 | + |
| 73 | +## Setting up a separate Postgres Container |
| 74 | + |
| 75 | +To be able to keep the database when stopping the container, we create a |
| 76 | +named volume. |
| 77 | +We are using a Debian postgres container here, but it doesn't matter what |
| 78 | +you use. |
| 79 | +``` |
| 80 | +podman volume create mypostgres |
| 81 | +podman run -it --rm --name postgres-openqa \ |
| 82 | + -v mypostgres:/var/lib/postgresql/data \ |
| 83 | + -p 5432:5432 \ |
| 84 | + -e POSTGRES_PASSWORD="x" \ |
| 85 | + -d \ |
| 86 | + docker.io/library/postgres:17 |
| 87 | +
|
| 88 | +# Optionally add this to mount a directory for sql dumps to import |
| 89 | +# -v "$SQL_DUMP_DIR:/sqldumps" \ |
| 90 | +
|
| 91 | +# Create the role and database |
| 92 | +podman exec -it postgres-openqa bash |
| 93 | +
|
| 94 | +su - postgres |
| 95 | +
|
| 96 | +createuser -D -P geekotest |
| 97 | +# enter password ('x' in this example) |
| 98 | +createdb -O geekotest openqa-local |
| 99 | +``` |
| 100 | + |
| 101 | +## Preparing Config Files |
| 102 | + |
| 103 | +``` |
| 104 | +echo <<< EOM |
| 105 | +[localhost] |
| 106 | +key = 1234567890ABCDEF |
| 107 | +secret = 1234567890ABCDEF |
| 108 | +EOM >> $OPENQA_BASEDIR/config/client.conf |
| 109 | +``` |
| 110 | + |
| 111 | +``` |
| 112 | +echo <<< EOM |
| 113 | +[production] |
| 114 | +dsn = dbi:Pg:dbname=openqa-local;host=127.0.0.1;port=5432 |
| 115 | +user = geekotest |
| 116 | +password = x |
| 117 | +EOM >> $OPENQA_BASEDIR/config/database.ini |
| 118 | +``` |
| 119 | + |
| 120 | +``` |
| 121 | +cp $OPENQA_REPOS/openQA/etc/openqa/workers.ini $OPENQA_BASEDIR/config/workers.ini |
| 122 | +
|
| 123 | +# Add/edit the following setting: |
| 124 | +[global] |
| 125 | +HOST = http://localhost:9526 |
| 126 | +``` |
| 127 | + |
| 128 | +``` |
| 129 | +cp $OPENQA_REPOS/openQA/etc/openqa/openqa.ini $OPENQA_BASEDIR/config/openqa.ini |
| 130 | +
|
| 131 | +# Add/edit the following setting: |
| 132 | +[auth] |
| 133 | +method = Fake |
| 134 | +``` |
| 135 | + |
| 136 | + |
| 137 | +## Creating the Container |
| 138 | + |
| 139 | +``` |
| 140 | +cd $OPENQA_REPOS/openQA/container/devel |
| 141 | +# Optionally put any favourite tools into ./scripts/custom.sh |
| 142 | +# Build image |
| 143 | +make tools/openqadevel.leap |
| 144 | +``` |
| 145 | + |
| 146 | +## Last Build Steps |
| 147 | + |
| 148 | +Now you can use the container with `distrobox`: |
| 149 | +``` |
| 150 | +distrobox create -i localhost/tools/openqadev.leap -n box-openqadev |
| 151 | +distrobox enter box-openqadev |
| 152 | +source ~/localopenqa.leap.sh |
| 153 | +
|
| 154 | +# Build steps |
| 155 | +cd $OPENQA_REPOS/os-autoinst |
| 156 | +make |
| 157 | +cd $OPENQA_REPOS/openQA |
| 158 | +make node_modules |
| 159 | +
|
| 160 | +# Initialize the database schema. This is using the database.ini you |
| 161 | +created above. |
| 162 | +$OPENQA_REPOS/openQA/script/initdb --help |
| 163 | +``` |
| 164 | + |
| 165 | +## Run openQA |
| 166 | + |
| 167 | +``` |
| 168 | +# WebUI |
| 169 | +$OPENQA_REPOS/openQA/script/openqa-webui-daemon |
| 170 | +
|
| 171 | +# websocket, worker etc. TBD |
0 commit comments