Skip to content

Commit f7318e9

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

File tree

7 files changed

+261
-0
lines changed

7 files changed

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

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 -f Dockerfile.openqa.leap .
4+
tools/openqadev.tumbleweed:
5+
podman build -t tools/openqadev.tumbleweed -f Dockerfile.openqa.tumbleweed .
6+

container/devel/README.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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
61+
62+
```
63+
source ~/localopenqa.leap.sh
64+
mkdir $OPENQA_BASEDIR
65+
mkdir $OPENQA_REPOS
66+
git clone [email protected]:os-autoinst/openQA $OPENQA_REPOS/openQA
67+
git clone [email protected]:os-autoinst/os-autoinst $OPENQA_REPOS/os-autoinst
68+
git clone [email protected]:os-autoinst/scripts $OPENQA_REPOS/scripts
69+
70+
mkdir $OPENQA_BASEDIR/openqa $OPENQA_BASEDIR/config $OPENQA_BASEDIR/perl5 $OPENQA_BASEDIR/openqa/db
71+
```
72+
73+
74+
## Setting up a separate Postgres Container
75+
76+
To be able to keep the database when stopping the container, we create a
77+
named volume.
78+
We are using a Debian postgres container here, but it doesn't matter what
79+
you use.
80+
```
81+
podman volume create mypostgres
82+
podman run -it --rm --name postgres-openqa \
83+
-v mypostgres:/var/lib/postgresql/data \
84+
-p 5432:5432 \
85+
-e POSTGRES_PASSWORD="x" \
86+
-d \
87+
docker.io/library/postgres:17
88+
89+
# Optionally add this to mount a directory for sql dumps to import
90+
# -v "$SQL_DUMP_DIR:/sqldumps" \
91+
92+
# Create the role and database
93+
podman exec -it postgres-openqa bash
94+
su - postgres
95+
createuser -D -P geekotest
96+
# enter password ('x' in this example)
97+
createdb -O geekotest openqa-local
98+
```
99+
100+
## Preparing Config Files
101+
102+
```
103+
echo <<< EOM
104+
[localhost]
105+
key = 1234567890ABCDEF
106+
secret = 1234567890ABCDEF
107+
EOM >> $OPENQA_BASEDIR/config/client.conf
108+
```
109+
110+
```
111+
echo <<< EOM
112+
[production]
113+
dsn = dbi:Pg:dbname=openqa-local;host=127.0.0.1;port=5432
114+
user = geekotest
115+
password = x
116+
EOM >> $OPENQA_BASEDIR/config/database.ini
117+
```
118+
119+
```
120+
cp $OPENQA_REPOS/openQA/etc/openqa/workers.ini $OPENQA_BASEDIR/config/workers.ini
121+
122+
# Add/edit the following setting:
123+
[global]
124+
HOST = http://localhost:9526
125+
```
126+
127+
```
128+
cp $OPENQA_REPOS/openQA/etc/openqa/openqa.ini $OPENQA_BASEDIR/config/openqa.ini
129+
130+
# Add/edit the following setting:
131+
[auth]
132+
method = Fake
133+
```
134+
135+
136+
## Creating the Container
137+
138+
```
139+
cd $OPENQA_REPOS/openQA/container/devel
140+
# Optionally put any favourite tools into ./scripts/custom.sh
141+
# Build image
142+
make tools/openqadevel.leap
143+
```
144+
145+
## Last Build Steps
146+
147+
Now you can use the container with `distrobox`:
148+
```
149+
distrobox create -i localhost/tools/openqadev.leap -n box-openqadev
150+
distrobox enter box-openqadev
151+
source ~/localopenqa.leap.sh
152+
153+
# Build steps
154+
cd $OPENQA_REPOS/os-autoinst
155+
make
156+
cd $OPENQA_REPOS/openQA
157+
make node_modules
158+
159+
# Initialize the database schema. This is using the `database.ini` you
160+
created above.
161+
$OPENQA_REPOS/openQA/script/initdb --help
162+
```
163+
164+
165+
## Run openQA
166+
167+
```
168+
# WebUI
169+
$OPENQA_REPOS/openQA/script/openqa-webui-daemon
170+
171+
# websocket, worker etc. TBD

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 /tmp/userscripts/*.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)