Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Use podman for container tests #245

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,9 @@ jobs:
- checkout
- run: make test_python_style


integration:
machine:
image: ubuntu-2004:202201-02
steps:
- checkout
- run:
command: |
pyenv versions
pyenv global 3.10.2
docker pull registry.opensuse.org/devel/openqa/ci/containers/serviced
sudo chown -R 1000:1000 .
make test_docker PRIVILEGED_TESTS=1

workflows:
version: 2.1
test:
jobs:
- unit
- integration
- style
14 changes: 14 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: CI

on: [pull_request, workflow_dispatch] # yamllint disable-line rule:truthy

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: integration
run: |
podman pull registry.opensuse.org/devel/openqa/ci/containers/serviced
make test_docker PRIVILEGED_TESTS=1
14 changes: 11 additions & 3 deletions t/docker/lib/common.sh → t/podman/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ prepare_project() {
prj=$1
suff=$2

su $dbuser -c "set -ex
(
cd /opt/openqa-trigger-from-obs
mkdir -p $prj
chown $dbuser $prj
echo geekotest > rsync.secret
chmod 600 rsync.secret
chown $dbuser rsync.secret
)

su $dbuser -c "set -ex
cd /opt/openqa-trigger-from-obs
python3 script/scriptgen.py $prj
for l in $prj/*/.run_last ; do
[ ! -e \$l ] || rm \$l
done
[ ! -e $prj/.run_last ] || rm $prj/.run_last
echo geekotest > rsync.secret
chmod 600 rsync.secret"
"

echo "[production]
dsn = DBI:Pg:dbname=openqa;host=/tmp" > /usr/share/openqa/etc/openqa/database.ini
Expand All @@ -28,6 +35,7 @@ chmod +x /var/lib/openqa/osc-plugin-factory/factory-package-news/factory-package

systemctl start postgresql

systemctl restart apache2
systemctl restart openqa-webui.service
systemctl restart openqa-websockets.service
systemctl restart rsyncd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ containername="localtest.${basename,,}"

test "${PRIVILEGED_TESTS}" == 1 || ( echo PRIVILEGED_TESTS is not set to 1 ; exit 1)

docker info >/dev/null 2>&1 || (echo Docker doesnt seem to be running ; exit 1)
podman info >/dev/null 2>&1 || (echo podman doesnt seem to be running ; exit 1)

map_port=""
[ -z "$EXPOSE_PORT" ] || map_port="-p $EXPOSE_PORT:80"
docker run --privileged $map_port -v"$thisdir/../../..":/opt/openqa-trigger-from-obs --env METHOD=$METHOD --rm --name "$containername" -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro -- registry.opensuse.org/devel/openqa/ci/containers/serviced
podman run --privileged $map_port -v"$thisdir/../../..":/opt/openqa-trigger-from-obs:z --env METHOD=$METHOD --rm --name "$containername" -d -- registry.opensuse.org/devel/openqa/ci/containers/serviced

in_cleanup=0

Expand All @@ -44,7 +44,7 @@ function cleanup {
read -rsn1 -p"Test failed, press any key to finish";echo
fi
[ "$ret" == 0 ] || echo FAIL $basename
docker stop -t 0 "$containername" >&/dev/null || :
podman stop -t 0 "$containername" >&/dev/null || :
}

trap cleanup INT TERM EXIT
Expand All @@ -53,17 +53,17 @@ counter=1
# wait container start
until [ $counter -gt 10 ]; do
sleep 0.5
docker exec "$containername" pwd >& /dev/null && break
podman exec "$containername" pwd >& /dev/null && break
((counter++))
done

docker exec "$containername" pwd >& /dev/null || (echo Cannot start container; exit 1 ) >&2
podman exec "$containername" pwd >& /dev/null || (echo Cannot start container; exit 1 ) >&2

docker exec "$containername" bash /opt/init-trigger-from-obs.sh
podman exec "$containername" bash /opt/init-trigger-from-obs.sh

[ -z "$CIRCLE_JOB" ] || echo 'aa-complain /usr/share/openqa/script/openqa' | docker exec "$containername" bash -x
[ -z "$CIRCLE_JOB" ] || echo 'aa-complain /usr/share/openqa/script/openqa' | podman exec "$containername" bash -x
set +e
docker cp lib/common.sh "$containername":/lib
docker exec -e TESTCASE="$testcase" "$containername" bash -xe /opt/openqa-trigger-from-obs/t/docker/$testcase
podman cp lib/common.sh "$containername":/lib
podman exec -e TESTCASE="$testcase" "$containername" bash -xe /opt/openqa-trigger-from-obs/t/podman/$testcase
ret=$?
( exit $ret )
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@ echo 1 > /mockOBS/openSUSE\:Factory\:ToTest/images/local/000product:openSUSE-Add
mkdir -p /mockOBS/openSUSE\:Factory\:ToTest/images/local/000product:openSUSE-Addon-NonOss-ftp-ftp-x86_64/openSUSE-Addon-NonOss-FTP-x86_64-Media3
echo 1 > /mockOBS/openSUSE\:Factory\:ToTest/images/local/000product:openSUSE-Addon-NonOss-ftp-ftp-x86_64/openSUSE-Addon-NonOss-FTP-x86_64-Media3/sourcefile

# create just empty files as at this point we are not interested about proper binaries
chown -R "$dbuser" /mockOBS

su $dbuser -c 'set -ex
(
cd /opt/openqa-trigger-from-obs
mkdir -p openSUSE:Factory:ToTest
python3 script/scriptgen.py openSUSE:Factory:ToTest
[ ! -e openSUSE:Factory:ToTest/base/.run_last ] || rm openSUSE:Factory:ToTest/base/.run_last
chown geekotest openSUSE:Factory:ToTest
echo geekotest > rsync.secret
chmod 600 rsync.secret'
chmod 600 rsync.secret
chown geekotest rsync.secret
)

su $dbuser -c 'set -ex
cd /opt/openqa-trigger-from-obs
python3 script/scriptgen.py openSUSE:Factory:ToTest
[ ! -e openSUSE:Factory:ToTest/base/.run_last ] || rm openSUSE:Factory:ToTest/base/.run_last'

echo '127.0.0.1 obspublish' >> /etc/hosts
systemctl enable --now postgresql
systemctl enable --now rsyncd
systemctl restart rsyncd
sleep 1 # is it a bug that rsyncd needs sleep to work properly?

runs_before="$(ls -lda /opt/openqa-trigger-from-obs/openSUSE:Factory:ToTest/base/.run_*/ 2>/dev/null | wc -l)"

Expand Down
2 changes: 1 addition & 1 deletion t/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")"

(
dockerfail=0
cd docker
cd podman
for t in *.sh; do
[ -x "$t" ] || continue
for i in $(seq 1 3); do
Expand Down
Loading