Transfer of tests to tests/grafana repo

This commit is contained in:
Jan Kurik 2023-08-09 11:26:34 +02:00
parent ba32fdafe7
commit 1818ba3ad8
17 changed files with 1 additions and 530 deletions

View File

@ -2,5 +2,6 @@ summary: CI Gating Plan
discover:
how: fmf
filter: tag:gating
url: https://src.fedoraproject.org/tests/grafana
execute:
how: tmt

View File

@ -1,63 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

@ -1,3 +0,0 @@
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

@ -1,16 +0,0 @@
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
tag:
- gating

View File

@ -1,64 +0,0 @@
#!/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

View File

@ -1,2 +0,0 @@
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

@ -1,64 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

@ -1,5 +0,0 @@
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

@ -1,14 +0,0 @@
summary: Test for BZ#1916083 (grafana-cli crashes when run from root's home)
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
tag:
- gating

View File

@ -1,48 +0,0 @@
#!/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

View File

@ -1,30 +0,0 @@
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled = 0
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/debug/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1

View File

@ -1,16 +0,0 @@
summary: Chek for used licenses in packages
test: ./test.sh
link:
- relates: https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_1
- relates: https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_2
framework: beakerlib
component:
- grafana
contact: Jan Kuřík <jkurik@redhat.com>
recommend:
- grafana
- rpm-build
- license-validate
duration: 15m
tag:
- gating

View File

@ -1,67 +0,0 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE=grafana
TCWD="$(pwd)"
rlJournalStart
rlPhaseStartSetup
rlRun "tmp=\$(mktemp -d /var/tmp/XXXXXXXXXXXXXX)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlRun "set -o pipefail"
# Ensure we have license tools available
EPELREPO=
if ! which license-fedora2spdx &>/dev/null; then
YUMPARAM=
if rlIsRHEL || rlIsCentOS; then
EPELREPO="/etc/yum.repos.d/$(basename ${tmp})"
rlRun "cp ${TCWD}/epel.repo ${EPELREPO}"
YUMPARAM="--enablerepo=epel"
else
rlDie "Can not find license-validate tool"
fi
rlRun "yum install -y ${YUMPARAM} license-validate" \
|| rlDie "Failed to install license-validate tool"
fi
# Get list of rpms
rlFetchSrcForInstalled --quiet "${PACKAGE}" || \
rlDie 'Can not get source package of ${PACKAGE} .... giving up...'
SOURCEPKG=$(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE})
rlAssertExists "${tmp}/${SOURCEPKG}"
rlRun "rpm -D '_topdir ${tmp}' -i ${tmp}/${SOURCEPKG}"
rlRun "LICENSES=\"\$(rpm -q --qf '%{license}\n' --specfile ${tmp}/SPECS/${PACKAGE}.spec\
| sed -e 's/ and /\\n/g' -e 's/^ *//' -e 's/ *$//')\""
rlRun "TUPLE=\"\$(rpm -q --qf '%{name} %{license}\n' \
--specfile ${tmp}/SPECS/${PACKAGE}.spec )\""
rlPhaseEnd
while read l; do
rlPhaseStart FAIL "License check of ${l}"
retcode=
rlRun -s "license-validate '${l}'" || retcode=Fail
#rlAssertNotGrep 'Warning: ' "${rlRun_LOG}" \
# || { rlLogInfo "$(cat ${rlRun_LOG})"; retcode="warn"; }
#rlAssertEquals "Check if the package license is SPDX identifier" \
# "${l}" "$(cat ${rlRun_LOG})" || retcode="fail"
# Report affected packages
if [[ -n "${retcode}" ]]; then
rlLogInfo "The following packages needs to fix the ${l} license:"
#for p in $(awk "\$0~/${l}/{print \$1;}" <<< "${TUPLE}"); do
for p in $(grep "${l}" <<< "${TUPLE}" | cut -d ' ' -f 1); do
rlLogInfo " - ${p}"
done
fi
rlPhaseEnd
done < <(sort -u <<< "${LICENSES}")
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlRun "yum clean metadata"
[[ -n "${EPELREPO}" ]] && rlRun "rm -f ${EPELREPO}"
rlPhaseEnd
rlJournalEnd

View File

@ -1,63 +0,0 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/grafana/Sanity/verify-systemd-units
# Description: Verification of systemd unit files
# Author: Jan Kuřík <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2020 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/Sanity/verify-systemd-units
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: Verification of systemd unit files" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(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 "Releases: -RHEL7 -RHEL4 -RHEL6 -RHELClient5 -RHELServer5" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -1,3 +0,0 @@
PURPOSE of /tools/grafana/Sanity/verify-systemd-units
Description: Verification of systemd unit files
Author: Jan Kuřík <jkurik@redhat.com>

View File

@ -1,13 +0,0 @@
summary: Verification of systemd unit files
contact: Jan Kuřík <jkurik@redhat.com>
component:
- grafana
test: ./runtest.sh
framework: beakerlib
recommend:
- grafana
duration: 5m
extra-summary: /tools/grafana/Sanity/verify-systemd-units
extra-task: /tools/grafana/Sanity/verify-systemd-units
tag:
- gating

View File

@ -1,59 +0,0 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/grafana/Sanity/verify-systemd-units
# Description: Verification of systemd unit files
# Author: Jan Kuřík <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2020 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"
PKGS="grafana"
UNITS=""
rlJournalStart
rlPhaseStartSetup
for P in ${PKGS}; do
rlAssertRpm "${P}"
done
# Generate list of unit files
UNITS="$(rpm -ql ${PKGS} | grep /usr/lib/systemd/system/)"
rlLog "Available unit files: ${UNITS}"
rlPhaseEnd
rlPhaseStartTest
FAILEDU=""
for U in ${UNITS}; do
if ! rlRun -s "systemd-analyze verify ${U}"; then
rlFail "Error in ${U}: $(cat ${rlRun_LOG})"
FAILEDU="${FAILEDU} $(basename ${U})"
fi
done
[[ -n "${FAILEDU}" ]] && rlLog "List of failed units: ${FAILEDU}"
rlPhaseEnd
rlPhaseStartCleanup
rlPhaseEnd
rlJournalPrintText
rlJournalEnd