From e48696b784ca603d2fb85813bb602f2b35eb9790 Mon Sep 17 00:00:00 2001 From: Francisco de Paz Galan Date: Thu, 18 May 2023 09:37:35 +0200 Subject: [PATCH] [bitnami/parse-dashboard] Add VIB tests (#30863) * [bitnami/parse-dashboard] Add VIB tests Signed-off-by: FraPazGal * Support owner and group as optional params for check-files Signed-off-by: FraPazGal * Add VIB triggers Signed-off-by: FraPazGal * Use grep instead of rgrep Signed-off-by: FraPazGal * Fix app-version typo Signed-off-by: FraPazGal * Simplify goss dirs and files templates Signed-off-by: FraPazGal * Apply suggestions from code review Co-authored-by: Jose Antonio Carmona Signed-off-by: Francisco de Paz Galan * Apply suggestions Signed-off-by: FraPazGal * Remove VIB trigger Signed-off-by: FraPazGal * Remove testing file Signed-off-by: FraPazGal --------- Signed-off-by: FraPazGal Signed-off-by: Francisco de Paz Galan Co-authored-by: Jose Antonio Carmona --- .../goss/templates/check-directories.yaml | 22 ++++++++++------- .vib/common/goss/templates/check-files.yaml | 22 ++++++++++------- .vib/parse-dashboard/goss/goss.yaml | 11 +++++++++ .../parse-dashboard/goss/parse-dashboard.yaml | 12 ++++++++++ .vib/parse-dashboard/goss/vars.yaml | 13 ++++++++++ .vib/parse-dashboard/vib-publish.json | 24 +++++++++++++++---- .vib/parse-dashboard/vib-verify.json | 18 +++++++++++++- 7 files changed, 99 insertions(+), 23 deletions(-) create mode 100644 .vib/parse-dashboard/goss/goss.yaml create mode 100644 .vib/parse-dashboard/goss/parse-dashboard.yaml create mode 100644 .vib/parse-dashboard/goss/vars.yaml diff --git a/.vib/common/goss/templates/check-directories.yaml b/.vib/common/goss/templates/check-directories.yaml index 8e343a43ee99..16b2efd856f9 100644 --- a/.vib/common/goss/templates/check-directories.yaml +++ b/.vib/common/goss/templates/check-directories.yaml @@ -6,19 +6,23 @@ # - .Vars.directories.paths (Array) # Optional vars: # - .Vars.directories.mode (String) +# - .Vars.directories.owner (String) +# - .Vars.directories.group (String) ######################## file: - {{ range .Vars.directories }} - {{ $mode := "" }} - {{ if contains "mode:" (. | toString) }} - {{ $mode = .mode }} - {{ end }} - {{ range $directory := .paths }} - {{ $directory }}: + {{ range $dirs := .Vars.directories }} + {{ range $path := .paths }} + {{ $path }}: exists: true filetype: directory - {{ if $mode }} - mode: "{{ $mode }}" + {{ if and (index $dirs "mode") }} + mode: "{{ printf "%s" $dirs.mode }}" + {{ end }} + {{ if and (index $dirs "owner") }} + owner: {{ printf "%s" $dirs.owner }} + {{ end }} + {{ if and (index $dirs "group") }} + group: {{ printf "%s" $dirs.group }} {{ end }} {{ end }} {{ end }} diff --git a/.vib/common/goss/templates/check-files.yaml b/.vib/common/goss/templates/check-files.yaml index 8d8d7cf10bdf..b1ec4b924478 100644 --- a/.vib/common/goss/templates/check-files.yaml +++ b/.vib/common/goss/templates/check-files.yaml @@ -6,19 +6,23 @@ # - .Vars.files.paths (Array) # Optional vars: # - .Vars.files.mode (String) +# - .Vars.files.owner (String) +# - .Vars.files.group (String) ######################## file: - {{ range .Vars.files }} - {{ $mode := "" }} - {{ if contains "mode:" (. | toString) }} - {{ $mode = .mode }} - {{ end }} - {{ range $file := .paths }} - {{ $file }}: + {{ range $files := .Vars.files }} + {{ range $path := .paths }} + {{ $path }}: exists: true filetype: file - {{ if $mode }} - mode: "{{ $mode }}" + {{ if and (index $files "mode") }} + mode: "{{ printf "%s" $files.mode }}" + {{ end }} + {{ if and (index $files "owner") }} + owner: {{ printf "%s" $files.owner }} + {{ end }} + {{ if and (index $files "group") }} + group: {{ printf "%s" $files.group }} {{ end }} {{ end }} {{ end }} diff --git a/.vib/parse-dashboard/goss/goss.yaml b/.vib/parse-dashboard/goss/goss.yaml new file mode 100644 index 000000000000..abe1d138d36f --- /dev/null +++ b/.vib/parse-dashboard/goss/goss.yaml @@ -0,0 +1,11 @@ +gossfile: + # Goss tests exclusive to the current container + ../../parse-dashboard/goss/parse-dashboard.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-directories.yaml: {} + ../../common/goss/templates/check-linked-libraries.yaml: {} + ../../common/goss/templates/check-sed-in-place.yaml: {} + ../../common/goss/templates/check-spdx.yaml: {} diff --git a/.vib/parse-dashboard/goss/parse-dashboard.yaml b/.vib/parse-dashboard/goss/parse-dashboard.yaml new file mode 100644 index 000000000000..1693cb57929f --- /dev/null +++ b/.vib/parse-dashboard/goss/parse-dashboard.yaml @@ -0,0 +1,12 @@ +group: + parsedashboard: + exists: true +user: + parsedashboard: + exists: true +command: + check-app-version: + exec: grep "version" /opt/bitnami/parse-dashboard/package.json + exit-status: 0 + stdout: + - {{ .Env.APP_VERSION }} diff --git a/.vib/parse-dashboard/goss/vars.yaml b/.vib/parse-dashboard/goss/vars.yaml new file mode 100644 index 000000000000..eef3de672b8c --- /dev/null +++ b/.vib/parse-dashboard/goss/vars.yaml @@ -0,0 +1,13 @@ +binaries: + - node + - python +directories: + - mode: "0775" + owner: "parsedashboard" + group: "root" + paths: + - /bitnami/parse-dashboard + - /opt/bitnami/parse-dashboard + - /opt/bitnami/parse-dashboard/tmp + - /opt/bitnami/parse-dashboard/logs +root_dir: /opt/bitnami diff --git a/.vib/parse-dashboard/vib-publish.json b/.vib/parse-dashboard/vib-publish.json index 8b6fe8eab4e6..478698ad3124 100644 --- a/.vib/parse-dashboard/vib-publish.json +++ b/.vib/parse-dashboard/vib-publish.json @@ -3,7 +3,8 @@ "resources": { "url": "{VIB_ENV_CONTAINER_URL}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -77,9 +78,24 @@ "url": "{VIB_ENV_PACKAGES_JSON_URL}", "path": "/{VIB_ENV_PATH}", "authn": { - "header": "Authorization", - "token": "Bearer {VIB_ENV_GITHUB_TOKEN}" - } + "header": "Authorization", + "token": "Bearer {VIB_ENV_GITHUB_TOKEN}" + } + } + } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "parse-dashboard/goss/goss.yaml", + "vars_file": "parse-dashboard/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-parse-dashboard" + } } } } diff --git a/.vib/parse-dashboard/vib-verify.json b/.vib/parse-dashboard/vib-verify.json index a34e8aee9161..f6c55ad4b9a0 100644 --- a/.vib/parse-dashboard/vib-verify.json +++ b/.vib/parse-dashboard/vib-verify.json @@ -3,7 +3,8 @@ "resources": { "url": "{SHA_ARCHIVE}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -46,6 +47,21 @@ "OS" ] } + }, + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "parse-dashboard/goss/goss.yaml", + "vars_file": "parse-dashboard/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-parse-dashboard" + } + } + } } ] }