[bitnami/jruby] Add VIB tests (#26705)

* [bitnami/jruby] Add VIB tests

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

* Remove VIB trigger

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

* Exclude paths

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

* Add linked-libraries

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

* Increase timeouts

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

* Use new naming for property

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

* Improve identification of optional args

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

* Remove VIB trigger

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

* Fix files.mode path

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-03-09 16:15:49 +01:00 committed by GitHub
parent 4442830427
commit 0fec0ce8e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 98 additions and 6 deletions

View File

@ -7,5 +7,8 @@ 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
if [[ -n $EXCLUDE_PATHS ]] && [[ "$file" =~ $EXCLUDE_PATHS ]]; then
continue
fi
[[ $(ldd "$file" | grep -c "not found") -eq 0 ]] || exit 1
done

View File

@ -9,7 +9,7 @@
file:
{{ range .Vars.directories }}
{{ $mode := "" }}
{{ if (gt (len .) 1) }}
{{ if contains "mode:" (. | toString) }}
{{ $mode = .mode }}
{{ end }}
{{ range $directory := .paths }}

View File

@ -4,12 +4,12 @@
# Needed vars:
# - .Vars.files (Array)
# - .Vars.files.paths (Array)
# - .Vars.directories.mode (Optional - String)
# - .Vars.files.mode (Optional - String)
########################
file:
{{ range .Vars.files }}
{{ $mode := "" }}
{{ if (gt (len .) 1) }}
{{ if contains "mode:" (. | toString) }}
{{ $mode = .mode }}
{{ end }}
{{ range $file := .paths }}

View File

@ -2,8 +2,14 @@
# Check components executables have no missing linked libraries
# Needed vars:
# - .Vars.root_dir
# - .Vars.linked_libraries.exclude_paths (Optional - Array)
########################
command:
check-linked-libraries:
exec: export BITNAMI_ROOT_DIR={{ .Vars.root_dir }} && ./common/goss/scripts/check-linked-libraries.sh
{{ $exclude_paths := "" }}
{{ if contains "exclude_paths:" (.Vars | toString) }}
{{ $exclude_paths = (.Vars.linked_libraries.exclude_paths | join "|") }}
{{ end }}
exec: export BITNAMI_ROOT_DIR={{ .Vars.root_dir }}{{ if $exclude_paths }} && export EXCLUDE_PATHS='{{ $exclude_paths }}'{{ end }} && ./common/goss/scripts/check-linked-libraries.sh
timeout: 20000
exit-status: 0

View File

@ -0,0 +1,9 @@
gossfile:
# Goss tests exclusive to the current container
../../jruby/goss/jruby.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-linked-libraries.yaml: {}
../../common/goss/templates/check-sed-in-place.yaml: {}

View File

@ -0,0 +1,30 @@
command:
# Revisions are displayed as "x.y.z.r" instead of "x.y.z-r"
check-app-version:
exec: jruby --version | grep $(echo $APP_VERSION | tr '-' '.')
exit-status: 0
check-bundle:
exec: cd /tmp && echo "source 'https://rubygems.org'" > Gemfile && bundle
timeout: 30000
exit-status: 0
check-jruby-ssl:
exec: jruby -rnet/https -e "Net::HTTP.get URI('https://bitnami.com')"
timeout: 30000
exit-status: 0
check-rake-task:
exec: echo "task :test do; puts 'Hello VIB'; end" > /tmp/test-rake.rb && rake -f /tmp/test-rake.rb test
exit-status: 0
timeout: 30000
stdout:
- Hello VIB
check-mariadb-jdbc-driver:
exec: jruby -e "puts Java::org.mariadb.jdbc.Driver"
exit-status: 0
timeout: 30000
stdout:
- Java::OrgMariadbJdbc::Driver
file:
/opt/bitnami/jruby/bin/ruby:
exists: true
filetype: symlink
linked-to: /opt/bitnami/jruby/bin/jruby

12
.vib/jruby/goss/vars.yaml Normal file
View File

@ -0,0 +1,12 @@
binaries:
- jruby
- ruby
- gem
- python
- node
- java
linked_libraries:
exclude_paths:
# Ignore Gems build output directory
- .*\/gems\/shared\/gems\/[^/]+\/buildout\/.*
root_dir: /opt/bitnami

View File

@ -3,7 +3,8 @@
"resources": {
"url": "{VIB_ENV_CONTAINER_URL}",
"path": "{VIB_ENV_PATH}"
}
},
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
},
"phases": {
"package": {
@ -33,6 +34,21 @@
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "jruby/goss/goss.yaml",
"vars_file": "jruby/goss/vars.yaml",
"remote": {
"pod": {
"workload": "deploy-jruby"
}
}
}
},
{
"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,21 @@
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "jruby/goss/goss.yaml",
"vars_file": "jruby/goss/vars.yaml",
"remote": {
"pod": {
"workload": "deploy-jruby"
}
}
}
},
{
"action_id": "trivy",
"params": {