Skip to content

Commit ed94d79

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

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, 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

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)