forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pytest fixture that runs OpenSearch client. Add a simple test in the new suite to verify that OpenSearch in running correctly.
- Loading branch information
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (C) 2024-present ScyllaDB | ||
# | ||
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0 | ||
# | ||
# This file configures pytest for all tests in this directory, and also | ||
# defines common test fixtures for all of them to use. | ||
from opensearchpy import OpenSearch | ||
import pytest | ||
import os | ||
|
||
@pytest.fixture(scope="function") | ||
async def opensearch(): | ||
host = os.environ.get('OPENSEARCH_ADDRESS') | ||
port = os.environ.get('OPENSEARCH_PORT') | ||
|
||
client = OpenSearch( | ||
hosts = [{'host': host, 'port': port}], | ||
http_compress = True, | ||
use_ssl = False, | ||
verify_certs = False, | ||
ssl_assert_hostname = False, | ||
ssl_show_warn = False | ||
) | ||
|
||
yield client | ||
|
||
client.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type: OpenSearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Copyright (C) 2025-present ScyllaDB | ||
# | ||
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0 | ||
# | ||
import pytest | ||
|
||
@pytest.mark.asyncio | ||
async def test_opensearch_basic(opensearch): | ||
|
||
index_name = 'python-test-index' | ||
index_body = { | ||
'settings': { | ||
'index': { | ||
'number_of_shards': 4 | ||
} | ||
} | ||
} | ||
|
||
response = opensearch.indices.create(index_name, body=index_body) | ||
print(f"Index creation response: {response}") | ||
|
||
response = opensearch.cat.indices(format='json') | ||
for index in response: | ||
print(index['index']) |