[bitnami/*] Refactor Goss' common tests (#24127)

* [bitnami/*] Refactor Goss' common tests

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Trigger VIB for MariaDB

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Fix path typo

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Trigger VIB for WordPress

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Trigger VIB for Apache

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Remove VIB triggers

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Add missing MariaDB tests and launch VIB pipeline

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Remove VIB trigger

Signed-off-by: FraPazGal <fdepaz@vmware.com>

---------

Signed-off-by: FraPazGal <fdepaz@vmware.com>
This commit is contained in:
Francisco de Paz Galan
2023-02-16 11:37:25 +01:00
committed by GitHub
parent 8a5fd25163
commit 9d243a6d23
15 changed files with 127 additions and 121 deletions

View File

@@ -1,3 +1,19 @@
command:
# There are no syntax error in the configuration
check-configuration:
exec: apachectl -t
exit-status: 0
# Check explicitly enabled and disabled modules
check-loaded-modules:
exec: apachectl -M
exit-status: 0
stdout:
{{ range $module := .Vars.modules.loaded }}
- "{{ $module }}_module"
{{ end }}
{{ range $module := .Vars.modules.disabled }}
- "!{{ $module }}_module"
{{ end }}
file:
# Main Apache config file includes other config files
{{ .Vars.root_dir }}/apache/conf/httpd.conf:
@@ -31,19 +47,3 @@ file:
exists: true
filetype: file
{{ end }}
command:
# There are no syntax error in the configuration
check-configuration:
exec: apachectl -t
exit-status: 0
# Check explicitly enabled and disabled modules
check-loaded-modules:
exec: apachectl -M
exit-status: 0
stdout:
{{ range $module := .Vars.modules.loaded }}
- "{{ $module }}_module"
{{ end }}
{{ range $module := .Vars.modules.disabled }}
- "!{{ $module }}_module"
{{ end }}

View File

@@ -3,10 +3,10 @@ gossfile:
../../apache/goss/apache.yaml: {}
# Load scripts from .vib/common/goss/templates
../../common/goss/templates/check-app-version.yaml: {}
../../common/goss/templates/check-binaries.yaml: {}
../../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-directories.yaml: {}
../../common/goss/templates/check-files.yaml: {}
../../common/goss/templates/check-linked-libraries.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}

View File

@@ -1,14 +1,14 @@
components:
binaries:
- httpd
- gosu
- render-template
files:
- /opt/bitnami/apache/conf/modsecurity.conf
- /opt/bitnami/apache/conf/unicode.mapping
filesystem:
binaries:
- httpd
- gosu
- render-template
files:
- paths:
- /opt/bitnami/apache/conf/modsecurity.conf
- /opt/bitnami/apache/conf/unicode.mapping
directories:
- mode: "0775"
directories:
paths:
- /opt/bitnami/apache/var/run
- /opt/bitnami/apache/conf
- /opt/bitnami/apache/logs
@@ -46,4 +46,4 @@ modules:
root_dir: /opt/bitnami
version:
bin_name: apachectl
flag: -v
flag: -v

View File

@@ -1,10 +1,10 @@
########################
# Checks components binaries are added to the $PATH
# Checks binaries are added to the $PATH
# Needed vars:
# - .Vars.components.binaries (Array)
# - .Vars.binaries (Array)
########################
command:
{{ range $binary := .Vars.components.binaries }}
{{ range $binary := .Vars.binaries }}
check-{{ $binary }}-binary:
exec: which {{ $binary }}
exit-status: 0

View File

@@ -1,11 +0,0 @@
########################
# Checks components directories exist
# Needed vars:
# - .Vars.components.directories (Array)
########################
file:
{{ range $directory := .Vars.components.directories }}
{{ $directory }}:
exists: true
filetype: directory
{{ end }}

View File

@@ -1,11 +0,0 @@
########################
# Checks components files exist
# Needed vars:
# - .Vars.components.files (Array)
########################
file:
{{ range $file := .Vars.components.files }}
{{ $file }}:
exists: true
filetype: file
{{ end }}

View File

@@ -1,17 +0,0 @@
########################
# Checks directories permissions, usually changed in the postunpack stage
# Needed vars:
# - .Vars.filesystem (Array)
# - .Vars.filesystem.directories (Array)
# - .Vars.filesystem.mode (String)
########################
file:
{{ range .Vars.filesystem }}
{{ $mode := .mode }}
{{ range $directory := .directories }}
{{ $directory }}:
exists: true
filetype: directory
mode: "{{ $mode }}"
{{ end }}
{{ end }}

View File

@@ -0,0 +1,23 @@
########################
# Checks directories exist,
# optionally checking their permissions
# Needed vars:
# - .Vars.directories (Array)
# - .Vars.directories.paths (Array)
# - .Vars.directories.mode (Optional - String)
########################
file:
{{ range .Vars.directories }}
{{ $mode := "" }}
{{ if (gt (len .) 1) }}
{{ $mode = .mode }}
{{ end }}
{{ range $directory := .paths }}
{{ $directory }}:
exists: true
filetype: directory
{{ if $mode }}
mode: "{{ $mode }}"
{{ end }}
{{ end }}
{{ end }}

View File

@@ -0,0 +1,23 @@
########################
# Checks files exist,
# optionally checking their permissions
# Needed vars:
# - .Vars.files (Array)
# - .Vars.files.paths (Array)
# - .Vars.directories.mode (Optional - String)
########################
file:
{{ range .Vars.files }}
{{ $mode := "" }}
{{ if (gt (len .) 1) }}
{{ $mode = .mode }}
{{ end }}
{{ range $file := .paths }}
{{ $file }}:
exists: true
filetype: file
{{ if $mode }}
mode: "{{ $mode }}"
{{ end }}
{{ end }}
{{ end }}

View File

@@ -1,11 +1,11 @@
gossfile:
# Goss tests exclusive to the current container
../../mariadb/goss/templates/mariadb.yaml: {}
../../mariadb/goss/mariadb.yaml: {}
# Load scripts from .vib/common/goss/templates
../../common/goss/templates/check-app-version.yaml: {}
../../common/goss/templates/check-binaries.yaml: {}
../../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-directories-permissions.yaml: {}
../../common/goss/templates/check-directories.yaml: {}
../../common/goss/templates/check-linked-libraries.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}

View File

@@ -1,11 +1,10 @@
components:
binaries:
- gosu
- ini-file
- mysql
filesystem:
binaries:
- gosu
- ini-file
- mysql
directories:
- mode: "0775"
directories:
paths:
- /bitnami/mariadb
- /bitnami/mariadb/data
- /opt/bitnami/mariadb/conf

View File

@@ -2,10 +2,10 @@ gossfile:
# Goss tests exclusive to the current container
../../wordpress/goss/wordpress.yaml: {}
# Load scripts from .vib/common/goss/templates
../../common/goss/templates/check-binaries.yaml: {}
../../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-directories.yaml: {}
../../common/goss/templates/check-files.yaml: {}
../../common/goss/templates/check-linked-libraries.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}

View File

@@ -1,17 +1,17 @@
components:
binaries:
- apachectl
- gosu
- mariadb
- php
- render-template
- wp
files:
binaries:
- apachectl
- gosu
- mariadb
- php
- render-template
- wp
files:
- paths:
- /opt/bitnami/apache/modules/libphp.so
- /opt/bitnami/wordpress/wp-config.php
filesystem:
directories:
- mode: "0775"
directories:
paths:
- /bitnami/wordpress
- /opt/bitnami/wordpress
- /opt/bitnami/wordpress/tmp
@@ -41,4 +41,4 @@ phpmodules:
- zip
# Specific from postunpack logic
- memcached
root_dir: /opt/bitnami
root_dir: /opt/bitnami

View File

@@ -1,3 +1,24 @@
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 }}
file:
# HTTP vhost should have been properly rendered
{{ .Vars.root_dir }}/apache/conf/vhosts/wordpress-vhost.conf:
@@ -20,30 +41,9 @@ file:
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
exists: true