1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-24 17:16:12 +01:00

Move behave tests from Kanku to Podman, run them in GitHub actions

This commit is contained in:
Daniel Mach 2022-12-05 15:10:50 +01:00
parent 7eeb564b7c
commit b00f66b3f6
41 changed files with 818 additions and 531 deletions

View File

@ -1,4 +1,4 @@
name: 'unit tests'
name: 'tests'
on:
push:
@ -15,8 +15,8 @@ on:
- 'tests/**'
jobs:
test:
name: 'unit tests'
unit:
name: "unit"
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
@ -91,3 +91,26 @@ jobs:
- name: 'Upload coverage reports to Codecov (openSUSE Tumbleweed)'
if: ${{ matrix.container == 'opensuse/tumbleweed' }}
uses: codecov/codecov-action@v3
behave:
name: "behave"
# to save resources, run only after unit tests have passed
needs: unit
runs-on: "ubuntu-latest"
steps:
- name: "Install packages"
run: |
sudo apt-get -y update
sudo apt-get -y --no-install-recommends install python3-behave diffstat diffutils python3 python3-cryptography python3-pip python3-rpm python3-setuptools python3-urllib3
- name: "Checkout sources"
uses: actions/checkout@v3
- name: "Pull container image"
run: |
podman pull ghcr.io/suse-autobuild/obs-server:latest
- name: "Run tests"
run: |
cd behave
behave -Dosc=../osc-wrapper.py

32
behave/Containerfile Normal file
View File

