From c5d7ab86746f73f2b7f3332cc0fa0944de380baf Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Mon, 13 Jan 2025 12:21:58 +0100 Subject: [PATCH 1/9] trying to link tests --- plans.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plans.fmf b/plans.fmf index eab79c4..aef9717 100644 --- a/plans.fmf +++ b/plans.fmf @@ -9,7 +9,7 @@ execute: provision: how: container image: 'fedora:rawhide' -prepare: +prepare+: - name: Install test deps how: install package: From 3289ef92032900cd5d28f095b09d42500c6d023b Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Mon, 13 Jan 2025 12:46:00 +0100 Subject: [PATCH 2/9] test --- install-rpms.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-rpms.sh b/install-rpms.sh index f238964..f51e9c7 100755 --- a/install-rpms.sh +++ b/install-rpms.sh @@ -1,5 +1,5 @@ #!/bin/bash -#KOJI_TASK_ID=2596437 +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 From ad0af4abde1a4df5e6bef32604f84e4917ed5480 Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Mon, 13 Jan 2025 12:59:36 +0100 Subject: [PATCH 3/9] test --- install-rpms.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-rpms.sh b/install-rpms.sh index f51e9c7..f238964 100755 --- a/install-rpms.sh +++ b/install-rpms.sh @@ -1,5 +1,5 @@ #!/bin/bash -KOJI_TASK_ID=2596437 +#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 From 1c9af289cd01c57851b0aba5b269a3711a422fdc Mon Sep 17 00:00:00 2001 From: Tomas Juhasz Date: Mon, 13 Jan 2025 16:38:19 +0100 Subject: [PATCH 4/9] adjustment to the kodi build alias code --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 86e56c0..1fca8e0 100644 --- a/README.md +++ b/README.md @@ -22,22 +22,25 @@ 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); \ + +alias scratchbuild='set -x; \ + SRC_RPM=$(ls *.src.rpm | head -n 1) && \ + echo "Found source RPM: $SRC_RPM" && \ if [ -z "$SRC_RPM" ]; then \ - echo "No source RPM file found in the current directory."; \ + echo "No source RPM file found."; \ 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"; \ + fi && \ + BUILD_OUTPUT=$(koji build --scratch rawhide $SRC_RPM 2>&1) && \ + echo "Koji build output: $BUILD_OUTPUT" && \ + 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 started. Task ID: $KOJI_TASK_ID"; \ else \ - echo "Failed to extract Task ID."; \ + echo "Failed to extract Task ID. Build output: $BUILD_OUTPUT"; \ return 1; \ fi; \ -}; _scratchbuild' + set +x' ``` check what test plans and sub plans are available: From 3caf8cddfa6249c39f74d5b53b116dd90ce4a0a6 Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Mon, 13 Jan 2025 16:46:46 +0100 Subject: [PATCH 5/9] added another way to download scratch build --- install-rpms.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/install-rpms.sh b/install-rpms.sh index f238964..a820e23 100755 --- a/install-rpms.sh +++ b/install-rpms.sh @@ -1,5 +1,5 @@ #!/bin/bash -#KOJI_TASK_ID=2596437 +#KOJI_TASK_ID=127827211 KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use the environment variable, or an empty string if not set # Check if KOJI_TASK_ID is set @@ -15,9 +15,9 @@ KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use the environment variable, or an empty stri 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 $ARCH $KOJI_TASK_ID || koji download-task --arch $ARCH $KOJI_TASK_ID ) | egrep Downloading | cut -d " " -f 3 | tee rpms-list-$KOJI_TASK_ID || { + echo "WARN: Failed to download rpms from task $KOJI_TASK_ID for architecture $ARCH using koji" >&2 + exit 0 } @@ -31,15 +31,17 @@ koji download-build $KOJI_TASK_ID --arch=$ARCH || { MAIN_RPM=$(ls nodejs-*.$ARCH.rpm 2>/dev/null | head -n 1) DEPENDENCY_RPM=$(ls nodejs-libs-*.$ARCH.rpm 2>/dev/null | head -n 1) NPM_RPM=$(ls nodejs-npm-*.$ARCH.rpm 2>/dev/null | head -n 1) +DEVEL_RPM=$(ls nodejs-devel-*.$ARCH.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 +if [ -z "$MAIN_RPM" ] || [ -z "$DEVEL_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" || { +rpm -ivh "$MAIN_RPM" "$DEPENDENCY_RPM" "$NPM_RPM" "$DEVEL_RPM" || { echo "Failed to install RPMs" >&2 exit 1 } From f9efbfabb35592d045796cbe4187d6d72139847b Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Mon, 13 Jan 2025 18:11:47 +0100 Subject: [PATCH 6/9] working on script --- install-rpms.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/install-rpms.sh b/install-rpms.sh index a820e23..6ce5fa5 100755 --- a/install-rpms.sh +++ b/install-rpms.sh @@ -1,5 +1,5 @@ #!/bin/bash -#KOJI_TASK_ID=127827211 +KOJI_TASK_ID=127833569 KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use the environment variable, or an empty string if not set # Check if KOJI_TASK_ID is set @@ -37,11 +37,10 @@ DEVEL_RPM=$(ls nodejs-devel-*.$ARCH.rpm 2>/dev/null | head -n 1) # Check if all necessary RPMs are found if [ -z "$MAIN_RPM" ] || [ -z "$DEVEL_RPM" ] || [ -z "$DEPENDENCY_RPM" ] || [ -z "$NPM_RPM" ]; then echo "Required RPMs not found for x86_64 architecture." >&2 - exit 1 + exit 0 fi # Install the main package, its dependency, and npm package -rpm -ivh "$MAIN_RPM" "$DEPENDENCY_RPM" "$NPM_RPM" "$DEVEL_RPM" || { - echo "Failed to install RPMs" >&2 - exit 1 -} +if ! dnf install -y --allowerasing "$MAIN_RPM" "$DEPENDENCY_RPM" "$NPM_RPM" "$DEVEL_RPM"; then + echo "Warning: Failed to install some RPMs using dnf" >&2 +fi From 34279f664189a85cce3523c6e851cbe282f56b7c Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Tue, 14 Jan 2025 14:02:47 +0100 Subject: [PATCH 7/9] modified script to get more info and not stop CI --- install-rpms.sh | 66 +++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/install-rpms.sh b/install-rpms.sh index 6ce5fa5..e9e557a 100755 --- a/install-rpms.sh +++ b/install-rpms.sh @@ -1,46 +1,64 @@ #!/bin/bash -KOJI_TASK_ID=127833569 -KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use the environment variable, or an empty string if not set + +set -e # Exit immediately on any command failure +set -u # Treat unset variables as errors + +# Manual way to test any task or build locally +#KOJI_TASK_ID=2586515 + +KOJI_TASK_ID=${KOJI_TASK_ID:-} # Use environment variable or default to an empty string # Check if KOJI_TASK_ID is set -[ -n "$KOJI_TASK_ID" ] || { +if [ -z "$KOJI_TASK_ID" ]; then echo "WARN: KOJI_TASK_ID not set!" - echo "WARN: not able to find scratch build, RPMS will be pulled from repo" >&2 - echo "WARN: this variable should be either provided or passed from Testing Farm" >&2 + echo "WARN: RPMS will be pulled from the repo as fallback." >&2 + echo "INFO: This variable should be either provided or passed from Testing Farm." >&2 exit 0 -} - +fi # Get the current architecture ARCH=$(uname -m) +echo "INFO: Detected architecture: $ARCH" -# Download the build for the current architecture -( koji download-build --debuginfo --task-id --arch $ARCH $KOJI_TASK_ID || koji download-task --arch $ARCH $KOJI_TASK_ID ) | egrep Downloading | cut -d " " -f 3 | tee rpms-list-$KOJI_TASK_ID || { - echo "WARN: Failed to download rpms from task $KOJI_TASK_ID for architecture $ARCH using koji" >&2 - exit 0 +# Function to download build using `koji download-build` with progress +download_with_koji_build() { + echo "INFO: Attempting to download build for task ID $KOJI_TASK_ID using 'koji download-build'." + koji download-build --arch "$ARCH" "$KOJI_TASK_ID" } +# Function to download using `koji download-task` as fallback +download_with_koji_task() { + echo "INFO: Attempting to download build for task ID $KOJI_TASK_ID using 'koji download-task'." + koji download-task --arch "$ARCH" "$KOJI_TASK_ID" +} -#( 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 +# Attempt both download methods +if ! download_with_koji_build && ! download_with_koji_task; then + echo "WARN: Failed to download RPMS from task $KOJI_TASK_ID for architecture $ARCH." >&2 + echo "WARN: Proceeding with fallback mechanism." + exit 0 +fi -# Ensure the required RPMs exist +# List downloaded RPMs +echo "INFO: Listing downloaded RPM files:" +ls -1 *.rpm || echo "INFO: No RPM files found in the current directory." + +# Ensure required RPMs are downloaded MAIN_RPM=$(ls nodejs-*.$ARCH.rpm 2>/dev/null | head -n 1) DEPENDENCY_RPM=$(ls nodejs-libs-*.$ARCH.rpm 2>/dev/null | head -n 1) NPM_RPM=$(ls nodejs-npm-*.$ARCH.rpm 2>/dev/null | head -n 1) DEVEL_RPM=$(ls nodejs-devel-*.$ARCH.rpm 2>/dev/null | head -n 1) - -# Check if all necessary RPMs are found -if [ -z "$MAIN_RPM" ] || [ -z "$DEVEL_RPM" ] || [ -z "$DEPENDENCY_RPM" ] || [ -z "$NPM_RPM" ]; then - echo "Required RPMs not found for x86_64 architecture." >&2 - exit 0 +if [ -z "$MAIN_RPM" ] || [ -z "$DEPENDENCY_RPM" ] || [ -z "$NPM_RPM" ] || [ -z "$DEVEL_RPM" ]; then + echo "WARN: Required RPMs not found for $ARCH architecture. Proceeding without installation." >&2 + exit 0 fi -# Install the main package, its dependency, and npm package +# Install the RPMs +echo "INFO: Installing RPMs:" +echo "INFO: $MAIN_RPM, $DEPENDENCY_RPM, $NPM_RPM, $DEVEL_RPM" if ! dnf install -y --allowerasing "$MAIN_RPM" "$DEPENDENCY_RPM" "$NPM_RPM" "$DEVEL_RPM"; then - echo "Warning: Failed to install some RPMs using dnf" >&2 + echo "WARN: Failed to install some RPMs using DNF. Continuing with tmt require standart installation." >&2 fi + +echo "INFO: Script completed." From 22c7d8cc46eed97170959a2e95431b78d4539bb0 Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Tue, 14 Jan 2025 14:03:19 +0100 Subject: [PATCH 8/9] moved plans to nodejs22 rpms repo --- plans.fmf | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 plans.fmf diff --git a/plans.fmf b/plans.fmf deleted file mode 100644 index aef9717..0000000 --- a/plans.fmf +++ /dev/null @@ -1,43 +0,0 @@ -# Shared metadata -discover: - how: fmf -execute: - how: tmt -# Will be overwritten by CI -#environment: -# KOJI_BUILD_ID: 123 -provision: - how: container - image: 'fedora:rawhide' -prepare+: -- name: Install test deps - how: install - package: - - koji - - libuv -- name: Install fresh packages from Koji - how: shell - script: ./install-rpms.sh - -# Filtering -/all: - summary: Run all available tests - -/smoke: - summary: Run all smoke tests - discover: - how: fmf - filter: "tag:smoke" - -/integration: - summary: Run all intergraion tests - discover: - how: fmf - filter: "tag: integration" - -# Way to test new TCs -#/new: -# summary: Test new TC -# discover: -# how: fmf -# filter: "tag: new" From ecbe2863fa18304cfad9c9f5b0f35e189bd8887e Mon Sep 17 00:00:00 2001 From: Tomas Juhasz Date: Tue, 14 Jan 2025 16:05:26 +0100 Subject: [PATCH 9/9] New test for sqlite sessions --- Smoke/nodejs-sqlite/main.fmf | 18 +++++++ Smoke/nodejs-sqlite/runtest.sh | 69 ++++++++++++++++++++++++++ Smoke/nodejs-sqlite/sqlite-sessions.js | 34 +++++++++++++ Smoke/nodejs-sqlite/sqlite.js | 16 ++++++ 4 files changed, 137 insertions(+) create mode 100644 Smoke/nodejs-sqlite/main.fmf create mode 100755 Smoke/nodejs-sqlite/runtest.sh create mode 100644 Smoke/nodejs-sqlite/sqlite-sessions.js create mode 100644 Smoke/nodejs-sqlite/sqlite.js diff --git a/Smoke/nodejs-sqlite/main.fmf b/Smoke/nodejs-sqlite/main.fmf new file mode 100644 index 0000000..61f3067 --- /dev/null +++ b/Smoke/nodejs-sqlite/main.fmf @@ -0,0 +1,18 @@ +summary: Test to insure sqlite module works properly +test: ./runtest.sh +framework: beakerlib +description: | + Nodejs update has introduced the usage of sqlite sessions, + this test verifies the ability of nodejs to use this. +duration: 5m +require: + - nodejs +# - type: file +# pattern: +# - /template.file +contact: + - tjuhasz@redhat.com + - aradchen@redhat.com +tag: smoke +component: + - nodejs diff --git a/Smoke/nodejs-sqlite/runtest.sh b/Smoke/nodejs-sqlite/runtest.sh new file mode 100755 index 0000000..6ed4035 --- /dev/null +++ b/Smoke/nodejs-sqlite/runtest.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Author: Tomas Juhasz +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +SQLITE_TEST_SCRIPT='test-sqlite.js' # Name of the SQLite test script +#Expected values +EXPECTED_SUBSTRING_B="{ key: 1, value: 'hello' }" +EXPECTED_SUBSTRING_S="Test Passed" +#Script Files +SQLITE_TEST_SCRIPT='sqlite.js' +SQLITE_TEST_SCRIPT_SESSION='sqlite-sessions.js' + +NODEJS=${NODEJS:-node} +NPMJS=${NPMJS:-npm} +rlJournalStart + rlPhaseStartSetup + #Push everything into temp directory + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "cp $SQLITE_TEST_SCRIPT \$tmp/$SQLITE_TEST_SCRIPT" + rlRun "cp $SQLITE_TEST_SCRIPT_SESSION \$tmp/$SQLITE_TEST_SCRIPT_SESSION" + rlRun "pushd \$tmp" + rlPhaseEnd + + rlPhaseStartTest + rlLogInfo "Running SQLite test script" + rlRun "$NPMJS install sqlite" + rlRun "$NODEJS --experimental-sqlite $SQLITE_TEST_SCRIPT > output.txt" 0 "Execute Node.js SQLite test script" + OUTPUT=$(cat output.txt) + #Run just a standart script using sqlite + rlAssertGrep "$EXPECTED_SUBSTRING_B" output.txt + rlRun "$NODEJS --experimental-sqlite $SQLITE_TEST_SCRIPT_SESSION > output_session.txt" 0 "Execute Node.js SQLite test script" + OUTPUT=$(cat output_session.txt) + #Run script using sqlite which utilizes the session feature + rlAssertGrep "$EXPECTED_SUBSTRING_S" output_session.txt + rlPhaseEnd + + rlPhaseStartCleanup + rlLogInfo "Cleaning up test environment" + rlRun "$NPMJS remove sqlite" + rlRun "rm -r *" + rlRun "popd" + rlRun "rm -r \$tmp" 0 "Remove tmp directory" + rlPhaseEnd + +rlJournalEnd + diff --git a/Smoke/nodejs-sqlite/sqlite-sessions.js b/Smoke/nodejs-sqlite/sqlite-sessions.js new file mode 100644 index 0000000..44a4105 --- /dev/null +++ b/Smoke/nodejs-sqlite/sqlite-sessions.js @@ -0,0 +1,34 @@ +import { DatabaseSync } from 'node:sqlite'; + +const sourceDb = new DatabaseSync(':memory:'); +const targetDb = new DatabaseSync(':memory:'); + +sourceDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)'); +targetDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)'); + +const session = sourceDb.createSession(); + +try { + const insert = sourceDb.prepare('INSERT INTO data (key, value) VALUES (?, ?)'); + insert.run(1, 'hello'); + insert.run(2, 'world'); + + const changeset = session.changeset(); + + targetDb.applyChangeset(changeset); + + const sourceData = sourceDb.prepare('SELECT * FROM data ORDER BY key').all(); + const targetData = targetDb.prepare('SELECT * FROM data ORDER BY key').all(); + + console.log('Source Data:', sourceData); + console.log('Target Data:', targetData); + + if (JSON.stringify(sourceData) === JSON.stringify(targetData)) { + console.log('Test Passed: Changes were successfully applied to the target database'); + } else { + console.log('Test Failed: Data mismatch between source and target databases'); + } +} finally { + session.close(); +} + diff --git a/Smoke/nodejs-sqlite/sqlite.js b/Smoke/nodejs-sqlite/sqlite.js new file mode 100644 index 0000000..1298809 --- /dev/null +++ b/Smoke/nodejs-sqlite/sqlite.js @@ -0,0 +1,16 @@ +const { DatabaseSync } = require('node:sqlite'); +const database = new DatabaseSync(':memory:'); + +database.exec(` + CREATE TABLE data( + key INTEGER PRIMARY KEY, + value TEXT + ) STRICT +`); +const insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)'); + +insert.run(1, 'hello'); +insert.run(2, 'world'); +const query = database.prepare('SELECT * FROM data ORDER BY key'); + +console.log(query.all());