From 3806c75844bbdd13246ad6fb7d96599b0b01d0bf Mon Sep 17 00:00:00 2001 From: Francisco de Paz Galan Date: Fri, 17 Mar 2023 11:30:18 +0100 Subject: [PATCH] [bitnami/nginx] Add VIB tests (#27513) * [bitnami/nginx] Add VIB tests Signed-off-by: FraPazGal * Trigger VIB Signed-off-by: FraPazGal * Remove VIB trigger Signed-off-by: FraPazGal * Use fullpath for asset tests Signed-off-by: FraPazGal * Add missing binary check Signed-off-by: FraPazGal --------- Signed-off-by: FraPazGal --- .vib/nginx/goss/goss.yaml | 12 ++++++++ .vib/nginx/goss/nginx.yaml | 57 +++++++++++++++++++++++++++++++++++++ .vib/nginx/goss/vars.yaml | 53 ++++++++++++++++++++++++++++++++++ .vib/nginx/vib-publish.json | 18 +++++++++++- .vib/nginx/vib-verify.json | 20 +++++++++++-- 5 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 .vib/nginx/goss/goss.yaml create mode 100644 .vib/nginx/goss/nginx.yaml create mode 100644 .vib/nginx/goss/vars.yaml diff --git a/.vib/nginx/goss/goss.yaml b/.vib/nginx/goss/goss.yaml new file mode 100644 index 000000000000..67c9c66b6639 --- /dev/null +++ b/.vib/nginx/goss/goss.yaml @@ -0,0 +1,12 @@ +gossfile: + # Goss tests exclusive to the current container + ../../nginx/goss/nginx.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-files.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/nginx/goss/nginx.yaml b/.vib/nginx/goss/nginx.yaml new file mode 100644 index 000000000000..f05342846d22 --- /dev/null +++ b/.vib/nginx/goss/nginx.yaml @@ -0,0 +1,57 @@ +file: + # Checks configured symlinks + /opt/bitnami/nginx/conf/bitnami/certs: + exists: true + filetype: symlink + linked-to: /certs + /opt/bitnami/nginx/html: + exists: true + filetype: symlink + linked-to: /app + /opt/bitnami/nginx/logs/access.log: + exists: true + filetype: symlink + linked-to: /dev/stdout + /opt/bitnami/nginx/logs/error.log: + exists: true + filetype: symlink + linked-to: /dev/stderr + # Check selected dirs are not present + /opt/bitnami/certs: + exists: false + /opt/bitnami/server_blocks: + exists: false + # Check custom config + /opt/bitnami/nginx/conf/nginx.conf: + exists: true + filetype: file + contains: + - /listen.*{{ .Vars.ports.http }}/ + /opt/bitnami/nginx/conf/fastcgi_params: + exists: true + filetype: file + contains: + - /Unset.*HTTP_PROXY/ +command: + check-app-version: + exec: {{ .Vars.version.bin_name }} {{ .Vars.version.flag }} 2>&1 + exit-status: 0 + stdout: + - {{ .Env.APP_VERSION }} + test-config: + exec: nginx -t + exit-status: 0 + # Check enabled config and added/enabled modules at compilation time + check-compilation-opts: + exec: nginx -V 2>&1 + exit-status: 0 + stdout: + {{ range $added_module := .Vars.modules.added }} + - nginx-module-{{ $added_module }} + {{ end }} + {{ range $enabled_module := .Vars.modules.enabled }} + - with-{{ $enabled_module }}_module + {{ end }} + {{ range $additional_config := .Vars.config_opts }} + - with-{{ $additional_config }} + {{ end }} diff --git a/.vib/nginx/goss/vars.yaml b/.vib/nginx/goss/vars.yaml new file mode 100644 index 000000000000..f7e3e33a887f --- /dev/null +++ b/.vib/nginx/goss/vars.yaml @@ -0,0 +1,53 @@ +binaries: + - gosu + - nginx + - render-template +config_opts: + - stream + - mail + - threads + - compat +directories: + - mode: "0775" + paths: + - /bitnami/nginx + - /opt/bitnami/nginx/conf + - /opt/bitnami/nginx/conf/bitnami + - /opt/bitnami/nginx/conf/server_blocks + - /opt/bitnami/nginx/logs + - /opt/bitnami/nginx/tmp + - /docker-entrypoint-initdb.d + - paths: + - /app + - /certs +files: + - paths: + - /opt/bitnami/nginx/logs/access.log + - /opt/bitnami/nginx/logs/error.log + - /opt/bitnami/nginx/conf/nginx.conf.default +modules: + added: + - brotli + - geoip2 + - substitutions-filter + - vts + enabled: + - http_stub_status + - http_gzip_static + - http_realip + - http_stub_status + - http_v2 + - http_ssl + - mail_ssl + - http_gunzip + - http_auth_request + - http_sub + - http_geoip + - stream_realip + - stream_ssl +ports: + http: 8080 +root_dir: /opt/bitnami +version: + bin_name: nginx + flag: -v diff --git a/.vib/nginx/vib-publish.json b/.vib/nginx/vib-publish.json index b95e5f947244..ff8057be41ca 100644 --- a/.vib/nginx/vib-publish.json +++ b/.vib/nginx/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": "nginx/goss/goss.yaml", + "vars_file": "nginx/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-nginx" + } + } + } + }, { "action_id": "trivy", "params": { diff --git a/.vib/nginx/vib-verify.json b/.vib/nginx/vib-verify.json index 835cd556e241..52037e24e008 100644 --- a/.vib/nginx/vib-verify.json +++ b/.vib/nginx/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": "nginx/goss/goss.yaml", + "vars_file": "nginx/goss/vars.yaml", + "remote": { + "pod": { + "workload": "deploy-nginx" + } + } + } + }, { "action_id": "trivy", "params": { @@ -50,4 +66,4 @@ ] } } -} \ No newline at end of file +}