@ -0,0 +1,32 @@
FROM opensuse/leap:15.4
RUN zypper ar --repo http://download.opensuse.org/repositories/OBS:/Server:/Unstable/15.4/OBS:Server:Unstable.repo
RUN zypper -n --gpg-auto-import-keys refresh
RUN zypper -n install \
bash \
bash-completion \
git \
less \
obs-api \
obs-server \
obs-signd \
obs-worker \
osc \
openslp \
openssl \
perl-XML-SAX \
rpm-build \
systemd \
vim \
&& rm -rf /var/cache/zypp/*
# increase the number if we need to run the following setup steps again (for debugging purposes)
ENV BUILD_NUMBER 1
RUN /bin/bash /opt/obs/container-setup.sh
COPY container-oscrc /root/.config/osc/oscrc
RUN /bin/bash /opt/obs/container-setup-initial-data.sh
RUN /bin/bash /opt/obs/container-setup-prebuilt-rpms.sh
# /sbin/init doesn't exist on Leap 15.4
ENTRYPOINT ["/usr/lib/systemd/systemd"]

View File

@ -1,91 +0,0 @@
domain_name: obs-server
default_job: kanku-job
login_user: root
login_pass: opensuse
jobs:
kanku-job:
-
use_module: Kanku::Handler::SetJobContext
options:
host_interface: eth0
-
use_module: Kanku::Handler::OBSCheck
options:
api_url: https://api.opensuse.org/public
# Please have a look at
# kanku lsi
# to find more official Images
project: OBS:Server:Unstable
package: OBS-Appliance:qcow2
repository: images
arch: x86_64
use_oscrc: 0
-
use_module: Kanku::Handler::ImageDownload
-
use_module: Kanku::Handler::CreateDomain
options:
memory: 5G
vcpu: 4
use_9p: 1
-
use_module: Kanku::Handler::PrepareSSH
-
use_module: Kanku::Handler::ExecuteCommandViaSSH
options:
commands:
# fix the following error in scheduler: unknown host 'obs-server.kanku.site'
- echo "127.0.0.1 obs-server.kanku.site" >> /etc/hosts
- echo "::1 obs-server.kanku.site" >> /etc/hosts
# disable OBS:Server:Unstable, we want to install only stable packages from now on
- zypper --non-interactive modifyrepo --disable OBS:Server:Unstable
# refresh repodata and install additional packages
- zypper --non-interactive --gpg-auto-import-keys refresh
- zypper --non-interactive install bash-completion rpm-build sudo
# reinstall osc with a stable version
- zypper --non-interactive install --force osc
# install test requirements
- rpmbuild -bs --define='_srcrpmdir /opt/' --without=host_only_packages /tmp/kanku/requirements.spec
- zypper --non-interactive source-install --build-deps-only /opt/osc-behave-requirements-1-0.src.rpm
# zramswap for more available memory
- zypper --non-interactive install systemd-zram-service
- systemctl enable zramswap
# decrease number of workers
- sed -i 's@^OBS_WORKER_INSTANCES=.*@OBS_WORKER_INSTANCES="1"@' /etc/sysconfig/obs-server
# configure OBS URL (for osc browse)
- echo "UPDATE configurations SET obs_url='https://obs-server.kanku.site';" | mysql api_production
# configure download URL
- echo "UPDATE configurations SET download_url='http://obs-server.kanku.site:82';" | mysql api_production
# write configuration from the database on disk
- cd /srv/www/obs/api; RAILS_ENV=production SAFETY_ASSURED=1 bin/rails writeconfiguration
-
use_module: Kanku::Handler::Reboot
# Reboot to restart obs services.
# Restarting them via systemctl doesn't always work, it ends up with the following error:
# > scheduler is already running for <arch>!
# We also need them restarted because they're failing on unresolvable obs-server.kanku.site.
-
use_module: Kanku::Handler::ExecuteCommandViaSSH
options:
commands:
# use behave to setup OBS - create projects and packages
- cd /tmp/kanku && behave obs-setup
# unmount /tmp/kanku so we are able to create a snapshot of the VM
- umount /tmp/kanku
-
use_module: Kanku::Handler::DomainSnapshot
options:
# create a snapshot we'll use as a starting point for running tests
command: create
name: current

View File

@ -1,49 +1,66 @@
Prerequisities
--------------
First of all, we need to install requirements:
```
# optional step in case we want to use the latest kanku packages
$ zypper ar obs://devel:kanku:staging devel:kanku:staging
Install requirements
--------------------
On openSUSE:
```
$ zypper install osc podman python3-behave
```
On Fedora:
```
$ dnf install osc podman python3-behave
```
Build a container with OBS
--------------------------
```
$ cd behave
$ rpmbuild -bs --define='_srcrpmdir .' requirements.spec
$ sudo zypper source-install --build-deps-only ./osc-behave-requirements-1-0.src.rpm
# optional: refresh the base image
$ podman pull opensuse/leap:15.4
# build the container image
$ ./container-build.sh [--no-cache]
```
Then we need to build 'obs-server' VM using kanku:
We can also use the built container outside the test suite
```
# necessary if the 'obs-server' domain exists already
$ kanku destroy
$ cd behave
$ kanku up [--skip_all_checks]
# run 'obs-server' container on port 1443
$ ./container-run.sh
# shell into the started container
$ ./container-shell.sh
# stop the started container
$ podman stop|kill obs-server
# remove container image
$ podman rmi obs-server
```
Running tests
-------------
Run tests
---------
Run all tests
```
$ cd behave
$ behave
$ behave -Dosc=../osc-wrapper.py
```
Run selected tests
```
$ cd behave
$ behave features/<file>.feature
$ behave -Dosc=../osc-wrapper.py features/<file>.feature
```
Run tests being worked on (decorated with `@wip`)
```
$ cd behave
behave --wip -k
```
Run tests with the selected `osc` executable
```
$ cd behave
behave -Dosc=../osc-wrapper.py
behave -Dosc=../osc-wrapper.py --wip -k
```

9
behave/container-build.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
TOPDIR=$(dirname $(readlink -f $0))
podman build "$@" \
--tag obs-server \
--volume="$TOPDIR":/opt/obs \
$TOPDIR \
2>&1 | tee container-build.log

7
behave/container-oscrc Normal file
View File

@ -0,0 +1,7 @@
[general]
apiurl = https://localhost
[https://localhost]
user=Admin
pass=opensuse
credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager

18
behave/container-run.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
TOPDIR=$(dirname $(readlink -f $0))
podman run \
--name obs-server \
--hostname obs-server \
--replace \
--detach \
--interactive \
--tty \
--volume="$TOPDIR":/opt/obs \
--cap-add SYS_PTRACE \
-p 1443:443 \
obs-server
sleep 0.5
podman exec -it obs-server /usr/bin/systemctl is-system-running --wait

View File

@ -0,0 +1,39 @@
set -x
set -e
MYSQL_HELPER=/usr/libexec/mysql/mysql-systemd-helper
if [ ! -f "$MYSQL_HELPER" ]; then
MYSQL_HELPER=/usr/lib/mysql/mysql-systemd-helper
fi
function init_mysql {
"$MYSQL_HELPER" install
"$MYSQL_HELPER" upgrade
}
function start_mysql {
su --shell=/bin/bash - mysql "$MYSQL_HELPER" start 2>&1 >/dev/null &
}
function start_apache {
/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k start &
}
function start_obs_repserver {
/usr/lib/obs/server/bs_repserver --logfile rep_server.log 2>&1 >/dev/null &
}
function start_obs_srcserver {
/usr/lib/obs/server/bs_srcserver --logfile src_server.log 2>&1 >/dev/null &
}
function start_obs_scheduler {
/usr/sbin/obsscheduler start
}

View File

@ -0,0 +1,109 @@
set -x
set -e
TOPDIR=$(dirname $(readlink -f "$0"))
source "$TOPDIR/container-setup-common.sh"
start_mysql
start_apache
start_obs_srcserver
sleep 1
FIXTURES_DIR="$TOPDIR/fixtures"
OSC="osc -A https://localhost"
# create projects
$OSC api -X PUT '/source/openSUSE.org/_meta' --file "$FIXTURES_DIR/prj/openSUSE.org.xml"
$OSC api -X PUT '/source/devel/_meta' --file "$FIXTURES_DIR/prj/devel.xml"
$OSC api -X PUT '/source/release/_meta' --file "$FIXTURES_DIR/prj/release.xml"
$OSC api -X PUT '/source/openSUSE:Factory/_meta' --file "$FIXTURES_DIR/prj/openSUSE_Factory.xml"
$OSC api -X PUT '/source/home:Admin/_meta' --file "$FIXTURES_DIR/prj/home_Admin.xml"
# create package 'openSUSE:Factory/test-pkgA'
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
$OSC checkout openSUSE:Factory
cd "$_"
$OSC mkpac test-pkgA
cd "$_"
cp "$FIXTURES_DIR/pac/test-pkgA-1.spec" test-pkgA.spec
cp "$FIXTURES_DIR/pac/test-pkgA-1.changes" test-pkgA.changes
$OSC add test-pkgA.spec test-pkgA.changes
$OSC commit -m 'Initial commit'
cp "$FIXTURES_DIR/pac/test-pkgA-2.spec" test-pkgA.spec
cp "$FIXTURES_DIR/pac/test-pkgA-2.changes" test-pkgA.changes
$OSC commit -m 'Version 2'
cp "$FIXTURES_DIR/pac/test-pkgA-3.spec" test-pkgA.spec
cp "$FIXTURES_DIR/pac/test-pkgA-3.changes" test-pkgA.changes
$OSC commit -m 'Version 3'
rm -rf "$TMP_DIR"
# create package 'openSUSE:Factory/test-pkgB'
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
$OSC checkout openSUSE:Factory
cd "$_"
$OSC mkpac test-pkgB
cd "$_"
cp "$FIXTURES_DIR/pac/test-pkgB-1.spec" test-pkgB.spec
cp "$FIXTURES_DIR/pac/test-pkgB-1.changes" test-pkgB.changes
$OSC add test-pkgB.spec test-pkgB.changes
$OSC commit -m 'Initial commit'
cp "$FIXTURES_DIR/pac/test-pkgB-2.spec" test-pkgB.spec
cp "$FIXTURES_DIR/pac/test-pkgB-2.changes" test-pkgB.changes
$OSC commit -m 'Version 2'
rm -rf "$TMP_DIR"
# create package 'openSUSE:Factory/multibuild-pkg'
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
$OSC checkout openSUSE:Factory
cd "$_"
$OSC mkpac multibuild-pkg
cd "$_"
cp "$FIXTURES_DIR/pac/multibuild-pkg-1._multibuild" _multibuild
cp "$FIXTURES_DIR/pac/multibuild-pkg-1.spec" multibuild-pkg.spec
cp "$FIXTURES_DIR/pac/multibuild-pkg-1.changes" multibuild-pkg.changes
$OSC add _multibuild multibuild-pkg.spec multibuild-pkg.changes
$OSC commit -m 'Initial commit'
rm -rf "$TMP_DIR"
# create package 'devel/test-pkgA'
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
$OSC checkout devel
cd "$_"
$OSC mkpac test-pkgA
cd "$_"
# commit an empty package
$OSC commit -m 'Initial commit'
# set the devel project
$OSC setdevelproject openSUSE:Factory/test-pkgA devel/test-pkgA

View File

@ -0,0 +1,97 @@
set -x
set -e
TOPDIR=$(dirname $(readlink -f "$0"))
source "$TOPDIR/container-setup-common.sh"
start_obs_srcserver
start_obs_repserver
sleep 1
FIXTURES_DIR="$TOPDIR/fixtures"
function upload_rpms() {
local TMP_DIR=$(mktemp -d)
local RPM_DIR="$1"
local PROJECT="$2"
local REPO="$3"
local ARCH="$4"
local PACKAGE="$5"
# scan directory for all RPMs and link them to a flat dir to avoid
# 400 remote error: cpio filename contains a '/'
find "$RPM_DIR/SRPMS" -name '*.rpm' -exec ln -s {} "$TMP_DIR/" \; || :
find "$RPM_DIR/RPMS/noarch" -name '*.rpm' -exec ln -s {} "$TMP_DIR/" \; || :
find "$RPM_DIR/RPMS/$ARCH" -name '*.rpm' -exec ln -s {} "$TMP_DIR/" \; || :
pushd "$TMP_DIR"
find -name '*.rpm' | cpio --create --dereference -H newc > upload.cpio
curl \
--data-binary '@upload.cpio' \
-H 'X-username: Admin' \
-H 'Content-Type: application/x-cpio' \
"http://localhost:5352/build/$PROJECT/$REPO/$ARCH/$PACKAGE"
rm -rf "$TMP_DIR"
popd
}
# build package 'openSUSE:Factory/test-pkgA'
TMP_DIR=$(mktemp -d)
rpmbuild -ba "$FIXTURES_DIR/pac/test-pkgA-3.spec" --define "_topdir $TMP_DIR"
upload_rpms "$TMP_DIR" openSUSE:Factory standard i586 test-pkgA
upload_rpms "$TMP_DIR" openSUSE:Factory standard x86_64 test-pkgA
rm -rf "$TMP_DIR"
# build package 'openSUSE:Factory/test-pkgB'
TMP_DIR=$(mktemp -d)
rpmbuild -ba "$FIXTURES_DIR/pac/test-pkgB-2.spec" --define "_topdir $TMP_DIR"
upload_rpms "$TMP_DIR" openSUSE:Factory standard i586 test-pkgB
upload_rpms "$TMP_DIR" openSUSE:Factory standard x86_64 test-pkgB
rm -rf "$TMP_DIR"
# build package 'openSUSE:Factory/multibuild-pkg'
TMP_DIR=$(mktemp -d)
rpmbuild -ba "$FIXTURES_DIR/pac/multibuild-pkg-1.spec" --define "_topdir $TMP_DIR" --target=x86_64,i586 --define "flavor %{nil}"
upload_rpms "$TMP_DIR" openSUSE:Factory standard i586 multibuild-pkg
upload_rpms "$TMP_DIR" openSUSE:Factory standard x86_64 multibuild-pkg
rm -rf "$TMP_DIR"
# build package 'openSUSE:Factory/multibuild-pkg:flavor1'
TMP_DIR=$(mktemp -d)
rpmbuild -ba "$FIXTURES_DIR/pac/multibuild-pkg-1.spec" --define "_topdir $TMP_DIR" --target=x86_64,i586 --define "flavor flavor1"
upload_rpms "$TMP_DIR" openSUSE:Factory standard i586 multibuild-pkg:flavor1
upload_rpms "$TMP_DIR" openSUSE:Factory standard x86_64 multibuild-pkg:flavor1
rm -rf "$TMP_DIR"
# build package 'openSUSE:Factory/multibuild-pkg:flavor2'
TMP_DIR=$(mktemp -d)
rpmbuild -ba "$FIXTURES_DIR/pac/multibuild-pkg-1.spec" --define "_topdir $TMP_DIR" --target=x86_64,i586 --define "flavor flavor2"
upload_rpms "$TMP_DIR" openSUSE:Factory standard i586 multibuild-pkg:flavor2
upload_rpms "$TMP_DIR" openSUSE:Factory standard x86_64 multibuild-pkg:flavor2
rm -rf "$TMP_DIR"
# run scheduler to process all jobs
/usr/lib/obs/server/bs_sched --testmode i586
/usr/lib/obs/server/bs_sched --testmode x86_64
# create fake empty files that usually accompany RPMs
ARCHES="i586 x86_64"
PACKAGES="test-pkgA test-pkgB multibuild-pkg multibuild-pkg:flavor1 multibuild-pkg:flavor2"
FILES="_buildenv _statistics rpmlint.log"
for ARCH in $ARCHES; do
for PACKAGE in $PACKAGES; do
for FILE in $FILES; do
touch /srv/obs/build/openSUSE:Factory/standard/$ARCH/$PACKAGE/$FILE
done
done
done

127
behave/container-setup.sh Normal file
View File

@ -0,0 +1,127 @@
set -x
set -e
TOPDIR=$(dirname $(readlink -f "$0"))
source "$TOPDIR/container-setup-common.sh"
# tweak configuration
# hard-code hostname to "localhost"
sed -i 's!^my $hostname = .*!my $hostname = "localhost";!' /usr/lib/obs/server/BSConfig.pm
# set signd server to "localhost" (workarounds the "will not proxy to myself" error)
sed -i 's!^#server: .*!server: localhost!' /etc/sign.conf
# limit number of workers
sed -i 's!^OBS_WORKER_INSTANCES=.*!OBS_WORKER_INSTANCES="1"!' /etc/sysconfig/obs-server
# enable xforward
sed -i 's!^#use_xforward:.*!use_xforward: true!' /srv/www/obs/api/config/options.yml
# configure passenger
sed -i -E 's!^(\s*)PassengerRuby .*!\1PassengerRuby "/usr/bin/ruby.ruby3.1"!' /etc/apache2/conf.d/mod_passenger.conf
# enable apache SSL server flag
sed -i 's!^APACHE_SERVER_FLAGS=.*!APACHE_SERVER_FLAGS="SSL"!' /etc/sysconfig/apache2
# enable apache mods
APACHE_MODS="passenger rewrite proxy proxy_http xforward headers ssl socache_shmcb"
for mod in $APACHE_MODS; do
/usr/sbin/a2enmod $mod
done
# create missing dirs, set perms
mkdir -p /srv/obs/repos
chown obsrun:obsrun /srv/obs/repos
chmod 0755 /srv/obs/repos
mkdir -p /srv/obs/certs
chown root:root /srv/obs/certs
chmod 0700 /srv/obs/certs
# create a self-signed certificate for 'localhost'
cd /srv/obs/certs
openssl req -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -addext "subjectAltName = DNS:localhost" -out server.crt -keyout server.key -subj '/CN=localhost'
# copy server cert into osc's trusted certs
mkdir -p /root/.config/osc/trusted-certs
cp /srv/obs/certs/server.crt /root/.config/osc/trusted-certs/localhost_443.pem
# configure mysql
cat <<EOF > /etc/my.cnf.d/obs-server.cnf
[mysqld]
bind-address = 127.0.0.1
datadir = /srv/obs/MySQL
[mysqld_multi]
datadir = /srv/obs/MySQL
EOF
# mysql user's home
mkdir -p /var/lib/mysql
chown mysql:mysql /var/lib/mysql
chmod 0700 /var/lib/mysql
# datadir for OBS
mkdir -p /srv/obs/MySQL
chown mysql:mysql /srv/obs/MySQL
chmod 0700 /srv/obs/MySQL
# initialize database
init_mysql
start_mysql
sleep 1
# set mysql superuser's password; user=root, password=opensuse
mysqladmin -u root password opensuse
echo "ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password USING PASSWORD('opensuse');" | mysql
# start srcserver (needed for OBS initialization)
start_obs_srcserver
# initialize the OBS database
cd /srv/www/obs/api
RAILS_ENV=production SAFETY_ASSURED=1 bin/rails db:setup writeconfiguration data:schema:load
# fix perms
chown -R wwwrun:www /srv/www/obs/api/log/
chown -R wwwrun:www /srv/www/obs/api/tmp/
# OBS api
#systemctl enable memcached
systemctl enable apache2
systemctl enable mysql
# starting obs-api-support.target incl. all dependencies is expensive
# let's start it only when needed
# systemctl enable obs-api-support.target
# OBS backend
systemctl enable obssrcserver
systemctl enable obsrepserver
#systemctl enable obsdispatcher
#systemctl enable obspublisher
#systemctl enable obsscheduler
#systemctl enable obsservice
#systemctl enable obssignd
#systemctl enable obssigner
#systemctl enable obswarden
#systemctl enable obsdodup
#systemctl enable obsdeltastore
#systemctl enable obsservicedispatch
# OBS worker
# systemctl enable obsworker

9
behave/container-shell.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
TOPDIR=$(dirname $(readlink -f $0))
podman exec \
--interactive \
--tty \
obs-server \
/bin/bash

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc add` command

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc checkout` command

View File

@ -1,8 +1,8 @@
import os
from steps import kanku
from steps import osc
from steps import common
from steps import osc
from steps import podman
def before_step(context, step):
@ -14,18 +14,20 @@ def after_step(context, step):
def before_scenario(context, scenario):
context.osc = osc.Osc(context)
pass
def after_scenario(context, scenario):
if "destructive" in scenario.tags:
# start a new container after a destructive test
context.podman.kill()
context.podman = podman.Podman()
context.osc.clear()
common.check_exit_code(context)
del context.osc
def before_feature(context, feature):
# decorate Feature with @no-snapshot to avoid doing a snapshot rollback
if "no-snapshot" not in feature.tags:
context.kanku.revert_to_snapshot()
pass
def after_feature(context, feature):
@ -44,14 +46,12 @@ def before_all(context):
# absolute path to .../behave/fixtures
context.fixtures = os.path.join(os.path.dirname(__file__), "..", "fixtures")
kankufile = os.path.join(os.path.dirname(__file__), "..", "KankuFile")
context.kanku = kanku.Kanku(context, kankufile)
# This fails if the snapshot exists already.
# It's ok in most cases, because it's the same snapshot we'd normally create.
context.kanku.create_snapshot()
context.podman = podman.Podman()
context.osc = osc.Osc(context)
def after_all(context):
del context.kanku
del context.osc
context.podman.kill()
del context.podman
del context.fixtures

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <project> <package> <repo> <arch> <file>` command
@ -8,54 +7,54 @@ Background:
Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file>`
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-1-1.1.x86_64.rpm"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-1-1.x86_64.rpm"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-1-1.x86_64.rpm
"""
Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file> --multibuild-package=<flavor>`
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-flavor1-1-1.1.x86_64.rpm --multibuild-package=flavor1"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-flavor1-1-1.x86_64.rpm --multibuild-package=flavor1"
# the option is allowed only in a package checkout
Then the exit code is 2
Scenario: Run `osc getbinaries <project> <package>:<flavor> <repo> <arch> <file>` where file is a package
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg:flavor1 standard x86_64 multibuild-pkg-flavor1-1-1.1.x86_64.rpm"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg:flavor1 standard x86_64 multibuild-pkg-flavor1-1-1.x86_64.rpm"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
"""
Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file>` where file is a source package
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-1-1.1.src.rpm"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-1-1.src.rpm"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
"""
Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file> --source` where file is a source package
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-1-1.1.src.rpm --source"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-1-1.src.rpm --source"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-1-1.src.rpm
"""
Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file>` where file is a debuginfo package
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-debuginfo-1-1.1.x86_64.rpm"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-debuginfo-1-1.x86_64.rpm"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
"""
Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file> --debuginfo` where file is a debuginfo package
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-debuginfo-1-1.1.x86_64.rpm --debuginfo"
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64 multibuild-pkg-debuginfo-1-1.x86_64.rpm --debuginfo"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.x86_64.rpm
"""

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <project> <package> <repo> <arch>` command
@ -11,7 +10,7 @@ Scenario: Run `osc getbinaries <project> <package> <repo> <arch>`
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg standard x86_64"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -28,7 +27,7 @@ Scenario: Run `osc getbinaries <project> <package>:<flavor> <repo> <arch>`
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg:flavor1 standard x86_64"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -39,8 +38,8 @@ Scenario: Run `osc getbinaries <project> <package>:<flavor> <repo> <arch> --sour
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg:flavor1 standard x86_64 --source"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -51,8 +50,8 @@ Scenario: Run `osc getbinaries <project> <package>:<flavor> <repo> <arch> --debu
When I execute osc with args "getbinaries openSUSE:Factory multibuild-pkg:flavor1 standard x86_64 --debuginfo"
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <project> <repo> <arch>` command
@ -11,11 +10,11 @@ Scenario: Run `osc getbinaries <project> <repo> <arch>`
When I execute osc with args "getbinaries openSUSE:Factory standard x86_64"
Then directory tree in "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgB-2-1.1.noarch.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgB-2-1.noarch.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log
@ -44,15 +43,15 @@ Scenario: Run `osc getbinaries <project> <repo> <arch> --debuginfo`
When I execute osc with args "getbinaries openSUSE:Factory standard x86_64 --debuginfo"
Then directory tree in "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-debugsource-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-debuginfo-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgB-2-1.1.noarch.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.x86_64.rpm
multibuild-pkg-debugsource-1-1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.x86_64.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
multibuild-pkg-flavor2-debuginfo-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgB-2-1.noarch.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <repo> <arch>` command from a package checkout
@ -13,7 +12,7 @@ Scenario: Run `osc getbinaries <repo> <arch>` from a package checkout
When I execute osc with args "getbinaries standard x86_64"
Then directory listing of "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -24,7 +23,7 @@ Scenario: Run `osc getbinaries <repo> <arch> --multibuild-package=<flavor>` from
When I execute osc with args "getbinaries standard x86_64 --multibuild-package=flavor1"
Then directory listing of "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/binaries/" is
"""
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -35,9 +34,9 @@ Scenario: Run `osc getbinaries <repo> <arch> --debuginfo` from a package checkou
When I execute osc with args "getbinaries standard x86_64 --debuginfo"
Then directory listing of "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-debugsource-1-1.1.x86_64.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.x86_64.rpm
multibuild-pkg-debugsource-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <repo> <arch>` command from a project checkout
@ -13,11 +12,11 @@ Scenario: Run `osc getbinaries <repo> <arch>` from a project checkout
When I execute osc with args "getbinaries standard x86_64"
Then directory tree in "{context.osc.temp}/openSUSE:Factory/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgB-2-1.1.noarch.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgB-2-1.noarch.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log
@ -46,16 +45,16 @@ Scenario: Run `osc getbinaries <repo> <arch> --sources` from a project checkout
When I execute osc with args "getbinaries standard x86_64 --sources"
Then directory tree in "{context.osc.temp}/openSUSE:Factory/binaries/" is
"""
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgA-3-1.1.src.rpm
test-pkgB-2-1.1.noarch.rpm
test-pkgB-2-1.1.src.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgA-3-1.src.rpm
test-pkgB-2-1.noarch.rpm
test-pkgB-2-1.src.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log
@ -78,15 +77,15 @@ Scenario: Run `osc getbinaries <repo> <arch> --debuginfo` from a project checkou
When I execute osc with args "getbinaries standard x86_64 --debuginfo"
Then directory tree in "{context.osc.temp}/openSUSE:Factory/binaries/" is
"""
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-debugsource-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-debuginfo-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgB-2-1.1.noarch.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.x86_64.rpm
multibuild-pkg-debugsource-1-1.x86_64.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.x86_64.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
multibuild-pkg-flavor2-debuginfo-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgB-2-1.noarch.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <repo>` command from a project checkout
@ -14,8 +13,8 @@ Scenario: Run `osc getbinaries <repo>` from a package checkout
When I execute osc with args "getbinaries standard"
Then directory listing of "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/binaries/" is
"""
multibuild-pkg-1-1.1.i586.rpm
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-1-1.i586.rpm
multibuild-pkg-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -26,8 +25,8 @@ Scenario: Run `osc getbinaries <repo> --multibuild-package=<flavor>` from a pack
When I execute osc with args "getbinaries standard --multibuild-package=flavor1"
Then directory listing of "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/binaries/" is
"""
multibuild-pkg-flavor1-1-1.1.i586.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.i586.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
@ -38,12 +37,12 @@ Scenario: Run `osc getbinaries <repo> --debuginfo` from a package checkout
When I execute osc with args "getbinaries standard --debuginfo"
Then directory listing of "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/binaries/" is
"""
multibuild-pkg-1-1.1.i586.rpm
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.1.i586.rpm
multibuild-pkg-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-debugsource-1-1.1.i586.rpm
multibuild-pkg-debugsource-1-1.1.x86_64.rpm
multibuild-pkg-1-1.i586.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.i586.rpm
multibuild-pkg-debuginfo-1-1.x86_64.rpm
multibuild-pkg-debugsource-1-1.i586.rpm
multibuild-pkg-debugsource-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc getbinaries <repo>` command from a project checkout
@ -13,14 +12,14 @@ Scenario: Run `osc getbinaries <repo>` from a project checkout
When I execute osc with args "getbinaries standard"
Then directory tree in "{context.osc.temp}/openSUSE:Factory/binaries/" is
"""
multibuild-pkg-1-1.1.i586.rpm
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.1.i586.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-1-1.1.i586.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgB-2-1.1.noarch.rpm
multibuild-pkg-1-1.i586.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-flavor1-1-1.i586.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor2-1-1.i586.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgB-2-1.noarch.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log
@ -49,19 +48,19 @@ Scenario: Run `osc getbinaries <repo> --sources` from a project checkout
When I execute osc with args "getbinaries standard --sources"
Then directory tree in "{context.osc.temp}/openSUSE:Factory/binaries/" is
"""
multibuild-pkg-1-1.1.i586.rpm
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-flavor1-1-1.1.i586.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-1-1.1.src.rpm
multibuild-pkg-flavor2-1-1.1.i586.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgA-3-1.1.src.rpm
test-pkgB-2-1.1.noarch.rpm
test-pkgB-2-1.1.src.rpm
multibuild-pkg-1-1.i586.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-flavor1-1-1.i586.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-1-1.src.rpm
multibuild-pkg-flavor2-1-1.i586.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgA-3-1.src.rpm
test-pkgB-2-1.noarch.rpm
test-pkgB-2-1.src.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log
@ -84,22 +83,22 @@ Scenario: Run `osc getbinaries <repo> --debuginfo` from a project checkout
When I execute osc with args "getbinaries standard --debuginfo"
Then directory tree in "{context.osc.temp}/openSUSE:Factory/binaries/" is
"""
multibuild-pkg-1-1.1.i586.rpm
multibuild-pkg-1-1.1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.1.i586.rpm
multibuild-pkg-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-debugsource-1-1.1.i586.rpm
multibuild-pkg-debugsource-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-1-1.1.i586.rpm
multibuild-pkg-flavor1-1-1.1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.1.i586.rpm
multibuild-pkg-flavor1-debuginfo-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-1-1.1.i586.rpm
multibuild-pkg-flavor2-1-1.1.x86_64.rpm
multibuild-pkg-flavor2-debuginfo-1-1.1.i586.rpm
multibuild-pkg-flavor2-debuginfo-1-1.1.x86_64.rpm
test-pkgA-3-1.1.noarch.rpm
test-pkgB-2-1.1.noarch.rpm
multibuild-pkg-1-1.i586.rpm
multibuild-pkg-1-1.x86_64.rpm
multibuild-pkg-debuginfo-1-1.i586.rpm
multibuild-pkg-debuginfo-1-1.x86_64.rpm
multibuild-pkg-debugsource-1-1.i586.rpm
multibuild-pkg-debugsource-1-1.x86_64.rpm
multibuild-pkg-flavor1-1-1.i586.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg-flavor1-debuginfo-1-1.i586.rpm
multibuild-pkg-flavor1-debuginfo-1-1.x86_64.rpm
multibuild-pkg-flavor2-1-1.i586.rpm
multibuild-pkg-flavor2-1-1.x86_64.rpm
multibuild-pkg-flavor2-debuginfo-1-1.i586.rpm
multibuild-pkg-flavor2-debuginfo-1-1.x86_64.rpm
test-pkgA-3-1.noarch.rpm
test-pkgB-2-1.noarch.rpm
multibuild-pkg/_buildenv
multibuild-pkg/_statistics
multibuild-pkg/rpmlint.log

View File

@ -1,4 +1,3 @@
@no-snapshot
Feature: `osc list` command
@ -6,9 +5,11 @@ Scenario: Run `osc list` with no arguments to display all projects
When I execute osc with args "list"
Then stdout is
"""
devel
home:Admin
openSUSE.org
openSUSE:Factory
release
"""

View File

@ -1,76 +0,0 @@
#!/usr/bin/python3
import os
import re
import subprocess
import behave
from ruamel.yaml import YAML
class Kanku:
def __init__(self, context, kankufile):
self.kankufile = kankufile
self.kankudir = os.path.dirname(self.kankufile)
self.domain_name = self._get_domain_name()
self.ip = self._get_ip()
def _get_domain_name(self):
"""
Get domain name directly from KankuFile yaml
"""
yaml = YAML(typ='safe')
doc = yaml.load(open(self.kankufile, "r"))
return doc["domain_name"]
def _run_kanku(self, args):
cmd = ["kanku"] + args
env = os.environ.copy()
env["KANKU_CONFIG"] = self.kankufile
proc = subprocess.Popen(
cmd,
cwd=self.kankudir,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8"
)
return proc
def _get_ip(self):
"""
Get IP from calling `kanku ip`
"""
proc = self._run_kanku(["ip"])
stdout, stderr = proc.communicate()
match = re.search(r"IP Address: ([\d\.]+)", stderr)
return match.group(1)
def create_snapshot(self):
# unmount /tmp/kanku so we are able to create a snapshot of the VM
self.run_command("umount /tmp/kanku")
proc = self._run_kanku(["snapshot", "--create", "--name", "current"])
proc.communicate()
def revert_to_snapshot(self):
proc = self._run_kanku(["snapshot", "--revert", "--name", "current"])
proc.communicate()
def delete_snapshot(self):
proc = self._run_kanku(["snapshot", "--remove", "--name", "current"])
proc.communicate()
def run_command(self, ssh_cmd, user="root"):
proc = self._run_kanku(["ssh", "-u", user, "--execute", ssh_cmd])
proc.wait()
@behave.step("I create VM snapshot")
def func(context, args):
context.kanku.create_snapshot(sudo=True)
@behave.step("I revert to VM snapshot")
def func(context, args):
context.kanku.revert_to_snapshot(sudo=True)

View File

@ -10,21 +10,12 @@ from steps.common import run_in_context
class Osc:
def __init__(self, context):
self.temp = tempfile.mkdtemp(prefix="osc_behave_")
if not hasattr(context, "podman"):
raise RuntimeError("context doesn't have 'podman' object set")
if not hasattr(context, "kanku"):
raise RuntimeError("context doesn't have kanku object set")
self.oscrc = os.path.join(self.temp, "oscrc")
with open(self.oscrc, "w") as f:
f.write("[general]\n")
f.write("\n")
f.write(f"[https://{context.kanku.ip}]\n")
f.write("user=Admin\n")
f.write("pass=opensuse\n")
f.write("credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager\n")
f.write("sslcertck=0\n")
f.write("trusted_prj=openSUSE.org:openSUSE:Tumbleweed\n")
self.context = context
self.temp = None
self.clear()
def __del__(self):
try:
@ -32,18 +23,35 @@ class Osc:
except Exception:
pass
def get_cmd(self, context):
osc_cmd = context.config.userdata.get("osc", "osc")
def clear(self):
if self.temp:
shutil.rmtree(self.temp)
self.temp = tempfile.mkdtemp(prefix="osc_behave_")
self.oscrc = os.path.join(self.temp, "oscrc")
with open(self.oscrc, "w") as f:
f.write("[general]\n")
f.write("\n")
f.write(f"[https://localhost:{self.context.podman.port}]\n")
f.write("user=Admin\n")
f.write("pass=opensuse\n")
f.write("credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager\n")
f.write("sslcertck=0\n")
f.write("http_headers =\n")
# avoid the initial 401 response by setting auth to Admin:opensuse directly
f.write(" authorization: Basic QWRtaW46b3BlbnN1c2U=\n")
def get_cmd(self):
osc_cmd = self.context.config.userdata.get("osc", "osc")
cmd = [osc_cmd]
cmd += ["--config", self.oscrc]
cmd += ["-A", f"https://{context.kanku.ip}"]
cmd += ["-A", f"https://localhost:{self.context.podman.port}"]
return cmd
@behave.step("I execute osc with args \"{args}\"")
def step_impl(context, args):
args = args.format(context=context)
cmd = context.osc.get_cmd(context) + [args]
cmd = context.osc.get_cmd() + [args]
cmd = " ".join(cmd)
run_in_context(context, cmd, can_fail=True)
@ -51,7 +59,7 @@ def step_impl(context, args):
@behave.step('I wait for osc results for "{project}" "{package}"')
def step_impl(context, project, package):
args = f"results {project} {package} --csv --format='%(code)s,%(dirty)s'"
cmd = context.osc.get_cmd(context) + [args]
cmd = context.osc.get_cmd() + [args]
cmd = " ".join(cmd)
while True:

View File

@ -0,0 +1,68 @@
import subprocess
class Podman:
def __init__(self):
self.container_id = None
self.run()
self.wait_on_systemd()
self.port = self.get_port()
def __del__(self):
try:
self.kill()
except Exception:
pass
def _run(self, args, check=True):
cmd = ["podman"] + args
proc = subprocess.run(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
check=check,
)
return proc
def run(self):
args = [
"run",
"--name", "obs-server-behave",
"--hostname", "obs-server-behave",
"--replace",
"--rm",
"--detach",
"--interactive",
"--tty",
"-p", "443",
"obs-server"
]
proc = self._run(args)
lines = proc.stdout.strip().splitlines()
self.container_id = lines[-1]
def kill(self):
if not self.container_id:
return
args = ["kill", self.container_id]
self._run(args)
self.container_id = None
def wait_on_systemd(self):
args = [
"exec",
self.container_id,
"/usr/bin/systemctl", "is-system-running", "--wait"
]
self._run(args, check=False)
def get_port(self):
args = ["port", self.container_id]
proc = self._run(args)
lines = proc.stdout.strip().splitlines()
for line in lines:
if line.startswith("443/tcp"):
# return <port> from: "443/tcp -> 0.0.0.0:<port>"
return line.split(":")[-1]
return None

View File

@ -1,4 +1,6 @@
%if %undefined flavor
%define flavor @BUILD_FLAVOR@%{nil}
%endif
# create own debug packages, because the auto-generated would get removed due to being empty
%undefine _debuginfo_subpackages
@ -6,7 +8,7 @@
Name: multibuild-pkg
Version: 1
Release: 0
Release: 1
License: GPL-2.0
Summary: Test package
URL: https://example.com/test-package/

View File

@ -1,6 +1,6 @@
Name: test-pkgA
Version: 1
Release: 0
Release: 1
License: GPL-2.0
Summary: Test package
URL: https://example.com/test-package/

View File

@ -1,6 +1,6 @@
Name: test-pkgA
Version: 2
Release: 0
Release: 1
License: GPL-2.0
Summary: Test package
URL: https://example.com/test-package/

View File

@ -1,6 +1,6 @@
Name: test-pkgA
Version: 3
Release: 0
Release: 1
License: GPL-2.0
Summary: Test package
URL: https://example.com/test-package/

View File

@ -1,6 +1,6 @@
Name: test-pkgB
Version: 1
Release: 0
Release: 1
License: GPL-2.0
Summary: Test package
URL: https://example.com/test-package/

View File

@ -1,6 +1,6 @@
Name: test-pkgB
Version: 2
Release: 0
Release: 1
License: GPL-2.0
Summary: Test package
URL: https://example.com/test-package/

View File

@ -0,0 +1,26 @@
<project name="devel">
<title>Devel project</title>
<description/>
<person userid="Admin" role="maintainer"/>
<build>
<disable/>
</build>
<publish>
<disable/>
</publish>
<useforbuild>
<disable/>
</useforbuild>
<repository name="standard">
<path project="openSUSE.org:openSUSE:Tumbleweed" repository="standard"/>
<arch>x86_64</arch>
<arch>i586</arch>
</repository>
</project>

View File

@ -5,6 +5,18 @@
<person userid="Admin" role="maintainer"/>
<build>
<disable/>
</build>
<publish>
<disable/>
</publish>
<useforbuild>
<disable/>
</useforbuild>
<repository name="openSUSE_Tumbleweed">
<path project="openSUSE.org:openSUSE:Tumbleweed" repository="standard"/>
<arch>x86_64</arch>

View File

@ -5,6 +5,18 @@
<person userid="Admin" role="maintainer"/>
<build>
<disable/>
</build>
<publish>
<disable/>
</publish>
<useforbuild>
<disable/>
</useforbuild>
<repository name="standard">
<path project="openSUSE.org:openSUSE:Tumbleweed" repository="standard"/>
<arch>x86_64</arch>

View File

@ -0,0 +1,28 @@
<project name="release">
<title>Release project</title>
<description/>
<person userid="Admin" role="maintainer"/>
<build>
<disable/>
</build>
<publish>
<disable/>
</publish>
<useforbuild>
<disable/>
</useforbuild>
<repository name="openSUSE_Tumbleweed">
<!--
<path project="openSUSE.org:openSUSE:Tumbleweed" repository="standard"/>
-->
<arch>x86_64</arch>
<arch>i586</arch>
</repository>
</project>

View File

@ -1,20 +0,0 @@
import os
from steps import osc
# doesn't do anything, just points osc to localhost
class FakeKanku:
ip = "localhost"
def before_all(context):
context.fixtures = os.path.join(os.path.dirname(__file__), "..", "fixtures")
context.kanku = FakeKanku()
context.osc = osc.Osc(context)
def after_all(context):
del context.osc
del context.kanku
del context.fixtures

View File

@ -1,113 +0,0 @@
# This is a special feature that should be used only in kanku VM to create initial OBS configuration.
# The scenarios follow each other and there is NO CLEANUP between them.
Feature: Setup OBS.
# Using interconnect feature is a must.
# We tried to configure projects from scratch (with download-on-demand repos),
# but there are simply too many settings that must be configured properly to make it work.
#
Scenario: Create openSUSE.org project that interconnects to another OBS instance
Given I execute osc with args "api -X PUT '/source/openSUSE.org/_meta' --file {context.fixtures}/prj/openSUSE.org.xml"
When I execute osc with args "list"
Then stdout is
"""
openSUSE.org
"""
Scenario: Create openSUSE:Factory project
Given I execute osc with args "api -X PUT '/source/openSUSE:Factory/_meta' --file {context.fixtures}/prj/openSUSE_Factory.xml"
When I execute osc with args "list"
Then stdout is
"""
openSUSE.org
openSUSE:Factory
"""
Scenario: Create home:Admin project
Given I execute osc with args "api -X PUT '/source/home:Admin/_meta' --file {context.fixtures}/prj/home_Admin.xml"
When I execute osc with args "list"
Then stdout is
"""
home:Admin
openSUSE.org
openSUSE:Factory
"""
Scenario: Create and build package 'test-pkgA' in 'openSUSE:Factory' project
# checkout project
Given I set working directory to "{context.osc.temp}"
When I execute osc with args "checkout openSUSE:Factory"
Then directory "{context.osc.temp}/openSUSE:Factory" exists
And directory "{context.osc.temp}/openSUSE:Factory/.osc" exists
# create package
Given I set working directory to "{context.osc.temp}/openSUSE:Factory"
When I execute osc with args "mkpac test-pkgA"
Then directory "{context.osc.temp}/openSUSE:Factory/test-pkgA" exists
And directory "{context.osc.temp}/openSUSE:Factory/test-pkgA/.osc" exists
# add and commit new package content
Given I set working directory to "{context.osc.temp}/openSUSE:Factory/test-pkgA"
# revision 1
When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/openSUSE:Factory/test-pkgA/test-pkgA.spec"
And I copy file "{context.fixtures}/pac/test-pkgA-1.changes" to "{context.osc.temp}/openSUSE:Factory/test-pkgA/test-pkgA.changes"
And I execute osc with args "add test-pkgA.spec test-pkgA.changes"
And I execute osc with args "commit -m 'Initial commit'"
# revision 2
And I copy file "{context.fixtures}/pac/test-pkgA-2.spec" to "{context.osc.temp}/openSUSE:Factory/test-pkgA/test-pkgA.spec"
And I copy file "{context.fixtures}/pac/test-pkgA-2.changes" to "{context.osc.temp}/openSUSE:Factory/test-pkgA/test-pkgA.changes"
And I execute osc with args "commit -m 'Version 2'"
# revision 3
And I copy file "{context.fixtures}/pac/test-pkgA-3.spec" to "{context.osc.temp}/openSUSE:Factory/test-pkgA/test-pkgA.spec"
And I copy file "{context.fixtures}/pac/test-pkgA-3.changes" to "{context.osc.temp}/openSUSE:Factory/test-pkgA/test-pkgA.changes"
And I execute osc with args "commit -m 'Version 3'"
Then I wait for osc results for "openSUSE:Factory" "test-pkgA"
Scenario: Create and build package 'test-pkgB' in 'openSUSE:Factory' project
# project checkout exists in temp already, no need to run checkout again
# create package
Given I set working directory to "{context.osc.temp}/openSUSE:Factory"
When I execute osc with args "mkpac test-pkgB"
Then directory "{context.osc.temp}/openSUSE:Factory/test-pkgB" exists
And directory "{context.osc.temp}/openSUSE:Factory/test-pkgB/.osc" exists
# add and commit new package content
Given I set working directory to "{context.osc.temp}/openSUSE:Factory/test-pkgB"
# revision 1
When I copy file "{context.fixtures}/pac/test-pkgB-1.spec" to "{context.osc.temp}/openSUSE:Factory/test-pkgB/test-pkgB.spec"
And I copy file "{context.fixtures}/pac/test-pkgB-1.changes" to "{context.osc.temp}/openSUSE:Factory/test-pkgB/test-pkgB.changes"
And I execute osc with args "add test-pkgB.spec test-pkgB.changes"
And I execute osc with args "commit -m 'Initial commit'"
# revision 2
And I copy file "{context.fixtures}/pac/test-pkgB-2.spec" to "{context.osc.temp}/openSUSE:Factory/test-pkgB/test-pkgB.spec"
And I copy file "{context.fixtures}/pac/test-pkgB-2.changes" to "{context.osc.temp}/openSUSE:Factory/test-pkgB/test-pkgB.changes"
And I execute osc with args "commit -m 'Version 2'"
Then I wait for osc results for "openSUSE:Factory" "test-pkgB"
Scenario: Create and build package 'multibuild-pkg' in 'openSUSE:Factory' project
# project checkout exists in temp already, no need to run checkout again
# create package
Given I set working directory to "{context.osc.temp}/openSUSE:Factory"
When I execute osc with args "mkpac multibuild-pkg"
Then directory "{context.osc.temp}/openSUSE:Factory/multibuild-pkg" exists
And directory "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/.osc" exists
# add and commit new package content
Given I set working directory to "{context.osc.temp}/openSUSE:Factory/multibuild-pkg"
# revision 1
When I copy file "{context.fixtures}/pac/multibuild-pkg-1.spec" to "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/multibuild-pkg.spec"
And I copy file "{context.fixtures}/pac/multibuild-pkg-1.changes" to "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/multibuild-pkg.changes"
And I copy file "{context.fixtures}/pac/multibuild-pkg-1._multibuild" to "{context.osc.temp}/openSUSE:Factory/multibuild-pkg/_multibuild"
And I execute osc with args "add multibuild-pkg.spec multibuild-pkg.changes _multibuild"
And I execute osc with args "commit -m 'Initial commit'"
Then I wait for osc results for "openSUSE:Factory" "multibuild-pkg"

View File

@ -1 +0,0 @@
../features/steps

View File

@ -1,46 +0,0 @@
# This package is not meant to be built and installed.
# It is for installing the test suite dependencies.
#
# Please follow the instructions in README.md.
# packages needed to manage virtual machines
%bcond_without host_only_packages
# minimal required behave version
%define behave_version 1.2.6
Name: osc-behave-requirements
Version: 1
Release: 0
Summary: Requirements for the OSC Behave tests
License: GPLv2
# don't install kanku inside a kanku VM
%if %{with host_only_packages}
BuildRequires: kanku
%endif
# osc
BuildRequires: osc
# behave
BuildRequires: (python3dist(behave) >= %{behave_version} or python3-behave >= %{behave_version})
# needed by steps/kanku.py
BuildRequires: (python3dist(ruamel.yaml) or python3-ruamel.yaml)
# fixes: ModuleNotFoundError: No module named 'pkg_resources'
BuildRequires: (python3dist(setuptools) or python3-setuptools)
%description
%{summary}
%files
%changelog

View File

@ -1 +0,0 @@
behave >= 1.2.6