Skip to content

Commit 1276a73

Browse files
authored
Merge pull request #688 from yih-redhat/konflux-its
ci: add konflux test cases
2 parents 4a0a7bf + 9b40777 commit 1276a73

6 files changed

Lines changed: 279 additions & 0 deletions

konflux/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Konflux integration test cases
2+
As RedHat uses Konflux to build, verify and release containers now, all fdo containers will be built in konflux. The integration test cases defined in this folder will be triggered by konflux when new fdo container images are built.
3+
4+
## How konflux trigger test cases
5+
konflux defines integration test workflow in this file: (when writing this doc, below files are not merged into konflux yet, will update it later)
6+
- https://gitlab.cee.redhat.com/releng/konflux-release-data/-/merge_requests/2167/diffs#3904e36f53d22f073f197dedd0bd6355289a0053
7+
8+
Within this file, it defines fdo repo url and test file path:
9+
- fdo repo: https://gitlab.cee.redhat.com/releng/konflux-release-data/-/merge_requests/2167/diffs#3904e36f53d22f073f197dedd0bd6355289a0053_0_15
10+
- test file: https://gitlab.cee.redhat.com/releng/konflux-release-data/-/merge_requests/2167/diffs#3904e36f53d22f073f197dedd0bd6355289a0053_0_19
11+
12+
When konflux trigger integration test workflow, it will go to fdo repo and get the test file, and execute the tasks defined in test file.
13+
14+
## Test files in this folder
15+
There are four pipeline files and one test file in this folder.
16+
- fdo-manufacturing-server-integration-tests.yaml
17+
- fdo-owner-onboarding-server-integration-tests.yaml
18+
- fdo-rendezvous-server-integration-tests.yaml
19+
- fdo-serviceinfo-api-server-integration-tests.yaml
20+
- fdo-container-test.yaml
21+
22+
## Test case definition (manufacturing server test case as example)
23+
There are two yaml files for manufacturing server test.
24+
25+
- fdo-manufacturing-server-integration-tests.yaml: This is the test file defined in konflux integration test workflow file, this file defines parameters, env variables and tasks. It also defines a task file path and pass all the parameters to that task file.
26+
Example of parameters:
27+
- SNAPSHOT: a parameter from konflux, it is basically the description of container that was built.
28+
- GIT_URL: tell konflux which git repo to get
29+
- GIT_REF: tell konflux which branch to use
30+
31+
- fdo-container-test.yaml: This is the task file that defined in fdo-manufacturing-server-integration-tests.yaml, it defines some actions:
32+
- get secrets from konflux
33+
- set parameters
34+
- get the url of fdo container we want to test
35+
- run bash script
36+
37+
## How to get fdo container
38+
In task yaml file, we can use parameter SNAPSHOT to retrieve container image url, the returned value will be like quay.io/fido-fdo/serviceinfo-api-server
39+
- IMAGE=$(echo "${SNAPSHOT}" | jq -r ".components[]|select(.name==\"$COMPONENT\")|.containerImage")
40+
41+
## How to set test runner
42+
In task yaml file, we can specify the os and version of test runner to execute all the actions.
43+
Set image like this, "- image: quay.io/testing-farm/cli:latest"
44+
- It means to use the latest testing-farm cli container as runner, the benefit is that if you want to reserve a testing-farm machine to run test cases, you can use testing-farm command directly in script section and no need to install testing-farm related packages.
45+
- If you want to run test cases in this runner directly, just write all test cases in script section.
46+
47+
Depends on the os of test runner, you need to use different commands in bash script.
48+
- For testing-farm runner, run apk to install packages
49+
- For RHEL, Centos-Stream, Fedora, run dnf or yum to install packages.
50+
51+
52+
53+

