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

Reconfigured test-cmd to continue on failure #10083

Merged

Conversation

stevekuznetsov
Copy link
Contributor

As test-cmd test bucket sizes shrink and cross-test
dependencies are removed, it makes less and less
sense to fail once and for all when a test-cmd test
case fails. Instead, we know we can't run any more
tests in the same bucket as the failed test, but we
can try to run every other test bucket.

Signed-off-by: Steve Kuznetsov [email protected]

@liggitt @deads2k @smarterclayton @Kargakis PTAL

@liggitt
Copy link
Contributor

liggitt commented Jul 28, 2016

depends... I want the merge job to fail as fast as possible. test jobs I could see allowing to continue

@stevekuznetsov
Copy link
Contributor Author

I want the merge job to fail as fast as possible

Since we run our tests in parallel, you won't see any difference in runtime unless all of our test cases fail early and this one is still running... but since go test and ginkgo already have this behavior, I don't see that happening.

@stevekuznetsov
Copy link
Contributor Author

conformance flakes: #9548 #9490

re[test]

@deads2k
Copy link
Contributor

deads2k commented Jul 28, 2016

depends... I want the merge job to fail as fast as possible. test jobs I could see allowing to continue

We don't fail the test job when test-go hits its first failure. I want the job to fail, but I want the process to continue running to show me all the failures.

@stevekuznetsov
Copy link
Contributor Author

stevekuznetsov commented Jul 28, 2016

integration flake on #10090

re[test]

@deads2k
Copy link
Contributor

deads2k commented Aug 4, 2016

if @Miciah says this will still fail my test-cmd runs in the end, I like the change in concept.

oc project ${CLUSTER_ADMIN_CONTEXT}
oc delete project "cmd-${name}"
cp ${KUBECONFIG}{.bak,} # since nothing ever gets deleted from kubeconfig, reset it
done

if [[ -n "${failed:-}" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Without my bash manual, I don't know what this does. If this doesn't fail properly, we just lost all the tests. be sure

Copy link
Contributor Author

@stevekuznetsov stevekuznetsov Aug 4, 2016

Choose a reason for hiding this comment

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

From the manual the first important bit is:

7.3. Other Comparison Operators
string comparison
-n
    string is not null.

From the manual the other important bit is:

10.2. Parameter Substitution
Manipulating and/or expanding variables
${parameter-default}, ${parameter:-default}
    If parameter not set, use default.
    ${parameter-default} and ${parameter:-default} are almost equivalent. The extra : makes a difference only when parameter has been declared, but is null. 

Quick example to show what that means for us:

#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

# run the test with no variable set
echo -n "\$value unset    : "
if [[ -n "${value:-}" ]]; then
    echo "true"
else
    echo "false" # because the variable is unset, we default it to nothing (${var:-}) and the test fails
fi

# run the test with an empty variable
echo -n "\$value=''       : "
value=''
if [[ -n "${value:-}" ]]; then
    echo "true"
else
    echo "false" # because the variable is set but null, we default it to nothing (${var:-}) and the test fails
fi

# run the test with a non-empty variable
echo -n "\$value=\"test\"   : "
value="test"
if [[ -n "${value:-}" ]]; then
    echo "true" # because the variable is set and not null, the test passes
else
    echo "false"
fi

# output
# $value unset    : false
# $value=''       : false
# $value="test"   : true

So this code will set $failed to a value when a test fails, ergo the check here will fail.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2016
@stevekuznetsov stevekuznetsov force-pushed the skuznets/test-cmd-effort branch from 1189732 to 1007c4b Compare August 4, 2016 13:42
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2016
@stevekuznetsov
Copy link
Contributor Author

@liggitt @deads2k thoughts on this one?

@deads2k
Copy link
Contributor

deads2k commented Sep 12, 2016

@liggitt @deads2k thoughts on this one?

I like the idea in the title. I don't speak bash very well, so I can't say with confidence that this does that.

@stevekuznetsov
Copy link
Contributor Author

I can't say with confidence

I can. It's been tested locally, as well.

@deads2k
Copy link
Contributor

deads2k commented Sep 12, 2016

I can. It's been tested locally, as well.

If @Miciah agrees

@smarterclayton
Copy link
Contributor

This makes sense to me.

@@ -337,12 +330,19 @@ for test in "${tests[@]}"; do
os::cmd::try_until_text "oc get projects -o name" "project/${namespace}"
os::test::junit::declare_suite_end

${test}
if ! ${test}; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Running the test in an if block means we will no longer call any EXIT trap handler that the test may have set up. Typically, a test sets an EXIT trap handler that invokes os::test::junit::reconcile_output, which invokes os::test::junit::declare_suite_end as necessary. Will this change not cause us to fail to ensure we always call os::test::junit::declare_suite_end after a failed test, or will our failing to do so not cause problems?

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought, ${test} is a script which will run in a separate shell process, right? So that shell process will still exit and invoke its EXIT trap handler.

Copy link
Contributor Author

@stevekuznetsov stevekuznetsov Sep 13, 2016

Choose a reason for hiding this comment

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

$ cat test.sh 
#!/bin/bash
function my_trap() {
    echo "Inside of trap!"
}
trap my_trap EXIT
set -o errexit
grep

$ if ./test.sh; then echo "Success!"; else echo "Failure!"; fi
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Inside of trap!
Failure!

Seems to work fine -- I'm not familiar with the EXIT trap override you are talking about. Do you have a link for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The placement inside of the if will fail to send ERR if the test fails, so set -o errexit and our ERR trap (the stacktrace) won't fire, but that's on purpose.

@stevekuznetsov
Copy link
Contributor Author

@Miciah LGTM'ed in an IRC conversation @deads2k

@deads2k
Copy link
Contributor

deads2k commented Sep 13, 2016

@stevekuznetsov removed the merge comment. Whenever the queue opens up, this is fine to go in.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 12, 2016
As test-cmd test bucket sizes shrink and cross-test
dependencies are removed, it makes less and less
sense to fail once and for all when a test-cmd test
case fails. Instead, we know we can't run any more
tests in the same bucket as the failed test, but we
can try to run every other test bucket.

Signed-off-by: Steve Kuznetsov <[email protected]>
@stevekuznetsov stevekuznetsov force-pushed the skuznets/test-cmd-effort branch from 1007c4b to db62c8a Compare November 16, 2016 15:13
@stevekuznetsov
Copy link
Contributor Author

@smarterclayton this is ready for merge imo

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to db62c8a

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11489/) (Base Commit: a799ce2)

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 16, 2016
@stevekuznetsov
Copy link
Contributor Author

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Nov 16, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11489/) (Image: devenv-rhel7_5370)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to db62c8a

@openshift-bot openshift-bot merged commit a4b7101 into openshift:master Nov 16, 2016
@stevekuznetsov stevekuznetsov deleted the skuznets/test-cmd-effort branch January 31, 2017 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants