From 4f96f4feaf772c941dd3f8a7fb97f9afec4c4395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Iranzo=20G=C3=B3mez?= Date: Mon, 13 Jun 2022 10:06:29 +0200 Subject: [PATCH] feat(validations): Attempt to add validations --- .github/workflows/risu.txt | 32 +++++++++++++++ .risu.conf | 1 + test-requirements.txt | 1 + validations/build.sh | 1 + validations/core/openshift/acm/agents.sh | 40 +++++++++++++++++++ .../core/openshift/acm/managedcluster.sh | 40 +++++++++++++++++++ validations/core/openshift/pendingcsr.sh | 40 +++++++++++++++++++ validations/core/openshift/poderrors.sh | 40 +++++++++++++++++++ validations/profiles/ZTPFW-validations.txt | 12 ++++++ validations/test/.placeholder | 0 website/validations/.placeholder | 0 11 files changed, 207 insertions(+) create mode 100644 .github/workflows/risu.txt create mode 100644 .risu.conf create mode 100644 validations/build.sh create mode 100755 validations/core/openshift/acm/agents.sh create mode 100755 validations/core/openshift/acm/managedcluster.sh create mode 100755 validations/core/openshift/pendingcsr.sh create mode 100755 validations/core/openshift/poderrors.sh create mode 100644 validations/profiles/ZTPFW-validations.txt create mode 100644 validations/test/.placeholder create mode 100644 website/validations/.placeholder diff --git a/.github/workflows/risu.txt b/.github/workflows/risu.txt new file mode 100644 index 000000000..ad3c70e35 --- /dev/null +++ b/.github/workflows/risu.txt @@ -0,0 +1,32 @@ +# TODO: This should be added to the main pipeline launch to validate the final deployment and upload the report + +# name: Run Risu analysis + +# on: +# push: +# # branches: +# # - main +# # schedule: +# # - cron: '0 0 * * *' + +# jobs: +# risu: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2.3.4 + +# # Use GitHub Actions' cache to shorten build times and decrease load on servers +# - uses: actions/cache@v2.1.6 +# with: +# path: ~/.cache/pip +# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements/*') }} +# restore-keys: | +# ${{ runner.os }}-pip- + +# - uses: risuorg/gh-action-risu@1.2.0 +# env: +# GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} +# SOSREPORT: ./validations/test +# CONFIGPATH: "./" +# RUNFILE: "./validations/build.sh" +# GH_PAGES_BRANCH: validation-results diff --git a/.risu.conf b/.risu.conf new file mode 100644 index 000000000..6c33b099b --- /dev/null +++ b/.risu.conf @@ -0,0 +1 @@ +{"output": "website/validations/risu.json", "web": true, "exclude": ["risuclient"], "extraplugintree": "validations/", "title": "Deployment Validations"} diff --git a/test-requirements.txt b/test-requirements.txt index 416634f52..a91da5773 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,2 @@ pre-commit +risu diff --git a/validations/build.sh b/validations/build.sh new file mode 100644 index 000000000..a9bf588e2 --- /dev/null +++ b/validations/build.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/validations/core/openshift/acm/agents.sh b/validations/core/openshift/acm/agents.sh new file mode 100755 index 000000000..562e2823e --- /dev/null +++ b/validations/core/openshift/acm/agents.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright (C) 2022 Pablo Iranzo Gómez +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# long_name: Checks if agents (ACI) have finished +# description: Checks agents cluster +# priority: 900 +# bugzilla: + +# Load common functions +[[ -f "${RISU_BASE}/common-functions.sh" ]] && . "${RISU_BASE}/common-functions.sh" + +FILE="${KUBECONFIG}" +is_mandatory_file ${FILE} + +is_required_command oc + +COUNT=$(oc get agents -A --no-headers | grep -v Done | wc -l) +DETAIL=$(oc get agents -A --no-headers | grep -v Done) +WHAT="Agents pending" + +if [ "${COUNT}" == 0 ]; then + # Nothing found + exit ${RC_OKAY} +else + echo -e "${WHAT} found:\n ${DETAIL}" >&2 + exit ${RC_FAILED} +fi diff --git a/validations/core/openshift/acm/managedcluster.sh b/validations/core/openshift/acm/managedcluster.sh new file mode 100755 index 000000000..7169b46ca --- /dev/null +++ b/validations/core/openshift/acm/managedcluster.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright (C) 2022 Pablo Iranzo Gómez +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# long_name: Checks if managed cluster has been detached +# description: Checks managed cluster +# priority: 900 +# bugzilla: + +# Load common functions +[[ -f "${RISU_BASE}/common-functions.sh" ]] && . "${RISU_BASE}/common-functions.sh" + +FILE="${KUBECONFIG}" +is_mandatory_file ${FILE} + +is_required_command oc + +COUNT=$(oc get managedcluster --no-headers | grep -v local-cluster | wc -l) +DETAIL=$(oc get managedcluster --no-headers | grep -v local-cluster) +WHAT="Undetached managedclusters" + +if [ "${COUNT}" == 0 ]; then + # Nothing found + exit ${RC_OKAY} +else + echo -e "${WHAT} found:\n ${DETAIL}" >&2 + exit ${RC_FAILED} +fi diff --git a/validations/core/openshift/pendingcsr.sh b/validations/core/openshift/pendingcsr.sh new file mode 100755 index 000000000..5b7735d8f --- /dev/null +++ b/validations/core/openshift/pendingcsr.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright (C) 2022 Pablo Iranzo Gómez +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# long_name: Checks if there are pending CSRs +# description: Checks pending CSRs +# priority: 900 +# bugzilla: + +# Load common functions +[[ -f "${RISU_BASE}/common-functions.sh" ]] && . "${RISU_BASE}/common-functions.sh" + +FILE="${KUBECONFIG}" +is_mandatory_file ${FILE} + +is_required_command oc + +COUNT=$(oc get csr -A --no-headers | grep -v Approved | wc -l) +DETAIL=$(oc get csr -A --no-headers | grep -v Approved) +WHAT="Pending CSR" + +if [ "${COUNT}" == 0 ]; then + # Nothing found + exit ${RC_OKAY} +else + echo -e "${WHAT} found:\n ${DETAIL}" >&2 + exit ${RC_FAILED} +fi diff --git a/validations/core/openshift/poderrors.sh b/validations/core/openshift/poderrors.sh new file mode 100755 index 000000000..e0b67bbed --- /dev/null +++ b/validations/core/openshift/poderrors.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright (C) 2022 Pablo Iranzo Gómez +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# long_name: Checks if there are pods in error +# description: Checks pods not running nor complete +# priority: 900 +# bugzilla: + +# Load common functions +[[ -f "${RISU_BASE}/common-functions.sh" ]] && . "${RISU_BASE}/common-functions.sh" + +FILE="${KUBECONFIG}" +is_mandatory_file ${FILE} + +is_required_command oc + +COUNT=$(oc get pods -A --no-headers | grep -v Running | grep -v Compl | wc -l) +DETAIL=$(oc get pods -A --no-headers | grep -v Running | grep -v Compl) +WHAT="Failed pods" + +if [ "${COUNT}" == 0 ]; then + # Nothing found + exit ${RC_OKAY} +else + echo -e "${WHAT} found:\n ${DETAIL}" >&2 + exit ${RC_FAILED} +fi diff --git a/validations/profiles/ZTPFW-validations.txt b/validations/profiles/ZTPFW-validations.txt new file mode 100644 index 000000000..535797ff1 --- /dev/null +++ b/validations/profiles/ZTPFW-validations.txt @@ -0,0 +1,12 @@ +# Author: Pablo Iranzo Gómez (Pablo.Iranzo@redhat.com) + +# Copyright (C) 2020 Pablo Iranzo Gómez +# description: Checks ZTPFW Validations results +# long_name: ZTPFW Validations +# +# Defines which plugins to include, exclude, etc +# Syntax +# +keyword : includes keyword in plugin search +# -keyword : excludes keyword in plugin search + ++validations diff --git a/validations/test/.placeholder b/validations/test/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/website/validations/.placeholder b/website/validations/.placeholder new file mode 100644 index 000000000..e69de29bb