konflux/fdo-container-test.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apiVersion: tekton.dev/v1
2+
kind: Task
3+
metadata:
4+
name: fdo-container-test
5+
spec:
6+
description: Initiate test given a list of container images
7+
params:
8+
- name: SNAPSHOT
9+
description: A list of container images that should undergo testing
10+
- name: GIT_URL
11+
description: URL of the GIT repository that contains the tests.
12+
- name: GIT_REF
13+
description: Branch of the git repository used containing the tests
14+
volumes:
15+
- name: podinfo
16+
downwardAPI:
17+
items:
18+
- path: "labels"
19+
fieldRef:
20+
fieldPath: metadata.labels
21+
- path: "annotations"
22+
fieldRef:
23+
fieldPath: metadata.annotations
24+
steps:
25+
- image: quay.io/testing-farm/cli:latest
26+
volumeMounts:
27+
- name: podinfo
28+
mountPath: /etc/podinfo
29+
env:
30+
- name: SNAPSHOT
31+
value: $(params.SNAPSHOT)
32+
- name: GIT_URL
33+
value: $(params.GIT_URL)
34+
- name: GIT_REF
35+
value: $(params.GIT_REF)
36+
script: |
37+
#!/usr/bin/env bash
38+
sed -i -e 's/v3\.15/v3\.16/g' /etc/apk/repositories
39+
apk update
40+
apk add --upgrade apk-tools
41+
apk upgrade --available
42+
apk add skopeo jq grep curl
43+
44+
cat /etc/podinfo/labels
45+
PR_NAME=$(cat /etc/podinfo/labels | grep -oP '(?<=pipelineRun=")[^"]+')
46+
COMPONENT=$(cat /etc/podinfo/labels | grep -oP '(?<=component=")[^"]+')
47+
echo "PR_NAME:$PR_NAME"
48+
echo "COMPONENT:$COMPONENT"
49+
50+
echo "${SNAPSHOT}"
51+
IMAGE=$(echo "${SNAPSHOT}" | jq -r ".components[]|select(.name==\"$COMPONENT\")|.containerImage")
52+
COUNT=$(echo "${SNAPSHOT}" | jq -r ".components|map(select(.name==\"$COMPONENT\"))|length")
53+
if [[ ${COUNT} -ne 1 ]]; then
54+
echo "Error: multiple images: ${IMAGES} in this application with component name: ${COMPONENT}"
55+
exit 1
56+
fi
57+
echo $IMAGE
58+
59+
IMAGE_NAME=$(echo "${IMAGE##*/}" | cut -d @ -f 1)
60+
IMAGE_TAG=$(echo "${IMAGE##*/}" | cut -d : -f 2)
61+
echo "IMAGE_NAME:$IMAGE_NAME"
62+
echo "IMAGE_TAG:$IMAGE_TAG"
63+
64+
skopeo inspect docker://"$IMAGE" > skopeo_inspect.json
65+
cat skopeo_inspect.json
66+
NAME=$(cat skopeo_inspect.json | jq -r ".Name")
67+
echo "NAME:$NAME"
68+
69+
if [[ "$NAME" =~ "$IMAGE_NAME" ]]; then
70+
exit 0
71+
else
72+
exit 1
73+
fi
74+
timeout: "2h"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: tekton.dev/v1
2+
kind: Pipeline
3+
metadata:
4+
name: fdo manufacturing server integration tests
5+
spec:
6+
description: >-
7+
Expects a list of container images to be provided via the SNAPSHOT parameter.
8+
params:
9+
- name: SNAPSHOT
10+
description: A list of fdo container images that should undergo testing
11+
type: string
12+
- name: GIT_URL
13+
description: URL of the GIT repository that contains the tests.
14+
default: "https://github.com/fdo-rs/fido-device-onboard-rs"
15+
type: string
16+
- name: GIT_REF
17+
default: "main"
18+
description: Branch of the git repository used containing the tests
19+
type: string
20+
tasks:
21+
- name: fdo-container-test
22+
taskRef:
23+
resolver: git
24+
params:
25+
- name: url
26+
value: $(params.GIT_URL)
27+
- name: revision
28+
value: $(params.GIT_REF)
29+
- name: pathInRepo
30+
value: konflux/fdo-container-test.yaml
31+
params:
32+
- name: SNAPSHOT
33+
value: $(params.SNAPSHOT)
34+
- name: GIT_URL
35+
value: $(params.GIT_URL)
36+
- name: GIT_REF
37+
value: $(params.GIT_REF)
38+
timeout: "2h"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: tekton.dev/v1
2+
kind: Pipeline
3+
metadata:
4+
name: fdo owner onboarding server integration tests
5+
spec:
6+
description: >-
7+
Expects a list of container images to be provided via the SNAPSHOT parameter.
8+
params:
9+
- name: SNAPSHOT
10+
description: A list of fdo container images that should undergo testing
11+
type: string
12+
- name: GIT_URL
13+
description: URL of the GIT repository that contains the tests.
14+
default: "https://github.com/fdo-rs/fido-device-onboard-rs"
15+
type: string
16+
- name: GIT_REF
17+
default: "main"
18+
description: Branch of the git repository used containing the tests
19+
type: string
20+
tasks:
21+
- name: fdo-container-test
22+
taskRef:
23+
resolver: git
24+
params:
25+
- name: url
26+
value: $(params.GIT_URL)
27+
- name: revision
28+
value: $(params.GIT_REF)
29+
- name: pathInRepo
30+
value: konflux/fdo-container-test.yaml
31+
params:
32+
- name: SNAPSHOT
33+
value: $(params.SNAPSHOT)
34+
- name: GIT_URL
35+
value: $(params.GIT_URL)
36+
- name: GIT_REF
37+
value: $(params.GIT_REF)
38+
timeout: "2h"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: tekton.dev/v1
2+
kind: Pipeline
3+
metadata:
4+
name: fdo rendezvous server integration tests
5+
spec:
6+
description: >-
7+
Expects a list of container images to be provided via the SNAPSHOT parameter.
8+
params:
9+
- name: SNAPSHOT
10+
description: A list of fdo container images that should undergo testing
11+
type: string
12+
- name: GIT_URL
13+
description: URL of the GIT repository that contains the tests.
14+
default: "https://github.com/fdo-rs/fido-device-onboard-rs"
15+
type: string
16+
- name: GIT_REF
17+
default: "main"
18+
description: Branch of the git repository used containing the tests
19+
type: string
20+
tasks:
21+
- name: fdo-container-test
22+
taskRef:
23+
resolver: git
24+
params:
25+
- name: url
26+
value: $(params.GIT_URL)
27+
- name: revision
28+
value: $(params.GIT_REF)
29+
- name: pathInRepo
30+
value: konflux/fdo-container-test.yaml
31+
params:
32+
- name: SNAPSHOT
33+
value: $(params.SNAPSHOT)
34+
- name: GIT_URL
35+
value: $(params.GIT_URL)
36+
- name: GIT_REF
37+
value: $(params.GIT_REF)
38+
timeout: "2h"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: tekton.dev/v1
2+
kind: Pipeline
3+
metadata:
4+
name: fdo serviceinfo api server integration tests
5+
spec:
6+
description: >-
7+
Expects a list of container images to be provided via the SNAPSHOT parameter.
8+
params:
9+
- name: SNAPSHOT
10+
description: A list of fdo container images that should undergo testing
11+
type: string
12+
- name: GIT_URL
13+
description: URL of the GIT repository that contains the tests.
14+
default: "https://github.com/fdo-rs/fido-device-onboard-rs"
15+
type: string
16+
- name: GIT_REF
17+
default: "main"
18+
description: Branch of the git repository used containing the tests
19+
type: string
20+
tasks:
21+
- name: fdo-container-test
22+
taskRef:
23+
resolver: git
24+
params:
25+
- name: url
26+
value: $(params.GIT_URL)
27+
- name: revision
28+
value: $(params.GIT_REF)
29+
- name: pathInRepo
30+
value: konflux/fdo-container-test.yaml
31+
params:
32+
- name: SNAPSHOT
33+
value: $(params.SNAPSHOT)
34+
- name: GIT_URL
35+
value: $(params.GIT_URL)
36+
- name: GIT_REF
37+
value: $(params.GIT_REF)
38+
timeout: "2h"

0 commit comments

Comments
 (0)