Skip to content

Commit

Permalink
Update e2e scipts according to new structure
Browse files Browse the repository at this point in the history
This will update the e2e scripts to run tests according to
new catalog structure after reorg

Ignore cloudevent test as it is not working for now

Fix #420
  • Loading branch information
piyush-garg committed Jul 16, 2020
1 parent ccd1080 commit 3bffa60
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion task/buildah/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/buildpacks-v3/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/golang-build/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/golang-test/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/golangci-lint/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml

# Add service account
kubectl -n ${tns} create serviceaccount helm-pipeline-run-sa -o yaml --dry-run=client | kubectl apply -f -
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml

# Add service account
kubectl -n ${tns} create serviceaccount helm-pipeline-run-sa -o yaml --dry-run=client | kubectl apply -f -
Expand Down
2 changes: 1 addition & 1 deletion task/jib-gradle/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/jib-maven/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/kaniko/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/maven/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/prettier/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/replace-tokens/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/s2i/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
add_sidecar_registry ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
2 changes: 1 addition & 1 deletion task/upload-pypi/0.1/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
cat ${TMPF} | python -c 'import yaml,sys;data=yaml.load(sys.stdin.read());data["spec"]["sidecars"]=[{"image":"pypiserver/pypiserver:latest", "name":"server", "command":["pypi-server","-P",".","-a",".","/data/packages"], "volumeMounts":[{"name":"packages", "mountPath":"/data/packages"}]}];data["spec"]["volumes"]=[{"name":"packages", "emptyDir":{}}];print(yaml.dump(data, default_flow_style=False));' > ${TMPF}

# Add git-clone
kubectl -n ${tns} apply -f ./git/git-clone.yaml
kubectl -n ${tns} apply -f ./task/git-clone/0.1/git-clone.yaml
17 changes: 11 additions & 6 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function test_yaml_can_install() {
# Validate that all the Task CRDs in this repo are valid by creating them in a NS.
readonly ns="task-ns"
kubectl create ns "${ns}" || true
for runtest in $(find ${REPO_ROOT_DIR} -maxdepth 2 -name '*.yaml'); do
for runtest in $(find ${REPO_ROOT_DIR}/task -maxdepth 3 -name '*.yaml'); do
skipit=
for ignore in ${TEST_YAML_IGNORES};do
[[ ${ignore} == $(basename $(echo ${runtest%.yaml})) ]] && skipit=True
Expand Down Expand Up @@ -89,7 +89,10 @@ function show_failure() {
}
function test_task_creation() {
for runtest in ${@};do
local testname=${runtest%%/*}
# remove task/ from beginning
local runtestdir=${runtest#*/}
# remove /0.1/tests from end
local testname=${runtestdir%%/*}
local tns="${testname}-$$"
local skipit=
local maxloop=60 # 10 minutes max
Expand All @@ -98,24 +101,26 @@ function test_task_creation() {
[[ ${ignore} == ${testname} ]] && skipit=True
done

ls ${testname}/*.yaml 2>/dev/null >/dev/null || skipit=True
# remove /tests from end
local taskdir=${runtest%/*}
ls ${taskdir}/*.yaml 2>/dev/null >/dev/null || skipit=True

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

kubectl create namespace ${tns}

# Install the task itself first
for yaml in ${testname}/*.yaml;do
for yaml in ${taskdir}/*.yaml;do
cp ${yaml} ${TMPF}
[[ -f ${testname}/tests/pre-apply-task-hook.sh ]] && source ${testname}/tests/pre-apply-task-hook.sh
[[ -f ${taskdir}/tests/pre-apply-task-hook.sh ]] && source ${taskdir}/tests/pre-apply-task-hook.sh
function_exists pre-apply-task-hook && pre-apply-task-hook
kubectl -n ${tns} create -f ${TMPF}
done

# Install resource and run
for yaml in ${runtest}/*.yaml;do
cp ${yaml} ${TMPF}
[[ -f ${testname}/tests/pre-apply-taskrun-hook.sh ]] && source ${testname}/tests/pre-apply-taskrun-hook.sh
[[ -f ${taskdir}/tests/pre-apply-taskrun-hook.sh ]] && source ${taskdir}/tests/pre-apply-taskrun-hook.sh
function_exists pre-apply-taskrun-hook && pre-apply-taskrun-hook
kubectl -n ${tns} create -f ${TMPF}
done
Expand Down
4 changes: 2 additions & 2 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ TEST_YAML_IGNORES=${TEST_YAML_IGNORES:-""}

# Allow ignoring some yaml tests, space separated, should be the basename of the
# test for example "s2i"
TEST_TASKRUN_IGNORES=${TEST_TASKRUN_IGNORES:-""}
TEST_TASKRUN_IGNORES=${TEST_TASKRUN_IGNORES:-"cloudevent"}

set -ex
set -o pipefail

test_yaml_can_install
test_task_creation */tests
test_task_creation task/*/*/tests

success

0 comments on commit 3bffa60

Please sign in to comment.