diff --git a/.editorconfig b/.editorconfig new file mode 120000 index 00000000000..e7044a352b9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1 @@ +external/os-autoinst-common/.editorconfig \ No newline at end of file diff --git a/Makefile b/Makefile index 9a2b6fea284..be3b9277c02 100644 --- a/Makefile +++ b/Makefile @@ -293,7 +293,7 @@ prepare-and-launch-container-to-run-tests-within: container-test-build launch-co # all additional checks not called by prove .PHONY: test-checkstyle-standalone -test-checkstyle-standalone: test-shellcheck test-yaml test-critic +test-checkstyle-standalone: test-shellcheck test-yaml test-critic test-shfmt ifeq ($(CONTAINER_TEST),1) test-checkstyle-standalone: test-check-containers endif @@ -317,6 +317,11 @@ test-yaml: @# Fall back to find if there is no git, e.g. in package builds yamllint --strict $$((git ls-files "*.yml" "*.yaml" 2>/dev/null || find -name '*.y*ml') | grep -v ^dbicdh) +.PHONY: test-shfmt +test-shfmt: + @which shfmt >/dev/null 2>&1 || (echo "Command 'shfmt' not found, can not execute bash script syntax checks" && false) + shfmt -d . + .PHONY: test-check-containers test-check-containers: tools/static_check_containers diff --git a/container/openqa/entrypoint.sh b/container/openqa/entrypoint.sh index 6edca114e6b..864d96884f1 100644 --- a/container/openqa/entrypoint.sh +++ b/container/openqa/entrypoint.sh @@ -10,19 +10,19 @@ export LC_ALL="en_US.UTF-8" # First, try to upgrade all container dependencies (or we won't catch bugs # until a new container image is built) -[ "$UPGRADE_FROM_ZYPPER" -eq 1 ] && \ - sudo zypper --gpg-auto-import-keys -n ref --force && \ - sudo zypper up -l -y +[ "$UPGRADE_FROM_ZYPPER" -eq 1 ] \ + && sudo zypper --gpg-auto-import-keys -n ref --force \ + && sudo zypper up -l -y cp -rd /opt/openqa /opt/testing_area cd /opt/testing_area/openqa run_as_normal_user() { if [ "$INSTALL_FROM_CPAN" -eq 1 ]; then - echo ">> Trying to get dependencies from CPAN" - cpanm -M https://cpan.metacpan.org --local-lib=~/perl5 local::lib && cpanm -M https://cpan.metacpan.org -n --installdeps . + echo ">> Trying to get dependencies from CPAN" + cpanm -M https://cpan.metacpan.org --local-lib=~/perl5 local::lib && cpanm -M https://cpan.metacpan.org -n --installdeps . else - cpanm -n --mirror http://no.where/ --installdeps . + cpanm -n --mirror http://no.where/ --installdeps . fi MOJO_TMPDIR=$(mktemp -d) export MOJO_TMPDIR diff --git a/container/webui/nginx-entrypoint.sh b/container/webui/nginx-entrypoint.sh index cac5dba2038..fcdc13c5889 100755 --- a/container/webui/nginx-entrypoint.sh +++ b/container/webui/nginx-entrypoint.sh @@ -3,7 +3,7 @@ set -e replicas_cfg="" for i in $(seq "${OPENQA_WEBUI_REPLICAS:-2}"); do - replicas_cfg="server webui_webui_$i:9526;$replicas_cfg" + replicas_cfg="server webui_webui_$i:9526;$replicas_cfg" done reg="s/REPLICAS/$replicas_cfg/" diff --git a/container/webui/run_openqa.sh b/container/webui/run_openqa.sh index c07cc095253..51d4630ea50 100644 --- a/container/webui/run_openqa.sh +++ b/container/webui/run_openqa.sh @@ -2,72 +2,72 @@ set -e function wait_for_db_creation() { - echo "Waiting for DB creation" - while ! su geekotest -c 'PGPASSWORD=openqa psql -h db -U openqa --list | grep -qe openqa'; do sleep .1; done + echo "Waiting for DB creation" + while ! su geekotest -c 'PGPASSWORD=openqa psql -h db -U openqa --list | grep -qe openqa'; do sleep .1; done } function upgradedb() { - wait_for_db_creation - su geekotest -c '/usr/share/openqa/script/upgradedb --upgrade_database' + wait_for_db_creation + su geekotest -c '/usr/share/openqa/script/upgradedb --upgrade_database' } function scheduler() { - su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon + su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon } function websockets() { - su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon + su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon } function gru() { - wait_for_db_creation - su geekotest -c /usr/share/openqa/script/openqa-gru + wait_for_db_creation + su geekotest -c /usr/share/openqa/script/openqa-gru } function livehandler() { - wait_for_db_creation - su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon + wait_for_db_creation + su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon } function webui() { - wait_for_db_creation - su geekotest -c /usr/share/openqa/script/openqa-webui-daemon + wait_for_db_creation + su geekotest -c /usr/share/openqa/script/openqa-webui-daemon } function all_together_apache() { - # use certificate that comes with Mojolicious if none configured by the user (by making one available via `-v`) - local mojo_resources=$(perl -e 'use Mojolicious; print(Mojolicious->new->home->child("Mojo/IOLoop/resources"))') - cp --no-clobber "$mojo_resources"/server.crt /etc/apache2/ssl.crt/server.crt ||: - cp --no-clobber "$mojo_resources"/server.key /etc/apache2/ssl.key/server.key ||: - cp --no-clobber "$mojo_resources"/server.crt /etc/apache2/ssl.crt/ca.crt ||: + # use certificate that comes with Mojolicious if none configured by the user (by making one available via `-v`) + local mojo_resources=$(perl -e 'use Mojolicious; print(Mojolicious->new->home->child("Mojo/IOLoop/resources"))') + cp --no-clobber "$mojo_resources"/server.crt /etc/apache2/ssl.crt/server.crt || : + cp --no-clobber "$mojo_resources"/server.key /etc/apache2/ssl.key/server.key || : + cp --no-clobber "$mojo_resources"/server.crt /etc/apache2/ssl.crt/ca.crt || : - # run the database within the container if no database is configured by the user (by making one available via `-v`) - if [[ ! -e /data/conf/database.ini ]]; then - mkdir -p /data/conf - echo -e "[production]\ndsn = DBI:Pg:dbname=openqa" > /data/conf/database.ini - chown -R postgres:postgres /var/lib/pgsql # ensure right ownership in case `/var/lib/pgsql` is from host via `-v` - su postgres -c '/usr/share/postgresql/postgresql-script start' - su postgres -c '/usr/bin/openqa-setup-db' - fi + # run the database within the container if no database is configured by the user (by making one available via `-v`) + if [[ ! -e /data/conf/database.ini ]]; then + mkdir -p /data/conf + echo -e "[production]\ndsn = DBI:Pg:dbname=openqa" > /data/conf/database.ini + chown -R postgres:postgres /var/lib/pgsql # ensure right ownership in case `/var/lib/pgsql` is from host via `-v` + su postgres -c '/usr/share/postgresql/postgresql-script start' + su postgres -c '/usr/bin/openqa-setup-db' + fi - # run services and apache2 - su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon & - su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon & - su geekotest -c /usr/share/openqa/script/openqa-gru & - su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon & - apache2ctl start - su geekotest -c /usr/share/openqa/script/openqa-webui-daemon + # run services and apache2 + su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon & + su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon & + su geekotest -c /usr/share/openqa/script/openqa-gru & + su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon & + apache2ctl start + su geekotest -c /usr/share/openqa/script/openqa-webui-daemon } usermod --shell /bin/sh geekotest # run services case "$MODE" in - upgradedb ) upgradedb;; - scheduler ) scheduler;; - websockets ) websockets;; - gru ) gru;; - livehandler ) livehandler;; - webui ) webui;; - * ) all_together_apache;; + upgradedb) upgradedb ;; + scheduler) scheduler ;; + websockets) websockets ;; + gru) gru ;; + livehandler) livehandler ;; + webui) webui ;; + *) all_together_apache ;; esac diff --git a/container/worker/kvm-mknod.sh b/container/worker/kvm-mknod.sh index 7d2321414a5..26e80bab259 100644 --- a/container/worker/kvm-mknod.sh +++ b/container/worker/kvm-mknod.sh @@ -2,14 +2,14 @@ # If possible, create the /dev/kvm device node. set -e -kvm=$({ [[ -f /proc/config.gz ]] && test "$(zgrep CONFIG_KVM=y /proc/config.gz)" ; } || true) +kvm=$({ [[ -f /proc/config.gz ]] && test "$(zgrep CONFIG_KVM=y /proc/config.gz)"; } || true) $kvm || lsmod | grep '\' > /dev/null || { - echo >&2 "KVM module not loaded; software emulation will be used" - exit 1 + echo >&2 "KVM module not loaded; software emulation will be used" + exit 1 } [[ -c /dev/kvm ]] || mknod /dev/kvm c 10 "$(grep '\' /proc/misc | cut -f 1 -d' ')" || { - echo >&2 "Unable to make /dev/kvm node; software emulation will be used" - echo >&2 "(This can happen if the container is run without -privileged)" - exit 1 + echo >&2 "Unable to make /dev/kvm node; software emulation will be used" + echo >&2 "(This can happen if the container is run without -privileged)" + exit 1 } diff --git a/container/worker/launch_workers_pool.sh b/container/worker/launch_workers_pool.sh index ca5bb4e78f9..118077fa538 100755 --- a/container/worker/launch_workers_pool.sh +++ b/container/worker/launch_workers_pool.sh @@ -20,22 +20,28 @@ opts=$(getopt -o hs: --long help,size: -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage 0 ;; - -s | --size ) size=$2; shift ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage 0 ;; + -s | --size) + size=$2 + shift + ;; + --) + shift + break + ;; + *) break ;; + esac done for i in $(seq "$size"); do - echo "Creating worker $i" - $cre run \ - --detach --rm \ - --hostname "openqa_worker_$i" --name "openqa_worker_$i" \ - -v "$PWD/conf:/data/conf:ro" \ - -v "$PWD/../webui/workdir/data/factory:/data/factory:rw" \ - -v "$PWD/../webui/workdir/data/tests:/data/tests:ro" \ - --privileged openqa_worker \ - -e OPENQA_WORKER_INSTANCE="$i" + echo "Creating worker $i" + $cre run \ + --detach --rm \ + --hostname "openqa_worker_$i" --name "openqa_worker_$i" \ + -v "$PWD/conf:/data/conf:ro" \ + -v "$PWD/../webui/workdir/data/factory:/data/factory:rw" \ + -v "$PWD/../webui/workdir/data/tests:/data/tests:ro" \ + --privileged openqa_worker \ + -e OPENQA_WORKER_INSTANCE="$i" done diff --git a/container/worker/run_openqa_worker.sh b/container/worker/run_openqa_worker.sh index 5132f3b3aec..2fc2173796f 100644 --- a/container/worker/run_openqa_worker.sh +++ b/container/worker/run_openqa_worker.sh @@ -3,29 +3,29 @@ set -e if [[ -z $OPENQA_WORKER_INSTANCE ]]; then - OPENQA_WORKER_INSTANCE=1 + OPENQA_WORKER_INSTANCE=1 fi mkdir -p "/var/lib/openqa/pool/${OPENQA_WORKER_INSTANCE}/" chown -R _openqa-worker /var/lib/openqa/pool/ if [[ -z $qemu_no_kvm ]] || [[ $qemu_no_kvm -eq 0 ]]; then - if [ -e "/dev/kvm" ] && getent group kvm > /dev/null; then - /root/qemu/kvm-mknod.sh + if [ -e "/dev/kvm" ] && getent group kvm > /dev/null; then + /root/qemu/kvm-mknod.sh - group=$(ls -lhn /dev/kvm | cut -d ' ' -f 4) - groupmod -g "$group" --non-unique kvm - usermod -a -G kvm _openqa-worker - else - echo "Warning: /dev/kvm doesn't exist. If you want to use KVM, run the container with --device=/dev/kvm" - fi + group=$(ls -lhn /dev/kvm | cut -d ' ' -f 4) + groupmod -g "$group" --non-unique kvm + usermod -a -G kvm _openqa-worker + else + echo "Warning: /dev/kvm doesn't exist. If you want to use KVM, run the container with --device=/dev/kvm" + fi fi qemu-system-x86_64 -S & kill $! # Install test distribution dependencies -if [[ -z $TEST_DISTRI_DEPS ]] ; then +if [[ -z $TEST_DISTRI_DEPS ]]; then find -L "/var/lib/openqa/share/tests" -maxdepth 2 -type f -executable -name 'install_deps.*' -exec {} \; else zypper -n --gpg-auto-import-keys install $TEST_DISTRI_DEPS diff --git a/dependencies.yaml b/dependencies.yaml index 2ba006457ae..90b74c39707 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -181,11 +181,11 @@ test_requires: curl: jq: ShellCheck: - shfmt: os-autoinst-devel: postgresql-server: python3-setuptools: python3-yamllint: + shfmt: perl(App::cpanminus): perl(Perl::Critic): perl(Perl::Critic::Freenode): diff --git a/external/os-autoinst-common/.editorconfig b/external/os-autoinst-common/.editorconfig new file mode 100644 index 00000000000..503c34cfdf9 --- /dev/null +++ b/external/os-autoinst-common/.editorconfig @@ -0,0 +1,12 @@ +[*] +indent_style = space +indent_size = 4 +binary_next_line = true +switch_case_indent = true +space_redirects = true + +[.bpan/**] +ignore = true + +[*~] +ignore = true diff --git a/external/os-autoinst-common/.gitrepo b/external/os-autoinst-common/.gitrepo index 6abd47a1e32..f6aa8d56e6f 100644 --- a/external/os-autoinst-common/.gitrepo +++ b/external/os-autoinst-common/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:os-autoinst/os-autoinst-common.git branch = master - commit = a94b58b23be8ddb5bf85a7b1f87914ba9e71b9e6 - parent = 1e9bfef6f182ff6e30268174f6414bf48c35b89c + commit = fbd66e7f61d2397f55bc8b6143a405c8ed639008 + parent = 7f2e4f335e1ce7b7d89e5056da4acbb82b18bc94 method = merge cmdver = 0.4.6 diff --git a/script/configure-web-proxy b/script/configure-web-proxy index 78b7ad39f85..ae272336d04 100755 --- a/script/configure-web-proxy +++ b/script/configure-web-proxy @@ -17,25 +17,31 @@ opts=$(getopt -o hp: -l help -l proxy: -n "$0" -- "$@") || usage 1 eval set -- "$opts" web_proxy="apache" while true; do - case "$1" in - -h | --help ) usage 0 ;; - -p | --proxy ) web_proxy=${2#*=}; shift ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage 0 ;; + -p | --proxy) + web_proxy=${2#*=} + shift + ;; + --) + shift + break + ;; + *) break ;; + esac done sed -i -e 's/^.*httpsonly.*$/httpsonly = 0/g' /etc/openqa/openqa.ini -if [[ $web_proxy == "nginx" ]] ; then - echo "Setting up nginx" - sed "s/openqa.example.com/$(hostname)/" /etc/nginx/vhosts.d/openqa.conf.template > /etc/nginx/vhosts.d/openqa.conf - sed -i -e "s/\(^[^#]*server_name localhost;\)/#\1/" /etc/nginx/nginx.conf -elif [[ $web_proxy == "apache" || $web_proxy == "apache2" ]] ; then - echo "Setting up apache" - for i in headers proxy proxy_http proxy_wstunnel rewrite ; do a2enmod $i ; done - sed "s/#ServerName.*$/ServerName $(hostname)/" /etc/apache2/vhosts.d/openqa.conf.template > /etc/apache2/vhosts.d/openqa.conf +if [[ $web_proxy == "nginx" ]]; then + echo "Setting up nginx" + sed "s/openqa.example.com/$(hostname)/" /etc/nginx/vhosts.d/openqa.conf.template > /etc/nginx/vhosts.d/openqa.conf + sed -i -e "s/\(^[^#]*server_name localhost;\)/#\1/" /etc/nginx/nginx.conf +elif [[ $web_proxy == "apache" || $web_proxy == "apache2" ]]; then + echo "Setting up apache" + for i in headers proxy proxy_http proxy_wstunnel rewrite; do a2enmod $i; done + sed "s/#ServerName.*$/ServerName $(hostname)/" /etc/apache2/vhosts.d/openqa.conf.template > /etc/apache2/vhosts.d/openqa.conf else - echo "No supported proxy: $web_proxy" - exit 1 + echo "No supported proxy: $web_proxy" + exit 1 fi diff --git a/script/fetchneedles b/script/fetchneedles index 2c44c8f2638..343c0e79705 100755 --- a/script/fetchneedles +++ b/script/fetchneedles @@ -18,9 +18,9 @@ : "${updateall:="0"}" : "${force:="0"}" -if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then printf "Get %s tests and needles from:\n\t\t%s\n" "${dist_name}" "${giturl}" - if [ "$needles_separate" = 1 ] ; then + if [ "$needles_separate" = 1 ]; then printf "\tand\t%s\n" "${needles_giturl}" fi printf "\n(environment variables mentioned in '%s' can be set to change these values)\n" "$0" @@ -66,7 +66,7 @@ needlesdir() { deal_with_stale_lockfile() { lock_path=.git/index.lock - if [ -e "$lock_path" ] && ! fuser --silent "$lock_path"; then # fuser returns 0 if one or more processes hold the lock + if [ -e "$lock_path" ] && ! fuser --silent "$lock_path"; then # fuser returns 0 if one or more processes hold the lock echo "removing stale lock $PWD/$lock_path" rm "$lock_path" fi diff --git a/script/openqa-auto-update b/script/openqa-auto-update index c3cb89d9d9f..5efa2d3872c 100755 --- a/script/openqa-auto-update +++ b/script/openqa-auto-update @@ -16,11 +16,14 @@ EOF opts=$(getopt -o h --long help -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage 0 ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage 0 ;; + --) + shift + break + ;; + *) break ;; + esac done "$(dirname "${BASH_SOURCE[0]}")"/openqa-check-devel-repo @@ -28,4 +31,4 @@ done zypper -n ref zypper -n --no-refresh dup --replacefiles --auto-agree-with-licenses --download-in-advance # shellcheck disable=SC2015 -needs-restarting --reboothint >/dev/null || (command -v rebootmgrctl >/dev/null && rebootmgrctl reboot ||:) +needs-restarting --reboothint > /dev/null || (command -v rebootmgrctl > /dev/null && rebootmgrctl reboot || :) diff --git a/script/openqa-bootstrap b/script/openqa-bootstrap index e48cd6a67d2..2aebd62fb83 100755 --- a/script/openqa-bootstrap +++ b/script/openqa-bootstrap @@ -22,24 +22,23 @@ if [ "$NAME" = "openSUSE Leap" ]; then repobase=https://download.opensuse.org/repositories/devel:/openQA zypper -n addrepo -p 95 "$repobase/${VERSION}" 'devel:openQA' zypper -n addrepo -p 90 "$repobase:/Leap:/${VERSION}/${VERSION}" "devel:openQA:Leap:${VERSION}" - zypper -n --gpg-auto-import-keys refresh + zypper -n --gpg-auto-import-keys refresh fi - # install packages pkgs=(qemu-arm qemu-ppc qemu-x86 qemu-tools sudo iputils os-autoinst-distri-opensuse-deps) if [ "$(uname -m)" = "aarch64" ]; then pkgs+=(qemu-uefi-aarch64) fi -if [[ $setup_web_proxy == "nginx" ]] ; then +if [[ $setup_web_proxy == "nginx" ]]; then pkgs+=(openQA-single-instance-nginx) else pkgs+=(openQA-single-instance) fi # this was split into a separate package on newer dist versions - so install it if available -if zypper -n search -x qemu-hw-display-virtio-gpu-pci ; then +if zypper -n search -x qemu-hw-display-virtio-gpu-pci; then pkgs+=(qemu-hw-display-virtio-gpu qemu-hw-display-virtio-gpu-pci) fi zypper -n install --no-recommends "${pkgs[@]}" @@ -57,17 +56,16 @@ su postgres -c "/usr/share/openqa/script/setup-db" "$dbuser" "$dbname" proxy_args="" [[ -n "$setup_web_proxy" ]] && proxy_args="--proxy=$setup_web_proxy" setup=/usr/share/openqa/script/configure-web-proxy -if command -v $setup ; then +if command -v $setup; then bash -ex $setup "$proxy_args" else curl -s https://raw.githubusercontent.com/os-autoinst/openQA/master/script/configure-web-proxy | bash -ex -s -- "$proxy_args" fi sed -i -e 's/#*.*method.*=.*$/method = Fake/' /etc/openqa/openqa.ini - -if [ -z "$skip_suse_specifics" ] && ping -c1 download.suse.de. && (! rpm -q ca-certificates-suse) ; then +if [ -z "$skip_suse_specifics" ] && ping -c1 download.suse.de. && (! rpm -q ca-certificates-suse); then # add internal CA if executed within suse network - if ! zypper info ca-certificates-suse | grep -q ':' ; then + if ! zypper info ca-certificates-suse | grep -q ':'; then # add suse ca repo if needed # use this way of adding the repo to be distro agnostic if [ "$NAME" = "openSUSE Leap" ]; then @@ -85,16 +83,16 @@ fi # fetch tests and needles if [ -z "$skip_suse_tests" ]; then - if ping -c1 gitlab.suse.de. ; then + if ping -c1 gitlab.suse.de.; then # use faster local mirror if run from within SUSE network export needles_giturl="https://gitlab.suse.de/openqa/os-autoinst-needles-opensuse-mirror.git" fi /usr/share/openqa/script/fetchneedles - if [ ! -e /var/lib/openqa/tests/sle ] ; then + if [ ! -e /var/lib/openqa/tests/sle ]; then ln -s opensuse /var/lib/openqa/tests/sle fi - if ping -c1 gitlab.suse.de. ; then + if ping -c1 gitlab.suse.de.; then sles_needles_giturl="https://gitlab.suse.de/openqa/os-autoinst-needles-sles.git" sles_needles_directory="/var/lib/openqa/tests/opensuse/products/sle/needles" # clone SLE needles if run from within SUSE network @@ -106,25 +104,23 @@ if [ -z "$skip_suse_tests" ]; then fi fi - # ensure that the hostname is mapped to 127.0.0.1 (needed for livehandler) grep -q "$(hostname)" /etc/hosts || echo "127.0.0.1 $(hostname)" >> /etc/hosts - # start daemons if [ -z "$running_systemd" ]; then - pgrep -f openqa-scheduler-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon & - pgrep -f openqa-websockets-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon & - pgrep -f openqa-gru >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-gru & - pgrep -f openqa-livehandler-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon & - if [[ $setup_web_proxy == "nginx" ]] ; then + pgrep -f openqa-scheduler-daemon > /dev/null || su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon & + pgrep -f openqa-websockets-daemon > /dev/null || su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon & + pgrep -f openqa-gru > /dev/null || su geekotest -c /usr/share/openqa/script/openqa-gru & + pgrep -f openqa-livehandler-daemon > /dev/null || su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon & + if [[ $setup_web_proxy == "nginx" ]]; then nginx else /usr/sbin/start_apache2 -k start fi - pgrep -f openqa-webui-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-webui-daemon & + pgrep -f openqa-webui-daemon > /dev/null || su geekotest -c /usr/share/openqa/script/openqa-webui-daemon & else - if [[ $setup_web_proxy == "nginx" ]] ; then + if [[ $setup_web_proxy == "nginx" ]]; then systemctl enable --now nginx else systemctl enable --now apache2 @@ -134,7 +130,7 @@ else fi # wait for webui to become available -while ! curl -sI http://localhost/ | grep 200 ; do +while ! curl -sI http://localhost/ | grep 200; do sleep 3 done @@ -144,13 +140,12 @@ API_KEY=$(hexdump -n 8 -e '2/4 "%08X" 1 "\n"' /dev/random) API_SECRET=$(hexdump -n 8 -e '2/4 "%08X" 1 "\n"' /dev/random) echo "INSERT INTO api_keys (key, secret, user_id, t_created, t_updated) VALUES ('${API_KEY}', '${API_SECRET}', 2, NOW(), NOW());" | su postgres -c "psql $dbname" -cat >> /etc/openqa/client.conf <> /etc/openqa/client.conf << EOF [localhost] key = ${API_KEY} secret = ${API_SECRET} EOF - # start worker if [ -z "$running_systemd" ]; then /usr/bin/install -d -m 0755 -o _openqa-worker /var/lib/openqa/pool/1 diff --git a/script/openqa-bootstrap-container b/script/openqa-bootstrap-container index 3f346f94b02..f5776860131 100755 --- a/script/openqa-bootstrap-container +++ b/script/openqa-bootstrap-container @@ -33,7 +33,7 @@ PKGS_TO_INSTALL="aaa_base systemd shadow zypper openSUSE-release vim iproute2 ip zypper -n install systemd-container mkdir -p /var/lib/machines/ -cat > /etc/systemd/system/systemd-nspawn-openqa@.service < /etc/systemd/system/systemd-nspawn-openqa@.service << EOF [Unit] Description=Container %i Documentation=man:systemd-nspawn(1) @@ -67,7 +67,7 @@ DeviceAllow=block-blkext rw WantedBy=machines.target EOF -if [ ! -d $CONTAINER_PATH ] ; then +if [ ! -d $CONTAINER_PATH ]; then mkdir -p $CONTAINER_PATH zypper -n --root $CONTAINER_PATH addrepo "$DEFAULT_REPO" defaultrepo zypper -n --root $CONTAINER_PATH --gpg-auto-import-keys refresh @@ -84,8 +84,14 @@ systemctl daemon-reload systemctl start systemd-nspawn-openqa@$CONTAINER_NAME # ensure that the container is really running # ignore expected errors about 'Failed to create bus connection: Protocol error' and restarting error -while ! timeout -s9 2 systemd-run -qPM $CONTAINER_NAME /bin/bash -c whoami /dev/null 2>&1 ; do systemctl restart systemd-nspawn-openqa@$CONTAINER_NAME.service || true ; sleep 3 ; done +while ! timeout -s9 2 systemd-run -qPM $CONTAINER_NAME /bin/bash -c whoami /dev/null 2>&1; do + systemctl restart systemd-nspawn-openqa@$CONTAINER_NAME.service || true + sleep 3 +done systemd-run "${systemd_run_params[@]}" /bin/bash -c 'update-ca-certificates' systemd-run "${systemd_run_params[@]}" /bin/bash -c '/usr/share/openqa/script/openqa-bootstrap' -echo -e "$(tput setaf 2;tput bold)Your openQA container has been created. Run 'systemd-run -tM $CONTAINER_NAME /bin/bash' to get a shell in the container$(tput sgr0)" +echo -e "$( + tput setaf 2 + tput bold +)Your openQA container has been created. Run 'systemd-run -tM $CONTAINER_NAME /bin/bash' to get a shell in the container$(tput sgr0)" diff --git a/script/openqa-check-devel-repo b/script/openqa-check-devel-repo index 5ccab1055da..6ca00fd035a 100755 --- a/script/openqa-check-devel-repo +++ b/script/openqa-check-devel-repo @@ -16,17 +16,20 @@ EOF opts=$(getopt -o h --long help -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage 0 ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage 0 ;; + --) + shift + break + ;; + *) break ;; + esac done trap 'log_error' ERR log_error() { - echo "devel:openQA looks bad for Leap $VERSION ($ARCH):" - echo "${result:-Unable to query OBS}" + echo "devel:openQA looks bad for Leap $VERSION ($ARCH):" + echo "${result:-Unable to query OBS}" } [[ $VERSION ]] || . /etc/os-release diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index b8cd82f0efb..2fa950ed88d 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -49,7 +49,7 @@ throw_json_error() { } extract_urls_from_pr() { - urls=$(echo "$pr_content" | jq -r '.body | capture("^(?.*@openqa: Clone )(?http.*[0-9]*)") | .url') + urls=$(echo "$pr_content" | jq -r '.body | capture("^(?.*@openqa: Clone )(?http.*[0-9]*)") | .url') if [[ $urls == *"http"* ]]; then echo "$urls" fi @@ -58,14 +58,26 @@ extract_urls_from_pr() { opts=$(getopt -o vhnc: --long verbose,dry-run,help,clone-job-args: -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do - case "$1" in - -v | --verbose ) set -x; shift ;; - -h | --help ) usage 0 ;; - -n | --dry-run ) dry_run=true; shift ;; - -c | --clone-job-args ) clone_args="$2 $clone_args"; shift 2 ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -v | --verbose) + set -x + shift + ;; + -h | --help) usage 0 ;; + -n | --dry-run) + dry_run=true + shift + ;; + -c | --clone-job-args) + clone_args="$2 $clone_args" + shift 2 + ;; + --) + shift + break + ;; + *) break ;; + esac done job_list="${job:-"$2"}" @@ -76,7 +88,7 @@ if [[ -z "$repo_name" ]] || [[ -z "$pr" ]]; then target_repo_part=${pr_url%%/pull*} pr="${pr_url##*pull/}" pr="${pr%%/*}" - elif [[ $first_arg == *"tree"* ]]; then + elif [[ $first_arg == *"tree"* ]]; then #maybe a branch_url is given branch_url=$first_arg forked_repo_part=${branch_url%%/tree*} @@ -115,8 +127,8 @@ clone_job() { local json_url=${host}/tests/${job}/file/vars.json local json_data json_data=$(eval "${curl_openqa} -s ${json_url}") - echo "$json_data" | jq . &>/dev/null || \ - fail "Unreadable openQA job or no valid JSON data encountered. \ + echo "$json_data" | jq . &> /dev/null \ + || fail "Unreadable openQA job or no valid JSON data encountered. \ Please try 'curl $json_url' or select another job, e.g. in the same scenario: $host/t$job#next_previous" local testsuite="${testsuite:-"$(echo "$json_data" | jq -r '.TEST')"}" || throw_json_error "$json_url" "$json_data" local old_productdir @@ -130,7 +142,7 @@ Please try 'curl $json_url' or select another job, e.g. in the same scenario: $h else local productdir="${productdir:-"${repo_name##*/}/${old_productdir#*"${old_casedir##*/}"}"}" fi - productdir="${productdir/\/\//\/}" # avoid consecutive slashes + productdir="${productdir/\/\//\/}" # avoid consecutive slashes local old_needledir old_needledir=$(echo "$json_data" | jq -r '.NEEDLES_DIR | select (.!=null)') || throw_json_error "$json_url" "$json_data" local needles_dir="${needles_dir:-"$old_needledir"}" @@ -158,6 +170,7 @@ if [[ -z "$host" ]] && [[ -z "$job_list" ]]; then exit 1 fi args=("${@:3}") -IFS=',' ; for i in $job_list; do +IFS=',' +for i in $job_list; do clone_job "$i" done diff --git a/script/openqa-continuous-update b/script/openqa-continuous-update index ee29de641f2..e6fedd80876 100755 --- a/script/openqa-continuous-update +++ b/script/openqa-continuous-update @@ -16,11 +16,14 @@ EOF opts=$(getopt -o h --long help -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage 0 ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage 0 ;; + --) + shift + break + ;; + *) break ;; + esac done # check for new packages @@ -30,7 +33,7 @@ repo_name=${DEVEL_OPENQA_REPOSITORY:-devel_openQA} ref=$(zypper -n ref -r "$repo_name") if echo "$ref" | grep -q 'is up to date' && "$(dirname "${BASH_SOURCE[0]}")"/openqa-check-devel-repo; then - # call ref independently of dup to avoid unintended vendor changes in case ref fails (see poo#112595) - zypper -n ref - zypper -n --no-refresh dup --auto-agree-with-licenses --download-in-advance + # call ref independently of dup to avoid unintended vendor changes in case ref fails (see poo#112595) + zypper -n ref + zypper -n --no-refresh dup --auto-agree-with-licenses --download-in-advance fi diff --git a/script/openqa-rollback b/script/openqa-rollback index 34186a00c70..fa8362b1ca7 100755 --- a/script/openqa-rollback +++ b/script/openqa-rollback @@ -15,12 +15,18 @@ EOF opts=$(getopt -o hn --long help,dry-run -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage 0 ;; - -n | --dry-run ) dry_run="--dry-run"; shift ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage 0 ;; + -n | --dry-run) + dry_run="--dry-run" + shift + ;; + --) + shift + break + ;; + *) break ;; + esac done webui_before="${webui_before:-"/tmp/openqa_webui_before"}" diff --git a/systemd/systemd-openqa-generator b/systemd/systemd-openqa-generator index d83a76758e1..04f36e00b66 100755 --- a/systemd/systemd-openqa-generator +++ b/systemd/systemd-openqa-generator @@ -1,16 +1,16 @@ #!/bin/bash shopt -s nullglob if [ $# != 3 ]; then - logger -s "invalid number of arguments" - exit 1 + logger -s "invalid number of arguments" + exit 1 fi pooldir="/var/lib/openqa/pool" dir="$1" if [ -e /etc/tmpfiles.d/openqa.conf ]; then - /usr/bin/systemd-tmpfiles --create /etc/tmpfiles.d/openqa.conf + /usr/bin/systemd-tmpfiles --create /etc/tmpfiles.d/openqa.conf fi mkdir -p "$dir/openqa-worker.target.wants" for i in $pooldir/[0-9]*; do - i="${i#$pooldir/}" - ln -s "/usr/lib/systemd/system/openqa-worker@.service" "$dir/openqa-worker.target.wants/openqa-worker@$i.service" + i="${i#$pooldir/}" + ln -s "/usr/lib/systemd/system/openqa-worker@.service" "$dir/openqa-worker.target.wants/openqa-worker@$i.service" done diff --git a/t/data/openqa-trigger-from-obs/BatchedProj/Batch1/read_files.sh b/t/data/openqa-trigger-from-obs/BatchedProj/Batch1/read_files.sh index b454cc63186..b4a70b3cbff 100644 --- a/t/data/openqa-trigger-from-obs/BatchedProj/Batch1/read_files.sh +++ b/t/data/openqa-trigger-from-obs/BatchedProj/Batch1/read_files.sh @@ -1,5 +1,4 @@ -thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" echo "openSUSE-Leap-15.1-DVD-x86_64-Build470.2-Media.iso" > "$thisdir"/files_iso.lst echo "Build469.1" > "$thisdir"/Media1_ftp_ftp.lst - diff --git a/t/data/openqa-trigger-from-obs/BatchedProj/Batch2/read_files.sh b/t/data/openqa-trigger-from-obs/BatchedProj/Batch2/read_files.sh index c371d12b6e3..570f3dffa8b 100644 --- a/t/data/openqa-trigger-from-obs/BatchedProj/Batch2/read_files.sh +++ b/t/data/openqa-trigger-from-obs/BatchedProj/Batch2/read_files.sh @@ -1,4 +1,4 @@ -thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" echo "openSUSE-Leap-15.1-DVD-x86_64-Snapshot4704-Media.iso" > "$thisdir"/files_iso.lst echo "openSUSE-Leap-15.1-DVD-x86_64-Snapshot4703-Media.iso" >> "$thisdir"/files_iso.lst diff --git a/t/data/openqa-trigger-from-obs/Proj1/read_files.sh b/t/data/openqa-trigger-from-obs/Proj1/read_files.sh index 7a869a5026b..70158cf6c08 100644 --- a/t/data/openqa-trigger-from-obs/Proj1/read_files.sh +++ b/t/data/openqa-trigger-from-obs/Proj1/read_files.sh @@ -1,4 +1,3 @@ -thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" echo "openSUSE-Leap-15.1-DVD-x86_64-Build470.1-Media.iso" > "$thisdir"/files_iso.lst - diff --git a/t/data/openqa-trigger-from-obs/script/rsync.sh b/t/data/openqa-trigger-from-obs/script/rsync.sh index e2e1bb0e5f7..30f9e45c9d6 100755 --- a/t/data/openqa-trigger-from-obs/script/rsync.sh +++ b/t/data/openqa-trigger-from-obs/script/rsync.sh @@ -1,6 +1,6 @@ #!/bin/bash -thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" function sleep_until_file_created { for ((i = 0; i < 20; i += 1)); do @@ -11,5 +11,8 @@ function sleep_until_file_created { } [[ "$1" =~ MockProjectLongProcessing* ]] && { sleep_until_file_created "$1" || exit 1; } -[ "$1" != MockProjectError ] || { >&2 echo "Mock Error"; exit 1; } +[ "$1" != MockProjectError ] || { + echo >&2 "Mock Error" + exit 1 +} echo MOCK OK $1 diff --git a/t/test_postgresql b/t/test_postgresql index fa57eea1d9a..42bbcc904b5 100755 --- a/t/test_postgresql +++ b/t/test_postgresql @@ -7,16 +7,18 @@ else DIR=$(readlink -f "$DIR") fi if test -e "$DIR"/postmaster.pid; then - pg_ctl -D "$DIR" stop + pg_ctl -D "$DIR" stop fi if test -d "$DIR"; then - rm -r "$DIR" + rm -r "$DIR" fi initdb --auth-local=peer -N "$DIR" -U "$(id -u -n)" -(echo "listen_addresses=''" -echo "unix_socket_directories='$DIR'" -echo "fsync=off" -echo "full_page_writes=off") >> "$DIR"/postgresql.conf +( + echo "listen_addresses=''" + echo "unix_socket_directories='$DIR'" + echo "fsync=off" + echo "full_page_writes=off" +) >> "$DIR"/postgresql.conf LOGDIR="$DIR/log" LOGFILE="${LOGFILE:-"$LOGDIR/postgresql-openqa-test.log"}" diff --git a/tools/ci/build_autoinst.sh b/tools/ci/build_autoinst.sh index b6e1467161a..68e9bbafcd2 100755 --- a/tools/ci/build_autoinst.sh +++ b/tools/ci/build_autoinst.sh @@ -9,13 +9,14 @@ destdir=${1:-../os-autoinst} sha=${2:-$(cat tools/ci/autoinst.sha)} [[ -d $destdir ]] || { - sudo mkdir "$destdir" - sudo chown -R $USER "$destdir" + sudo mkdir "$destdir" + sudo chown -R $USER "$destdir" } echo Building os-autoinst $destdir $sha git clone https://github.com/os-autoinst/os-autoinst.git "$destdir" -( cd "$destdir" -git checkout $sha -cmake -G Ninja -DCMAKE_BUILD_TYPE=Release . -ninja symlinks +( + cd "$destdir" + git checkout $sha + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release . + ninja symlinks ) diff --git a/tools/ci/build_dependencies.sh b/tools/ci/build_dependencies.sh index dc141310276..690064e4f14 100755 --- a/tools/ci/build_dependencies.sh +++ b/tools/ci/build_dependencies.sh @@ -5,7 +5,7 @@ set -e -thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" CI_PACKAGES=$thisdir/ci-packages.txt DEPS_BEFORE="${DEPS_BEFORE:-"$(mktemp)"}" diff --git a/tools/ci/build_local_container.sh b/tools/ci/build_local_container.sh index 6acabbf5951..f1de8fc4e51 100755 --- a/tools/ci/build_local_container.sh +++ b/tools/ci/build_local_container.sh @@ -5,9 +5,9 @@ set -e -thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" cre="${cre:-"podman"}" -$cre build -t localtest -f- "$thisdir"< "$file.tmp" - cat "$file" >> "$file.tmp" - mv "$file.tmp" "$file" - done < <(find . -name '*.html' -print0) - cd .. + mkdir -p api/src + response=$(curl -o api/src/testapi.pm -sS -w "%{http_code}\n" https://raw.githubusercontent.com/os-autoinst/os-autoinst/master/testapi.pm) + [[ $response != 200 ]] && echo "Download of testapi.pm failed" && exit 1 + cd api + "${scriptroot}"/generate-documentation-genapi + + find . -name '*.asciidoc' -not -name 'header' -exec "${asciidoctor_bin}" {} \; + while IFS= read -r -d '' file; do + header_template "$file" > "$file.tmp" + cat "$file" >> "$file.tmp" + mv "$file.tmp" "$file" + done < <(find . -name '*.html' -print0) + cd .. } update_schemas() { - mkdir -p api/schema - cp "$scriptroot"/../public/schema/* api/schema + mkdir -p api/schema + cp "$scriptroot"/../public/schema/* api/schema } header_template() { -filename=$( basename -s .html "$1" ) -cat </dev/null || true # we don't care if the directory already exists + mkdir "${tmpwd}"/output 2> /dev/null || true # we don't care if the directory already exists cp -r images "${tmpwd}"/output [[ ${formats[pdf]} ]] \ @@ -217,7 +219,7 @@ call_asciidoctor() { [[ ${formats[html]} ]] \ && "${asciidoctor_bin}" -o "${tmpwd}"/output/openqa-documentation-"${verbose_doc_name}".html index.asciidoc -d book - echo -e "${green}The output has been generated at ${tmpwd}/output" + echo -e "${green}The output has been generated at ${tmpwd}/output" cd .. } diff --git a/tools/js-tidy b/tools/js-tidy index 81750eb4c65..e9d05f1d730 100755 --- a/tools/js-tidy +++ b/tools/js-tidy @@ -17,10 +17,10 @@ set -eo pipefail opts=$(getopt -o h --long help -n "$0" -- "$@") || usage eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage ;; + *) break ;; + esac done if ! command -v npm > /dev/null 2>&1; then diff --git a/tools/retry b/tools/retry index c3ca07b4998..0ac5ba41b46 100755 --- a/tools/retry +++ b/tools/retry @@ -28,6 +28,6 @@ else echo "Calling retry hook $HOOK" RETRY_ATTEMPT=$n "$HOOK" fi - n=$((n+1)) + n=$((n + 1)) done fi diff --git a/tools/run-tests-within-container b/tools/run-tests-within-container index b386f5a0d40..d3567977a8a 100755 --- a/tools/run-tests-within-container +++ b/tools/run-tests-within-container @@ -58,5 +58,5 @@ fi [ -r tests_failed ] && exit 1 if test -n "$TRAVIS"; then - cp -a assets/cache/* /opt/openqa/assets/cache + cp -a assets/cache/* /opt/openqa/assets/cache fi diff --git a/tools/test_containers_compose b/tools/test_containers_compose index a51f10677f4..23fffcc0180 100755 --- a/tools/test_containers_compose +++ b/tools/test_containers_compose @@ -3,56 +3,68 @@ set -euo pipefail wait_until() { - command=$1 - timeout=$2 + command=$1 + timeout=$2 - i=1 - until eval "$command" - do - ((i++)) - if [[ $i -gt $timeout ]]; then - echo "Command '$command' aborted because of timeout" - exit 1 - fi - sleep 1 - done + i=1 + until eval "$command"; do + ((i++)) + if [[ $i -gt $timeout ]]; then + echo "Command '$command' aborted because of timeout" + exit 1 + fi + sleep 1 + done } setup_containers() { - for retry in {2..0}; do sudo docker-compose build && break; echo "Remaining retries $retry"; done - exit_code="" - sudo MOJO_CLIENT_DEBUG=1 docker-compose up -d || exit_code=$? - if [[ -n $exit_code ]]; then - echo "docker-compose exited with non-zero code $exit_code, showing logs:" - docker-compose logs - exit "$exit_code" - fi - (docker-compose ps --services --filter status=stopped | grep "^[[:space:]]*$") || (docker-compose logs; sudo docker-compose ps; exit 1) + for retry in {2..0}; do + sudo docker-compose build && break + echo "Remaining retries $retry" + done + exit_code="" + sudo MOJO_CLIENT_DEBUG=1 docker-compose up -d || exit_code=$? + if [[ -n $exit_code ]]; then + echo "docker-compose exited with non-zero code $exit_code, showing logs:" + docker-compose logs + exit "$exit_code" + fi + (docker-compose ps --services --filter status=stopped | grep "^[[:space:]]*$") || ( + docker-compose logs + sudo docker-compose ps + exit 1 + ) } test_webui() { - ( - workspace=$(mktemp -d) && - trap 'docker-compose down; sudo rm -r "$workspace"' EXIT && - cp -r container/webui "$workspace" && - cd "$workspace/webui" && - sed -i -e "s/method = OpenID/method = Fake/" conf/openqa.ini - printf "[nginx]\nkey = 1234567890ABCDEF\nsecret = 1234567890ABCDEF\n" > conf/client.conf && - setup_containers && - docker-compose exec -T webui openqa-cli api -X POST jobs ISO=foo.iso DISTRI=my-distri FLAVOR=my-flavor VERSION=42 BUILD=42 TEST=my-test \ - --host http://nginx:9526 || (echo "Error executing a job"; exit 1) && - (wait_until 'docker-compose logs webui | grep "GET /api/wakeup" >/dev/null' 10) || (docker-compose logs webui; exit 1) - ) || exit 1; + ( + workspace=$(mktemp -d) \ + && trap 'docker-compose down; sudo rm -r "$workspace"' EXIT \ + && cp -r container/webui "$workspace" \ + && cd "$workspace/webui" \ + && sed -i -e "s/method = OpenID/method = Fake/" conf/openqa.ini + printf "[nginx]\nkey = 1234567890ABCDEF\nsecret = 1234567890ABCDEF\n" > conf/client.conf \ + && setup_containers \ + && docker-compose exec -T webui openqa-cli api -X POST jobs ISO=foo.iso DISTRI=my-distri FLAVOR=my-flavor VERSION=42 BUILD=42 TEST=my-test \ + --host http://nginx:9526 || ( + echo "Error executing a job" + exit 1 + ) \ + && (wait_until 'docker-compose logs webui | grep "GET /api/wakeup" >/dev/null' 10) || ( + docker-compose logs webui + exit 1 + ) + ) || exit 1 } test_worker() { - ( - workspace=$(mktemp -d) && - trap 'docker-compose down; sudo rm -r "$workspace"' EXIT && - cp -r container/worker "$workspace" && - cd "$workspace/worker" && - setup_containers - ) || exit 1; + ( + workspace=$(mktemp -d) \ + && trap 'docker-compose down; sudo rm -r "$workspace"' EXIT \ + && cp -r container/worker "$workspace" \ + && cd "$workspace/worker" \ + && setup_containers + ) || exit 1 } test_webui diff --git a/tools/test_helm_chart b/tools/test_helm_chart index cdc5e5a89e6..42ed29b0a4c 100755 --- a/tools/test_helm_chart +++ b/tools/test_helm_chart @@ -1,7 +1,7 @@ #!/bin/bash set -euo pipefail -which helm >/dev/null || echo "Error: Helm is not installed" +which helm > /dev/null || echo "Error: Helm is not installed" which ct > /dev/null || echo "Error: ct is not installed" cd container/helm diff --git a/tools/tidy b/tools/tidy index f16b5e332df..99d85666dac 100755 --- a/tools/tidy +++ b/tools/tidy @@ -32,15 +32,30 @@ selection='--all' opts=$(getopt -o hcfol --long help,check,force,only-changed,list -n "$0" -- "$@") || usage eval set -- "$opts" while true; do - case "$1" in - -h | --help ) usage ;; - -c | --check ) args+=' --check-only'; shift ;; - -f | --force ) force=true; shift ;; - -o | --only-changed ) selection='--git'; shift ;; - -l | --list ) args+='--list'; shift ;; - -- ) shift; break ;; - * ) break ;; - esac + case "$1" in + -h | --help) usage ;; + -c | --check) + args+=' --check-only' + shift + ;; + -f | --force) + force=true + shift + ;; + -o | --only-changed) + selection='--git' + shift + ;; + -l | --list) + args+='--list' + shift + ;; + --) + shift + break + ;; + *) break ;; + esac done shift $((OPTIND - 1))