diff options
author | Chase Qi <chase.qi@linaro.org> | 2017-10-25 16:30:29 +0800 |
---|---|---|
committer | Chase Qi <chase.qi@linaro.org> | 2018-04-02 16:47:02 +0800 |
commit | 889987ff0d98a04eb1d5fd5d8d76708283f8c88c (patch) | |
tree | 6a58b9dc1917219dbe8eeb726f3bd63bfc862ca9 | |
parent | 34bd8600ebd15374ce8e05fd3f891a655a12ad78 (diff) |
linux: fix lamp test on debian stretch
* Move from mysql to mariadb.
* PHP upgraded from v5 to v7. Remove version number from package names.
* 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.
Note: It is not backwards compatible. Branch erp-17.08 should be used to
run this test on Debian Jessie.
Change-Id: Id37f2236dcbab621566a85632bd437994c11fef6
Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rw-r--r-- | automated/linux/lamp/html/add-record.php | 4 | ||||
-rw-r--r-- | automated/linux/lamp/html/connect-db.php | 4 | ||||
-rw-r--r-- | automated/linux/lamp/html/create-db.php | 4 | ||||
-rw-r--r-- | automated/linux/lamp/html/create-table.php | 4 | ||||
-rw-r--r-- | automated/linux/lamp/html/delete-record.php | 4 | ||||
-rw-r--r-- | automated/linux/lamp/html/select-record.php | 4 | ||||
-rwxr-xr-x | automated/linux/lamp/lamp.sh | 23 |
7 files changed, 25 insertions, 22 deletions
diff --git a/automated/linux/lamp/html/add-record.php b/automated/linux/lamp/html/add-record.php index f7802ae..321cbb2 100644 --- a/automated/linux/lamp/html/add-record.php +++ b/automated/linux/lamp/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/lamp/html/connect-db.php b/automated/linux/lamp/html/connect-db.php index c43dff7..00297c2 100644 --- a/automated/linux/lamp/html/connect-db.php +++ b/automated/linux/lamp/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/lamp/html/create-db.php b/automated/linux/lamp/html/create-db.php index 1373709..92946e8 100644 --- a/automated/linux/lamp/html/create-db.php +++ b/automated/linux/lamp/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/lamp/html/create-table.php b/automated/linux/lamp/html/create-table.php index 04eb56e..c05647c 100644 --- a/automated/linux/lamp/html/create-table.php +++ b/automated/linux/lamp/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/lamp/html/delete-record.php b/automated/linux/lamp/html/delete-record.php index 3556256..30a3367 100644 --- a/automated/linux/lamp/html/delete-record.php +++ b/automated/linux/lamp/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/lamp/html/select-record.php b/automated/linux/lamp/html/select-record.php index 62a4460..e153f03 100644 --- a/automated/linux/lamp/html/select-record.php +++ b/automated/linux/lamp/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/lamp/lamp.sh b/automated/linux/lamp/lamp.sh index 32d7af5..cc15ac2 100755 --- a/automated/linux/lamp/lamp.sh +++ b/automated/linux/lamp/lamp.sh @@ -34,17 +34,14 @@ else # shellcheck disable=SC2154 case "${dist}" in debian|ubuntu) - if [ "${dist}" = "debian" ]; then - pkgs="apache2 mysql-server php5-mysql php5-common libapache2-mod-php5" - elif [ "${dist}" = "ubuntu" ]; then - pkgs="apache2 mysql-server php-mysql php-common libapache2-mod-php" - fi + # Tested on Debian 9 and Ubuntu 17.10. + pkgs="apache2 apache2-utils libapache2-mod-php mariadb-server php php-mysql" install_deps "curl ${pkgs}" - echo "extension=mysqli.so" >> /etc/php5/apache2/php.ini systemctl restart apache2 systemctl restart mysql ;; centos|fedora) + # Tested on CentOS 7. pkgs="httpd mariadb-server mariadb php php-mysql" install_deps "curl ${pkgs}" systemctl start httpd.service @@ -62,9 +59,14 @@ curl -o "${OUTPUT}/index.html" "http://localhost/index.html" grep "Test Page for the Apache HTTP Server" "${OUTPUT}/index.html" check_return "apache2-test-page" -# Test MySQL. +# Setup MySQL authentication. mysqladmin -u root password lxmptest > /dev/null 2>&1 || true -mysql --user="root" --password="lxmptest" -e "show databases" +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. +mysql --user="admin" --password="password" -e "show databases" check_return "mysql-show-databases" # Test PHP. @@ -102,5 +104,6 @@ curl -o "${OUTPUT}/delete-record" "http://localhost/delete-record.php" grep "Record deleted successfully" "${OUTPUT}/delete-record" check_return "php-delete-record" -# 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' |