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

MINIFICPP-2456 Remove curl output from Elasticsearch responses #1867

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docker/test/integration/cluster/checkers/ElasticSearchChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@ def __init__(self, container_communicator):
self.container_communicator = container_communicator

def is_elasticsearch_empty(self, container_name):
(code, output) = self.container_communicator.execute_command(container_name, ["curl", "-u", "elastic:password", "-k", "-XGET", "https://localhost:9200/_search"])
(code, output) = self.container_communicator.execute_command(container_name, ["curl", "-s", "-u", "elastic:password", "-k", "-XGET", "https://localhost:9200/_search"])
return code == 0 and '"hits":[]' in output

def create_doc_elasticsearch(self, container_name, index_name, doc_id):
(code, output) = self.container_communicator.execute_command(container_name, ["/bin/bash", "-c",
"curl -u elastic:password -k -XPUT https://localhost:9200/" + index_name + "/_doc/" + doc_id + " -H Content-Type:application/json -d'{\"field1\":\"value1\"}'"])
"curl -s -u elastic:password -k -XPUT https://localhost:9200/" + index_name + "/_doc/" + doc_id + " -H Content-Type:application/json -d'{\"field1\":\"value1\"}'"])
return code == 0 and ('"_id":"' + doc_id + '"') in output

def check_elastic_field_value(self, container_name, index_name, doc_id, field_name, field_value):
(code, output) = self.container_communicator.execute_command(container_name, ["/bin/bash", "-c",
"curl -u elastic:password -k -XGET https://localhost:9200/" + index_name + "/_doc/" + doc_id])
"curl -s -u elastic:password -k -XGET https://localhost:9200/" + index_name + "/_doc/" + doc_id])
return code == 0 and (field_name + '":"' + field_value) in output

def elastic_generate_apikey(self, elastic_container_name):
(_, output) = self.container_communicator.execute_command(elastic_container_name, ["/bin/bash", "-c",
"curl -u elastic:password -k -XPOST https://localhost:9200/_security/api_key -H Content-Type:application/json -d'{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\": {\"cluster\": [\"all\"],\"index\": [{\"names\": [\"my_index\"],\"privileges\": [\"all\"]}]}}}'"])
(code, output) = self.container_communicator.execute_command(elastic_container_name, ["/bin/bash", "-c",
"curl -s -u elastic:password -k -XPOST https://localhost:9200/_security/api_key -H Content-Type:application/json -d'{\"name\":\"my-api-key\",\"expiration\":\"1d\",\"role_descriptors\":{\"role-a\": {\"cluster\": [\"all\"],\"index\": [{\"names\": [\"my_index\"],\"privileges\": [\"all\"]}]}}}'"])
if code != 0:
return None
output_lines = output.splitlines()
result = json.loads(output_lines[-1])
return result["encoded"]

def add_elastic_user_to_opensearch(self, container_name):
(code, output) = self.container_communicator.execute_command(container_name, ["/bin/bash", "-c",
'curl -u admin:admin -k -XPUT https://{hostname}:9200/_plugins/_security/api/internalusers/elastic -H Content-Type:application/json -d\'{{"password":"password","backend_roles":["admin"]}}\''.format(hostname=container_name)])
'curl -s -u admin:admin -k -XPUT https://{hostname}:9200/_plugins/_security/api/internalusers/elastic -H Content-Type:application/json -d\'{{"password":"password","backend_roles":["admin"]}}\''.format(hostname=container_name)])
return code == 0 and '"status":"CREATED"' in output
2 changes: 1 addition & 1 deletion docker/test/integration/features/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def retry_check(max_tries=5, retry_interval=1):
def retry_check_func(func):
@functools.wraps(func)
def retry_wrapper(*args, **kwargs):
for i in range(max_tries):
for _ in range(max_tries):
if func(*args, **kwargs):
return True
time.sleep(retry_interval)
Expand Down