diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..ce3cdc1 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,19 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 0000000..1ad2c12 --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,6 @@ +summary: CI Gating Plan +discover: + how: fmf + directory: tests +execute: + how: beakerlib diff --git a/tests/Install/Install-test-of-grafana-package/Makefile b/tests/Install/Install-test-of-grafana-package/Makefile new file mode 100644 index 0000000..6389ba6 --- /dev/null +++ b/tests/Install/Install-test-of-grafana-package/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/grafana/Install/Install-test-of-grafana-package +# Description: Installation of grafana package and a check if grafana server runs +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# 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 2 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 http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/grafana/Install/Install-test-of-grafana-package +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jan Kuřík " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Installation of grafana package and a check if grafana server runs" >> $(METADATA) + @echo "Type: Install" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: grafana" >> $(METADATA) + @echo "Requires: grafana curl" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHEL6 -RHEL7 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Install/Install-test-of-grafana-package/PURPOSE b/tests/Install/Install-test-of-grafana-package/PURPOSE new file mode 100644 index 0000000..1986e1e --- /dev/null +++ b/tests/Install/Install-test-of-grafana-package/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/grafana/Install/Install-test-of-grafana-package +Description: Installation of grafana package and a check if grafana server runs +Author: Jan Kuřík diff --git a/tests/Install/Install-test-of-grafana-package/main.fmf b/tests/Install/Install-test-of-grafana-package/main.fmf new file mode 100644 index 0000000..b270115 --- /dev/null +++ b/tests/Install/Install-test-of-grafana-package/main.fmf @@ -0,0 +1,14 @@ +summary: Installation of grafana package and a check if grafana server runs +description: '' +contact: +- Jan Kuřík +component: +- grafana +test: ./runtest.sh +framework: beakerlib +recommend: +- grafana +- curl +duration: 15m +extra-summary: /tools/grafana/Install/Install-test-of-grafana-package +extra-task: /tools/grafana/Install/Install-test-of-grafana-package diff --git a/tests/Install/Install-test-of-grafana-package/runtest.sh b/tests/Install/Install-test-of-grafana-package/runtest.sh new file mode 100755 index 0000000..6d029ba --- /dev/null +++ b/tests/Install/Install-test-of-grafana-package/runtest.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/grafana/Install/Install-test-of-grafana-package +# Description: Installation of grafana package and a check if grafana server runs +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# 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 2 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 http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="grafana" + +rlJournalStart + rlPhaseStartTest + rlAssertRpm $PACKAGE || \ + { rlFail "$PACKAGE is not installed"; rlDie "Giving up"; } + rlServiceStart grafana-server + + HTTP_CODE="000" + RETRIES=12 + while [[ "${HTTP_CODE}" == "000" ]]; do + rlRun -s "curl -X GET -s -w \"\\n%{http_code}\\n\" \ + http://localhost:3000/login" \ + 0-255 "Checking if Grafana is alive and responding" + HTTP_CODE=$(tail -n 1 ${rlRun_LOG}) + if [[ "${HTTP_CODE}" == "000" ]]; then + ((RETRIES--)) + if [[ ${RETRIES} -eq 0 ]]; then + rlFail "Retry limit has been reached" + break + fi + else + rlAssertEquals "Response code should be 200" "${HTTP_CODE}" "200" + break + fi + rlRun "sleep 10" 0 "Give grafana more time to start" + done + rlPhaseEnd + + rlPhaseStartCleanup + rlServiceRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..9ad59d4 --- /dev/null +++ b/tests/README @@ -0,0 +1,2 @@ +The test's Makefiles are not used in Fedora CI infrastructure. But are kept here +for backward compatibility with traditional beakerlib test harness in RHEL. diff --git a/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/Makefile b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/Makefile new file mode 100644 index 0000000..42a6485 --- /dev/null +++ b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/grafana/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home +# Description: Test for BZ#1916083 (grafana-cli crashes when run from root's home) +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# 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 2 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 http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/grafana/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jan Kuřík " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Test for BZ#1916083 (grafana-cli crashes when run from root's home)" >> $(METADATA) + @echo "Type: Regression" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: grafana" >> $(METADATA) + @echo "Requires: grafana" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1916083" >> $(METADATA) + @echo "Releases: -RHEL4 -RHEL6 -RHEL7 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/PURPOSE b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/PURPOSE new file mode 100644 index 0000000..a53e064 --- /dev/null +++ b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /tools/grafana/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home +Description: Test for BZ#1916083 (grafana-cli crashes when run from root's home) +Author: Jan Kuřík +Bug summary: grafana-cli crashes when run from root's home directory +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1916083 diff --git a/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/main.fmf b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/main.fmf new file mode 100644 index 0000000..9a0846d --- /dev/null +++ b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/main.fmf @@ -0,0 +1,15 @@ +summary: Test for BZ#1916083 (grafana-cli crashes when run from root's home) +description: | + Bug summary: grafana-cli crashes when run from root's home directory + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1916083 +contact: +- Jan Kuřík +component: +- grafana +test: ./runtest.sh +framework: beakerlib +recommend: +- grafana +duration: 15m +extra-summary: /tools/grafana/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home +extra-task: /tools/grafana/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home diff --git a/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/runtest.sh b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/runtest.sh new file mode 100755 index 0000000..b739cec --- /dev/null +++ b/tests/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home/runtest.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/grafana/Regression/bz1916083-grafana-cli-crashes-when-run-from-root-s-home +# Description: Test for BZ#1916083 (grafana-cli crashes when run from root's home) +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2021 Red Hat, Inc. +# +# 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 2 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 http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="grafana" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "pushd ~root" + rlPhaseEnd + + rlPhaseStartTest + rlRun "grafana-cli plugins ls" 0 \ + "This should not crash when CWD is in inaccessible directory for grafana user" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd