Skip to content

Commit

Permalink
Update mariadb plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
uberhacker committed May 27, 2024
1 parent f4fca03 commit 994a84b
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 151 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr-wordpress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- examples/wordpress-export
- examples/wordpress-import
- examples/wordpress-init
- examples/wordpress-mariadb
- examples/wordpress-mariadb-mysql
- examples/wordpress-mysql8
- examples/wordpress-nginx
lando-version:
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

* Updated mariadb plugin [#51](https://github.com/lando/mariadb/issues/51)
* Use mysql command for MariaDB 10.3.x and below
* Cleaned up test comments

## v1.3.0 - [March 8, 2024](https://github.com/lando/wordpress/releases/tag/v1.3.0)
* Updated to latest database services.

* Updated to latest database services.

## v1.2.1 - [March 4, 2024](https://github.com/lando/wordpress/releases/tag/v1.2.1)

### Fixes

* Improved `database` selection for purposes of `config` loading, fixes some `database` bootup issues when the `database` type is overriden downstream
* Improved `database` selection for purposes of `config` loading, fixes some `database` bootup issues when the `database` type is overridden downstream

## v1.2.0 - [February 22, 2024](https://github.com/lando/wordpress/releases/tag/v1.2.0)

Expand Down
30 changes: 25 additions & 5 deletions builders/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,20 @@ const toolingDefaults = {
},
};

