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

prefer testify Error/NoError over NotNil/Nil #20044

Merged
merged 1 commit into from
Jul 20, 2020

Conversation

trashhalo
Copy link
Contributor

What does this PR do?

replaces calls to require/assert Nil/NotNil to NoError/Error

NoError is for asserting no error was return
Error is for asserting an error was returned

Why is it important?

return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...)
return Fail(t, "An error is expected but got nil.", msgAndArgs...)

When these fail their message explicitly calls out that we were or were not expecting an error. This communicates the intent of the assertion.

Checklist

  • My code follows the style guidelines of this project

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • I have made corresponding change to the default configuration files

  • I have added tests that prove my fix is effective or that my feature works

  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc
    Im not sure what you are looking for here.

How to test this PR locally

run go test make sure it still passes.

@trashhalo trashhalo requested review from a team as code owners July 18, 2020 23:54
@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

1 similar comment
@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 18, 2020
@cla-checker-service
Copy link

cla-checker-service bot commented Jul 18, 2020

💚 CLA has been signed

@trashhalo
Copy link
Contributor Author

CLA signed.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 19, 2020

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [andrewkroh commented: jenkins, run tests]

  • Start Time: 2020-07-20T12:12:39.614+0000

  • Duration: 89 min 28 sec

Test stats 🧪

Test Results
Failed 0
Passed 14867
Skipped 1884
Total 16751

Steps errors

Expand to view the steps failures

  • Name: Mage build test

    • Description: mage build test

    • Duration: 9 min 35 sec

    • Start Time: 2020-07-20T12:44:04.485+0000

    • log

  • Name: Report to Codecov

    • Description: curl -sSLo codecov https://codecov.io/bash for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat do FILE="${i}/build/coverage/full.cov" if [ -f "${FILE}" ]; then bash codecov -f "${FILE}" fi done

    • Duration: 2 min 22 sec

    • Start Time: 2020-07-20T12:52:37.972+0000

    • log

  • Name: Report to Codecov

    • Description: curl -sSLo codecov https://codecov.io/bash for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat do FILE="${i}/build/coverage/full.cov" if [ -f "${FILE}" ]; then bash codecov -f "${FILE}" fi done

    • Duration: 1 min 27 sec

    • Start Time: 2020-07-20T12:50:00.187+0000

    • log

  • Name: Mage build test

    • Description: mage build test

    • Duration: 7 min 27 sec

    • Start Time: 2020-07-20T12:44:09.382+0000

    • log

  • Name: Report to Codecov

    • Description: curl -sSLo codecov https://codecov.io/bash for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat do FILE="${i}/build/coverage/full.cov" if [ -f "${FILE}" ]; then bash codecov -f "${FILE}" fi done

    • Duration: 1 min 27 sec

    • Start Time: 2020-07-20T12:55:31.601+0000

    • log

  • Name: Report to Codecov

    • Description: curl -sSLo codecov https://codecov.io/bash for i in auditbeat filebeat heartbeat libbeat metricbeat packetbeat winlogbeat journalbeat do FILE="${i}/build/coverage/full.cov" if [ -f "${FILE}" ]; then bash codecov -f "${FILE}" fi done

    • Duration: 2 min 22 sec

    • Start Time: 2020-07-20T12:47:12.255+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-07-20T13:41:39.757Z] + [ -f packetbeat/build/coverage/full.cov ]
