From 0fec0ce8e9089e4fcd8dbdb867c538140e0d3ec9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Carmona Date: Thu, 9 Mar 2023 16:15:49 +0100 Subject: [PATCH] [bitnami/jruby] Add VIB tests (#26705) * [bitnami/jruby] Add VIB tests Signed-off-by: Jose Antonio Carmona * Remove VIB trigger Signed-off-by: Jose Antonio Carmona * Exclude paths Signed-off-by: Jose Antonio Carmona * Add linked-libraries Signed-off-by: Jose Antonio Carmona * Increase timeouts Signed-off-by: Jose Antonio Carmona * Use new naming for property Signed-off-by: Jose Antonio Carmona * Improve identification of optional args Signed-off-by: Jose Antonio Carmona * Remove VIB trigger Signed-off-by: Jose Antonio Carmona * Fix files.mode path Signed-off-by: Jose Antonio Carmona --------- Signed-off-by: Jose Antonio Carmona --- .../goss/scripts/check-linked-libraries.sh | 3 ++ .../goss/templates/check-directories.yaml | 2 +- .vib/common/goss/templates/check-files.yaml | 4 +-- .../templates/check-linked-libraries.yaml | 8 ++++- .vib/jruby/goss/goss.yaml | 9 ++++++ .vib/jruby/goss/jruby.yaml | 30 +++++++++++++++++++ .vib/jruby/goss/vars.yaml | 12 ++++++++ .vib/jruby/vib-publish.json | 18 ++++++++++- .vib/jruby/vib-verify.json | 18 ++++++++++- 9 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 .vib/jruby/goss/goss.yaml create mode 100644 .vib/jruby/goss/jruby.yaml create mode 100644 .vib/jruby/goss/vars.yaml diff --git a/.vib/common/goss/scripts/check-linked-libraries.sh b/.vib/common/goss/scripts/check-linked-libraries.sh index 3c8502d8b1b1..5df0adfe9582 100755 --- a/.vib/common/goss/scripts/check-linked-libraries.sh +++ b/.vib/common/goss/scripts/check-linked-libraries.sh @@ -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 diff --git a/.vib/common/goss/templates/check-directories.yaml b/.vib/common/goss/templates/check-directories.yaml index 2301a24ea260..3e72f51d7046 100644 --- a/.vib/common/goss/templates/check-directories.yaml +++ b/.vib/common/goss/templates/check-directories.yaml @@ -9,7 +9,7 @@ file: {{ range .Vars.directories }} {{ $mode := "" }} - {{ if (gt (len .) 1) }} + {{ if contains "mode:" (. | toString) }} {{ $mode = .mode }} {{ end }} {{ range $directory := .paths }} diff --git a/.vib/common/goss/templates/check-files.yaml b/.vib/common/goss/templates/check-files.yaml index eed7ab63e5a5..6d997c938338 100644 --- a/.vib/common/goss/templates/check-files.yaml +++ b/.vib/common/goss/templates/check-files.yaml @@ -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 }} diff --git a/.vib/common/goss/templates/check-linked-libraries.yaml b/.vib/common/goss/templates/check-linked-libraries.yaml index 6d22576dd9fa..c5ca224d22ec 100644 --- a/.vib/common/goss/templates/check-linked-libraries.yaml +++ b/.vib/common/goss/templates/check-linked-libraries.yaml @@ -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 diff --git a/.vib/jruby/goss/goss.yaml b/.vib/jruby/goss/goss.yaml new file mode 100644 index 000000000000..8d492dbf4341 --- /dev/null +++ b/.vib/jruby/goss/goss.yaml @@ -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: {} diff --git a/.vib/jruby/goss/jruby.yaml b/.vib/jruby/goss/jruby.yaml new file mode 100644 index 000000000000..a94b69b5a61e --- /dev/null +++ b/.vib/jruby/goss/jruby.yaml @@ -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 \ No newline at end of file diff --git a/.vib/jruby/goss/vars.yaml b/.vib/jruby/goss/vars.yaml new file mode 100644 index 000000000000..23cc8f8a41b2 --- /dev/null +++ b/.vib/jruby/goss/vars.yaml @@ -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 diff --git a/.vib/jruby/vib-publish.json b/.vib/jruby/vib-publish.json index b95e5f947244..0ee54393a61c 100644 --- a/.vib/jruby/vib-publish.json +++ b/.vib/jruby/vib-publish.json @@ -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": { diff --git a/.vib/jruby/vib-verify.json b/.vib/jruby/vib-verify.json index 835cd556e241..a3e35dd7e900 100644 --- a/.vib/jruby/vib-verify.json +++ b/.vib/jruby/vib-verify.json @@ -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": {