summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-10-25 20:39:35 +0800
committerChase Qi <chase.qi@linaro.org>2018-04-02 16:47:23 +0800
commit9cd5da26f65fd0fb6980e5ae78f47b57ac21e2bb (patch)
tree1f05b2d28a7754e97b7126af54a564fa6840b607
parent889987ff0d98a04eb1d5fd5d8d76708283f8c88c (diff)
linux: fix lemp test on debian stretch
* Move from php5 to php7.0 * Move from mysql to mairadb * Since Mariadb v10, it uses unix_socket authentication for root user by default. It breaks the password authentication using for data accessing from PHP code. This patch create a new super user with password authentication and use it for testing. It is possible to disable unix_socket plugin for root, but it is not consistent across distributions and database versions. Change-Id: Ib269b2fd6abfb65e2f6a249457f2c38fe2d6ed5c Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rw-r--r--automated/linux/lemp/debian-nginx.conf2
-rw-r--r--automated/linux/lemp/html/add-record.php4
-rw-r--r--automated/linux/lemp/html/connect-db.php4
-rw-r--r--automated/linux/lemp/html/create-db.php4
-rw-r--r--automated/linux/lemp/html/create-table.php4
-rw-r--r--automated/linux/lemp/html/delete-record.php4
-rw-r--r--automated/linux/lemp/html/select-record.php4
-rwxr-xr-xautomated/linux/lemp/lemp.sh27
8 files changed, 26 insertions, 27 deletions
diff --git a/automated/linux/lemp/debian-nginx.conf b/automated/linux/lemp/debian-nginx.conf
index 3e3e3e7..0826a65 100644
--- a/automated/linux/lemp/debian-nginx.conf
+++ b/automated/linux/lemp/debian-nginx.conf
@@ -12,6 +12,6 @@ server {
location ~ \.php$ {
include snippets/fastcgi-php.conf;
- fastcgi_pass unix:/var/run/php5-fpm.sock;
+ fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
diff --git a/automated/linux/lemp/html/add-record.php b/automated/linux/lemp/html/add-record.php
index f7802ae..321cbb2 100644
--- a/automated/linux/lemp/html/add-record.php
+++ b/automated/linux/lemp/html/add-record.php
@@ -1,7 +1,7 @@
<?php
$servername = "localhost";
-$username = "root";
-$password = "lxmptest";
+$username = "admin";
+$password = "password";
$dbname = "myDB";
// Create connection
diff --git a/automated/linux/lemp/html/connect-db.php b/automated/linux/lemp/html/connect-db.php
index c43dff7..00297c2 100644
--- a/automated/linux/lemp/html/connect-db.php
+++ b/automated/linux/lemp/html/connect-db.php
@@ -1,7 +1,7 @@
<?php
$servername = "localhost";
-$username = "root";
-$password = "lxmptest";
+$username = "admin";
+$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
diff --git a/automated/linux/lemp/html/create-db.php b/automated/linux/lemp/html/create-db.php
index 1373709..92946e8 100644
--- a/automated/linux/lemp/html/create-db.php
+++ b/automated/linux/lemp/html/create-db.php
@@ -1,7 +1,7 @@
<?php
$servername = "localhost";
-$username = "root";
-$password = "lxmptest";
+$username = "admin";
+$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
diff --git a/automated/linux/lemp/html/create-table.php b/automated/linux/lemp/html/create-table.php
index 04eb56e..c05647c 100644
--- a/automated/linux/lemp/html/create-table.php
+++ b/automated/linux/lemp/html/create-table.php
@@ -1,7 +1,7 @@
<?php
$servername = "localhost";
-$username = "root";
-$password = "lxmptest";
+$username = "admin";
+$password = "password";
$dbname = "myDB";
// Create connection
diff --git a/automated/linux/lemp/html/delete-record.php b/automated/linux/lemp/html/delete-record.php
index 3556256..30a3367 100644
--- a/automated/linux/lemp/html/delete-record.php
+++ b/automated/linux/lemp/html/delete-record.php
@@ -1,7 +1,7 @@
<?php
$servername = "localhost";
-$username = "root";
-$password = "lxmptest";
+$username = "admin";
+$password = "password";
$dbname = "myDB";
// Create connection
diff --git a/automated/linux/lemp/html/select-record.php b/automated/linux/lemp/html/select-record.php
index 62a4460..e153f03 100644
--- a/automated/linux/lemp/html/select-record.php
+++ b/automated/linux/lemp/html/select-record.php
@@ -1,7 +1,7 @@
<?php
$servername = "localhost";
-$username = "root";
-$password = "lxmptest";
+$username = "admin";
+$password = "password";
$dbname = "myDB";
// Create connection
diff --git a/automated/linux/lemp/lemp.sh b/automated/linux/lemp/lemp.sh
index fcc13d1..2c1ece8 100755
--- a/automated/linux/lemp/lemp.sh
+++ b/automated/linux/lemp/lemp.sh
@@ -21,20 +21,14 @@ case "${dist}" in
# Stop apache server in case it is installed and running.
systemctl stop apache2 > /dev/null 2>&1 || true
- install_deps "nginx mysql-server php5-mysql php5-fpm curl"
-
- systemctl restart nginx
- systemctl restart mysql
-
- # Configure PHP.
- cp /etc/php5/fpm/php.ini /etc/php5/fpm/php.ini.bak
- sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini
- systemctl restart php5-fpm
+ install_deps "nginx mariadb-server php-mysql php-fpm curl"
# Configure NGINX for PHP.
mv -f /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
cp ./debian-nginx.conf /etc/nginx/sites-available/default
systemctl restart nginx
+ systemctl restart mysql
+ systemctl restart php7.0-fpm
;;
centos)
# x86_64 nginx package can be installed from epel repo. However, epel
@@ -84,10 +78,15 @@ curl -o "${OUTPUT}/index.html" "http://localhost/index.html"
test_command="grep 'Test Page for the Nginx HTTP Server' ${OUTPUT}/index.html"
run_test_case "${test_command}" "test-nginx-server" "${skip_list}"
+# Setup MySQL authentication.
+mysqladmin -u root password lxmptest > /dev/null 2>&1 || true
+mysql --user='root' --password='lxmptest' -e 'DROP USER admin@localhost' || true
+mysql --user='root' --password='lxmptest' -e "CREATE USER admin@localhost IDENTIFIED BY 'password'"
+mysql --user='root' --password='lxmptest' -e "GRANT ALL ON *.* TO admin@localhost WITH GRANT OPTION"
+
# Test MySQL.
skip_list="$(echo "${skip_list}" | awk '{ for (i=2; i<=NF; i++) print $i}')"
-mysqladmin -u root password lxmptest > /dev/null 2>&1 || true
-test_command="mysql --user='root' --password='lxmptest' -e 'show databases'"
+test_command="mysql --user='admin' --password='password' -e 'show databases'"
run_test_case "${test_command}" "mysql-show-databases" "${skip_list}"
# Test PHP.
@@ -132,8 +131,9 @@ test_command="grep 'Record deleted successfully' ${OUTPUT}/delete-record"
run_test_case "${test_command}" "php-delete-record"
# Cleanup.
-# Delete myDB for the next run.
-mysql --user='root' --password='lxmptest' -e 'DROP DATABASE myDB'
+# Delete myDB and admin for the next run.
+mysql --user='admin' --password='password' -e 'DROP DATABASE myDB'
+mysql --user='root' --password='lxmptest' -e 'DROP USER admin@localhost'
# Restore from backups.
rm -rf /usr/share/nginx/html
@@ -141,7 +141,6 @@ mv /usr/share/nginx/html.bak /usr/share/nginx/html
# shellcheck disable=SC2154
case "${dist}" in
debian)
- mv -f /etc/php5/fpm/php.ini.bak /etc/php5/fpm/php.ini
mv -f /etc/nginx/sites-available/default.bak /etc/nginx/sites-available/default
;;
centos)