[2020-07-20T13:41:39.757Z] + FILE=winlogbeat/build/coverage/full.cov
[2020-07-20T13:41:39.757Z] + [ -f winlogbeat/build/coverage/full.cov ]
[2020-07-20T13:41:39.757Z] + FILE=journalbeat/build/coverage/full.cov
[2020-07-20T13:41:39.757Z] + [ -f journalbeat/build/coverage/full.cov ]
[2020-07-20T13:41:40.368Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats
[2020-07-20T13:41:40.691Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-07-20T13:41:40.705Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Lint
[2020-07-20T13:41:40.798Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-07-20T13:41:40.882Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-07-20T13:41:40.978Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Winlogbeat-oss
[2020-07-20T13:41:41.081Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Journalbeat-oss
[2020-07-20T13:41:41.174Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Dockerlogbeat
[2020-07-20T13:41:41.260Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-07-20T13:41:41.353Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-07-20T13:41:41.457Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-07-20T13:41:41.565Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-oss-Mac-OS-X
[2020-07-20T13:41:41.688Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-07-20T13:41:41.793Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Packetbeat-Linux
[2020-07-20T13:41:41.898Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-07-20T13:41:41.993Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-x-pack-Mac-OS-X
[2020-07-20T13:41:42.094Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-07-20T13:41:42.313Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Filebeat-Mac-OS-X
[2020-07-20T13:41:42.445Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Libbeat-oss
[2020-07-20T13:41:42.555Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Heartbeat-oss
[2020-07-20T13:41:42.663Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-07-20T13:41:42.804Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Filebeat-oss
[2020-07-20T13:41:42.942Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-07-20T13:41:43.074Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-07-20T13:41:43.182Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-07-20T13:41:43.303Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-07-20T13:41:43.412Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Libbeat-x-pack
[2020-07-20T13:41:43.513Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-07-20T13:41:43.619Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack-Mac-OS-X
[2020-07-20T13:41:43.717Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-07-20T13:41:43.831Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Filebeat-Windows
[2020-07-20T13:41:43.925Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-Windows
[2020-07-20T13:41:44.023Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-07-20T13:41:44.128Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-07-20T13:41:44.228Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Functionbeat-Mac-OS-X-x-pack
[2020-07-20T13:41:44.328Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Packetbeat-Mac-OS-X
[2020-07-20T13:41:44.431Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-Mac-OS-X
[2020-07-20T13:41:44.528Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-07-20T13:41:44.628Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Heartbeat-Mac-OS-X
[2020-07-20T13:41:44.732Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Filebeat-x-pack
[2020-07-20T13:41:44.840Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Functionbeat-Windows
[2020-07-20T13:41:44.937Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Packetbeat-Windows
[2020-07-20T13:41:45.041Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Heartbeat-Windows
[2020-07-20T13:41:45.190Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-OSS-Python-Integration-tests
[2020-07-20T13:41:45.282Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests
[2020-07-20T13:41:45.371Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Generators-Metricbeat-Mac-OS-X
[2020-07-20T13:41:45.463Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Generators-Beat-Mac-OS-X
[2020-07-20T13:41:45.548Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-07-20T13:41:45.952Z] + cat
[2020-07-20T13:41:45.952Z] + /usr/local/bin/runbld ./runbld-script
[2020-07-20T13:41:45.952Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-07-20T13:41:52.560Z] runbld>>> runbld started
[2020-07-20T13:41:52.560Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-07-20T13:41:53.943Z] runbld>>> The following profiles matched the job 'Beats/beats/PR-20044' in order of occurrence in the config (last value wins).
[2020-07-20T13:41:55.325Z] runbld>>> Debug logging enabled.
[2020-07-20T13:41:55.325Z] runbld>>> Storing result
[2020-07-20T13:41:55.325Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-07-20T13:41:55.325Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200720134155-1B3FA501
[2020-07-20T13:41:55.325Z] runbld>>> Adding system facts.
[2020-07-20T13:41:56.263Z] runbld>>> Adding vcs info for the latest commit:  bef1ce305f1c35838bb3af50d85dc6d9e0d6ce01
[2020-07-20T13:41:56.263Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-07-20T13:41:56.263Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-07-20T13:41:56.263Z] + echo 'Processing JUnit reports with runbld...'
[2020-07-20T13:41:56.263Z] Processing JUnit reports with runbld...
[2020-07-20T13:41:56.832Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-07-20T13:41:56.832Z] runbld>>> DURATION: 35ms
[2020-07-20T13:41:56.832Z] runbld>>> STDOUT: 40 bytes
[2020-07-20T13:41:56.832Z] runbld>>> STDERR: 49 bytes
[2020-07-20T13:41:56.832Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-07-20T13:41:56.832Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats
[2020-07-20T13:41:57.771Z] runbld>>> Storing build metadata: 
[2020-07-20T13:41:57.771Z] runbld>>> Adding test report.
[2020-07-20T13:41:57.771Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats
[2020-07-20T13:41:58.712Z] runbld>>> Found 132 test output files
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-07-20T13:42:00.096Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20044/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-07-20T13:42:01.478Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 16601 Skipped: 1624
[2020-07-20T13:42:01.478Z] runbld>>> Storing result
[2020-07-20T13:42:01.478Z] runbld>>> FAILURES: 0
[2020-07-20T13:42:01.478Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-07-20T13:42:01.478Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200720134155-1B3FA501
[2020-07-20T13:42:01.738Z] runbld>>> Email notification disabled by environment variable.
[2020-07-20T13:42:01.738Z] runbld>>> Slack notification disabled by environment variable.
[2020-07-20T13:42:07.284Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-20044
[2020-07-20T13:42:07.386Z] [INFO] getVaultSecret: Getting secrets
[2020-07-20T13:42:07.464Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-20T13:42:08.189Z] + chmod 755 generate-build-data.sh
[2020-07-20T13:42:08.189Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20044/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20044/runs/2 FAILURE 5368316
[2020-07-20T13:42:08.189Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20044/runs/2/steps/?limit=10000 -o steps-info.json
[2020-07-20T13:42:10.050Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20044/runs/2/tests/?status=FAILED -o tests-errors.json

@andrewkroh
Copy link
Member

jenkins, test this

@andrewkroh andrewkroh added review Team:Services (Deprecated) Label for the former Integrations-Services team labels Jul 19, 2020
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 19, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the cleanup.

@andrewkroh
Copy link
Member

jenkins, run tests

@andrewkroh andrewkroh merged commit 7007d97 into elastic:master Jul 20, 2020
v1v added a commit to v1v/beats that referenced this pull request Jul 21, 2020
…-basis-when

* upstream/master:
  [CI] run everything for branches/tags (elastic#20057)
  Limit the number of bytes read by LineReader in Filebeat (elastic#19552)
  Prefer testify.Error/NoError over NotNil/Nil (elastic#20044)
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants