Skip to content

Commit

Permalink
lampy tests (#44)
Browse files Browse the repository at this point in the history
* Update custom installation instructions.

* Add in more extensive LAMP-y tests.

* Update dependencies.

* Default nginx to 1.25 and update tests for LAMP.

* Better config merge, correct nginx settings.
  • Loading branch information
reynoldsalec authored Dec 21, 2023
1 parent c500a93 commit 28241e9
Show file tree
Hide file tree
Showing 49 changed files with 954 additions and 65 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/pr-lamp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ jobs:
node-version:
- '18'
leia-test:
- examples/lamp
- examples/lamp-init
- examples/lamp-custom
- examples/lamp-defaults
- examples/lamp-export
- examples/lamp-import
- examples/lamp-mysql8
- examples/lamp-nginx

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion builders/lamp-mariadb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
parent: '_service',
builder: (parent, config) => class LampMariadb extends LandoMariadb.builder(parent, LandoMariadb.config) {
constructor(id, options = {}) {
super(id, options, {services: _.set({}, options.name)});
super(id, _.merge({}, config, options), {services: _.set({}, options.name)});
};
},
};
2 changes: 1 addition & 1 deletion builders/lamp-mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
parent: '_service',
builder: (parent, config) => class LampMongo extends LandoMongo.builder(parent, LandoMongo.config) {
constructor(id, options = {}) {
super(id, options, {services: _.set({}, options.name)});
super(id, _.merge({}, config, options), {services: _.set({}, options.name)});
};
},
};
2 changes: 1 addition & 1 deletion builders/lamp-mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
parent: '_service',
builder: (parent, config) => class LampMysql extends LandoMysql.builder(parent, LandoMysql.config) {
constructor(id, options = {}) {
super(id, options, {services: _.set({}, options.name)});
super(id, _.merge({}, config, options), {services: _.set({}, options.name)});
};
},
};
5 changes: 4 additions & 1 deletion builders/lamp-nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ const PhpNginx = require('@lando/php/builders/php-nginx.js');
module.exports = {
name: 'lamp-nginx',
parent: '_webserver',
config: {
version: '1.25',
},
builder: (parent, config) => class LampNginx extends PhpNginx.builder(parent, PhpNginx.config) {
constructor(id, options = {}) {
super(id, options, {services: _.set({}, options.name)});
super(id, _.merge({}, config, options), {services: _.set({}, options.name)});
};
},
};
2 changes: 1 addition & 1 deletion builders/lamp-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
constructor(id, options = {}, factory) {
loadScripts(options);
options.nginxServiceType = 'lamp-nginx';
super(id, options, factory);
super(id, _.merge({}, config, options), factory);
};
},
};
2 changes: 1 addition & 1 deletion builders/lamp-postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
parent: '_service',
builder: (parent, config) => class LampPostgres extends LandoPostgres.builder(parent, LandoPostgres.config) {
constructor(id, options = {}) {
super(id, options, {services: _.set({}, options.name)});
super(id, _.merge({}, config, options), {services: _.set({}, options.name)});
};
},
};
18 changes: 18 additions & 0 deletions copy-examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/bash
set -e

plugin=$(basename "$PWD")
plugin_uppercase=$(echo "$plugin" | awk '{first=toupper(substr($0,1,1)); rest=substr($0,2); print first rest}')
echo $plugin_uppercase

cp -R ~/workspace/lando-scripts-big-update/laravel/examples/ examples
cd examples
for dir in laravel-*; do mv "$dir" "${dir/laravel-/$plugin-}"; done
cd ..
find examples -type f -exec sh -c 'tmpfile=$(mktemp); sed "s/laravel/$1/g" "$0" > "$tmpfile" && mv "$tmpfile" "$0"' {} $plugin \;
find examples -type f -exec sh -c 'tmpfile=$(mktemp); sed "s/laravel/$1/g" "$0" > "$tmpfile" && mv "$tmpfile" "$0"' {} $plugin_uppercase \;
rm -r examples/$plugin-init
mv examples/$plugin examples/$plugin-init

chmod u+x examples/$plugin-import/test.sh
chmod u+x examples/$plugin-export/mysql-test.sh
18 changes: 12 additions & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ This plugin is included with Lando by default. That means if you have Lando vers
However if you would like to manually install the plugin, update it to the bleeding edge or install a particular version then use the below. Note that this installation method requires Lando `3.5.0+`.

:::: code-group
::: code-group-item LANDO 3.21+
```bash:no-line-numbers
lando plugin-add @lando/lamp
```
:::
::: code-group-item HYPERDRIVE
```bash:no-line-numbers
# @TODO
# @NOTE: This doesn't actaully work yet
hyperdrive install @lando/lamp
```
:::
::: code-group-item DOCKER
```bash:no-line-numbers
# Ensure you have a global plugins directory
Expand All @@ -61,12 +73,6 @@ docker run --rm -it -v ${HOME}/.lando/plugins:/plugins -w /tmp node:14-alpine sh
lando --clear
```
:::
::: code-group-item HYPERDRIVE
```bash:no-line-numbers
# @TODO
# @NOTE: This doesn't actaully work yet
hyperdrive install @lando/lamp
```
::::

You should be able to verify the plugin is installed by running `lando config --path plugins` and checking for `@lando/lamp`. This command will also show you _where_ the plugin is being loaded from.
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/.lando.upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugins:
"@lando/lamp": ../../..
3 changes: 3 additions & 0 deletions examples/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: stealth-plugin-loader
plugins:
"@lando/lamp": ..
18 changes: 18 additions & 0 deletions examples/lamp-custom/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: lamp-custom
recipe: lamp
config:
php: '7.4'
composer_version: '2.0.7'
via: nginx:1.17
webroot: bob
database: mysql:5.7
xdebug: true
config:
database: config/mysql.cnf
php: config/php.ini
vhosts: config/default.conf

# do not remove this
plugins:
"@lando/lamp": ../..

61 changes: 61 additions & 0 deletions examples/lamp-custom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# LAMP Custom 8Example

This example exists primarily to test the following documentation:

* [LAMP Recipe](https://docs.lando.dev/lamp/config.html)

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

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

```bash
# Should start up successfully
lando poweroff
lando start
```

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

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

```bash
# Should serve from bob folder
lando ssh -s appserver -c "curl -L appserver_nginx" | grep "HI BOB"

# Should be serving from nginx 1.17
lando ssh -s appserver_nginx -c "nginx -v" 2>&1 | grep "nginx version" | grep "nginx/1.17"
lando ssh -s appserver -c "curl -IL appserver_nginx" | grep Server | grep nginx

# Should use php 7.4
lando php -v | grep "PHP 7.4"

# Should use composer 2.0.7
lando ssh -s appserver -c "/bin/sh -c 'NO_COLOR=1 composer -V'" | grep "Composer version 2.0.7"

# Should be running mysql 5.7 by default
lando mysql -V | grep 5.7

# Should be able to connect to the database with the default creds
lando mysql lamp -e quit

# Should have xdebug enabled
lando php -m | grep Xdebug

# Should be using custom config files
lando ssh -s appserver -c "curl -L appserver_nginx/info.php" | grep memory_limit | grep 513M
lando ssh -s appserver_nginx -c "cat /opt/bitnami/nginx/conf/vhosts/lando.conf" | grep server_name | grep pirog
lando mysql -u root -e "show variables;" | grep thread_cache_size | grep 12
```

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

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

```bash
# Should be destroyed with success
lando destroy -y
lando poweroff
```
1 change: 1 addition & 0 deletions examples/lamp-custom/bob/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
HI BOB
1 change: 1 addition & 0 deletions examples/lamp-custom/bob/info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php phpinfo(); ?>
41 changes: 41 additions & 0 deletions examples/lamp-custom/config/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
server {
listen 80 default_server;
listen 443 ssl;

server_name pirog;

ssl_certificate /certs/cert.crt;
ssl_certificate_key /certs/cert.key;
ssl_verify_client off;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

root "{{LANDO_WEBROOT}}";

index index.html index.htm index.php;

port_in_redirect off;
client_max_body_size 100M;

location / {
error_page 404 = @lamp;
}

location @lamp {
rewrite ^(.*)$ /index.php?q=$1 last;
}

location ~ \.php$ {
fastcgi_pass fpm:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
}

}
110 changes: 110 additions & 0 deletions examples/lamp-custom/config/mysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#
# The MySQL database server configuration file for Lando
#

[mysqld]
#
# * Basic Settings
#
# Data is stored in a volume on the db container /sql
default-storage-engine = innodb

#
# * Fine Tuning
#
key_buffer_size = 38M
max_allowed_packet = 32M
thread_stack = 400K
thread_cache_size = 12
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M

#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 64M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /src/.lando/log/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /src/.lando/log/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# Uncomment the following if you are using InnoDB tables
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = C:\mysql\data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 0
#innodb_lock_wait_timeout = 50
innodb_buffer_pool_size = 384M
innodb_log_buffer_size = 4M
innodb_file_per_table = 1
innodb_open_files = 256
innodb_io_capacity = 512
innodb_flush_method = O_DIRECT
innodb_thread_concurrency = 8
innodb_lock_wait_timeout = 120
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

[mysqldump]
quick
quote-names
max_allowed_packet = 32M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completion

[isamchk]
key_buffer_size = 384M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
Loading

0 comments on commit 28241e9

Please sign in to comment.