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

Add support for Elasticsearch 7.x #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AbhyudayaSharma
Copy link

Hi! We are using Elasticsearch 7.4.0 with which this pack is not compatible. This PR handles some of the breaking changes introduced in 7.0 and makes it compatible with 7.x. I've tested the changes in this PR with our local Elasticsearch instance and it works just fine.

@AbhyudayaSharma
Copy link
Author

The CI passes on Python 2.7 but on Python 3.6 the failure looks unrelated:

Running pylint on pack: repo
PYTHONPATH=/tmp/st2/st2actions:/tmp/st2/st2api:/tmp/st2/st2auth:/tmp/st2/st2client:/tmp/st2/st2common:/tmp/st2/st2debug:/tmp/st2/st2exporter:/tmp/st2/st2reactor:/tmp/st2/st2stream:/tmp/st2/st2tests:/home/circleci/repo/actions/lib:/tmp/st2/st2common:
PYTHON_BINARY=/home/circleci/virtualenv/bin/python
Using config file /home/circleci/ci/lint-configs/python/.pylintrc-exchange
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/__main__.py", line 7, in <module>
    pylint.run_pylint()
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/lint.py", line 1353, in __init__
    linter.check(args)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/lint.py", line 774, in check
    self._do_check(files_or_modules)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/lint.py", line 907, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/lint.py", line 986, in check_astroid_module
    walker.walk(ast_node)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/utils.py", line 1016, in walk
    cb(astroid)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/checkers/imports.py", line 443, in leave_module
    std_imports, ext_imports, loc_imports = self._check_imports_order(node)
  File "/home/circleci/virtualenv/lib/python3.6/site-packages/pylint/checkers/imports.py", line 588, in _check_imports_order
    isort_obj = isort.SortImports(
AttributeError: module 'isort' has no attribute 'SortImports'

Copy link
Contributor

@nmaludy nmaludy left a comment

Choose a reason for hiding this comment

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

First off, thank you VERY much for these updates!

Along with the comments below, please:

  • Add a CHANGELOG entry.
  • Bump the version by 0.x to represent new features.
  • Make sure builds are passing.

Thanks again for the support here, let me know if i can be of any help.

@@ -40,7 +40,23 @@ def poll(self):
data = self.es.search(index=self.index, body=query_payload)

hits = data.get('hits', None)
if hits.get('total', 0) > self.count_threshold:
if hits is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great to see some unit tests for these new conditions.

Copy link
Author

Choose a reason for hiding this comment

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

@nmaludy I was unable to find any tests apart from the bash scripts in /test. I tried to use Docker Compose but I believe that is broken because there is no st2 image on DockerHub. From the CI output, it doesn't look like that script is being run. Where and how should I add tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

@AbhyudayaSharma Unit tests go in the tests/ folder. These use the standard python unittest2 framework. Some examples can be seen in the vSphere pack here: https://github.com/StackStorm-Exchange/stackstorm-vsphere/blob/master/tests/test_action_affinity_rule_create.py

@AbhyudayaSharma
Copy link
Author

AbhyudayaSharma commented Jul 9, 2020

The build failures on Python 3.6 is not looking at all related to this PR. Can you point me in the right direction?

Copy link
Contributor

@nmaludy nmaludy left a comment

Choose a reason for hiding this comment

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

@AbhyudayaSharma we've fixed the upstream build issue.

Only requested change now is to please bump the pack version to 1.2.0 here: https://github.com/StackStorm-Exchange/stackstorm-elasticsearch/blob/master/pack.yaml#L9

@AbhyudayaSharma
Copy link
Author

@AbhyudayaSharma we've fixed the upstream build issue.

Only requested change now is to please bump the pack version to 1.2.0 here: master/pack.yaml#L9

@nmaludy Done! I would also suggest using https://github.com/release-drafter/release-drafter which can automatically changelog entries from pull requests.

@AbhyudayaSharma AbhyudayaSharma requested a review from nmaludy July 11, 2020 06:25
@AbhyudayaSharma
Copy link
Author

@nmaludy do I need to change anything else?

@nmaludy
Copy link
Contributor

nmaludy commented Jul 13, 2020

@AbhyudayaSharma Still looking for unit tests here, if you wouldn't mind?

@nmaludy
Copy link
Contributor

nmaludy commented Jul 13, 2020

@AbhyudayaSharma
Copy link
Author

Okay. Will try to add some tests tomorrow.

@ghost ghost mentioned this pull request Aug 4, 2020
@nmaludy
Copy link
Contributor

nmaludy commented Sep 25, 2020

@AbhyudayaSharma any luck on the unit tests?

@AbhyudayaSharma
Copy link
Author

@nmaludy Sorry. My internship got over and I no longer have access to the StackStorm and Elasticsearch instances that I was using. I'm really busy with university stuff right now but will try to set everything up and add the tests when I get some time.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants