[bitnami/wordpress] Add VIB tests (#23835)

* [bitnami/wordpress] Add VIB tests

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

---------

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>
This commit is contained in:
Jose Antonio Carmona
2023-02-15 17:06:25 +01:00
committed by GitHub
parent d87f86f3f4
commit 59896270a4
5 changed files with 134 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
gossfile:
# Goss tests exclusive to the current container
../../wordpress/goss/wordpress.yaml: {}
# Load scripts from .vib/common/goss/templates
../../common/goss/templates/check-broken-symlinks.yaml: {}
../../common/goss/templates/check-ca-certs.yaml: {}
../../common/goss/templates/check-components-binaries.yaml: {}
../../common/goss/templates/check-components-files.yaml: {}
../../common/goss/templates/check-directories-permissions.yaml: {}
../../common/goss/templates/check-linked-libraries.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}

View File

@@ -0,0 +1,44 @@
components:
binaries:
- apachectl
- gosu
- mariadb
- php
- render-template
- wp
files:
- /opt/bitnami/apache/modules/libphp.so
- /opt/bitnami/wordpress/wp-config.php
filesystem:
- mode: "0775"
directories:
- /bitnami/wordpress
- /opt/bitnami/wordpress
- /opt/bitnami/wordpress/tmp
- /opt/bitnami/wordpress/wp-content/upgrade
- /opt/bitnami/wordpress/wp-content/uploads
- /opt/bitnami/wordpress/wp-content/languages
# WP-CLI
- /opt/bitnami/wp-cli/.cache
- /opt/bitnami/wp-cli/.packages
phpmodules:
# Based on https://make.wordpress.org/hosting/handbook/server-environment/#php-extensions
# Required
- json
- mysqli
# Recommended
- curl
- dom
- exif
- fileinfo
- hash
- imagick
- mbstring
- sodium
- openssl
- pcre
- xml
- zip
# Specific from postunpack logic
- memcached
root_dir: /opt/bitnami

View File

@@ -0,0 +1,49 @@
file:
# HTTP vhost should have been properly rendered
{{ .Vars.root_dir }}/apache/conf/vhosts/wordpress-vhost.conf:
exists: true
filetype: file
contains:
- "RewriteRule ^bitnami/wordpress(/.*) $1"
- /DocumentRoot.*{{ .Vars.root_dir }}/wordpress/
# HTTPs vhost should have been properly rendered
{{ .Vars.root_dir }}/apache/conf/vhosts/wordpress-https-vhost.conf:
exists: true
filetype: file
contains:
- "SSLEngine on"
- "RewriteRule ^bitnami/wordpress(/.*) $1"
- /DocumentRoot.*{{ .Vars.root_dir }}/wordpress/
# WP-CLI should point to wordpress' installation path
{{ .Vars.root_dir }}/wp-cli/conf/wp-cli.yml:
exists: true
filetype: file
contains:
- /path.*{{ .Vars.root_dir }}/wordpress/
command:
check-app-version:
exec: cat {{ .Vars.root_dir }}/wordpress/wp-includes/version.php | grep "wp_version"
exit-status: 0
stdout:
- {{ .Env.APP_VERSION }}
# WP-CLI points to correct binaries and config file
check-wp-cli-conf:
exec: wp --info
exit-status: 0
stdout:
- "{{ .Vars.root_dir }}/php/bin/php"
- "{{ .Vars.root_dir }}/mysql/bin/mysql"
- "{{ .Vars.root_dir }}/wp-cli/conf/wp-cli.yml"
check-enabled-modules:
exec: php -m
exit-status: 0
stdout:
{{ range $module := .Vars.phpmodules }}
- "{{ $module }}"
{{ end }}
group:
daemon:
exists: true
user:
daemon:
exists: true

View File

@@ -3,7 +3,8 @@
"resources": {
"url": "{VIB_ENV_CONTAINER_URL}",
"path": "{VIB_ENV_PATH}"
}
},
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
},
"phases": {
"package": {
@@ -33,6 +34,19 @@
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "wordpress/goss/goss.yaml",
"vars_file": "wordpress/goss/vars.yaml",
"remote": {
"workload": "deploy-wordpress"
}
}
},
{
"action_id": "trivy",
"params": {

View File

@@ -3,7 +3,8 @@
"resources": {
"url": "{SHA_ARCHIVE}",
"path": "{VIB_ENV_PATH}"
}
},
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
},
"phases": {
"package": {
@@ -29,6 +30,19 @@
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "wordpress/goss/goss.yaml",
"vars_file": "wordpress/goss/vars.yaml",
"remote": {
"workload": "deploy-wordpress"
}
}
},
{
"action_id": "trivy",
"params": {