From 6e021788e1befe654a2b3e1740c52a69717acfd8 Mon Sep 17 00:00:00 2001 From: Tomas Juhasz Date: Wed, 8 Jan 2025 12:49:33 +0100 Subject: [PATCH] rewritte of test --- Integration/expressjs-testsuite/main.fmf | 7 - Integration/fs-module/main.fmf | 14 ++ Integration/fs-module/runtest.sh | 22 ++++ Integration/fs-module/script.js | 41 ++++++ .../npm-integration-global-install/main.fmf | 12 ++ .../npm-integration-global-install/runtest.sh | 120 ++++++++++++++++++ README.md | 22 ++++ Sanity/express-testsuite/main.fmf | 10 -- Sanity/express-testsuite/runtest.sh | 62 --------- Sanity/http-smoke/main.fmf | 7 - Sanity/http-smoke/runtest.sh | 97 -------------- Sanity/http-smoke/server.js | 18 --- Sanity/install-expo/main.fmf | 10 -- Sanity/install-expo/runtest.sh | 50 -------- Sanity/nodejs-smoke/main.fmf | 4 - Sanity/nodejs-smoke/runtest.sh | 44 ------- Sanity/npm-install/main.fmf | 11 -- Sanity/npm-install/runtest.sh | 56 -------- Sanity/npm-smoke/main.fmf | 13 -- Sanity/npm-unit-tests/main.fmf | 11 -- Sanity/npm-unit-tests/runtest.sh | 72 ----------- Sanity/run-basic-js-script/main.fmf | 4 - Sanity/run-basic-js-script/runtest.sh | 54 -------- Sanity/smoke/main.fmf | 10 -- Sanity/smoke/runtest.sh | 98 -------------- Sanity/smoke/server.js | 18 --- Smoke/install-expo/main.fmf | 11 ++ Smoke/install-expo/runtest.sh | 30 +++++ .../npm-install-modules}/_package.json | 0 Smoke/npm-install-modules/main.fmf | 12 ++ .../npm-install-modules}/runtest.sh | 6 +- Smoke/upstream-expresss-suite/main.fmf | 13 ++ .../upstream-expresss-suite}/runtest.sh | 10 +- install-rpms.sh | 44 +++++++ main.fmf | 3 +- plans.fmf | 53 ++++---- 36 files changed, 382 insertions(+), 687 deletions(-) delete mode 100644 Integration/expressjs-testsuite/main.fmf create mode 100644 Integration/fs-module/main.fmf create mode 100755 Integration/fs-module/runtest.sh create mode 100644 Integration/fs-module/script.js create mode 100644 Integration/npm-integration-global-install/main.fmf create mode 100755 Integration/npm-integration-global-install/runtest.sh delete mode 100644 Sanity/express-testsuite/main.fmf delete mode 100755 Sanity/express-testsuite/runtest.sh delete mode 100644 Sanity/http-smoke/main.fmf delete mode 100755 Sanity/http-smoke/runtest.sh delete mode 100644 Sanity/http-smoke/server.js delete mode 100644 Sanity/install-expo/main.fmf delete mode 100755 Sanity/install-expo/runtest.sh delete mode 100644 Sanity/nodejs-smoke/main.fmf delete mode 100755 Sanity/nodejs-smoke/runtest.sh delete mode 100644 Sanity/npm-install/main.fmf delete mode 100755 Sanity/npm-install/runtest.sh delete mode 100644 Sanity/npm-smoke/main.fmf delete mode 100644 Sanity/npm-unit-tests/main.fmf delete mode 100755 Sanity/npm-unit-tests/runtest.sh delete mode 100644 Sanity/run-basic-js-script/main.fmf delete mode 100755 Sanity/run-basic-js-script/runtest.sh delete mode 100644 Sanity/smoke/main.fmf delete mode 100755 Sanity/smoke/runtest.sh delete mode 100644 Sanity/smoke/server.js create mode 100644 Smoke/install-expo/main.fmf create mode 100755 Smoke/install-expo/runtest.sh rename {Sanity/npm-smoke => Smoke/npm-install-modules}/_package.json (100%) create mode 100644 Smoke/npm-install-modules/main.fmf rename {Sanity/npm-smoke => Smoke/npm-install-modules}/runtest.sh (95%) create mode 100644 Smoke/upstream-expresss-suite/main.fmf rename {Integration/expressjs-testsuite => Smoke/upstream-expresss-suite}/runtest.sh (86%) create mode 100755 install-rpms.sh diff --git a/Integration/expressjs-testsuite/main.fmf b/Integration/expressjs-testsuite/main.fmf deleted file mode 100644 index f1b46d6..0000000 --- a/Integration/expressjs-testsuite/main.fmf +++ /dev/null @@ -1,7 +0,0 @@ -summary: Runs internal expressjs tests. -description: | - Test to verify Express’s compatibility with the Node.js. -duration: 5m -require: - - nodejs - - git diff --git a/Integration/fs-module/main.fmf b/Integration/fs-module/main.fmf new file mode 100644 index 0000000..23f84ef --- /dev/null +++ b/Integration/fs-module/main.fmf @@ -0,0 +1,14 @@ +summary: FS module test +test: ./runtest.sh +framework: beakerlib +description: | + Test ensures that nodejs can read and write files +duration: 5m +require: + - nodejs + - type: file + pattern: + - /script.js +tier: integration +component: + - nodejs diff --git a/Integration/fs-module/runtest.sh b/Integration/fs-module/runtest.sh new file mode 100755 index 0000000..c58cab8 --- /dev/null +++ b/Integration/fs-module/runtest.sh @@ -0,0 +1,22 @@ +#!/bin/bash +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "mv script.js $tmp" + rlRun "pushd $tmp" + rlRun "set -o pipefail" + rlPhaseEnd + + rlPhaseStartTest + rlShowPackageVersion nodejs + rlRun "node script.js > out.log" 0 "Running a script" + rlAssertGrep "All tests passed!" out.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd diff --git a/Integration/fs-module/script.js b/Integration/fs-module/script.js new file mode 100644 index 0000000..44c1cd0 --- /dev/null +++ b/Integration/fs-module/script.js @@ -0,0 +1,41 @@ +const fs = require('fs'); +const path = require('path'); + +// Test file path +const testFile = path.join(__dirname, 'test-file.txt'); + +try { + // Step 1: Write to a file + console.log('Writing to file...'); + const data = 'Hello, TMT fs test!'; + fs.writeFileSync(testFile, data); + if (fs.existsSync(testFile)) { + console.log('✔ File created successfully.'); + } else { + throw new Error('✘ Failed to create file.'); + } + + // Step 2: Read from the file + console.log('Reading from file...'); + const fileContent = fs.readFileSync(testFile, 'utf8'); + if (fileContent === data) { + console.log('✔ File content matches expected.'); + } else { + throw new Error('✘ File content mismatch.'); + } + + // Step 3: Delete the file + console.log('Deleting file...'); + fs.unlinkSync(testFile); + if (!fs.existsSync(testFile)) { + console.log('✔ File deleted successfully.'); + } else { + throw new Error('✘ Failed to delete file.'); + } + + console.log('All tests passed!'); + process.exit(0); // Success exit code +} catch (error) { + console.error(error.message); + process.exit(1); // Failure exit code +} diff --git a/Integration/npm-integration-global-install/main.fmf b/Integration/npm-integration-global-install/main.fmf new file mode 100644 index 0000000..998ce49 --- /dev/null +++ b/Integration/npm-integration-global-install/main.fmf @@ -0,0 +1,12 @@ +summary: User of different priviliges can use global modules +test: ./runtest.sh +framework: beakerlib +description: | + Test ensures that users of various priviliges can access global module. +duration: 5m +recommend: +require: +tier: '1' +component: + - npm + - nodejs diff --git a/Integration/npm-integration-global-install/runtest.sh b/Integration/npm-integration-global-install/runtest.sh new file mode 100755 index 0000000..77a73af --- /dev/null +++ b/Integration/npm-integration-global-install/runtest.sh @@ -0,0 +1,120 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +function check_and_cleanup() +{ + rlAssertExists "./node_modules/optimist/package.json" + rlRun "[[ -e './node_modules/optimist/node_modules/wordwrap/package.json' ]] || [[ -e './node_modules/wordwrap/package.json' ]]" 0 "File wordwrap/package.json should exist." + # Skip directory cleanup if the first parameter is empty + [[ -z "$1" ]] && rlRun "rm -rf ./node_modules && ! ls ./node_modules" 0 "Cleaning up local modules" + rlRun "$NPMJS cache clean --force" 0 "Cleaning up npm cache" +} + +function create_user() +{ + local username=$1 + local role=$2 + rlLog "Creating user '$username' with role '$role'" + rlRun "useradd -g "$role" "$username"" +} + +function verify_user_access() +{ + local username=$1 + rlLog "Verifying npm access for user '$username'" + rlRun "su "$username" -c 'coffee -h'" +} + +function delete_user() +{ + local username=$1 + rlLog "Deleting user '$username'" + rlRun "userdel -r "$username"" +} +# Packages to be tested +PACKAGES=${PACKAGES:-nodejs} +# Other required packages +REQUIRES=${REQUIRES:-} +# Node binary name parametrized +NODEJS=${NODEJS:-node} +# NPM binary name parametrized +NPMJS=${NPMJS:-npm} + +# Parameters to check using "npm parameter" and what to look for in their output + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $NODEJS + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + #Create user + + #Install package globbaly + rlLog "Installing globally from web repository:" + rlRun "$NPMJS install coffeescript --global " 0 "Installing \"coffeescript\" globally" + rlRun "which coffee" 0 "Executable \"coffeescript\" should be in binary path" + rlRun "$NPMJS cache clean --force" 0 "Cleaning up npm cache" + rlRun "coffee -h" + #Creating various users + rlLog "Creating users:" + create_user test_admin wheel + create_user test_editor users + create_user test_viewer adm + rlPhaseEnd + + rlPhaseStartTest "Install" + + rlLog "Verifying user access to global npm module:" + verify_user_access test_admin + verify_user_access test_editor + verify_user_access test_viewer + + rlPhaseEnd + rlPhaseStartTest "Remove" + rlLog "Removing global package:" + rlRun "$NPMJS remove coffeescript --global" 0 "Removing global \"coffeescript\"" + rlAssertNotExists "${npm_global_path}/coffeescript/package.json" + + rlLog "Deleting test users:" + delete_user test_admin + delete_user test_editor + delete_user test_viewer + + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm /root/.npmrc" 0,1 + rlRun "rm /root/.npm" 0,1 + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + diff --git a/README.md b/README.md index d79ec29..86e56c0 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,28 @@ or if you want all tools (virtual and container): ```bash sudo dnf install -y tmt+all ``` + +## If not provided create koji build and set env variable +you can use the following allias to create build and set env automatically: +```bash +alias scratchbuild='function _scratchbuild() { \ + SRC_RPM=$(ls *.src.rpm | head -n 1); \ + if [ -z "$SRC_RPM" ]; then \ + echo "No source RPM file found in the current directory."; \ + return 1; \ + fi; \ + BUILD_OUTPUT=$(koji build --scratch rawhide $SRC_RPM 2>&1); \ + KOJI_TASK_ID=$(echo "$BUILD_OUTPUT" | grep -oP "(?<=Task ID: )[0-9]+"); \ + if [[ -n $KOJI_TASK_ID ]]; then \ + export KOJI_TASK_ID=$KOJI_TASK_ID; \ + echo "Scratch build completed. Task ID: $KOJI_TASK_ID"; \ + else \ + echo "Failed to extract Task ID."; \ + return 1; \ + fi; \ +}; _scratchbuild' +``` + check what test plans and sub plans are available: ```bash tmt plans diff --git a/Sanity/express-testsuite/main.fmf b/Sanity/express-testsuite/main.fmf deleted file mode 100644 index 8f35ecb..0000000 --- a/Sanity/express-testsuite/main.fmf +++ /dev/null @@ -1,10 +0,0 @@ -summary: extension fs is installed without error -test: ./runtest.sh -framework: beakerlib -description: | - Test ensures that extension fs is installed without errors. -duration: 5m -recommend: nodejs -require: - - nodejs -tier: '1' diff --git a/Sanity/express-testsuite/runtest.sh b/Sanity/express-testsuite/runtest.sh deleted file mode 100755 index 8276871..0000000 --- a/Sanity/express-testsuite/runtest.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2020 Red Hat, Inc. -# -# 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -# Packages to be tested -PACKAGES=${PACKAGES:-nodejs nodejs-npm} -# Other required packages -REQUIRES=${REQUIRES:-git} - - -rlJournalStart - rlPhaseStartSetup - rlAssertRpm --all - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - rlRun "pushd $TmpDir" - - rlPhaseEnd - - rlPhaseStartTest "Testsuite" - rlRun "git clone https://github.com/expressjs/express.git" 0 "Clone the upstream repo with the Express framework" - rlRun "pushd express" 0 "Change directory to the express repo directory" - - rlRun "latest_express=$(npm show express version)" 0 "Figuring out what the latest express version is" - rlRun "npm install mocha" - rlLog "Latest Express version: ${latest_express}" - rlRun "git stash" 0 "Stashing eventual changes so they don't prevent checkout" - rlRun "git checkout '${latest_express}'" 0 "Checkout git's tag ${latest_express}" - - rlRun -s "npm test" 0 "Running the test-suite" - rlAssertGrep "[0-9]* passing" "$rlRun_LOG" -E - rlAssertNotGrep "[0-9]* failing" "$rlRun_LOG" -E - rlAssertNotGrep "Test failed" "$rlRun_LOG" - rlRun "popd" 0 "Get back to the original directory" - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "popd" - rlRun "rm -r $TmpDir" 0 "Removing tmp directory" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/Sanity/http-smoke/main.fmf b/Sanity/http-smoke/main.fmf deleted file mode 100644 index 2ef8e44..0000000 --- a/Sanity/http-smoke/main.fmf +++ /dev/null @@ -1,7 +0,0 @@ -summary: Basic server running. -description: | - Test ensures that nodejs can import http module and run basic http server. -duration: 5m -require: - - nodejs -component: nodejs diff --git a/Sanity/http-smoke/runtest.sh b/Sanity/http-smoke/runtest.sh deleted file mode 100755 index f344124..0000000 --- a/Sanity/http-smoke/runtest.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2013 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -# Packages to be tested -PACKAGES=${PACKAGES:-nodejs} -# Other required packages -REQUIRES=${REQUIRES:-curl} -# Binary name parametrized -NODEJS=${NODEJS:-node} - -# Port range for server to choose from -MIN_SERVER_PORT=${MIN_SERVER_PORT:-8000} -MAX_SERVER_PORT=${MAX_SERVER_PORT:-8080} - -# Actual server port to use -SERVER_PORT=${SERVER_PORT:-8008} - -# Time delay for server to start and for curl to download -SLEEP_TIME=${SLEEP_TIME:-10} - -rlJournalStart - rlPhaseStartSetup - rlAssertRpm --all - rlAssertBinaryOrigin $NODEJS - - port_chosen=false - rlLogInfo "Choosing server port..." - for port in $(seq ${MIN_SERVER_PORT} 1 ${MAX_SERVER_PORT}); do - if ! fuser ${port}/tcp >/dev/null 2>&1; then - SERVER_PORT=${port} - port_chosen=true - rlLogInfo "\"${SERVER_PORT}\" chosen" - break - fi - done - - $port_chosen || rlLogWarning "No port available from a given range \"${MIN_SERVER_PORT}\" - \"${MAX_SERVER_PORT}\". Using \"${SERVER_PORT}\" anyway." - - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - rlRun "cp server.js $TmpDir/." 0 "Copying server source file" - rlRun "pushd $TmpDir" - rlPhaseEnd - - rlPhaseStartTest - echo "---node-processes--" - ps -e | grep node - echo "---" - - rlRun "${NODEJS} server.js ${SERVER_PORT} 2>&1 > server_out &" 0 "Running server and logging output" - rlRun "sleep ${SLEEP_TIME}" 0 "Giving server \"${SLEEP_TIME}\" seconds to start" - rlRun "curl --max-time ${SLEEP_TIME} http://127.0.0.1:${SERVER_PORT} > curl_out && cat curl_out" 0 "Querying server" - rlRun "grep 'Hello World' curl_out" 0 "Response should contain \"Hello World\"" - rlRun "kill $!" 0 "Stopping the server" - sleep 1 - rlRun "ps -e | grep $!" 1 "Server should not be running" - - echo "---server-output--" - cat server_out - echo "---" - - rlRun "grep 'Request received.' server_out" 0 "Output should contain \"Request received.\"" - rlRun "grep 'Server has started.' server_out" 0 "Output should contain \"Server has started.\"" - rlRun "kill -SIGKILL $!" 0,1 "Attempt killing possibly leftover server process" - - echo "---node-processes-and-directory-contents--" - ps -e | grep node - ls -lah - echo "---" - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "popd" - rlRun "rm -r $TmpDir" 0 "Removing tmp directory" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/Sanity/http-smoke/server.js b/Sanity/http-smoke/server.js deleted file mode 100644 index 7f8a600..0000000 --- a/Sanity/http-smoke/server.js +++ /dev/null @@ -1,18 +0,0 @@ -// server.js -- minimal node.js http server -// Usage: node server.js [PORT] -// Default port is 8000 - -var http = require("http"); -var port = process.argv[2] || 8000; - -function onRequest(request, response) { - console.log("Request received."); - response.writeHead(200, {"Content-Type": "text/plain"}); - response.write("Hello World\n"); - response.end(); -} - -http.createServer(onRequest).listen(port); - -console.log("Server has started."); - diff --git a/Sanity/install-expo/main.fmf b/Sanity/install-expo/main.fmf deleted file mode 100644 index 8f35ecb..0000000 --- a/Sanity/install-expo/main.fmf +++ /dev/null @@ -1,10 +0,0 @@ -summary: extension fs is installed without error -test: ./runtest.sh -framework: beakerlib -description: | - Test ensures that extension fs is installed without errors. -duration: 5m -recommend: nodejs -require: - - nodejs -tier: '1' diff --git a/Sanity/install-expo/runtest.sh b/Sanity/install-expo/runtest.sh deleted file mode 100755 index 2d9cfb1..0000000 --- a/Sanity/install-expo/runtest.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Description: Basic sanity test for express module. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2020 Red Hat, Inc. -# -# 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -NPMJS=${NPMJS:-npm} -rlJournalStart - rlPhaseStartSetup - rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" - rlRun "pushd $tmp" - rlPhaseEnd - #Test an installation and usage of expo - rlPhaseStartTest - rlRun "$NPMJS install -g expo" 0 - rlRun "$NPMJS list -g expo" 0 - rlRun "npx create-expo-app my-app -y" 0 - rlRun "cd my-app && npx expo start --port 19000 &" 0 "starting server" - rlRun "sleep 10" 0 - rlRun "curl http://localhost:19000" 0 - rlPhaseEnd - - rlPhaseStartCleanup - rlLogInfo "Deleting files created by npm install" - rlRun "popd" - rlRun "rm -r $tmp" 0 "Remove tmp directory" - rlPhaseEnd - -rlJournalEnd - diff --git a/Sanity/nodejs-smoke/main.fmf b/Sanity/nodejs-smoke/main.fmf deleted file mode 100644 index 2ba74a3..0000000 --- a/Sanity/nodejs-smoke/main.fmf +++ /dev/null @@ -1,4 +0,0 @@ -summary: Basic nodejs smoke test using beakerlib framework. -component: nodejs -require: - - nodejs diff --git a/Sanity/nodejs-smoke/runtest.sh b/Sanity/nodejs-smoke/runtest.sh deleted file mode 100755 index 9eb4de2..0000000 --- a/Sanity/nodejs-smoke/runtest.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Description: Basic smoke tests for nodejs. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2020 Red Hat, Inc. -# -# 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -. /usr/share/beakerlib/beakerlib.sh || exit 1 - - -rlJournalStart - rlPhaseStartSetup - rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" - rlRun "pushd $tmp" - rlRun "set -o pipefail" - rlPhaseEnd - - rlPhaseStartTest - rlRun "node -v" 0 "Check Node Version" - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "popd" - rlRun "rm -r $tmp" 0 "Remove tmp directory" - rlPhaseEnd -rlJournalEnd diff --git a/Sanity/npm-install/main.fmf b/Sanity/npm-install/main.fmf deleted file mode 100644 index fcd9595..0000000 --- a/Sanity/npm-install/main.fmf +++ /dev/null @@ -1,11 +0,0 @@ -summary: extension fs is installed without error -test: ./runtest.sh -framework: beakerlib -description: | - Test ensures that extension fs is installed without errors. -duration: 5m -recommend: nodejs -require: - - nodejs - - gcc -tier: '1' diff --git a/Sanity/npm-install/runtest.sh b/Sanity/npm-install/runtest.sh deleted file mode 100755 index f15ac6a..0000000 --- a/Sanity/npm-install/runtest.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Description: Basic sanity test for npm install. -# -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2020 Red Hat, Inc. -# -# 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -TEST_USER="nodeuser" - -rlJournalStart - rlPhaseStartSetup - rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" - rlRun "pushd $tmp" - rlRun "set -o pipefail" - id $TEST_USER && rlRun "userdel -r $TEST_USER" - rlRun "useradd $TEST_USER" 0 "Adding user '$TEST_USER' to the system" - rlRun "chown -R $TEST_USER:$TEST_USER $tmp" 0 "$TEST_USER can (un)install npm in $tmp" - rlPhaseEnd - - rlPhaseStartTest - rlRun "su -c 'npm install fs' $TEST_USER" 0 "Try to install fs with npm under $TEST_USER" - rlPhaseEnd - - - rlPhaseStartCleanup - rlLogInfo "Deleting files created by npm install" - su -c 'set -o pipefail; npm config get cache | xargs rm -rf' $TEST_USER || \ - su -c 'set -o pipefail; npm config list | grep "cache" | awk -F "=" '"'"'{print $2}'"'"' | xargs rm -rf' $TEST_USER - rlRun "userdel -r $TEST_USER" - rlRun "popd" - rlRun "rm -r $tmp" 0 "Remove tmp directory" - rlPhaseEnd - -rlJournalEnd - - diff --git a/Sanity/npm-smoke/main.fmf b/Sanity/npm-smoke/main.fmf deleted file mode 100644 index eb699a0..0000000 --- a/Sanity/npm-smoke/main.fmf +++ /dev/null @@ -1,13 +0,0 @@ -summary: extension fs is installed without error -test: ./runtest.sh -framework: beakerlib -description: | - Test ensures that extension fs is installed without errors. -duration: 5m -recommend: - - nodejs - - nodejs-npm -require: - - nodejs - - nodejs-npm -tier: '1' diff --git a/Sanity/npm-unit-tests/main.fmf b/Sanity/npm-unit-tests/main.fmf deleted file mode 100644 index 50dbfad..0000000 --- a/Sanity/npm-unit-tests/main.fmf +++ /dev/null @@ -1,11 +0,0 @@ -summary: extension fs is installed without error -test: ./runtest.sh -framework: beakerlib -description: | - Test ensures that extension fs is installed without errors. -duration: 5m -recommend: nodejs -require: - - nodejs - - rpm-build -tier: '1' diff --git a/Sanity/npm-unit-tests/runtest.sh b/Sanity/npm-unit-tests/runtest.sh deleted file mode 100755 index 452bae5..0000000 --- a/Sanity/npm-unit-tests/runtest.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2024 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=${PACKAGE:-"npm"} -REQUIRES=${REQUIRES:-"rpm-build"} - - -rlJournalStart - rlPhaseStartSetup - - rlAssertRpm --all - rlRun "pushd /root" - #Currently running locally against newest version - rlRun "rlFetchSrcForInstalled nodejs" - rlRun "rpm -ivh ~/nodejs*.src.rpm" - rlRun "dnf -y builddep ~/rpmbuild/SPECS/nodejs22.spec" - rlRun "rpmbuild -bp ~/rpmbuild/SPECS/nodejs22.spec" - - - ## Installing npm modules needed to test itself - rlRun "mkdir modules" - rlRun "cd modules" - rlRun "npm config set registry https://registry.npmjs.org/" - rlRun "npm install tap" - rlRun "npm install mock-globals" - rlRun "npm install npm-registry-mock" - rlRun "cp -r ~/modules/* ~/rpmbuild/BUILD/nodejs22-22.11.0-build/node-v22.11.0/deps/npm/test" - rlRun "cd ~/rpmbuild/BUILD/nodejs22-22.11.0-build/node-v22.11.0/deps/npm/test" - rlPhaseEnd - - rlPhaseStartTest - rlRun "node index.js &> log.out" 0,1 "Run npm unit tests" - echo "== log.out ===========" - cat log.out - echo "==/log.out ===========" - - if [ `node -e "console.log(process.version.split('.')[0].split('v')[1])"` == 16 ]; then - rlAssertGrep "{ total: 5, pass: 5 }" log.out - else - rlAssertGrep "total: 3, pass: 2, fail: 1 " log.out - fi - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "cd ~" - rlRun "rm -rf rpmbuild" - rlRun "rm -rf nodejs*.src.rpm" - rlRun "rm -rf modules" - rlRun "popd" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/Sanity/run-basic-js-script/main.fmf b/Sanity/run-basic-js-script/main.fmf deleted file mode 100644 index 17ec356..0000000 --- a/Sanity/run-basic-js-script/main.fmf +++ /dev/null @@ -1,4 +0,0 @@ -summary: Run basic js script -recommend: - nodejs -tier: smoke diff --git a/Sanity/run-basic-js-script/runtest.sh b/Sanity/run-basic-js-script/runtest.sh deleted file mode 100755 index a6b2232..0000000 --- a/Sanity/run-basic-js-script/runtest.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -. /usr/share/beakerlib/beakerlib.sh || exit 1 -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Description: Basic sanity test for running a JavaScript. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2020 Red Hat, Inc. -# -# 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -TEST_USER="nodeuser" -JS_FILE="$tmp/test-script.js" - -rlJournalStart - rlPhaseStartSetup - rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" - rlRun "pushd $tmp" - rlRun "set -o pipefail" - id $TEST_USER && rlRun "userdel -r $TEST_USER" - rlRun "useradd $TEST_USER" 0 "Adding user '$TEST_USER' to the system" - rlRun "chown -R $TEST_USER:$TEST_USER $tmp" 0 "$TEST_USER can (un)install modules in $tmp" - rlPhaseEnd - - rlPhaseStartTest - rlRun "node -v" 0 "Check Node Version" - # Create the JavaScript file - rlRun "echo 'console.log(\"Hello from BeakerLib!\");' > $JS_FILE" 0 "Create JavaScript file" - rlRun "node $JS_FILE > out.log" 0 "Run basic script and output into log file" - rlAssertGrep "Hello from BeakerLib!" out.log - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "userdel -r $TEST_USER" - rlRun "popd" - rlRun "rm -r $tmp" 0 "Remove tmp directory" - rlRun "rm -f $JS_FILE" 0 "Remove JavaScript file" - rlPhaseEnd -rlJournalEnd diff --git a/Sanity/smoke/main.fmf b/Sanity/smoke/main.fmf deleted file mode 100644 index 8f35ecb..0000000 --- a/Sanity/smoke/main.fmf +++ /dev/null @@ -1,10 +0,0 @@ -summary: extension fs is installed without error -test: ./runtest.sh -framework: beakerlib -description: | - Test ensures that extension fs is installed without errors. -duration: 5m -recommend: nodejs -require: - - nodejs -tier: '1' diff --git a/Sanity/smoke/runtest.sh b/Sanity/smoke/runtest.sh deleted file mode 100755 index 4446216..0000000 --- a/Sanity/smoke/runtest.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Copyright (c) 2013 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. -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -# Packages to be tested -PACKAGES=${PACKAGES:-nodejs} -# Other required packages -REQUIRES=${REQUIRES:-curl} -# Binary name parametrized -NODEJS=${NODEJS:-node} - -# Port range for server to choose from -MIN_SERVER_PORT=${MIN_SERVER_PORT:-8000} -MAX_SERVER_PORT=${MAX_SERVER_PORT:-8080} - -# Actual server port to use -SERVER_PORT=${SERVER_PORT:-8008} - -# Time delay for server to start and for curl to download -SLEEP_TIME=${SLEEP_TIME:-10} - -rlJournalStart - rlPhaseStartSetup - rlAssertRpm --all - rlAssertBinaryOrigin $NODEJS - - # Try to choose port from a port range - port_chosen=false - rlLogInfo "Choosing server port..." - for port in $(seq ${MIN_SERVER_PORT} 1 ${MAX_SERVER_PORT}); do - if ! fuser ${port}/tcp >/dev/null 2>&1; then - SERVER_PORT=${port} - port_chosen=true - rlLogInfo "\"${SERVER_PORT}\" chosen" - break - fi - done - - # Warn if port was not chosen from a port range - $port_chosen || rlLogWarning "No port available from a given range \"${MIN_SERVER_PORT}\" - \"${MAX_SERVER_PORT}\". Using \"${SERVER_PORT}\" anyway." - - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - rlRun "cp server.js $TmpDir/." 0 "Copying server source file" - rlRun "pushd $TmpDir" - rlPhaseEnd - - rlPhaseStartTest - echo "---node-processes--" - ps -e | grep node - echo "---" - - rlRun "${NODEJS} server.js ${SERVER_PORT} 2>&1 > server_out &" 0 "Running server and logging output" - rlRun "sleep ${SLEEP_TIME}" 0 "Giving server \"${SLEEP_TIME}\" seconds to start" - rlRun "curl --max-time ${SLEEP_TIME} http://127.0.0.1:${SERVER_PORT} > curl_out && cat curl_out" 0 "Querying server" - rlRun "grep 'Hello World' curl_out" 0 "Response should contain \"Hello World\"" - rlRun "kill $!" 0 "Stopping the server" - sleep 1 - rlRun "ps -e | grep $!" 1 "Server should not be running" - - echo "---server-output--" - cat server_out - echo "---" - - rlRun "grep 'Request received.' server_out" 0 "Output should contain \"Request received.\"" - rlRun "grep 'Server has started.' server_out" 0 "Output should contain \"Server has started.\"" - rlRun "kill -SIGKILL $!" 0,1 "Attempt killing possibly leftover server process" - - echo "---node-processes-and-directory-contents--" - ps -e | grep node - ls -lah - echo "---" - rlPhaseEnd - - rlPhaseStartCleanup - rlRun "popd" - rlRun "rm -r $TmpDir" 0 "Removing tmp directory" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/Sanity/smoke/server.js b/Sanity/smoke/server.js deleted file mode 100644 index 7f8a600..0000000 --- a/Sanity/smoke/server.js +++ /dev/null @@ -1,18 +0,0 @@ -// server.js -- minimal node.js http server -// Usage: node server.js [PORT] -// Default port is 8000 - -var http = require("http"); -var port = process.argv[2] || 8000; - -function onRequest(request, response) { - console.log("Request received."); - response.writeHead(200, {"Content-Type": "text/plain"}); - response.write("Hello World\n"); - response.end(); -} - -http.createServer(onRequest).listen(port); - -console.log("Server has started."); - diff --git a/Smoke/install-expo/main.fmf b/Smoke/install-expo/main.fmf new file mode 100644 index 0000000..a8a7125 --- /dev/null +++ b/Smoke/install-expo/main.fmf @@ -0,0 +1,11 @@ +summary: Basic expo server test +test: ./runtest.sh +framework: beakerlib +description: | + Test ensures that nodejs and npm can install and run expo app +duration: 15m +require: nodejs +tier: smoke +component: + - npm + - nodejs diff --git a/Smoke/install-expo/runtest.sh b/Smoke/install-expo/runtest.sh new file mode 100755 index 0000000..c786b14 --- /dev/null +++ b/Smoke/install-expo/runtest.sh @@ -0,0 +1,30 @@ +#!/bin/bash +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +TEST_USER="nodeuser" +NPMJS=${NPMJS:-npm} +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + rlPhaseEnd + + #Test installation and usage of expo + rlPhaseStartTest + rlShowPackageVersion nodejs + rlRun "npm install expo create-expo-app --verbose" 0 + rlRun "npx create-expo-app my-app -y" 0 + rlRun "cd my-app" 0 + rlRun "nohup npx expo start --port=19000 &>server.log &" 0 "Starting a server" + rlRun "sleep 10" 0 + rlRun "curl http://localhost:19000" 0 + rlPhaseEnd + + rlPhaseStartCleanup + rlLogInfo "Deleting files created by npm install" + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd + +rlJournalEnd + diff --git a/Sanity/npm-smoke/_package.json b/Smoke/npm-install-modules/_package.json similarity index 100% rename from Sanity/npm-smoke/_package.json rename to Smoke/npm-install-modules/_package.json diff --git a/Smoke/npm-install-modules/main.fmf b/Smoke/npm-install-modules/main.fmf new file mode 100644 index 0000000..ecc801f --- /dev/null +++ b/Smoke/npm-install-modules/main.fmf @@ -0,0 +1,12 @@ +summary: Verify ability to install modules through various means +test: ./runtest.sh +framework: beakerlib +description: | + Test ensures that npm has the ability to install modules through various means. +duration: 5m +recommend: +require: +tier: '1' +component: + - npm + - nodejs diff --git a/Sanity/npm-smoke/runtest.sh b/Smoke/npm-install-modules/runtest.sh similarity index 95% rename from Sanity/npm-smoke/runtest.sh rename to Smoke/npm-install-modules/runtest.sh index e0959a7..fc1ff98 100755 --- a/Sanity/npm-smoke/runtest.sh +++ b/Smoke/npm-install-modules/runtest.sh @@ -1,4 +1,8 @@ #!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Copyright (c) 2013 Red Hat, Inc. All rights reserved. @@ -41,6 +45,7 @@ NODEJS=${NODEJS:-node} # NPM binary name parametrized NPMJS=${NPMJS:-npm} +# Parameters to check using "npm parameter" and what to look for in their output rlJournalStart rlPhaseStartSetup @@ -123,4 +128,3 @@ rlJournalStart rlJournalPrintText rlJournalEnd - diff --git a/Smoke/upstream-expresss-suite/main.fmf b/Smoke/upstream-expresss-suite/main.fmf new file mode 100644 index 0000000..8dd58cd --- /dev/null +++ b/Smoke/upstream-expresss-suite/main.fmf @@ -0,0 +1,13 @@ +summary: NPM implementation can pass upstream test suite +test: ./runtest.sh +framework: beakerlib +description: | + Test ensures that NPM implementation can pass upstream test suite. +duration: 5m +recommend: +require: + - git +tier: '1' +component: + - npm + - nodejs diff --git a/Integration/expressjs-testsuite/runtest.sh b/Smoke/upstream-expresss-suite/runtest.sh similarity index 86% rename from Integration/expressjs-testsuite/runtest.sh rename to Smoke/upstream-expresss-suite/runtest.sh index 64c5c9e..f39a016 100755 --- a/Integration/expressjs-testsuite/runtest.sh +++ b/Smoke/upstream-expresss-suite/runtest.sh @@ -1,7 +1,11 @@ #!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # +# runtest.sh of /CoreOS/nodejs/Sanity/express-testsuite # Description: Basic sanity test for express module. +# Author: Tomáš Juhász +# Inspired by internal test by: Honza Horak # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # @@ -22,6 +26,10 @@ # Boston, MA 02110-1301, USA. # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# This test supports following parameters: +# Standard PACKAGES, REQUIRES, COLLECTIONS parameters. + # Include Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 @@ -45,8 +53,6 @@ rlJournalStart rlRun "latest_express=$(npm show express version)" 0 "Figuring out what the latest express version is" rlLog "Latest Express version: ${latest_express}" - rlRun "git stash" 0 "Stashing eventual changes so they don't prevent checkout" - rlRun "git checkout '${latest_express}'" 0 "Checkout git's tag ${latest_express}" rlRun "npm install mocha" rlRun -s "npm test" 0 "Running the test-suite" rlAssertGrep "[0-9]* passing" "$rlRun_LOG" -E diff --git a/install-rpms.sh b/install-rpms.sh new file mode 100755 index 0000000..9188f5d --- /dev/null +++ b/install-rpms.sh @@ -0,0 +1,44 @@ +#!/bin/bash +KOJI_TASK_ID=2596437 +#KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use the environment variable, or an empty string if not set + +# Check if KOJI_TASK_ID is set +[ -n "$KOJI_TASK_ID" ] || { + echo "env variable \$KOJI_TASK_ID not specified" >&2 + echo "This variable should be present in TestingFarm" >&2 + exit 1 +} + + +# Get the current architecture +ARCH=$(uname -m) + +# Download the build for the current architecture +koji download-build $KOJI_TASK_ID --arch=$ARCH || { + echo "Failed to download build $KOJI_TASK_ID for architecture $ARCH using koji" >&2 + exit 1 +} + + +#( koji download-build --debuginfo --task-id --arch noarch --arch x86_64 --arch i686 --arch src $KOJI_TASK_ID || koji download-task --arch noarch --arch x86_64 --arch i686 --arch src $KOJI_TASK_ID ) | egrep Downloading | cut -d " " -f 3 | tee rpms-list-$KOJI_TASK_ID +#ls *[^.src].rpm | sed -r "s/(.*)-.*-.*/\1 \0/" | egrep -v "i686" | awk "{print \$2}" | tee rpms-list +#dnf -y reinstall $(cat rpms-list) || true +#if [ ! -z "$(sed 's/\s//g' rpms-list)" ];then dnf -y install --allowerasing $(cat rpms-list);else echo "Nothing to install, rpms-list is empty"; fi +#if [ ! -z "$(sed 's/\s//g' rpms-list)" ];then sed 's/.rpm$//' rpms-list | xargs -n1 command printf '%q\n' | xargs -d'\n' rpm -q;else echo 'Nothing to verify, rpms-list is empty'; fi + +# Ensure the required RPMs exist +MAIN_RPM=$(ls nodejs-*.x86_64.rpm 2>/dev/null | head -n 1) +DEPENDENCY_RPM=$(ls nodejs-libs-*.x86_64.rpm 2>/dev/null | head -n 1) +NPM_RPM=$(ls nodejs-npm-*.x86_64.rpm 2>/dev/null | head -n 1) + +# Check if all necessary RPMs are found +if [ -z "$MAIN_RPM" ] || [ -z "$DEPENDENCY_RPM" ] || [ -z "$NPM_RPM" ]; then + echo "Required RPMs not found for x86_64 architecture." >&2 + exit 1 +fi + +# Install the main package, its dependency, and npm package +rpm -ivh "$MAIN_RPM" "$DEPENDENCY_RPM" "$NPM_RPM" || { + echo "Failed to install RPMs" >&2 + exit 1 +} diff --git a/main.fmf b/main.fmf index 71c23cd..38725c5 100644 --- a/main.fmf +++ b/main.fmf @@ -1,5 +1,4 @@ # This metadata will be applied to each test case contact: Tomas Juhasz Andrei Radchenko -test: ./runtest.sh -framework: beakerlib + diff --git a/plans.fmf b/plans.fmf index cce911b..e1b3695 100644 --- a/plans.fmf +++ b/plans.fmf @@ -1,36 +1,37 @@ -# Root plan: Defines common metadata -/: -# To not inherit anything from some tests 'above'? - inherit: false - -# This will apply to each sub-plans below +# Shared metadata +discover: + how: fmf execute: how: tmt +environment: + KOJI_BUILD_ID: 123 +provision: + how: container + image: 'fedora:rawhide' +prepare: +- name: Install test deps + how: install + package: + - beakerlib + - koji + - libuv + - cpio +- name: Install fresh packages from Koji + how: shell + script: ./install-rpms.sh -# Subplan: Run all the tests +# Filtering /all: - summary: Run all Node.js tests. - discover: - how: fmf -# You probably dont want to run all TCs on each commit to this repo. -# Still need to figure out where this check happens - adjust: - - when: trigger == commit - enabled: false - -# Subplan: Run smoke tests only + summary: Run all available tests + /smoke: - summary: Run smoke tests for Node.js. + summary: Run all smoke tests discover: how: fmf - filter: "tier:smoke" # Filter tests tagged as smoke tests + filter: "tier: smoke" -# Subplan: Run extended tests (long-running) -/extended: - summary: Run extended Node.js tests. +/integration: + summary: Run all intergraion tests discover: how: fmf - filter: "tier:extended" # Filter tests tagged as extended - adjust: - - when: environment == production - enabled: false # Disable extended tests in production environments + filter: "tier: integration"