diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.tekton/testing-devel/kustomization.yaml b/.tekton/testing-devel/kustomization.yaml index 39719979ed..d1713b283e 100644 --- a/.tekton/testing-devel/kustomization.yaml +++ b/.tekton/testing-devel/kustomization.yaml @@ -5,3 +5,4 @@ resources: - on-pull-request - on-pull-request-overrides - on-push + - testing-farm.yaml diff --git a/.tekton/testing-devel/testing-farm.yaml b/.tekton/testing-devel/testing-farm.yaml new file mode 100644 index 0000000000..7c6302ca5b --- /dev/null +++ b/.tekton/testing-devel/testing-farm.yaml @@ -0,0 +1,65 @@ +apiVersion: appstudio.redhat.com/v1beta2 +kind: IntegrationTestScenario +metadata: + labels: + test.appstudio.openshift.io/optional: "true" + name: fedora-coreos-testing-devel-kola-tests-x86-64 +spec: + application: fedora-coreos-testing-devel + contexts: + - name: component_fedora-coreos-testing-devel + resolverRef: + params: + - name: url + value: https://gitlab.com/testing-farm/integrations-konflux + - name: revision + value: v3.16 + - name: pathInRepo + value: pipeline/tmt-via-testing-farm/tmt-via-testing-farm.yaml + resolver: git + params: + - name: COMPOSE + value: Fedora-43 + - name: ARCH + value: x86_64 + - name: IMAGE_TAG + value: v3.16 + - name: GIT_URL + value: https://github.com/Roshan-R/fedora-coreos-config + - name: GIT_REF + value: testing-farm-kola + - name: TMT_PLAN + value: tmt +--- +apiVersion: appstudio.redhat.com/v1beta2 +kind: IntegrationTestScenario +metadata: + labels: + test.appstudio.openshift.io/optional: "true" + name: fedora-coreos-testing-devel-kola-tests-aarch64 +spec: + application: fedora-coreos-testing-devel + contexts: + - name: component_fedora-coreos-testing-devel + resolverRef: + params: + - name: url + value: https://gitlab.com/testing-farm/integrations-konflux + - name: revision + value: v3.16 + - name: pathInRepo + value: pipeline/tmt-via-testing-farm/tmt-via-testing-farm.yaml + resolver: git + params: + - name: COMPOSE + value: Fedora-43 + - name: ARCH + value: aarch64 + - name: IMAGE_TAG + value: v3.16 + - name: GIT_URL + value: https://github.com/Roshan-R/fedora-coreos-config + - name: GIT_REF + value: testing-farm-kola + - name: TMT_PLAN + value: tmt diff --git a/plans.fmf b/plans.fmf new file mode 100644 index 0000000000..4fc507f57f --- /dev/null +++ b/plans.fmf @@ -0,0 +1,5 @@ +/kola: + enabled: true + discover: + how: fmf + path: tmt diff --git a/tmt/plans/kola-iso.fmf b/tmt/plans/kola-iso.fmf new file mode 100644 index 0000000000..71465eaf90 --- /dev/null +++ b/tmt/plans/kola-iso.fmf @@ -0,0 +1,32 @@ +discover: + how: fmf + test: + - init + - build-iso + - test-iso +adjust+: + - when: arch == x86_64 or arch == aarch64 + provision: + hardware: + cpu: + processors: ">= 4" + memory: ">= 8 GB" + disk: + - size: ">= 50 GB" + virtualization: + is-supported: true +prepare: + - how: install + package: + - libvirt + - qemu-kvm + - qemu-img + - skopeo + - virt-install + - wget + - jq + - git + - how: shell + script: podman pull quay.io/coreos-assembler/coreos-assembler:latest +execute: + how: tmt diff --git a/tmt/plans/kola-qemu.fmf b/tmt/plans/kola-qemu.fmf new file mode 100644 index 0000000000..8edefd459b --- /dev/null +++ b/tmt/plans/kola-qemu.fmf @@ -0,0 +1,32 @@ +discover: + how: fmf + test: + - init + - build-qemu + - test-qemu +adjust+: + - when: arch == x86_64 or arch == aarch64 + provision: + hardware: + cpu: + processors: ">= 4" + memory: ">= 8 GB" + disk: + - size: ">= 50 GB" + virtualization: + is-supported: true +prepare: + - how: install + package: + - libvirt + - qemu-kvm + - qemu-img + - skopeo + - virt-install + - wget + - jq + - git + - how: shell + script: podman pull quay.io/coreos-assembler/coreos-assembler:latest +execute: + how: tmt diff --git a/tmt/tests/build-iso.sh b/tmt/tests/build-iso.sh new file mode 100755 index 0000000000..e7c9f64648 --- /dev/null +++ b/tmt/tests/build-iso.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -eo pipefail +set -x + +source $HOME/utils.sh + +mkdir -p $COSA_DIR +cosa init --force ${TESTING_FARM_GIT_URL} --branch ${TESTING_FARM_GIT_REF} +cosa import docker://$IMAGE_URL +CONFIG_COMMIT=$(jq -r ".\"coreos-assembler.oci-imported-labels\".\"vcs-ref\"" ${COSA_DIR}/builds/latest/$(arch)/meta.json) +pushd ${COSA_DIR}/src/config +git config --global --add safe.directory ${COSA_DIR}/src/config +git checkout $CONFIG_COMMIT +popd +cosa osbuild live metal metal4k diff --git a/tmt/tests/build-qemu.sh b/tmt/tests/build-qemu.sh new file mode 100755 index 0000000000..b834d4c0ca --- /dev/null +++ b/tmt/tests/build-qemu.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -eo pipefail +set -x + +source $HOME/utils.sh + +mkdir -p $COSA_DIR +cosa init --force ${TESTING_FARM_GIT_URL} --branch ${TESTING_FARM_GIT_REF} +cosa import docker://$IMAGE_URL +CONFIG_COMMIT=$(jq -r ".\"coreos-assembler.oci-imported-labels\".\"vcs-ref\"" ${COSA_DIR}/builds/latest/$(arch)/meta.json) +pushd ${COSA_DIR}/src/config +git config --global --add safe.directory ${COSA_DIR}/src/config +git checkout $CONFIG_COMMIT +popd +cosa osbuild qemu diff --git a/tmt/tests/init.sh b/tmt/tests/init.sh new file mode 100755 index 0000000000..61a67859db --- /dev/null +++ b/tmt/tests/init.sh @@ -0,0 +1,37 @@ +#!/bin/bash +export COREOS_ASSEMBLER_CONTAINER_LATEST="quay.io/coreos-assembler/coreos-assembler:latest" + +cat <<'EOF' > $HOME/utils.sh +export COSA_DIR=$HOME/workspace/build +cosa () +{ + export COREOS_ASSEMBLER_CONTAINER_LATEST="quay.io/coreos-assembler/coreos-assembler:latest" + set -x; + podman run --rm --security-opt=label=disable --privileged \ + -v=${COSA_DIR}:/srv/ --device=/dev/kvm \ + --device=/dev/fuse --tmpfs=/tmp -v=/var/tmp:/var/tmp --name=cosa ${COREOS_ASSEMBLER_CONTAINER_LATEST} "$@"; +} +collect_kola_artifacts() { + mkdir -p "$TMT_TEST_DATA" + cd $COSA_DIR && tar -C "$OUTPUT_DIR" -c --xz "$KOLA_ID" > "$KOLA_ID-$TOKEN.tar.xz" + cd $COSA_DIR && mv "$KOLA_ID-$TOKEN.tar.xz" "$TMT_TEST_DATA/$KOLA_ID-$TOKEN.tar.xz" +} +run_kola(){ + OUTPUT_DIR=$(cd $COSA_DIR && cosa shell -- mktemp -d tmp/kola-XXXX) + TOKEN=$(uuidgen | cut -f1 -d -) + KOLA_ID=${KOLA_ID:-kola} + cd $COSA_DIR && cosa kola "$KOLA_ACTION" --build=latest --arch=$(arch) --output-dir="$OUTPUT_DIR/$KOLA_ID" $KOLA_EXTRA_ARGS +} +EOF + +echo "cosa container: $COREOS_ASSEMBLER_CONTAINER_LATEST" +echo "arch: $(arch)" +echo "using image: $IMAGE_URL" +echo "git version: $(git --version)" +echo "git url: ${TESTING_FARM_GIT_URL}" +echo "git branch: ${TESTING_FARM_GIT_REF}" +git clone ${TESTING_FARM_GIT_URL} /tmp/git-repo +pushd /tmp/git-repo +git checkout ${TESTING_FARM_GIT_REF} +# assert commit and $TESTING_FARM_GIT_REF are the same ? +echo "git commit message: $(git log --format=%B -n 1 HEAD)" diff --git a/tmt/tests/kola.fmf b/tmt/tests/kola.fmf new file mode 100644 index 0000000000..9fbcf0cd16 --- /dev/null +++ b/tmt/tests/kola.fmf @@ -0,0 +1,31 @@ +test: ./test.sh + +/init: + duration: 1h + order: 60 + environment: + TEST_CASE: init + +/build-qemu: + duration: 1h + order: 70 + environment: + TEST_CASE: build-qemu + +/test-qemu: + duration: 2h + order: 80 + environment: + TEST_CASE: test-qemu + +/build-iso: + duration: 1h + order: 90 + environment: + TEST_CASE: build-iso + +/test-iso: + duration: 2h + order: 100 + environment: + TEST_CASE: test-iso diff --git a/tmt/tests/test-iso.sh b/tmt/tests/test-iso.sh new file mode 100755 index 0000000000..eaacaec172 --- /dev/null +++ b/tmt/tests/test-iso.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail +set -x + +source $HOME/utils.sh +trap collect_kola_artifacts EXIT + +KOLA_ACTION="testiso" +KOLA_ID="testiso" +KOLA_EXTRA_ARGS="--inst-insecure" +run_kola +#cosa kola testiso --inst-insecure --build=latest --arch=$(arch) diff --git a/tmt/tests/test-qemu.sh b/tmt/tests/test-qemu.sh new file mode 100755 index 0000000000..8eb5c0e834 --- /dev/null +++ b/tmt/tests/test-qemu.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -euo pipefail +set -x + +source $HOME/utils.sh +trap collect_kola_artifacts EXIT + +KOLA_ACTION="run" +KOLA_ID="kola" +KOLA_EXTRA_ARGS="--rerun --allow-rerun-success=tags=needs-internet --on-warn-failure-exit-77 --tag=!reprovision --parallel=5" +run_kola +#cosa kola run --rerun --allow-rerun-success=tags=needs-internet \ +# --build=latest --on-warn-failure-exit-77 --arch=$(arch) \ +# '--tag=!reprovision' --parallel=5 diff --git a/tmt/tests/test.sh b/tmt/tests/test.sh new file mode 100755 index 0000000000..e6b8a05fbd --- /dev/null +++ b/tmt/tests/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +if [ "$TEST_CASE" = "init" ]; then + ./init.sh +elif [ "$TEST_CASE" = "build-qemu" ]; then + ./build-qemu.sh +elif [ "$TEST_CASE" = "test-qemu" ]; then + ./test-qemu.sh +elif [ "$TEST_CASE" = "build-iso" ]; then + ./build-iso.sh +elif [ "$TEST_CASE" = "test-iso" ]; then + ./test-iso.sh +else + echo "Error: Test case $TEST_CASE not found!" + exit 1 +fi