-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Libbeat test fixes for Python 3 #15726
Libbeat test fixes for Python 3 #15726
Conversation
This has a few fixes to python system tests under libbeat/tests/system. assert_docs_written_to_alias had an invalid assertion ever since Elasticsearch changed the format of the hits count to allow for track_total_hits false. Many tests were using this assertion even when not indexing any events so the hit count would always be zero so I removed the assertion from those tests. In other tests I was getting spurious failures because _search was being called before the index was refreshed to allow the documents to be search able. So I added an explicit /_refresh to fix the issue. I changed create_kibana_space to allow a 409 response code so you can run the tests more than once against a Kibana instance. I fixed an assertion on the mode bits of a file since the format of octal numbers is always prefixed with '0o' now. And I fixed the libbeat keystore tests by encoding the secret string to binary before calling os.write. This fixed this error: ``` ====================================================================== ERROR: Add a secret to the store using stdin ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/akroh/go/src/github.com/elastic/beats/libbeat/tests/system/test_cmd_keystore.py", line 130, in test_keystore_add_secret_from_stdin exit_code = self.add_secret("willnotdelete") File "/Users/akroh/go/src/github.com/elastic/beats/libbeat/tests/system/keystore.py", line 29, in add_secret os.write(proc.stdin_write, value) TypeError: a bytes-like object is required, not 'str' ```
|
||
|
||
class IdxMgmt(object): | ||
class IdxMgmt(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this didn't appear when we run the automatic conversion scripts 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't strictly a python3 issue, I wanted to have a more descriptive assertion error by using unittest.assertEqual
rather than assert
which doesn't provide much in the way of understanding why the assertion failed.
This has a few fixes to python system tests under libbeat/tests/system. assert_docs_written_to_alias had an invalid assertion ever since Elasticsearch changed the format of the hits count to allow for track_total_hits false. Many tests were using this assertion even when not indexing any events so the hit count would always be zero so I removed the assertion from those tests. In other tests I was getting spurious failures because _search was being called before the index was refreshed to allow the documents to be search able. So I added an explicit /_refresh to fix the issue. I changed create_kibana_space to allow a 409 response code so you can run the tests more than once against a Kibana instance. I fixed an assertion on the mode bits of a file since the format of octal numbers is always prefixed with '0o' now. And I fixed the libbeat keystore tests by encoding the secret string to binary before calling os.write. This fixed this error: ``` ====================================================================== ERROR: Add a secret to the store using stdin ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/akroh/go/src/github.com/elastic/beats/libbeat/tests/system/test_cmd_keystore.py", line 130, in test_keystore_add_secret_from_stdin exit_code = self.add_secret("willnotdelete") File "/Users/akroh/go/src/github.com/elastic/beats/libbeat/tests/system/keystore.py", line 29, in add_secret os.write(proc.stdin_write, value) TypeError: a bytes-like object is required, not 'str' ```
This has a few fixes to python system tests under libbeat/tests/system.
assert_docs_written_to_alias had an invalid assertion ever since Elasticsearch
changed the format of the hits count to allow for track_total_hits false. Many
tests were using this assertion even when not indexing any events so the hit
count would always be zero so I removed the assertion from those tests.
In other tests I was getting spurious failures because _search was being called
before the index was refreshed to allow the documents to be search able. So I
added an explicit /_refresh to fix the issue.
I changed create_kibana_space to allow a 409 response code so you can run the
tests more than once against a Kibana instance.
I fixed an assertion on the mode bits of a file since the format of octal numbers is
always prefixed with '0o' now.
And I fixed the libbeat keystore tests by encoding the secret string to binary
before calling os.write. This fixed this error: