...
1#!/bin/bash
2
3set -o nounset
4set -o pipefail
5
6source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
7
8# Build yq when it's not present and not overriden for a specific file.
9if [ -z "${YQ:-}" ];then
10 ${TOOLS_MAKE} yq
11 YQ="${TOOLS_OUTPUT}/yq"
12fi
13
14validate_suite_files() {
15 FOLDER=$1
16
17 for file in ${FOLDER}/*.yaml; do
18 if [ ! -f $file ]; then
19 # It's likely the bash expansion didn't find any yaml files.
20 continue
21 fi
22
23 if [ $(${YQ} eval '.apiVersion' $file) != "apiextensions.k8s.io/v1" ]; then
24 continue
25 fi
26
27 if [ $(${YQ} eval '.kind' $file) != "CustomResourceDefinition" ]; then
28 continue
29 fi
30
31 CRD_NAME=$(echo $file | sed s:"${FOLDER}/":: )
32 GROUP=$(${YQ} eval '.spec.group' $file)
33 KIND=$(${YQ} eval '.spec.names.kind' $file)
34 SINGULAR=$(${YQ} eval '.spec.names.singular' $file)
35
36 FILE_BASE="stable"
37
38 FEATURESET=$(${YQ} eval '.metadata.annotations["release.openshift.io/feature-set"]' $file)
39 if [ ${FEATURESET} == "TechPreviewNoUpgrade" ]; then
40 # TechPreviewNoUpgrade CRDs should start with techpreview for their test suites.
41 FILE_BASE="techpreview"
42 fi
43
44 SUITE_FILE=${FOLDER}/${FILE_BASE}.${SINGULAR}.testsuite.yaml
45
46 if [ ! -f ${SUITE_FILE} ]; then
47 echo "No test suite file found for CRD ${file}"
48 exit 1
49 fi
50 done
51}
52
53for groupVersion in ${API_GROUP_VERSIONS}; do
54 echo "Validating integration tests for ${groupVersion}"
55 validate_suite_files ${SCRIPT_ROOT}/${groupVersion}
56done
View as plain text