// Default DB cli commands
// MariaDB cli commands
const mariadbCli = {
service: ':host',
description: 'Drops into a MariaDB shell on a database service',
cmd: 'mariadb -uroot',
options: {
host: {
description: 'The database service to use',
default: 'database',
alias: ['h'],
},
},
};
// MySQL DB cli commands
const mysqlCli = {
service: ':host',
description: 'Drops into a MySQL shell on a database service',
Expand All @@ -130,6 +143,7 @@ const mysqlCli = {
},
},
};
// Postgres DB cli commands
const postgresCli = {
service: ':host',
description: 'Drops into a psql shell on a database service',
Expand All @@ -149,13 +163,19 @@ const postgresCli = {
*/
const getDbTooling = database => {
// Make sure we strip out any version number
database = database.split(':')[0];
const db = database.split(':')[0];
const ver = database.split(':')[1];
// Choose wisely
if (_.includes(['mysql', 'mariadb'], database)) {
if (db === 'mysql') {
return {mysql: mysqlCli};
} else if (db === 'mariadb' && ver < 10.4) {
// Use mysql command for MariaDB 10.3.x and below
return {mysql: mysqlCli};
} else if (database === 'postgres') {
} else if (db === 'mariadb') {
return {mariadb: mariadbCli};
} else if (db === 'postgres') {
return {psql: postgresCli};
} else if (database === 'mongo') {
} else if (db === 'mongo') {
return {mongo: {
service: 'database',
description: 'Drop into the mongo shell',
Expand Down
2 changes: 1 addition & 1 deletion examples/wordpress-downstreamer-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lando mysql -V | grep 8.0
# Should use the default database connection info
lando mysql -uwordpress -pwordpress wordpress -e quit

# Should use the defauly mysql8 config file
# Should use the default mysql8 config file
lando ssh -s database -c "cat /opt/bitnami/mysql/conf/my_custom.cnf" | grep "LANDOWORDPRESSMYSQL8CNF"
lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 127
```
Expand Down
2 changes: 1 addition & 1 deletion examples/wordpress-downstreamer-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lando mysql -V | grep 8.0
# Should use the default database connection info
lando mysql -uwordpress -pwordpress wordpress -e quit

# Should use the defauly mysql8 config file
# Should use the default mysql8 config file
lando ssh -s database -c "cat /opt/bitnami/mysql/conf/my_custom.cnf" | grep "LANDOWORDPRESSMYSQL8CNF"
lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 127
```
Expand Down
1 change: 1 addition & 0 deletions examples/wordpress-mariadb-mysql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mariadb
88 changes: 88 additions & 0 deletions examples/wordpress-mariadb-mysql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
WordPress MariaDB/MySQL Example
===============================

This example exists primarily to test the following documentation:

* [WordPress Recipe](https://docs.devwithlando.io/tutorials/wordpress.html)

Versions of MariaDB 10.3.x and lower do not have the mariadb command and must use the mysql executable.

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should poweroff
lando poweroff

# Should initialize the latest WordPress codebase
rm -rf mariadb && mkdir -p mariadb && cd mariadb
cp -f ../../.lando.upstream.yml .lando.upstream.yml && cat .lando.upstream.yml
lando init --source remote --remote-url https://wordpress.org/latest.tar.gz --recipe wordpress --webroot wordpress --name lando-wordpress-mariadb --option php=8.3 --option database=mariadb:10.3

# Should start up successfully
cd mariadb
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should return the WordPress installation page by default
cd mariadb
lando ssh -s appserver -c "curl -L localhost" | grep "WordPress"

# Should use 8.3 as the default php version
cd mariadb
lando php -v | grep "PHP 8.3."

# Should be running apache 2.4 by default
cd mariadb
lando ssh -s appserver -c "apachectl -V | grep 2.4"
lando ssh -s appserver -c "curl -IL localhost" | grep Server | grep 2.4

# Should be running mariadb 10.3.x by default
cd mariadb
lando mysql -V | grep "MariaDB" | grep 10.3.

# Should not enable xdebug by default
cd mariadb
lando php -m | grep xdebug || echo $? | grep 1

# Should use the default database connection info
cd mariadb
lando mysql -uwordpress -pwordpress wordpress -e quit

# Should use the default mariadb config file
cd mariadb
lando ssh -s database -c "cat /opt/bitnami/mariadb/conf/my_custom.cnf" | grep "innodb_lock_wait_timeout = 121"
lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 121

# Should have the 2.x wp-cli
cd mariadb
lando wp cli version | grep "WP-CLI 2."

# Should create a wp-config file
cd mariadb/wordpress
lando wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database --force

# Should be able to install wordpress
cd mariadb/wordpress
lando wp core install --url=lando-wordpress.lndo.site --title=LandoPress --admin_user=admin --admin_email=mike@pirog.com --skip-email
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
cd mariadb
lando destroy -y
lando poweroff
```
1 change: 1 addition & 0 deletions examples/wordpress-mariadb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mariadb
86 changes: 86 additions & 0 deletions examples/wordpress-mariadb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
WordPress MariaDB Example
=========================

This example exists primarily to test the following documentation:

* [WordPress Recipe](https://docs.devwithlando.io/tutorials/wordpress.html)

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should poweroff
lando poweroff

# Should initialize the latest WordPress codebase
rm -rf mariadb && mkdir -p mariadb && cd mariadb
cp -f ../../.lando.upstream.yml .lando.upstream.yml && cat .lando.upstream.yml
lando init --source remote --remote-url https://wordpress.org/latest.tar.gz --recipe wordpress --webroot wordpress --name lando-wordpress-mariadb --option php=8.3 --option database=mariadb:11.3

# Should start up successfully
cd mariadb
lando start
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should return the WordPress installation page by default
cd mariadb
lando ssh -s appserver -c "curl -L localhost" | grep "WordPress"

# Should use 8.3 as the default php version
cd mariadb
lando php -v | grep "PHP 8.3."

# Should be running apache 2.4 by default
cd mariadb
lando ssh -s appserver -c "apachectl -V | grep 2.4"
lando ssh -s appserver -c "curl -IL localhost" | grep Server | grep 2.4

# Should be running mariadb 11.3.x by default
cd mariadb
lando mariadb -V | grep 11.3.

# Should not enable xdebug by default
cd mariadb
lando php -m | grep xdebug || echo $? | grep 1

# Should use the default database connection info
cd mariadb
lando mariadb -uwordpress -pwordpress wordpress -e quit

# Should use the default mariadb config file
cd mariadb
lando ssh -s database -c "cat /opt/bitnami/mariadb/conf/my_custom.cnf" | grep "innodb_lock_wait_timeout = 121"
lando mariadb -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 121

# Should have the 2.x wp-cli
cd mariadb
lando wp cli version | grep "WP-CLI 2."

# Should create a wp-config file
cd mariadb/wordpress
lando wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database --force

# Should be able to install wordpress
cd mariadb/wordpress
lando wp core install --url=lando-wordpress.lndo.site --title=LandoPress --admin_user=admin --admin_email=mike@pirog.com --skip-email
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
cd mariadb
lando destroy -y
lando poweroff
```
6 changes: 3 additions & 3 deletions examples/wordpress-mysql8/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WordPress Example
=================
WordPress MySQL 8 Example
=========================

This example exists primarily to test the following documentation:

Expand Down Expand Up @@ -55,7 +55,7 @@ lando php -m | grep xdebug || echo $? | grep 1
cd mysql8
lando mysql -uwordpress -pwordpress wordpress -e quit

# Should use the defauly mysql8 config file
# Should use the default mysql8 config file
cd mysql8
lando ssh -s database -c "cat /opt/bitnami/mysql/conf/my_custom.cnf" | grep "LANDOWORDPRESSMYSQL8CNF"
lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 127
Expand Down
2 changes: 1 addition & 1 deletion examples/wordpress-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lando ssh -s appserver -c "curl -L appserver_nginx" | grep "NGINX"
# Should run using nginx if specified
lando ssh -s appserver -c "curl -IL appserver_nginx" | grep Server | grep nginx

# Should use nginx 1.25 by defualt
# Should use nginx 1.25 by default
lando nginx -v 2>&1 | grep "nginx version" | grep "nginx/1.25"

# Should load the correct default nginx config
Expand Down
Loading

0 comments on commit 994a84b

Please sign in to comment.