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

fix: printout errors even if we have a timeout #5628

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

jmrodri
Copy link
Member

@jmrodri jmrodri commented Apr 3, 2022

Signed-off-by: jesus m. rodriguez jesusr@redhat.com

Description of the change:
Handle DeadlineExceeded errors by allowing test output to be printed even during context timeouts

Motivation for the change:
context timeouts hide all test results

Fixes: #5415
Checklist

If the pull request includes user-facing changes, extra documentation is required:

@jmrodri
Copy link
Member Author

jmrodri commented Apr 3, 2022

before this change, timeout would simply result in the context error showing:

$ operator-sdk scorecard ./bundle --wait-time 5s
Error: error running tests context deadline exceeded
Usage:
  operator-sdk scorecard [flags]

Flags:
  -c, --config string            path to scorecard config file
  -h, --help                     help for scorecard
      --kubeconfig string        kubeconfig path
  -L, --list                     Option to enable listing which tests are run
  -n, --namespace string         namespace to run the test images in
  -o, --output string            Output format for results. Valid values: text, json, xunit (default "text")
  -l, --selector string          label selector to determine which tests are run
  -s, --service-account string   Service account to use for tests (default "default")
  -x, --skip-cleanup             Disable resource cleanup after tests are run
  -b, --storage-image string     Storage image to be used by the Scorecard pod (default "docker.io/library/busybox@sha256:c71cb4f7e8ececaffb34037c2637dc86820e4185100e18b4d02d613a9bd772af")
  -t, --test-output string       Test output directory. (default "test-output")
  -u, --untar-image string       Untar image to be used by the Scorecard pod (default "registry.access.redhat.com/ubi8@sha256:910f6bc0b5ae9b555eb91b88d28d568099b060088616eba2867b07ab6ea457c7")
  -w, --wait-time duration       seconds to wait for tests to complete. Example: 35s (default 30s)

Global Flags:
      --plugins strings   plugin keys to be used for this subcommand execution
      --verbose           Enable verbose logging

FATA[0005] error running tests context deadline exceeded 

@jmrodri
Copy link
Member Author

jmrodri commented Apr 3, 2022

after this change, the test results will printout

$ operator-sdk scorecard ./bundle --wait-time 5s                                                                                                
--------------------------------------------------------------------------------                                                                                                              
Image:      quay.io/operator-framework/scorecard-test:v1.18.0                                                                                                                                 
Entrypoint: [scorecard-test olm-crds-have-resources]                                                                                                                                          
Labels:                                                                                                                                                                                       
        "suite":"olm"                                                                                                                                                                         
        "test":"olm-crds-have-resources-test"                                                                                                                                                 
Results:                                                                                                                                                                                      
        Name: olm-crds-have-resources                                                                                                                                                         
        State: fail                                                                                                                                                                           
                                                                                                                                                                                              
        Errors:                                                                                                                                                                               
                Owned CRDs do not have resources specified                                                                                                                                    
        Log:                                                                                                                                                                                  
                Loaded ClusterServiceVersion: memcached-operator.v0.0.1                                                                                                                       
                                                                                                                                                                                              
                                                                                                                                                                                              
--------------------------------------------------------------------------------                                                                                                              
Image:      quay.io/operator-framework/scorecard-test:v1.18.0                                                                                                                                 
Entrypoint: [scorecard-test basic-check-spec]                                                                                                                                                 
Labels:                                                                                                                                                                                       
        "suite":"basic"                                                                                                                                                                       
        "test":"basic-check-spec-test"                                                                                                                                                        
Results:                                                                                                                                                                                      
        State: fail                                                                                                                                                                           
                                                                                                                                                                                              
        Errors:                                                                                                                                                                               
                timed out waiting for the condition                                                                                                                                           
                                                                                                                                                                                              
                                                                                                                                                                                              
