Legoktm has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/393435 )

Change subject: Add basic tests via autopkgtest
......................................................................


Add basic tests via autopkgtest

autopkgtest is the Debian CI system that is triggered on new package
uploads, and whenever any dependencies are updated.

The `lint` test runs a PHP linter and a JSON linter.

The `install-$dbtype` tests set up MediaWiki against the respective
database backend and then a few verifications that it functions
correctly.

Change-Id: Ia95fd9afc36ff8de6b1934b4f8cf9b8062a9651d
---
M debian/changelog
A debian/tests/control
A debian/tests/install-mysql
A debian/tests/install-postgresql
A debian/tests/install-sqlite
A debian/tests/lint
6 files changed, 79 insertions(+), 0 deletions(-)

Approvals:
  Muehlenhoff: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/debian/changelog b/debian/changelog
index 8ec2246..a9ac1de 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+mediawiki (1:1.27.4-3) UNRELEASED; urgency=medium
+
+  * Add basic tests via autopkgtest
+
+ -- Kunal Mehta <[email protected]>  Sat, 25 Nov 2017 16:29:10 -0800
+
 mediawiki (1:1.27.4-2) unstable; urgency=medium
 
   * Bump Standards-Version to 4.1.1
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..e88e635
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,14 @@
+Tests: lint
+Depends: @, php-cli, jsonlint
+
+Tests: install-sqlite
+Depends: @, php-cli, php-sqlite3, curl, sudo, apache2
+Restrictions: needs-root
+
+Tests: install-mysql
+Depends: @, php-cli, php-mysql, default-mysql-server, curl, sudo, apache2
+Restrictions: needs-root
+
+Tests: install-postgresql
+Depends: @, php-cli, php-pgsql, postgresql, curl, sudo, apache2
+Restrictions: needs-root
diff --git a/debian/tests/install-mysql b/debian/tests/install-mysql
new file mode 100644
index 0000000..e7f4e9d
--- /dev/null
+++ b/debian/tests/install-mysql
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Install MediaWiki on the MySQL backend
+# and then verify the installation was successful.
+set -e
+
+mkdir /tmp/mw-install
+echo "CREATE USER 'wikidebadmin'@'localhost' IDENTIFIED BY 'password1';" > 
/tmp/mw-install/db_setup.sql
+echo "GRANT ALL PRIVILEGES ON * . * TO 'wikidebadmin'@'localhost';" >> 
/tmp/mw-install/db_setup.sql
+sudo mysql < /tmp/mw-install/db_setup.sql
+rm /tmp/mw-install/db_setup.sql
+php /var/lib/mediawiki/maintenance/install.php --confpath /tmp/mw-install 
--dbname autopkgtestwiki --dbtype mysql --dbuser wikidebadmin --dbpass 
password1 --pass password1 Debian-Autopkgtest Administrator
+php /var/lib/mediawiki/maintenance/getText.php --conf 
/tmp/mw-install/LocalSettings.php "Main_Page" | grep "MediaWiki has been 
installed"
+sudo cp /tmp/mw-install/LocalSettings.php /etc/mediawiki/LocalSettings.php
+curl -I --silent "http://localhost/mediawiki/index.php/Main_Page";
+curl --silent "http://localhost/mediawiki/index.php/Main_Page"; | grep 
"MediaWiki has been installed"
+curl --silent "http://localhost/mediawiki/index.php/Special:BlankPage"; | grep 
"This page is intentionally left blank."
+
diff --git a/debian/tests/install-postgresql b/debian/tests/install-postgresql
new file mode 100644
index 0000000..a05e1c9
--- /dev/null
+++ b/debian/tests/install-postgresql
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Install MediaWiki on the PostgreSQL backend
+# and then verify the installation was successful.
+set -e
+
+mkdir /tmp/mw-install
+sudo -u postgres createuser --createdb -e wikidebadmin
+sudo -u postgres psql -c "ALTER USER wikidebadmin WITH PASSWORD 'password1';"
+php /var/lib/mediawiki/maintenance/install.php --confpath /tmp/mw-install 
--dbname autopkgtestwiki --dbtype postgres --dbserver localhost --dbuser 
wikidebadmin --dbpass password1 --pass password1 Debian-Autopkgtest 
Administrator
+php /var/lib/mediawiki/maintenance/getText.php --conf 
/tmp/mw-install/LocalSettings.php "Main_Page" | grep "MediaWiki has been 
installed"
+sudo cp /tmp/mw-install/LocalSettings.php /etc/mediawiki/LocalSettings.php
+curl -I --silent "http://localhost/mediawiki/index.php/Main_Page";
+curl --silent "http://localhost/mediawiki/index.php/Main_Page"; | grep 
"MediaWiki has been installed"
+curl --silent "http://localhost/mediawiki/index.php/Special:BlankPage"; | grep 
"This page is intentionally left blank."
+
diff --git a/debian/tests/install-sqlite b/debian/tests/install-sqlite
new file mode 100644
index 0000000..57877f2
--- /dev/null
+++ b/debian/tests/install-sqlite
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Install MediaWiki on the SQLite backend
+# and then verify the installation was successful.
+# We use /etc instead of /tmp for the data directory
+# since apache has a private tmp directory.
+set -e
+
+sudo mkdir /etc/mw-install
+sudo chgrp www-data /etc/mw-install
+sudo chmod g+w /etc/mw-install
+php /var/lib/mediawiki/maintenance/install.php --confpath /etc/mw-install 
--dbpath /etc/mw-install --dbtype sqlite --pass password1 Debian-Autopkgtest 
Administrator
+php /var/lib/mediawiki/maintenance/getText.php --conf 
/etc/mw-install/LocalSettings.php "Main_Page" | grep "MediaWiki has been 
installed"
+sudo cp /etc/mw-install/LocalSettings.php /etc/mediawiki/LocalSettings.php
+curl --silent -I "http://localhost/mediawiki/index.php/Main_Page";
+curl --silent "http://localhost/mediawiki/index.php/Main_Page"; | grep 
"MediaWiki has been installed"
+curl --silent "http://localhost/mediawiki/index.php/Special:BlankPage"; | grep 
"This page is intentionally left blank."
diff --git a/debian/tests/lint b/debian/tests/lint
new file mode 100644
index 0000000..f7639e9
--- /dev/null
+++ b/debian/tests/lint
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Lint both PHP and JSON files
+
+set -e
+
+# Bool and Null are already fixed upstream:
+# <https://github.com/ruflin/Elastica/issues/825>
+# Ignore LocalSettings.php since it is just a symlink
+# that does not exist yet.
+find /usr/share/mediawiki -not -type d -name '*.php' -not -name 'Bool.php' 
-not -name 'Null.php' -not -name 'LocalSettings.php' | xargs -n1 -exec php -l
+find /usr/share/mediawiki -not -type d -name '*.json' | xargs -n1 -exec 
jsonlint-php

-- 
To view, visit https://gerrit.wikimedia.org/r/393435
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia95fd9afc36ff8de6b1934b4f8cf9b8062a9651d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/debian
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Muehlenhoff <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to