Initial set of gating tests for grafana on Fedora

This commit is contained in:
Jan Kurik 2021-02-03 19:58:40 +01:00
parent 7dbccd67bd
commit a59fc24268
12 changed files with 304 additions and 0 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

19
gating.yaml Normal file
View File

@ -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}

6
plans/ci.fmf Normal file
View File

@ -0,0 +1,6 @@
summary: CI Gating Plan
discover:
how: fmf
directory: tests
execute:
how: beakerlib

View File

@ -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 <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jkurik@redhat.com>" > $(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)

View File

@ -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 <jkurik@redhat.com>

View File

@ -0,0 +1,14 @@
summary: Installation of grafana package and a check if grafana server runs
description: ''
contact:
- Jan Kuřík <jkurik@redhat.com>
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

View File

@ -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 <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

2
tests/README Normal file
View File

@ -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.

View File

@ -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 <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jkurik@redhat.com>" > $(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)

View File

@ -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 <jkurik@redhat.com>
Bug summary: grafana-cli crashes when run from root's home directory
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1916083

View File

@ -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 <jkurik@redhat.com>
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

View File

@ -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 <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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