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

Test command #4590

Merged
merged 6 commits into from
Jul 11, 2017
Merged

Test command #4590

merged 6 commits into from
Jul 11, 2017

Conversation

exekias
Copy link
Contributor

@exekias exekias commented Jun 30, 2017

This PR adds a self-testing framework, different parts of beats can implement Testable interface to allow the user to test her settings.
Current features:

  • Test utils with output to console
  • Output testing (ES & Logstash)

example ERROR:

X1 :: elastic/beats/filebeat ‹test-command*› » ./filebeat test output                                              1 ↵
elasticsearch: https://badhost:9243...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... ERROR lookup badhost: no such host

example OK:

X1 :: elastic/beats/filebeat ‹test-command*› » ./filebeat test output 
elasticsearch: https://61fc3e1983ebd7b13e9d6098e4651345.us-east-1.aws.found.io:9243...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... OK
    addresses: 54.235.139.222, 54.221.244.80, 54.243.122.128, 54.204.28.14, 54.221.223.25, 54.243.118.44, 54.243.142.98, 54.235.122.205
    dial up... OK
  TLS...
    security: server's certificate chain verification is enabled
    handshake... OK
    TLS version: TLSv1.2
    dial up... OK
  talk to server... OK
  version: 5.5.0

TODO:

  • Unit tests
  • Integration tests

@exekias exekias added enhancement in progress Pull request is currently in progress. libbeat review labels Jun 30, 2017
@exekias exekias force-pushed the test-command branch 8 times, most recently from 930f275 to 9e5cbfe Compare July 7, 2017 14:40
@exekias exekias force-pushed the test-command branch 2 times, most recently from 3f56e23 to d145d1a Compare July 10, 2017 17:20
@exekias exekias changed the title [WIP] Test command Test command Jul 10, 2017
@exekias exekias removed the in progress Pull request is currently in progress. label Jul 10, 2017
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. The color is nice touch. Look forward to trying this out.


assert exit_code == 1
assert self.log_contains('parse url... OK')
assert self.log_contains('dns lookup... ERROR lookup badhost: no such host')
Copy link
Member

Choose a reason for hiding this comment

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

I would be careful with matching the specific error message coming from the stdlib or the OS. This has bit me a few times when running my tests on different OSes and Golang versions.

elasticsearch: http://badhost:9200...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... ERROR lookup badhost on 127.0.0.11:53: no such host
======================================================================
FAIL: Test test wrong output works
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/go/src/github.com/elastic/beats/libbeat/tests/system/test_cmd.py", line 169, in test_test_wrong_output
    assert self.log_contains('dns lookup... ERROR lookup badhost: no such host')

@exekias
Copy link
Contributor Author

exekias commented Jul 11, 2017

jenkins retest this please

@exekias
Copy link
Contributor Author

exekias commented Jul 11, 2017

thanks for the review, btw I had a pending check that color works on Mac, I guess you just confirmed it?

@andrewkroh
Copy link
Member

Yeah, the color works in Terminal on macOS.

@andrewkroh andrewkroh merged commit 7e10451 into elastic:master Jul 11, 2017
@tsg tsg mentioned this pull request Jul 24, 2017
28 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants