From bd65ea9dea448722e164ec92b4095e6698376787 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Fri, 3 Mar 2023 12:53:49 +0100 Subject: [PATCH] Onboard package into gating --- .fmf/version | 1 + gating.yaml | 8 ++++++++ plans/plan.fmf | 5 +++++ tests/main.fmf | 4 ++++ tests/smoke/main.fmf | 3 +++ tests/smoke/runtest.sh | 23 +++++++++++++++++++++++ tests/smoke/smoke.lua | 37 +++++++++++++++++++++++++++++++++++++ 7 files changed, 81 insertions(+) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 plans/plan.fmf create mode 100644 tests/main.fmf create mode 100644 tests/smoke/main.fmf create mode 100755 tests/smoke/runtest.sh create mode 100644 tests/smoke/smoke.lua 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/gating.yaml b/gating.yaml new file mode 100644 index 0000000..05d1cc5 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,8 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: + - bodhi_update_push_testing + - bodhi_update_push_stable +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/plans/plan.fmf b/plans/plan.fmf new file mode 100644 index 0000000..39a49cb --- /dev/null +++ b/plans/plan.fmf @@ -0,0 +1,5 @@ +summary: Run smoke tests from dist-git +discover: + how: fmf +execute: + how: tmt diff --git a/tests/main.fmf b/tests/main.fmf new file mode 100644 index 0000000..99fd67e --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,4 @@ +contact: Mikolaj Izdebski +framework: beakerlib +test: ./runtest.sh +tier: 0 diff --git a/tests/smoke/main.fmf b/tests/smoke/main.fmf new file mode 100644 index 0000000..1f8a6d4 --- /dev/null +++ b/tests/smoke/main.fmf @@ -0,0 +1,3 @@ +summary: Lujavrite smoke test +description: Test basic functionality of Lujavrite. +require: java-17-openjdk-headless diff --git a/tests/smoke/runtest.sh b/tests/smoke/runtest.sh new file mode 100755 index 0000000..b8f57ed --- /dev/null +++ b/tests/smoke/runtest.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Author: Mikolaj Izdebski +. /usr/share/beakerlib/beakerlib.sh + +rlJournalStart + + rlPhaseStartSetup + rlAssertRpm lujavrite + rlAssertRpm java-17-openjdk-headless + export JAVA_HOME=/usr/lib/jvm/jre-17-openjdk + rlPhaseEnd + + rlPhaseStartTest + rlAssertExists "${JAVA_HOME}" + rlAssertExists "${JAVA_HOME}/lib/server/libjvm.so" + rlRun -s "lua smoke.lua" + rlAssertGrep "Java version is 17" $rlRun_LOG + rlAssertGrep "foo is bar" $rlRun_LOG + rlAssertGrep "nil in Lua is null in Java" $rlRun_LOG + rlPhaseEnd + +rlJournalEnd +rlJournalPrintText diff --git a/tests/smoke/smoke.lua b/tests/smoke/smoke.lua new file mode 100644 index 0000000..20c6148 --- /dev/null +++ b/tests/smoke/smoke.lua @@ -0,0 +1,37 @@ +local lujavrite = require "lujavrite" + +-- Determine Java home to use +java_home = os.getenv("JAVA_HOME") +if java_home == nil then + java_home = "/usr/lib/jvm/jre" +end + +-- Initialize JVM +lujavrite.init(java_home .. "/lib/server/libjvm.so", "-ea", "-esa") + +-- System.getProperty(key) +function get_property(key) + return lujavrite.call( + "java/lang/System", "getProperty", + "(Ljava/lang/String;)Ljava/lang/String;", + key + ) +end + +-- System.setProperty(key, value) +function set_property(key, value) + return lujavrite.call( + "java/lang/System", "setProperty", + "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", + key, value + ) +end + +local java_version = get_property("java.version") +print("Java version is " .. java_version) + +set_property("foo", "bar") +print("foo is " .. get_property("foo")) + +local java_nil = lujavrite.call("java/lang/String", "valueOf", "(Ljava/lang/Object;)Ljava/lang/String;", nil) +print("nil in Lua is " .. java_nil .. " in Java")