--------------------------------------------------------------------------------                                                                                                              
Image:      quay.io/operator-framework/scorecard-test:v1.18.0                                                                                                                                 
Entrypoint: [scorecard-test olm-spec-descriptors]                                                                                                                                             
Labels:                                                                                                                                                                                       
        "suite":"olm"                                                                                                                                                                         
        "test":"olm-spec-descriptors-test"                                                                                                                                                    
Results:                                                                                                                                                                                      
        State: fail                       
                                                                                                                                                                                              
        Errors:
                timed out waiting for the condition


--------------------------------------------------------------------------------
Image:      quay.io/operator-framework/scorecard-test:v1.18.0
Entrypoint: [scorecard-test olm-bundle-validation]
Labels:
        "suite":"olm"
        "test":"olm-bundle-validation-test"
Results:
        State: fail

        Errors:
                timed out waiting for the condition


--------------------------------------------------------------------------------
Image:      quay.io/operator-framework/scorecard-test:v1.18.0
Entrypoint: [scorecard-test olm-status-descriptors]
Labels:
        "suite":"olm"
        "test":"olm-status-descriptors-test"
Results:
        State: fail

        Errors:
                timed out waiting for the condition


--------------------------------------------------------------------------------
Image:      quay.io/operator-framework/scorecard-test:v1.18.0
Entrypoint: [scorecard-test olm-crds-have-validation]
Labels:
        "suite":"olm"
        "test":"olm-crds-have-validation-test"
Results:
        State: fail

        Errors:
                timed out waiting for the condition


Error: error running tests context deadline exceeded
Usage:
  operator-sdk scorecard [flags]

Flags:
  -c, --config string            path to scorecard config file
  -h, --help                     help for scorecard
      --kubeconfig string        kubeconfig path
  -L, --list                     Option to enable listing which tests are run
  -n, --namespace string         namespace to run the test images in
  -o, --output string            Output format for results. Valid values: text, json, xunit (default "text")
  -l, --selector string          label selector to determine which tests are run
  -s, --service-account string   Service account to use for tests (default "default")
  -x, --skip-cleanup             Disable resource cleanup after tests are run
  -b, --storage-image string     Storage image to be used by the Scorecard pod (default "docker.io/library/busybox@sha256:c71cb4f7e8ececaffb34037c2637dc86820e4185100e18b4d02d613a9bd772af")
  -t, --test-output string       Test output directory. (default "test-output")
  -u, --untar-image string       Untar image to be used by the Scorecard pod (default "registry.access.redhat.com/ubi8@sha256:910f6bc0b5ae9b555eb91b88d28d568099b060088616eba2867b07ab6ea457c7
")
  -w, --wait-time duration       seconds to wait for tests to complete. Example: 35s (default 30s)

Global Flags:
      --plugins strings   plugin keys to be used for this subcommand execution
      --verbose           Enable verbose logging

FATA[0005] error running tests context deadline exceeded 

Signed-off-by: jesus m. rodriguez <jesusr@redhat.com>
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2022
Copy link
Member

@rashmigottipati rashmigottipati left a comment

Choose a reason for hiding this comment

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

Just one nit.

/lgtm

@@ -233,6 +233,12 @@ func (c *scorecardCmd) run() (err error) {

scorecardTests, err = o.Run(ctx)
if err != nil {
// if we got a timeout; printout the test results if there are any
if err == context.DeadlineExceeded {
Copy link
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
if err == context.DeadlineExceeded {
if errors.Is(err, context.DeadlineExceeded) {

@jmrodri jmrodri merged commit fda35b2 into operator-framework:master Apr 7, 2022
VenkatRamaraju pushed a commit to VenkatRamaraju/operator-sdk that referenced this pull request May 18, 2022
Signed-off-by: jesus m. rodriguez <jesusr@redhat.com>
Signed-off-by: Venkat Ramaraju <vramaraj@redhat.com>
VenkatRamaraju pushed a commit to VenkatRamaraju/operator-sdk that referenced this pull request May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: error running tests context deadline exceeded is missing the root cause
3 participants