From 0e9277b6ce4c737e510267996c5d1daa95dbb717 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Aug 18 2020 20:55:25 +0000 Subject: [PATCH 1/5] Convert tests to FMF using tmt also create fmf metadata. --- 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/main.fmf b/main.fmf index d8dccdd..54b0796 100644 --- a/main.fmf +++ b/main.fmf @@ -1,9 +1,3 @@ contact: Vít Ondruch test: runtest.sh category: integration - -/run-basic-rails-application: - component: rubygem-rails - -/systemtap-static-probes-in-ruby: - component: systemtap diff --git a/run-basic-rails-application/main.fmf b/run-basic-rails-application/main.fmf new file mode 100644 index 0000000..2dea690 --- /dev/null +++ b/run-basic-rails-application/main.fmf @@ -0,0 +1,19 @@ +summary: Test creates new rails application in collection and runs it +description: | + Test ensure it is possible to create new rails application and run it. +component: +- rubygem-rails +- ruby +recommend: +- rubygems +- rubygem-rails +- ruby-devel +- sqlite-devel +- libxml2-devel +- libxslt-devel +- gcc-c++ +- net-tools +- procps-ng +- psmisc +duration: 60m +extra-task: /CoreOS/rubygem-rails/run-basic-rails-application diff --git a/systemtap-static-probes-in-ruby/main.fmf b/systemtap-static-probes-in-ruby/main.fmf new file mode 100644 index 0000000..0a17723 --- /dev/null +++ b/systemtap-static-probes-in-ruby/main.fmf @@ -0,0 +1,14 @@ +summary: It tests there are static probes in ruby package. +description: | + Simple test to exercise ruby's systemtap API. +component: +- ruby +recommend: +- ruby +- ruby-doc +- ruby-libs +- systemtap +- grep +- procps-ng +duration: 5m +extra-task: /CoreOS/ruby/Regression/systemtap-static-probes-in-ruby From 3af87f3776bb9d1866d0e0781405b42f044d5845 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Aug 18 2020 20:55:40 +0000 Subject: [PATCH 2/5] Fix rails and systemtap tests - dependencies - kernel install for systemtap test --- diff --git a/main.fmf b/main.fmf index 54b0796..c4b253c 100644 --- a/main.fmf +++ b/main.fmf @@ -1,3 +1,3 @@ contact: Vít Ondruch -test: runtest.sh +test: ./runtest.sh category: integration diff --git a/run-basic-rails-application/main.fmf b/run-basic-rails-application/main.fmf index 2dea690..d2f7c55 100644 --- a/run-basic-rails-application/main.fmf +++ b/run-basic-rails-application/main.fmf @@ -7,6 +7,13 @@ component: recommend: - rubygems - rubygem-rails +- rubygem-nokogiri +- rubygem-sqlite3 +- rubygem-sass-rails +- rubygem-puma +- rubygem-jbuilder +- rubygem-byebug +- rubygem-web-console - ruby-devel - sqlite-devel - libxml2-devel @@ -15,5 +22,6 @@ recommend: - net-tools - procps-ng - psmisc +- wget duration: 60m extra-task: /CoreOS/rubygem-rails/run-basic-rails-application diff --git a/run-basic-rails-application/runtest.sh b/run-basic-rails-application/runtest.sh index 6774bed..686c059 100755 --- a/run-basic-rails-application/runtest.sh +++ b/run-basic-rails-application/runtest.sh @@ -65,24 +65,21 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest - rlRun "rails new app | tee bundle.log" 0 "Creating new rails application" + rlRun "rails new app --skip-bundle --skip-spring --skip-test --skip-bootsnap --skip-webpacker --skip-javascript -f | tee bundle.log" 0 "Creating new rails application" [ ! -z "$COLLECTIONS" ] && rlAssertGrep "bundle install --local" bundle.log || rlAssertNotGrep "bundle install --local" bundle.log rlRun "pushd app/" rlAssertExists "app" - if [[ ! "$COLLECTIONS" =~ "rh-ror50" ]] + if [ -z "$COLLECTIONS" ] && rlIsRHEL '<=7' then - rlRun "echo \"gem 'therubyracer'\" >> Gemfile" 0 "Adding therubyracer gem into Gemfile" - rlRun "bundle install" + rlRun "bundle install --local" fi - if [ -z "$COLLECTIONS" ] && rlIsRHEL '<=7' + if rlIsFedora then - rlRun "echo \"gem 'nokogiri', '1.6.8'\" >> Gemfile" 0 "Adding nokogiri gem into Gemfile" - sed -i "s/gem 'spring'/#gem 'spring'/" Gemfile - rlRun "gem pristine nokogiri" 0 "Restore installed nokogiri to pristine condition" - rlRun "bundle config build.nokogiri --use-system-libraries" 0 "Build nokogiri with system libraries" - rlRun "bundle install" + rlRun "sed -i \"s/\(gem..puma.\).*/\1/\" Gemfile" 0 'Relaxing puma dependency' + rlRun "sed -i \"s/\(gem..listen.\).*/\1/\" Gemfile" 0 'Relaxing listen dependency' + rlRun "bundle install --local --without development test" fi rlRun "netstat -tulpn | grep 3000" 1 "Check if port 3000 isn't engaged" rlRun "rails server &" 0 "Running rails server" diff --git a/systemtap-static-probes-in-ruby/runtest.sh b/systemtap-static-probes-in-ruby/runtest.sh index 2eee65d..9f3ba59 100755 --- a/systemtap-static-probes-in-ruby/runtest.sh +++ b/systemtap-static-probes-in-ruby/runtest.sh @@ -41,10 +41,25 @@ RUBY=${RUBY:-ruby} _STAP_FILE="`rpm -ql $PACKAGES | grep 'ruby-exercise.stp' 2>/dev/null`" _LOG_FILE="ruby.log" _STAP_OUT="stap-out.log" +_KERNEL_DEVEL="kernel-devel-`uname -r`" # for ruby on RHEL7 and in collections PRINT="Kernel::printf" +_run_stap () { + local t="${1:-2}" + rlRun "( timeout $t stap -v ${_STAP_FILE} -o ${_LOG_FILE} 1>&2 2>${_STAP_OUT} & )" 0 "Running systemtap in background" + sleep 1 + # wait for systemtap to start + rlWaitForCmd "grep 'starting run' ${_STAP_OUT}" +} + +_log_file () { + sleep 1 + echo -e "---${_LOG_FILE}--" + grep ' -e:1$' ${_LOG_FILE} +} + rlJournalStart rlPhaseStartSetup rlAssertRpm --all @@ -54,6 +69,9 @@ rlJournalStart rlRun "pushd ${TmpDir}" _LOG_FILE="${TmpDir}/${_LOG_FILE}" touch ${_LOG_FILE} + if rlIsRHEL '>=8' || rlIsFedora; then + rlRun "rpm -q '$_KERNEL_DEVEL' || dnf install -y '$_KERNEL_DEVEL'" 0 'Installing corresponding kernel-devel: $_KERNEL_DEVEL' + fi rlPhaseEnd rlPhaseStartTest @@ -61,45 +79,50 @@ rlJournalStart rlRun "rpm -ql $PACKAGES | grep 'stp' | grep 'tapset'" 0 "Checking tapset file" rlRun "rpm -ql $PACKAGES | grep 'stp' | grep 'doc'" 0 "Checking doc file" - rlRun "{ stap -v ${_STAP_FILE} -o ${_LOG_FILE} |& tee ${_STAP_OUT}; } &" 0 "Running systemtap in background" - _STAP_PID=$! - echo -e "--_STAP_PID--\n${_STAP_PID}" # info + # stap takes long time to start for the first time + _run_stap 60 + rlRun "grep -q 'starting run' ${_STAP_OUT}" 0 "Checking stap output." + _log_file - # wait for systemtap to start - rlWaitForCmd "grep 'starting run' ${_STAP_OUT}" + if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ] + then + _run_stap + rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test" + _log_file + rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test" + # for ruby on RHEL6 + PRINT="Object::printf" + fi - rlRun "$RUBY -e '1.0 + 9.0'" 0 "Running ruby interpreter: Float test" + _run_stap rlRun "$RUBY -e '[1, 2, 3].push(4)'" 0 "Running ruby interpreter: Array test" + _log_file + rlRun "grep -q 'Array::push -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Array test" + + _run_stap rlRun "$RUBY -e '(1..10).step(1)'" 0 "Running ruby interpreter: Range test" + _log_file + rlRun "grep -q 'Range::step -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Range test" + + _run_stap rlRun "$RUBY -e 'Hash.new()'" 0 "Running ruby interpreter: Hash test" - rlRun "$RUBY -e '\"abc\".slice!(\"c\")'" 0 "Running ruby interpreter: String test" - rlRun "$RUBY -e '5.times { printf \"Ruby!\n\" }'" 0 "Running ruby interpreter: Cycle and print test" + _log_file + rlRun "grep -q 'Hash::initialize -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Hash test" - # wait for all output - rlRun "sleep 10" 0 "Waiting \"10\" seconds" + _run_stap + rlRun "$RUBY -e '\"abc\".slice!(\"c\")'" 0 "Running ruby interpreter: String test" + _log_file + rlRun "grep -q 'String::slice! -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: String test" - rlRun "kill ${_STAP_PID}" 0 "Terminating stap" - sleep 1 # No Operation + _run_stap + rlRun "$RUBY -e '5.times { printf \"Ruby!\n\" }'" 0 "Running ruby interpreter: Cycle and print test" + _log_file + rlRun "grep -q 'Integer::times -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - iteration number" + rlRun "grep -q '$PRINT -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - printf function" + rlRun "grep -q 'IO::write -e:1$' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - IO write" - echo -e "---ps-out--" && ps -e | grep stap # info - rlRun "kill -s SIGKILL ${_STAP_PID}" 0,1 "Attempt killing stap" rlRun "pkill stapio" 0,1 "Attempt killing all leftover stapios" echo -e "---ps-out--" && ps -e | grep stap # info - - echo -e "---${_LOG_FILE}--" && cat ${_LOG_FILE} # info - if rlIsRHEL '<7' && [ -z "$COLLECTIONS" ] - then - rlRun "grep -q 'Float::+' ${_LOG_FILE}" 0 "Checking systemtap log: Float test" - # for ruby on RHEL6 - PRINT="Object::printf" - fi - rlRun "grep -q 'Array::push' ${_LOG_FILE}" 0 "Checking systemtap log: Array test" - rlRun "grep -q 'Range::step' ${_LOG_FILE}" 0 "Checking systemtap log: Range test" - rlRun "grep -q 'Hash::initialize' ${_LOG_FILE}" 0 "Checking systemtap log: Hash test" - rlRun "grep -q 'String::slice!' ${_LOG_FILE}" 0 "Checking systemtap log: String test" - rlRun "grep -q 'Integer::times' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - iteration number" - rlRun "grep -q '$PRINT' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - printf function" - rlRun "grep -q 'IO::write' ${_LOG_FILE}" 0 "Checking systemtap log: Cycle and print test - IO write" rlPhaseEnd rlPhaseStartCleanup From 32f750b2f542c2f5a61a9677cfccc4b3963b5a83 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Aug 18 2020 20:55:40 +0000 Subject: [PATCH 3/5] Upgrade for Ruby on Rails 6. --- diff --git a/run-basic-rails-application/main.fmf b/run-basic-rails-application/main.fmf index d2f7c55..ccdb80c 100644 --- a/run-basic-rails-application/main.fmf +++ b/run-basic-rails-application/main.fmf @@ -14,6 +14,7 @@ recommend: - rubygem-jbuilder - rubygem-byebug - rubygem-web-console +- rubygem-listen - ruby-devel - sqlite-devel - libxml2-devel diff --git a/run-basic-rails-application/runtest.sh b/run-basic-rails-application/runtest.sh index 686c059..2dd158b 100755 --- a/run-basic-rails-application/runtest.sh +++ b/run-basic-rails-application/runtest.sh @@ -77,9 +77,13 @@ rlJournalStart if rlIsFedora then - rlRun "sed -i \"s/\(gem..puma.\).*/\1/\" Gemfile" 0 'Relaxing puma dependency' - rlRun "sed -i \"s/\(gem..listen.\).*/\1/\" Gemfile" 0 'Relaxing listen dependency' - rlRun "bundle install --local --without development test" + rlRun "sed -i \"s/\(gem .puma.\).*/\1/\" Gemfile" 0 'Relax puma dependency' + rlRun "sed -i \"s/\(gem .listen.\).*/\1/\" Gemfile" 0 'Relax listen dependency' + rlRun "sed -i \"/gem .sass-rails./ s/^/#/\" Gemfile" 0 'Drop sass-rails dependency' + + rlRun "bundle config set without test" 0 "Set bundle config(1)" + rlRun "bundle config set deployment false" 0 "Set bundle config(2)" + rlRun "bundle install --local" 0 "Bundle dependencies locally" fi rlRun "netstat -tulpn | grep 3000" 1 "Check if port 3000 isn't engaged" rlRun "rails server &" 0 "Running rails server" From 8b697b11f81c0f190f7ebac0442f23adac466589 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Nov 18 2020 14:42:16 +0000 Subject: [PATCH 4/5] Fixup --- diff --git a/main.fmf b/main.fmf index c4b253c..733aeda 100644 --- a/main.fmf +++ b/main.fmf @@ -1,3 +1,4 @@ contact: Vít Ondruch test: ./runtest.sh category: integration +how: beakerlib diff --git a/systemtap-static-probes-in-ruby/main.fmf b/systemtap-static-probes-in-ruby/main.fmf index 0a17723..4a5cdff 100644 --- a/systemtap-static-probes-in-ruby/main.fmf +++ b/systemtap-static-probes-in-ruby/main.fmf @@ -3,6 +3,8 @@ description: | Simple test to exercise ruby's systemtap API. component: - ruby +require: +- /usr/share/doc/ruby-doc/ruby-exercise.stp recommend: - ruby - ruby-doc From 85bd479c96cc5bbfeb8a305eb8a7139fc5902b75 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Nov 18 2020 14:42:24 +0000 Subject: [PATCH 5/5] Cleanup --- diff --git a/run-basic-rails-application/Makefile b/run-basic-rails-application/Makefile deleted file mode 100644 index 5de7f8f..0000000 --- a/run-basic-rails-application/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Makefile of /CoreOS/rubygem-rails/run-basic-rails-application -# Description: Test creates new rails application and runs it -# Author: Iveta Senfeldova -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2012 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing -# to use, modify, copy, or redistribute it subject to the terms -# and conditions of the GNU General Public License version 2. -# -# 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, write to the Free -# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -export TEST=/CoreOS/rubygem-rails/run-basic-rails-application -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: Iveta Senfeldova " > $(METADATA) - @echo "Name: $(TEST)" >> $(METADATA) - @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) - @echo "Path: $(TEST_DIR)" >> $(METADATA) - @echo "Description: Test creates new rails application in collection and runs it" >> $(METADATA) - @echo "Type: Sanity" >> $(METADATA) - @echo "TestTime: 60m" >> $(METADATA) - @echo "RunFor: rubygem-rails ruby" >> $(METADATA) - @echo "Requires: rubygems rubygem-rails ruby-devel sqlite-devel libxml2-devel libxslt-devel gcc-c++ net-tools procps-ng psmisc" >> $(METADATA) - @echo "Priority: Normal" >> $(METADATA) - @echo "License: GPLv2" >> $(METADATA) - @echo "Confidential: no" >> $(METADATA) - @echo "Destructive: no" >> $(METADATA) - @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) - - rhts-lint $(METADATA) diff --git a/systemtap-static-probes-in-ruby/Makefile b/systemtap-static-probes-in-ruby/Makefile deleted file mode 100644 index 011d562..0000000 --- a/systemtap-static-probes-in-ruby/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Makefile of /CoreOS/ruby/Regression/systemtap-static-probes-in-ruby -# Description: It tests there are static probes in ruby package. -# Author: Ales Marecek -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2011 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing -# to use, modify, copy, or redistribute it subject to the terms -# and conditions of the GNU General Public License version 2. -# -# 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, write to the Free -# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -export TEST=/CoreOS/ruby/Regression/systemtap-static-probes-in-ruby -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) - chmod a+x runtest.sh - -clean: - rm -f *~ $(BUILT_FILES) - - --include /usr/share/rhts/lib/rhts-make.include - -$(METADATA): Makefile - @echo "Owner: Iveta Senfeldova " > $(METADATA) - @echo "Name: $(TEST)" >> $(METADATA) - @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) - @echo "Path: $(TEST_DIR)" >> $(METADATA) - @echo "Description: It tests there are static probes in ruby package." >> $(METADATA) - @echo "Type: Regression" >> $(METADATA) - @echo "TestTime: 5m" >> $(METADATA) - @echo "RunFor: ruby" >> $(METADATA) - @echo "Requires: ruby ruby-doc ruby-libs systemtap grep procps-ng" >> $(METADATA) - @echo "Releases: RHEL6" >> $(METADATA) - @echo "Priority: Normal" >> $(METADATA) - @echo "License: GPLv2" >> $(METADATA) - @echo "Confidential: no" >> $(METADATA) - @echo "Destructive: no" >> $(METADATA) - @echo "Bug: 673162" >> $(METADATA) - - rhts-lint $(METADATA)