Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend catalog test script to run tests for different platforms #797

Merged
merged 1 commit into from Nov 12, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions test/e2e-common.sh
Expand Up @@ -33,6 +33,15 @@ if [ "${BASH_VERSINFO:-0}" -lt 4 ];then
exit 1
fi

# Default registry image value to use in this script
REGISTRY_IMAGE="registry"

# Do the tasks modifications if special PLATFORM value is specified. By default nothing happens.
if [[ -n ${PLATFORM} ]] && [[ -f "$(dirname $0)/$(echo ${PLATFORM}| tr / -).sh" ]]; then
# Load script specific to platform. File name should follow the pattern "os-arch.sh", for instance "linux-s390x.sh".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

source $(dirname $0)/$(echo ${PLATFORM}| tr / -).sh
fi

## Commands

function require_command() {
Expand Down Expand Up @@ -86,7 +95,7 @@ print(yaml.dump(data, default_flow_style=False))
# Add an internal registry as sidecar to a task so we can upload it directly
# from our tests withouth having to go to an external registry.
function add_sidecar_registry() {
add_sidecars ${1} '{"image":"registry", "name": "registry"}'
add_sidecars ${1} "{'image':${REGISTRY_IMAGE}, 'name': 'registry'}"
}

# Run a secure registry as a sidecar to allow the tasks to push to this registry using the certs.
Expand Down Expand Up @@ -166,6 +175,10 @@ function test_yaml_can_install() {
for ignore in ${TEST_YAML_IGNORES};do
[[ ${ignore} == "${testname}" ]] && skipit=True
done

# In case if PLATFORM env variable is specified, do the tests only for matching tasks
[[ -n ${PLATFORM} ]] && [[ $(grep "tekton.dev/platforms" ${runtest} 2>/dev/null) != *"${PLATFORM}"* ]] && skipit=True

[[ -n ${skipit} ]] && break
echo "Checking ${testname}"
${KUBECTL_CMD} -n ${ns} apply -f <(sed "s/namespace:.*/namespace: task-ns/" "${runtest}")
Expand Down Expand Up @@ -224,7 +237,10 @@ function test_task_creation() {

cat ${taskdir}/*.yaml | grep 'tekton.dev/deprecated: \"true\"' && skipit=True

[[ -n ${skipit} ]] && continue
# In case if PLATFORM env variable is specified, do the tests only for matching tasks
[[ -n ${PLATFORM} ]] && [[ $(grep "tekton.dev/platforms" ${taskdir}/*.yaml 2>/dev/null) != *"${PLATFORM}"* ]] && skipit=True

[[ -n ${skipit} ]] && continue

# In case of rerun it's fine to ignore this error
${KUBECTL_CMD} create namespace ${tns} >/dev/null 2>/dev/null || :
Expand Down
38 changes: 38 additions & 0 deletions test/linux-s390x.sh
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# Copyright 2021 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# s390x specific registry
export REGISTRY_IMAGE=ibmcom/registry:2.6.2.5
# Maven image to use for s390x maven tasks
export MAVEN_IMAGE=maven:3.6.3-adoptopenjdk-11
# Architecture to use for golang tasks
export GOARCH=s390x
# Gradle image to use for s390x gradle tasks
export BUILDER_IMAGE=gradle:5.6.2-jdk11
# Tasks to skip so far for s390x
export TEST_TASKRUN_IGNORES="helm-upgrade-from-repo helm-upgrade-from-source golang-test kaniko"

echo "Add extra MAVEN_IMAGE parameter"
find task/*maven*/*/tests/run.yaml | xargs -I{} yq eval '(..|select(.kind?=="Pipeline")|select(.metadata.name?=="jib-maven-test-pipeline"|"maven-test-pipeline")|.spec.tasks[1].params) |= . +{"name": "MAVEN_IMAGE","value": env(MAVEN_IMAGE)}' -i {}

echo "Change registry image value"
find task -name *registry*.yaml | xargs -I{} yq eval '(..|select(.kind?=="Deployment")|select(.metadata.name?=="registry")|.spec.template.spec.containers[0].image)|= env(REGISTRY_IMAGE)' -i {}

echo "Change GOARCH parameter value"
find task/golang*/*/tests/run.yaml | xargs -I{} yq eval '(..|select(.kind?=="Pipeline")|.spec.tasks[1].params) |= . +{"name": "GOARCH","value": env(GOARCH)}' -i {}

echo "Add extra BUILDER_IMAGE parameter"
find task/jib-gradle/*/tests/run.yaml | xargs -I{} yq eval '(..|select(.kind?=="Pipeline")|.spec.tasks[1].params) |= . +{"name": "BUILDER_IMAGE","value": env(BUILDER_IMAGE)}' -i {}