[bitnami/mariadb] Add VIB tests (#23253)
* [bitnami/mariadb] Add VIB tests Signed-off-by: FraPazGal <fdepaz@vmware.com> * Remove VIB trigger Signed-off-by: FraPazGal <fdepaz@vmware.com> * Avoid using BITNAMI_APP_NAME env for asset test files Signed-off-by: FraPazGal <fdepaz@vmware.com> --------- Signed-off-by: FraPazGal <fdepaz@vmware.com>
This commit is contained in:
parent
9ba9a65aab
commit
c3cdb610a4
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
mapfile -t files < <( find "$BITNAMI_ROOT_DIR"/"$BITNAMI_APP_NAME" "$BITNAMI_ROOT_DIR"/common -type f -executable )
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
[[ $(ldd "$file" | grep -c "not found") -eq 0 ]] || exit 1
|
||||
done
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
mapfile -t files < <( find /bitnami "$BITNAMI_ROOT_DIR" -name '*.sh' )
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
[[ $(grep -cE "sed -i|sed --in-place" "$file") -eq 0 ]] || exit 1
|
||||
done
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
########################
|
||||
# Checks asset version via its binary
|
||||
# Needed vars:
|
||||
# - .Vars.version.bin_name (String)
|
||||
# - .Vars.version.flag (String)
|
||||
########################
|
||||
command:
|
||||
check-app-version:
|
||||
exec: {{ .Vars.version.bin_name }} {{ .Vars.version.flag }}
|
||||
exit-status: 0
|
||||
stdout:
|
||||
- {{ .Env.APP_VERSION }}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
########################
|
||||
# Checks there are no broken symlinks in the components folders
|
||||
# Needed vars:
|
||||
# - .Vars.root_dir (String)
|
||||
########################
|
||||
command:
|
||||
check-broken-symlinks:
|
||||
exec: if [ $(find {{ .Vars.root_dir }} -xtype l | wc -l) -gt 0 ]; then exit 1; fi
|
||||
exit-status: 0
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
########################
|
||||
# Checks the ca-certificates package
|
||||
# is installed accesing an HTTPS URL
|
||||
########################
|
||||
http:
|
||||
https://www.bitnami.com:
|
||||
status: 200
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
########################
|
||||
# Checks components binaries are added to the $PATH
|
||||
# Needed vars:
|
||||
# - .Vars.components.binaries (Array)
|
||||
########################
|
||||
command:
|
||||
{{ range $binary := .Vars.components.binaries }}
|
||||
check-{{ $binary }}-binary:
|
||||
exec: which {{ $binary }}
|
||||
exit-status: 0
|
||||
{{ end }}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
########################
|
||||
# Checks components directories exist
|
||||
# Needed vars:
|
||||
# - .Vars.components.directories (Array)
|
||||
########################
|
||||
file:
|
||||
{{ range $directory := .Vars.components.directories }}
|
||||
{{ $directory }}:
|
||||
exists: true
|
||||
filetype: directory
|
||||
{{ end }}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
########################
|
||||
# Checks components files exist
|
||||
# Needed vars:
|
||||
# - .Vars.components.files (Array)
|
||||
########################
|
||||
file:
|
||||
{{ range $file := .Vars.components.files }}
|
||||
{{ $file }}:
|
||||
exists: true
|
||||
filetype: file
|
||||
{{ end }}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
########################
|
||||
# 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 }}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
########################
|
||||
# Check components executables have no missing linked libraries
|
||||
# Needed vars:
|
||||
# - .Vars.root_dir
|
||||
########################
|
||||
command:
|
||||
check-linked-libraries:
|
||||
exec: export BITNAMI_ROOT_DIR={{ .Vars.root_dir }} && ./common/goss/scripts/check-linked-libraries.sh
|
||||
exit-status: 0
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
########################
|
||||
# Checks components scripts do not have calls
|
||||
# to sed commands with the in-place argument
|
||||
# Needed vars:
|
||||
# - .Vars.root_dir
|
||||
########################
|
||||
command:
|
||||
check-sed-in-place:
|
||||
exec: export BITNAMI_ROOT_DIR={{ .Vars.root_dir }} && ./common/goss/scripts/check-sed-in-place.sh
|
||||
exit-status: 0
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
"resources": {
|
||||
"url": "{VIB_ENV_CONTAINER_URL}",
|
||||
"path": "{VIB_ENV_PATH}"
|
||||
}
|
||||
},
|
||||
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
|
||||
},
|
||||
"phases": {
|
||||
"package": {
|
||||
|
|
@ -32,6 +33,19 @@
|
|||
},
|
||||
"verify": {
|
||||
"actions": [
|
||||
{
|
||||
"action_id": "goss",
|
||||
"params": {
|
||||
"resources": {
|
||||
"path": "/.vib"
|
||||
},
|
||||
"tests_file": "mariadb/goss/goss.yaml",
|
||||
"vars_file": "mariadb/goss/vars.yaml",
|
||||
"remote": {
|
||||
"workload": "deploy-mariadb"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "trivy",
|
||||
"params": {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
"resources": {
|
||||
"url": "{VIB_ENV_CONTAINER_URL}",
|
||||
"path": "{VIB_ENV_PATH}"
|
||||
}
|
||||
},
|
||||
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
|
||||
},
|
||||
"phases": {
|
||||
"package": {
|
||||
|
|
@ -32,6 +33,19 @@
|
|||
},
|
||||
"verify": {
|
||||
"actions": [
|
||||
{
|
||||
"action_id": "goss",
|
||||
"params": {
|
||||
"resources": {
|
||||
"path": "/.vib"
|
||||
},
|
||||
"tests_file": "mariadb/goss/goss.yaml",
|
||||
"vars_file": "mariadb/goss/vars.yaml",
|
||||
"remote": {
|
||||
"workload": "deploy-mariadb"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "trivy",
|
||||
"params": {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
gossfile:
|
||||
# Goss tests exclusive to the current container
|
||||
../../mariadb/goss/templates/mariadb.yaml: {}
|
||||
# Load scripts from .vib/common/goss/templates
|
||||
../../common/goss/templates/check-app-version.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-linked-libraries.yaml: {}
|
||||
../../common/goss/templates/check-sed-in-place.yaml: {}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
file:
|
||||
# Checks there is a template already loaded as a config file
|
||||
{{ .Vars.root_dir }}/mariadb/conf/my.cnf:
|
||||
exists: true
|
||||
filetype: file
|
||||
contains:
|
||||
- socket={{ .Vars.root_dir }}/mariadb/tmp/mysql.sock
|
||||
# Checks the postunpack phase properly creates the plugin's symlink
|
||||
{{ .Vars.root_dir }}/mariadb/lib/plugin:
|
||||
exists: true
|
||||
filetype: symlink
|
||||
# Check the plugins added at compilation time are available
|
||||
{{ .Vars.root_dir }}/mariadb/plugin/auth_pam.so:
|
||||
exists: true
|
||||
filetype: file
|
||||
mode: "0644"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
components:
|
||||
binaries:
|
||||
- gosu
|
||||
- ini-file
|
||||
- mysql
|
||||
filesystem:
|
||||
- mode: "0775"
|
||||
directories:
|
||||
- /bitnami/mariadb
|
||||
- /bitnami/mariadb/data
|
||||
- /opt/bitnami/mariadb/conf
|
||||
- /opt/bitnami/mariadb/conf/bitnami
|
||||
- /opt/bitnami/mariadb/logs
|
||||
- /opt/bitnami/mariadb/tmp
|
||||
root_dir: /opt/bitnami
|
||||
version:
|
||||
bin_name: mysql
|
||||
flag: --version
|
||||
|
|
@ -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": "mariadb/goss/goss.yaml",
|
||||
"vars_file": "mariadb/goss/vars.yaml",
|
||||
"remote": {
|
||||
"workload": "deploy-mariadb"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "trivy",
|
||||
"params": {
|
||||
|
|
|
|||
|
|
@ -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": "mariadb/goss/goss.yaml",
|
||||
"vars_file": "mariadb/goss/vars.yaml",
|
||||
"remote": {
|
||||
"workload": "deploy-mariadb"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"action_id": "trivy",
|
||||
"params": {
|
||||
|
|
@ -50,4 +64,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue