From 1fd3a93a10beda3daa88a7b79ad9f2f68666e1c0 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Sun, 11 Jun 2023 18:53:10 +0200 Subject: [PATCH 1/5] copied the script part of rust/agama-cli/doc/backend-for-testing.md --- rust/agama-cli/doc/backend-for-testing.md | 53 ++--------------------- testing_using_container.sh | 47 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 49 deletions(-) create mode 100644 testing_using_container.sh diff --git a/rust/agama-cli/doc/backend-for-testing.md b/rust/agama-cli/doc/backend-for-testing.md index a5612620ac..d23c993cf7 100644 --- a/rust/agama-cli/doc/backend-for-testing.md +++ b/rust/agama-cli/doc/backend-for-testing.md @@ -33,53 +33,8 @@ of [.github/workflows/ci.yml][ci.yml]. [ci.yml]: https://github.com/openSUSE/agama/blob/25462f57ab695d6910beb59ff0b21a7afaeda47e/.github/workflows/ci.yml +## Resulting Script -```sh -# https://build.opensuse.org/package/show/systemsmanagement:Agama:Staging/agama-testing -CIMAGE=registry.opensuse.org/systemsmanagement/agama/staging/containers/opensuse/agama-testing:latest -# rename this if you test multiple things -CNAME=agama -# the '?' here will report a shell error -# if you accidentally paste a command without setting the variable first -echo ${CNAME?} - -test -f service/agama.gemspec || echo "You should run this from a checkout of agama" - -# destroy the previous instance -podman stop ${CNAME?} -podman rm ${CNAME?} - -mkdir -p ./mnt/log-yast2 # needed? -mkdir -p ./mnt/run-agama # only needed for D-Bus access from outside, unused now - -# Update our image -podman pull ${CIMAGE?} - -podman run --name ${CNAME?} \ - --privileged --detach --ipc=host \ - -v .:/checkout -v ./mnt/run-agama:/run/agama -v ./mnt/log-yast2:/var/log/YaST2 \ - ${CIMAGE?} - -# shortcut for the following -CEXEC="podman exec ${CNAME?} bash -c" - -${CEXEC?} "cd /checkout && ./setup-services.sh" - -# Optional: explicit service start using a separate log file -${CEXEC?} "cd /checkout/service && (bundle exec bin/agamactl > service.log 2>&1 &)" - -# Now the CLI is in the same repo, just symlink it -${CEXEC?} "ln -sfv /checkout/./rust/target/debug/agama /usr/bin/agama" - -# Optional: Play! -${CEXEC?} "agama -f yaml config show" - -# Optional: show logs of autostarted services -${CEXEC?} "journalctl --since=-5min" - -# Optional: show logs of explicitly started services -${CEXEC?} "cat /checkout/service/service.log" - -# Optional: Interactive shell in the container -podman exec --tty --interactive ${CNAME?} bash -``` +The script, which used to be inlined here, is now at +[`/testing_using_container.sh`](../../../testing_using_container.sh). +>>>>>>> 8f2f0404 (copied the script part of rust/agama-cli/doc/backend-for-testing.md) diff --git a/testing_using_container.sh b/testing_using_container.sh new file mode 100644 index 0000000000..4aec88f197 --- /dev/null +++ b/testing_using_container.sh @@ -0,0 +1,47 @@ +# https://build.opensuse.org/package/show/YaST:Head:Containers/agama-testing +CIMAGE=registry.opensuse.org/yast/head/containers/containers_tumbleweed/opensuse/agama-testing:latest +# rename this if you test multiple things +CNAME=agama +# the '?' here will report a shell error +# if you accidentally paste a command without setting the variable first +echo ${CNAME?} + +test -f service/agama.gemspec || echo "You should run this from a checkout of agama" + +# destroy the previous instance +podman stop ${CNAME?} +podman rm ${CNAME?} + +mkdir -p ./mnt/log-yast2 # needed? +mkdir -p ./mnt/run-agama # only needed for D-Bus access from outside, unused now + +# Update our image +podman pull ${CIMAGE?} + +podman run --name ${CNAME?} \ + --privileged --detach --ipc=host \ + -v .:/checkout -v ./mnt/run-agama:/run/agama -v ./mnt/log-yast2:/var/log/YaST2 \ + ${CIMAGE?} + +# shortcut for the following +CEXEC="podman exec ${CNAME?} bash -c" + +${CEXEC?} "cd /checkout && ./setup-services.sh" + +# Optional: explicit service start using a separate log file +${CEXEC?} "cd /checkout/service && (bundle exec bin/agamactl > service.log 2>&1 &)" + +# Now the CLI is in the same repo, just symlink it +${CEXEC?} "ln -sfv /checkout/./rust/target/debug/agama /usr/bin/agama" + +# Optional: Play! +${CEXEC?} "agama -f yaml config show" + +# Optional: show logs of autostarted services +${CEXEC?} "journalctl --since=-5min" + +# Optional: show logs of explicitly started services +${CEXEC?} "cat /checkout/service/service.log" + +# Optional: Interactive shell in the container +podman exec --tty --interactive ${CNAME?} bash From 7bbdf94014cf06e16a83b7ff55d8c5ab6bf43631 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Sun, 11 Jun 2023 18:55:42 +0200 Subject: [PATCH 2/5] updated from testing_using_container.md --- testing_using_container.sh | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/testing_using_container.sh b/testing_using_container.sh index 4aec88f197..fe2162ddb1 100644 --- a/testing_using_container.sh +++ b/testing_using_container.sh @@ -8,40 +8,29 @@ echo ${CNAME?} test -f service/agama.gemspec || echo "You should run this from a checkout of agama" -# destroy the previous instance +# destroy the previous instance, can fail if there is no previous instance podman stop ${CNAME?} podman rm ${CNAME?} -mkdir -p ./mnt/log-yast2 # needed? -mkdir -p ./mnt/run-agama # only needed for D-Bus access from outside, unused now - # Update our image podman pull ${CIMAGE?} podman run --name ${CNAME?} \ --privileged --detach --ipc=host \ - -v .:/checkout -v ./mnt/run-agama:/run/agama -v ./mnt/log-yast2:/var/log/YaST2 \ + -v .:/checkout \ + -p 9090:9090 \ ${CIMAGE?} # shortcut for the following CEXEC="podman exec ${CNAME?} bash -c" -${CEXEC?} "cd /checkout && ./setup-services.sh" - -# Optional: explicit service start using a separate log file -${CEXEC?} "cd /checkout/service && (bundle exec bin/agamactl > service.log 2>&1 &)" +${CEXEC?} "cd /checkout && ./setup.sh" # Now the CLI is in the same repo, just symlink it ${CEXEC?} "ln -sfv /checkout/./rust/target/debug/agama /usr/bin/agama" -# Optional: Play! -${CEXEC?} "agama -f yaml config show" - -# Optional: show logs of autostarted services -${CEXEC?} "journalctl --since=-5min" - -# Optional: show logs of explicitly started services -${CEXEC?} "cat /checkout/service/service.log" +# Manually start cockpit as socket activation does not work with port forwarding +${CEXEC?} "systemctl start cockpit" # Optional: Interactive shell in the container podman exec --tty --interactive ${CNAME?} bash From fecb7b4fd66e5e86e42909db50fb8b08dfa3ce3e Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Sun, 11 Jun 2023 21:30:37 +0200 Subject: [PATCH 3/5] use /checkout-ruby-dbus if WITH_RUBY_DBUS=1 Agama pushes the limits of ruby-dbus so often it is desirable to test against a WIP checkout of that library from ../ruby-dbus WITH_RUBY_DBUS=1 enables that --- setup-services.sh | 9 +++++++++ testing_using_container.sh | 20 +++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) mode change 100644 => 100755 testing_using_container.sh diff --git a/setup-services.sh b/setup-services.sh index e9a4596a1f..29abd1da43 100755 --- a/setup-services.sh +++ b/setup-services.sh @@ -102,6 +102,15 @@ fi # Rubygem dependencies ( cd $MYDIR/service + + if [ -d /checkout-ruby-dbus ]; then + # we are in a container, told to use that one + # instead of a released version + # edit +Gemfile and -gemspec + sed -e '/ruby-dbus/d' -i Gemfile agama.gemspec + sed -e '/gemspec/a gem "ruby-dbus", path: "/checkout-ruby-dbus"' -i Gemfile + fi + bundle config set --local path 'vendor/bundle' bundle install ) diff --git a/testing_using_container.sh b/testing_using_container.sh old mode 100644 new mode 100755 index fe2162ddb1..8b6186c4f2 --- a/testing_using_container.sh +++ b/testing_using_container.sh @@ -1,23 +1,33 @@ +#!/bin/bash +set -x +set -eu + # https://build.opensuse.org/package/show/YaST:Head:Containers/agama-testing CIMAGE=registry.opensuse.org/yast/head/containers/containers_tumbleweed/opensuse/agama-testing:latest # rename this if you test multiple things CNAME=agama -# the '?' here will report a shell error -# if you accidentally paste a command without setting the variable first -echo ${CNAME?} test -f service/agama.gemspec || echo "You should run this from a checkout of agama" # destroy the previous instance, can fail if there is no previous instance -podman stop ${CNAME?} -podman rm ${CNAME?} +podman stop ${CNAME?} || : no problem if there was nothing to stop +podman rm ${CNAME?} || : no problem if there was nothing to remove # Update our image podman pull ${CIMAGE?} +# Optionally use a git version of ruby-dbus +# because Agama pushes its limits so it's better +# to set up for easy testing +MORE_VOLUMES=() +if [ "${WITH_RUBY_DBUS-}" = 1 ]; then + MORE_VOLUMES=(-v ../ruby-dbus:/checkout-ruby-dbus) +fi + podman run --name ${CNAME?} \ --privileged --detach --ipc=host \ -v .:/checkout \ + ${MORE_VOLUMES[@]} \ -p 9090:9090 \ ${CIMAGE?} From 19cd86c7bbb6b82047add4d36e2404903cc7e319 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Tue, 31 Oct 2023 13:07:36 +0100 Subject: [PATCH 4/5] adjust OBS project --- testing_using_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing_using_container.sh b/testing_using_container.sh index 8b6186c4f2..de7c0a147e 100755 --- a/testing_using_container.sh +++ b/testing_using_container.sh @@ -2,8 +2,8 @@ set -x set -eu -# https://build.opensuse.org/package/show/YaST:Head:Containers/agama-testing -CIMAGE=registry.opensuse.org/yast/head/containers/containers_tumbleweed/opensuse/agama-testing:latest +# https://build.opensuse.org/package/show/systemsmanagement:Agama:Staging/agama-testing +CIMAGE=registry.opensuse.org/systemsmanagement/agama/staging/containers/opensuse/agama-testing:latest # rename this if you test multiple things CNAME=agama From b806f3b4b651fb0fd154b6cb544cf3ed6c629e89 Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Fri, 1 Dec 2023 14:21:21 +0100 Subject: [PATCH 5/5] Add doc comment to script; exit if not in the git checkout --- testing_using_container.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/testing_using_container.sh b/testing_using_container.sh index de7c0a147e..87becab2c6 100755 --- a/testing_using_container.sh +++ b/testing_using_container.sh @@ -1,4 +1,14 @@ #!/bin/bash +# Run checked-out Agama in a podman container. +# This is meant to be run from a working copy of the git repo. +# It uses the systemsmanagement:Agama:Staging/agama-testing image as +# a platform and runs /setup.sh +# +# Details: +# - container name: agama +# - port 9090 is exposed so that web UI works +# - 'WITH_RUBY_DBUS=1 $0' will prefer ../ruby-dbus to any ruby-dbus.gem + set -x set -eu @@ -7,7 +17,7 @@ CIMAGE=registry.opensuse.org/systemsmanagement/agama/staging/containers/opensuse # rename this if you test multiple things CNAME=agama -test -f service/agama.gemspec || echo "You should run this from a checkout of agama" +test -f service/agama.gemspec || { echo "You should run this from a checkout of agama"; exit 1; } # destroy the previous instance, can fail if there is no previous instance podman stop ${CNAME?} || : no problem if there was nothing to stop @@ -42,5 +52,5 @@ ${CEXEC?} "ln -sfv /checkout/./rust/target/debug/agama /usr/bin/agama" # Manually start cockpit as socket activation does not work with port forwarding ${CEXEC?} "systemctl start cockpit" -# Optional: Interactive shell in the container +# Interactive shell in the container podman exec --tty --interactive ${CNAME?} bash