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

Fail upgrade tests when test script fails #6871

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

lbernick
Copy link
Member

Prior to this commit, if any lines in the upgrade testing script that didn't have special error handling failed, the script would continue to run, making it very hard to debug.

This commit fails the script if any lines fail, and doesn't prevent lines with special error handling (i.e. fail_test) from performing their own cleanup steps.

In addition, prior to this commit, lines deleting Tekton CRDs were run after the pipelines webhook and CRD definitions were deleted. This commit moves deletion of resources to happen before Tekton is uninstalled, so deletion can happen successfully.

Lastly, this commit handles cases where the variable PIPELINE_FEATURE_GATE is not set, and causes the script to fail if any unbound variables are referenced.

/kind bug
closes #6869

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • n/a Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • n/a Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • n/a Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

Prior to this commit, if any lines in the upgrade testing script
that didn't have special error handling failed, the script would
continue to run, making it very hard to debug.

This commit fails the script if any lines fail, and doesn't prevent
lines with special error handling (i.e. `fail_test`) from performing
their own cleanup steps.

In addition, prior to this commit, lines deleting Tekton CRDs
were run after the pipelines webhook and CRD definitions were deleted.
This commit moves deletion of resources to happen before Tekton is
uninstalled, so deletion can happen successfully.

Lastly, this commit handles cases where the variable PIPELINE_FEATURE_GATE
is not set, and causes the script to fail if any unbound variables
are referenced.
@lbernick lbernick added the area/testing Issues or PRs related to testing label Jun 26, 2023
@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. release-note-none Denotes a PR that doesnt merit a release note. labels Jun 26, 2023
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 26, 2023
Copy link
Member

@Yongxuanzhang Yongxuanzhang left a comment

Choose a reason for hiding this comment

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

/lgtm

Comment on lines -147 to -148
# Make sure that everything is cleaned up in the current namespace.
delete_pipeline_resources
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it is the same if we move this line before line 144 instead of moving out of this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd prefer to decouple deleting the CRDs from uninstalling pipelines. It's doesn't make sense to me that uninstall_pipeline_crd should delete resources but uninstall_pipeline_crd_version shouldn't, but we can't have them both delete resources since we call uninstall_pipeline_crd and then uninstall_pipeline_crd_version right after (https://github.com/tektoncd/pipeline/blob/main/test/e2e-tests-upgrade.sh#L61-L62). IMO it's better to just let the calling script handle deletion since the calling script is what created the resources in the first place.

}

function uninstall_pipeline_crd_version() {
echo ">> Uninstalling Tekton Pipelines of version $1"
kubectl delete --ignore-not-found=true -f "https://github.com/tektoncd/pipeline/releases/download/$1/release.yaml"

if [ "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then
if [ -v ${PIPELINE_FEATURE_GATE+x} && "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

can this be instead? it seems "+x" is not needed in bash 4.3+?

Suggested change
if [ -v ${PIPELINE_FEATURE_GATE+x} && "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then
if [ -v ${PIPELINE_FEATURE_GATE} && "${PIPELINE_FEATURE_GATE}" == "alpha" ]; then

https://www.gnu.org/software/bash/manual/bash.html

Copy link
Member Author

Choose a reason for hiding this comment

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

good question; can you point me to where in that link you're seeing this? (I'm looking at this section.) I poked through our test runner dockerfile but there's not really a good way for me to tell what version of bash we are using, so I'd prefer to keep it. (Not sure how to go from hash-> dockerfile.)

@dibyom
Copy link
Member

dibyom commented Jul 7, 2023

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, Yongxuanzhang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2023
@tekton-robot tekton-robot merged commit a22c093 into tektoncd:main Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/testing Issues or PRs related to testing kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade tests should fail when script fails
5 participants