Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecbe2863fa | ||
|
|
1c9af289cd |
5 changed files with 151 additions and 11 deletions
25
README.md
25
README.md
|
|
@ -22,22 +22,25 @@ sudo dnf install -y tmt+all
|
||||||
## If not provided create koji build and set env variable
|
## If not provided create koji build and set env variable
|
||||||
you can use the following allias to create build and set env automatically:
|
you can use the following allias to create build and set env automatically:
|
||||||
```bash
|
```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 \
|
if [ -z "$SRC_RPM" ]; then \
|
||||||
echo "No source RPM file found in the current directory."; \
|
echo "No source RPM file found."; \
|
||||||
return 1; \
|
return 1; \
|
||||||
fi; \
|
fi && \
|
||||||
BUILD_OUTPUT=$(koji build --scratch rawhide $SRC_RPM 2>&1); \
|
BUILD_OUTPUT=$(koji build --scratch rawhide $SRC_RPM 2>&1) && \
|
||||||
KOJI_TASK_ID=$(echo "$BUILD_OUTPUT" | grep -oP "(?<=Task ID: )[0-9]+"); \
|
echo "Koji build output: $BUILD_OUTPUT" && \
|
||||||
if [[ -n $KOJI_TASK_ID ]]; then \
|
KOJI_TASK_ID=$(echo "$BUILD_OUTPUT" | grep -oP "(?<=Task ID: )[0-9]+") && \
|
||||||
export KOJI_TASK_ID=$KOJI_TASK_ID; \
|
if [ -n "$KOJI_TASK_ID" ]; then \
|
||||||
echo "Scratch build completed. Task ID: $KOJI_TASK_ID"; \
|
export KOJI_TASK_ID="$KOJI_TASK_ID"; \
|
||||||
|
echo "Scratch build started. Task ID: $KOJI_TASK_ID"; \
|
||||||
else \
|
else \
|
||||||
echo "Failed to extract Task ID."; \
|
echo "Failed to extract Task ID. Build output: $BUILD_OUTPUT"; \
|
||||||
return 1; \
|
return 1; \
|
||||||
fi; \
|
fi; \
|
||||||
}; _scratchbuild'
|
set +x'
|
||||||
```
|
```
|
||||||
|
|
||||||
check what test plans and sub plans are available:
|
check what test plans and sub plans are available:
|
||||||
|
|
|
||||||
18
Smoke/nodejs-sqlite/main.fmf
Normal file
18
Smoke/nodejs-sqlite/main.fmf
Normal file
|
|
@ -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
|
||||||
69
Smoke/nodejs-sqlite/runtest.sh
Executable file
69
Smoke/nodejs-sqlite/runtest.sh
Executable file
|
|
@ -0,0 +1,69 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# Author: Tomas Juhasz <tjuhasz@redhat.com>
|
||||||
|
#
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
34
Smoke/nodejs-sqlite/sqlite-sessions.js
Normal file
34
Smoke/nodejs-sqlite/sqlite-sessions.js
Normal file
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
16
Smoke/nodejs-sqlite/sqlite.js
Normal file
16
Smoke/nodejs-sqlite/sqlite.js
Normal file
|
|
@ -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());
|
||||||
Loading…
Add table
Add a link
Reference in a new issue