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

Add editorconfig and update bash files accordingly #5440

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions .editorconfig
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
kalikiana marked this conversation as resolved.
Show resolved Hide resolved
ifeq ($(CONTAINER_TEST),1)
test-checkstyle-standalone: test-check-containers
endif
Expand All @@ -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:
okurz marked this conversation as resolved.
Show resolved Hide resolved
@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
Expand Down
12 changes: 6 additions & 6 deletions container/openqa/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion container/webui/nginx-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
78 changes: 39 additions & 39 deletions container/webui/run_openqa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions container/worker/kvm-mknod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\<kvm\>' > /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 '\<kvm\>' /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
}
36 changes: 21 additions & 15 deletions container/worker/launch_workers_pool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions container/worker/run_openqa_worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 12 additions & 0 deletions external/os-autoinst-common/.editorconfig
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions external/os-autoinst-common/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:os-autoinst/os-autoinst-common.git
branch = master
commit = a94b58b23be8ddb5bf85a7b1f87914ba9e71b9e6
parent = 1e9bfef6f182ff6e30268174f6414bf48c35b89c
commit = fbd66e7f61d2397f55bc8b6143a405c8ed639008
parent = 7f2e4f335e1ce7b7d89e5056da4acbb82b18bc94
method = merge
cmdver = 0.4.6
38 changes: 22 additions & 16 deletions script/configure-web-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions script/fetchneedles
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading