Skip to content

Commit

Permalink
Merge pull request #1614 from M0ses/improve_testing
Browse files Browse the repository at this point in the history
[dist] system tests in own package
  • Loading branch information
adrianschroeter committed Mar 8, 2016
2 parents 7ca785b + 7176316 commit b91b77c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ nbproject
*.ipr
*.iws
.idea/
.kanku/
6 changes: 5 additions & 1 deletion dist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LOGROTATE_CONFIGS := obs-api obs-server
OBS_BIN_SCRIPTS := obs_productconvert
OBS_SBIN_SCRIPTS := obs_admin obs_serverstatus

install: install_obsapisetup install_apache install_initscripts install_project_update install_logrotate install_fillups install_slp install_obs_bin install_devel_docs install_overview
install: install_obsapisetup install_apache install_initscripts install_project_update install_logrotate install_fillups install_slp install_obs_bin install_devel_docs install_overview install_tests_appliance

#install_overview

Expand Down Expand Up @@ -48,6 +48,7 @@ system_dirs:
$(INSTALL) -d -m 755 $(DESTDIR)/usr/sbin/
$(INSTALL) -d -m 755 $(DESTDIR)/var/adm/fillup-templates
$(INSTALL) -d -m 755 $(DESTDIR)/usr/share/doc/packages/obs-devel
$(INSTALL) -d -m 755 $(DESTDIR)/usr/lib/obs/tests/appliance

install_devel_docs:
$(INSTALL) -m 644 README.devel $(DESTDIR)/usr/share/doc/packages/obs-devel/README.devel
Expand All @@ -56,6 +57,9 @@ install_overview:
$(INSTALL) -d -m 755 $(DESTDIR)$(OBS_DOCUMENT_ROOT)/overview
$(INSTALL) -m 644 overview.html.TEMPLATE $(DESTDIR)$(OBS_DOCUMENT_ROOT)/overview

install_tests_appliance:
cp -r ./t/* $(DESTDIR)/usr/lib/obs/tests/appliance/

test_unit:
prove -v t/*.t

Expand Down
25 changes: 25 additions & 0 deletions dist/obs-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ Requires: ruby
%description -n obs-utils
obs_project_update is a tool to copy a packages of a project from one obs to another

%package -n obs-tests-appliance

Summary: The Open Build Service -- Test cases for installed appliances

Requires: obs-server = %{version}
Requires: obs-api = %{version}

%if 0%{?suse_version} < 1210 && 0%{?suse_version:1}
Group: Productivity/Networking/Web/Utilities
%endif

%description -n obs-tests-appliance
This package contains test cases for testing a installed appliances.
Test cases can be for example:
* checks for setup-appliance.sh
* checks if database setup worked correctly
* checks if required service came up properly

#--------------------------------------------------------------------------------
%prep
export DESTDIR=$RPM_BUILD_ROOT
Expand Down Expand Up @@ -682,4 +700,11 @@ chown %{apache_user}:%{apache_group} /srv/www/obs/api/log/production.log
%dir %_docdir/obs-devel
%_docdir/obs-devel/README.devel

%files -n obs-tests-appliance
%defattr(-,root,root)
%dir /usr/lib/obs/tests/
%dir /usr/lib/obs/tests/appliance
/usr/lib/obs/tests/appliance/*


%changelog
16 changes: 14 additions & 2 deletions dist/t/0010-obs-bootstrap-api.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

export BOOTSTRAP_TEST_MODE=1
export NON_INTERACTIVE=1
export BASH_TAP_ROOT=t
export BASH_TAP_ROOT=$(dirname $0)


. $(dirname $0)/bash-tap-bootstrap
. $(dirname $0)/../setup-appliance.sh


if [ -f $(dirname $0)/../setup-appliance.sh ];
then
. $(dirname $0)/../setup-appliance.sh
else
if [ -f /usr/lib/obs/server/setup-appliance.sh ];then
. /usr/lib/obs/server/setup-appliance.sh
else
BAIL_OUT "Could not find setup-appliance.sh"
fi
fi

plan tests 12

Expand Down
16 changes: 15 additions & 1 deletion dist/t/0020-test-appliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ export BASH_TAP_ROOT=$(dirname $0)

. $(dirname $0)/bash-tap-bootstrap

plan tests 27
plan tests 29


MAX_WAIT=600

# Service enabled and started
for srv in \
obsapisetup \
obsapidelayed \
obsdispatcher \
obspublisher \
Expand All @@ -22,6 +26,16 @@ do
STATE=` systemctl is-enabled $srv\.service 2>/dev/null`
is "$STATE" "enabled" "Checking $srv enabled"
ACTIVE=`systemctl is-active $srv\.service`
tmpcount=$MAX_WAIT
while [[ $ACTIVE != 'active' ]];do
tmpcount=$(( $tmpcount - 1 ))
ACTIVE=`systemctl is-active $srv\.service`
if [[ $tmpcount -le 0 ]];then
ACTIVE='timeout'
break
fi
sleep 1
done
is "$ACTIVE" "active" "Checking $srv status"
done

Expand Down

0 comments on commit b91b77c

Please sign in to comment.