Skip to content

Commit

Permalink
ci: Use podman for container tests
Browse files Browse the repository at this point in the history
Docker has complications running systemd inside container
  • Loading branch information
andrii-suse committed May 16, 2024
1 parent 924ec20 commit 15feb95
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 28 deletions.
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.
File renamed without changes.
File renamed without changes.
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

0 comments on commit 15feb95

Please sign in to comment.