From b4f10864b1d4dd2ef0f83312b24eca764b6c63f4 Mon Sep 17 00:00:00 2001 From: Marian Koncek Date: Fri, 17 Mar 2023 14:22:37 +0100 Subject: [PATCH] Add smoke tests, enable JPV tests --- .fmf/version | 1 + ci.fmf | 1 + gating.yaml | 9 +++++++++ plans/Smoke.java | 45 ++++++++++++++++++++++++++++++++++++++++++ plans/javapackages.fmf | 7 +++++++ plans/smoke.fmf | 24 ++++++++++++++++++++++ 6 files changed, 87 insertions(+) create mode 100644 .fmf/version create mode 100644 ci.fmf create mode 100644 gating.yaml create mode 100644 plans/Smoke.java create mode 100644 plans/javapackages.fmf create mode 100644 plans/smoke.fmf 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/ci.fmf b/ci.fmf new file mode 100644 index 0000000..c5aa0e0 --- /dev/null +++ b/ci.fmf @@ -0,0 +1 @@ +resultsdb-testcase: separate diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..7b6e38f --- /dev/null +++ b/gating.yaml @@ -0,0 +1,9 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: + - bodhi_update_push_testing + - bodhi_update_push_stable +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build./plans/smoke.functional} + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build./plans/javapackages.functional} diff --git a/plans/Smoke.java b/plans/Smoke.java new file mode 100644 index 0000000..f51d935 --- /dev/null +++ b/plans/Smoke.java @@ -0,0 +1,45 @@ +import jakarta.xml.bind.annotation.XmlRootElement; + +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; + +import java.io.InputStream; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; + +@XmlRootElement(namespace = "org.fedoraproject.jaxb.test.smoke") +class Data +{ + public String text = "default text"; + public int number = 123; +} + +public class Smoke +{ + public static void main(String[] args) throws Exception + { + JAXBContext context = JAXBContext.newInstance(Data.class); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + m.marshal(new Data(), baos); + + Unmarshaller um = context.createUnmarshaller(); + + Data data; + try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) { + data = Data.class.cast(um.unmarshal(is)); + } + + if (!data.text.equals("default text")) + { + throw new RuntimeException("Expected \"default text\", found \"" + data.text + "\""); + } + if (data.number != 123) + { + throw new RuntimeException("Expected 123, found " + String.valueOf(data.number)); + } + } +} diff --git a/plans/javapackages.fmf b/plans/javapackages.fmf new file mode 100644 index 0000000..0cbb629 --- /dev/null +++ b/plans/javapackages.fmf @@ -0,0 +1,7 @@ +summary: Run javapackages-specific tests +discover: + how: fmf + url: https://src.fedoraproject.org/tests/javapackages + ref: f39 +execute: + how: tmt diff --git a/plans/smoke.fmf b/plans/smoke.fmf new file mode 100644 index 0000000..c2f8f41 --- /dev/null +++ b/plans/smoke.fmf @@ -0,0 +1,24 @@ +summary: Basic smoke test +prepare: + - how: install + package: + - java-11-openjdk-devel + - xmvn-tools + - mvn(jakarta.activation:jakarta.activation-api) + - mvn(jakarta.xml.bind:jakarta.xml.bind-api) + - mvn(com.sun.istack:istack-commons-runtime) +discover: + how: shell + tests: + - name: /smoke/marshal-unmarshal + test: | + CLASSPATH+=":$(xmvn-resolve jakarta.activation:jakarta.activation-api)" + CLASSPATH+=":$(xmvn-resolve jakarta.xml.bind:jakarta.xml.bind-api)" + CLASSPATH+=":$(xmvn-resolve com.sun.istack:istack-commons-runtime)" + CLASSPATH+=":$(xmvn-resolve org.glassfish.jaxb:jaxb-runtime)" + CLASSPATH+=":$(xmvn-resolve org.glassfish.jaxb:jaxb-core)" + export CLASSPATH + /usr/lib/jvm/java-11-openjdk/bin/javac plans/Smoke.java + /usr/lib/jvm/java-11-openjdk/bin/java -cp "${CLASSPATH}:plans" Smoke +execute: + how: tmt