Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

RHTAP/Testing Farm integration tests #120

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
61 changes: 61 additions & 0 deletions .tekton/centos-bootc-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: testing-farm
spec:
description: >-
Expects a list of container images to be provided via the SNAPSHOT parameter.
A secret containing the testing-farm API token should be made available via a secret with the name `testing-farm-secret` containing a key `testing-farm-token`.
params:
- name: SNAPSHOT
description: A list of container images that should undergo testing
type: string
- name: GIT_URL
description: URL of the GIT repository that contains the tests.
type: string
- name: GIT_REF
default: "main"
description: Branch of the git repository used containing the tests
type: string
- name: COMPOSE
default: "Fedora-Rawhide"
description: Compose to use for the system-under-test.
type: string
- name: ARCH
default: "x86_64"
description: Comma-separated list of architectures to run against.
type: string
- name: TIMEOUT
default: "720"
description: Set the timeout for the request in minutes. If the test takes longer than this, it will be terminated.
type: string
- name: TESTING_FARM_API_URL
default: https://api.dev.testing-farm.io/v0.1
description: The testing-farm instance API to use
type: string
tasks:
- name: testing-farm
taskRef:
resolver: git
params:
- name: url
value: https://github.com/centos/centos-bootc/
- name: revision
value: main
- name: pathInRepo
value: .tekton/testing-farm.yaml
params:
- name: SNAPSHOT
value: $(params.SNAPSHOT)
- name: GIT_URL
value: $(params.GIT_URL)
- name: GIT_REF
value: $(params.GIT_REF)
- name: COMPOSE
value: $(params.COMPOSE)
- name: ARCH
value: $(params.ARCH)
- name: TIMEOUT
value: $(params.TIMEOUT)
- name: TESTING_FARM_API_URL
value: $(params.TESTING_FARM_API_URL)
63 changes: 63 additions & 0 deletions .tekton/testing-farm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: testing-farm
spec:
description: Initiate testing-farm test given a list of container images
params:
- name: SNAPSHOT
description: A list of container images that should undergo testing
- name: GIT_URL
description: URL of the GIT repository that contains the tests.
- name: GIT_REF
default: "main"
description: Branch of the git repository used containing the tests
- name: COMPOSE
default: "Fedora-Rawhide"
description: Compose to use for the system-under-test.
- name: ARCH
default: "x86_64"
description: Comma-separated list of architectures to run against.
- name: TIMEOUT
default: "720"
description: Set the timeout for the request in minutes. If the test takes longer than this, it will be terminated.
- name: TESTING_FARM_API_URL
default: https://api.dev.testing-farm.io/v0.1
description: The testing-farm instance API to use
volumes:
- name: testing-farm-secret
secret:
secretName: testing-farm-secret
steps:
- image: quay.io/testing-farm/cli:latest
volumeMounts:
- name: testing-farm-secret
mountPath: "/etc/secrets"
readOnly: true
env:
- name: SNAPSHOT
value: $(params.SNAPSHOT)
- name: GIT_URL
value: $(params.GIT_URL)
- name: GIT_REF
value: $(params.GIT_REF)
- name: COMPOSE
value: $(params.COMPOSE)
- name: ARCH
value: $(params.ARCH)
- name: TIMEOUT
value: $(params.TIMEOUT)
- name: TESTING_FARM_API_URL
value: $(params.TESTING_FARM_API_URL)
script: |
#!/usr/bin/env bash

export TESTING_FARM_API_TOKEN=$(cat /etc/secrets/testing-farm-token)

testing-farm request \
--environment SNAPSHOT="$(echo ${SNAPSHOT} | base64 -w 0)" \
--git-url "${GIT_URL}" \
--git-ref "${GIT_REF}" \
--compose "${COMPOSE}" \
--arch "${ARCH}" \
--timeout "${TIMEOUT}"
30 changes: 30 additions & 0 deletions plans/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
summary: Example of working with Snapshots from RHTAP

prepare:
- name: Install packages
how: install
package:
# For working with the SNAPSHOT var
- jq
# Just for interacting with the images
- podman

execute:
# Note, the ' character works here because the ${SNAPSHOT} is not a shell
# environment variable. it is treated by tmt as a tmt variable which is
# injected into the script before it is evaluated by bash.
script: |
echo "This is where the test script goes."

echo "The base64 encoded snapshot is: ${SNAPSHOT}"
echo -n "The base64 decoded snapshot is: "
echo $SNAPSHOT | base64 -d

echo "It contains the following container images:"

IMAGES=$(echo '${SNAPSHOT}' | base64 -d | jq -r '.components[].containerImage')

# Then, perform some check
for IMAGE in $IMAGES; do
podman run $IMAGE cat /etc/os-release
done
Loading