Skip to content

Commit 6bc5a74

Browse files
committed
Add instructions for running a openQA/tools dev environment
Issue: https://progress.opensuse.org/issues/184459
1 parent 87a4d34 commit 6bc5a74

File tree

7 files changed

+270
-0
lines changed

7 files changed

+270
-0
lines changed

container/devel/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scripts/custom*
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM registry.opensuse.org/opensuse/leap:15.6
2+
3+
RUN zypper addrepo -G -p 95 https://download.opensuse.org/repositories/devel:/openQA/15.6 devel-openqa \
4+
&& zypper addrepo -G -p 95 https://download.opensuse.org/repositories/devel:/openQA:/Leap:/15.6/15.6/ devel-openqa-leap \
5+
&& zypper addrepo -G -p 95 https://download.opensuse.org/repositories/SUSE:/CA/15.6/SUSE:CA.repo \
6+
&& zypper -n ref
7+
8+
RUN zypper -n install ca-certificates-suse
9+
10+
# openqa
11+
RUN zypper -n ref && zypper -n install \
12+
os-autoinst-devel openQA-devel \
13+
expect \
14+
nodejs \
15+
openssh-clients
16+
17+
# scripts
18+
RUN zypper -n install \
19+
os-autoinst-scripts-deps \
20+
os-autoinst-scripts-deps-devel \
21+
python3-pytest \
22+
23+
# Run custom scripts
24+
# Put your scripts under ./scripts. Filename should start with "custom"
25+
# to be ignored by git
26+
RUN /userscripts/etc/runuserscripts.sh
27+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM registry.opensuse.org/opensuse/tumbleweed:latest
2+
3+
RUN zypper addrepo -G p 95 https://download.opensuse.org/repositories/devel:/openQA/openSUSE_Tumbleweed devel-openqa \
4+
&& zypper addrepo -G -p 95 https://download.opensuse.org/repositories/SUSE:/CA/openSUSE_Tumbleweed/SUSE:CA.repo \
5+
&& zypper -n ref
6+
7+
8+
RUN zypper -n install ca-certificates-suse
9+
10+
# openqa
11+
RUN zypper -n ref && zypper -n install \
12+
os-autoinst-devel openQA-devel \
13+
expect \
14+
nodejs \
15+
openssh-clients
16+
17+
# scripts
18+
RUN zypper -n install \
19+
os-autoinst-scripts-deps \
20+
os-autoinst-scripts-deps-devel \
21+
python3-pytest \
22+
23+
# Run custom scripts
24+
# Put your scripts under ./scripts. Filename should start with "custom"
25+
# to be ignored by git
26+
RUN /userscripts/etc/runuserscripts.sh
27+

container/devel/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
tools/openqadev.leap:
3+
podman build -t tools/openqadev.leap -v "$(PWD):/userscripts" -f Dockerfile.openqa.leap .
4+
tools/openqadev.tumbleweed:
5+
podman build -t tools/openqadev.tumbleweed -v "$(PWD):/userscripts" -f Dockerfile.openqa.tumbleweed .
6+

container/devel/README.md

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

container/devel/etc/runuserscripts.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -x
4+
for i in /userscripts/scripts/*.sh; do
5+
"$i"
6+
done

container/devel/scripts/dummy.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Run by podman build
4+
#
5+
# zypper in -n your-favorite-dev-tools
6+
#
7+
# e.g. tmux, jq, vim-full
8+
9+
# Put it into custom.sh to let it be ignored by git

0 commit comments

Comments
 (0)