Change all instances of es->opensearch and ES->OPENSEARCH
Signed-off-by: Rushi Agrawal <[email protected]>
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
# Version 1.0.1
|
# Version 1.0.1
|
||||||
# - Initial version after refactor
|
# - Initial version after refactor
|
||||||
|
|
||||||
if [[ -z $es_node_name ]]; then
|
if [[ -z $opensearch_node_name ]]; then
|
||||||
# only set these once
|
# only set these once
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export TEST_SUITE=${TEST_SUITE-oss}
|
export TEST_SUITE=${TEST_SUITE-oss}
|
||||||
@@ -14,7 +14,7 @@ if [[ -z $es_node_name ]]; then
|
|||||||
export CLEANUP=${CLEANUP-false}
|
export CLEANUP=${CLEANUP-false}
|
||||||
export OPENSEARCH_URL_EXTENSION=${OPENSEARCH_URL_EXTENSION-http}
|
export OPENSEARCH_URL_EXTENSION=${OPENSEARCH_URL_EXTENSION-http}
|
||||||
|
|
||||||
export es_node_name=instance
|
export opensearch_node_name=instance
|
||||||
export opensearch_image=opensearchproject/opensearch
|
export opensearch_image=opensearchproject/opensearch
|
||||||
if [[ "$CLUSTER" == "opendistro" ]]; then
|
if [[ "$CLUSTER" == "opendistro" ]]; then
|
||||||
export opensearch_image=amazon/opendistro-for-elasticsearch
|
export opensearch_image=amazon/opendistro-for-elasticsearch
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ source $script_path/functions/imports.sh
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on seperate terminals \033[0m"
|
echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on seperate terminals \033[0m"
|
||||||
cleanup_node $es_node_name
|
cleanup_node $opensearch_node_name
|
||||||
|
|
||||||
master_node_name=${es_node_name}
|
master_node_name=${opensearch_node_name}
|
||||||
cluster_name=search-rest-test
|
cluster_name=search-rest-test
|
||||||
|
|
||||||
declare -a volumes
|
declare -a volumes
|
||||||
environment=($(cat <<-END
|
environment=($(cat <<-END
|
||||||
--env node.name=$es_node_name
|
--env node.name=$opensearch_node_name
|
||||||
--env cluster.name=$cluster_name
|
--env cluster.name=$cluster_name
|
||||||
--env cluster.initial_master_nodes=$master_node_name
|
--env cluster.initial_master_nodes=$master_node_name
|
||||||
--env discovery.seed_hosts=$master_node_name
|
--env discovery.seed_hosts=$master_node_name
|
||||||
@@ -46,9 +46,9 @@ END
|
|||||||
NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
|
NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
|
||||||
http_port=9200
|
http_port=9200
|
||||||
for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do
|
for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do
|
||||||
node_name=${es_node_name}$i
|
node_name=${opensearch_node_name}$i
|
||||||
node_url=${external_opensearch_url/9200/${http_port}}$i
|
node_url=${external_opensearch_url/9200/${http_port}}$i
|
||||||
if [[ "$i" == "0" ]]; then node_name=$es_node_name; fi
|
if [[ "$i" == "0" ]]; then node_name=$opensearch_node_name; fi
|
||||||
environment+=($(cat <<-END
|
environment+=($(cat <<-END
|
||||||
--env node.name=$node_name
|
--env node.name=$node_name
|
||||||
END
|
END
|
||||||
@@ -93,7 +93,7 @@ END
|
|||||||
$CLUSTER;
|
$CLUSTER;
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
if wait_for_container "$es_node_name" "$network_name"; then
|
if wait_for_container "$opensearch_node_name" "$network_name"; then
|
||||||
echo -e "\033[32;1mSUCCESS:\033[0m Running on: $node_url\033[0m"
|
echo -e "\033[32;1mSUCCESS:\033[0m Running on: $node_url\033[0m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ def _make_path(*parts):
|
|||||||
GLOBAL_PARAMS = ("pretty", "human", "error_trace", "format", "filter_path")
|
GLOBAL_PARAMS = ("pretty", "human", "error_trace", "format", "filter_path")
|
||||||
|
|
||||||
|
|
||||||
def query_params(*es_query_params):
|
def query_params(*opensearch_query_params):
|
||||||
"""
|
"""
|
||||||
Decorator that pops all accepted parameters from method's kwargs and puts
|
Decorator that pops all accepted parameters from method's kwargs and puts
|
||||||
them in the params argument.
|
them in the params argument.
|
||||||
@@ -164,7 +164,7 @@ def query_params(*es_query_params):
|
|||||||
elif api_key is not None:
|
elif api_key is not None:
|
||||||
headers["authorization"] = "ApiKey %s" % (_base64_auth_header(api_key),)
|
headers["authorization"] = "ApiKey %s" % (_base64_auth_header(api_key),)
|
||||||
|
|
||||||
for p in es_query_params + GLOBAL_PARAMS:
|
for p in opensearch_query_params + GLOBAL_PARAMS:
|
||||||
if p in kwargs:
|
if p in kwargs:
|
||||||
v = kwargs.pop(p)
|
v = kwargs.pop(p)
|
||||||
if v is not None:
|
if v is not None:
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class Connection(object):
|
|||||||
if cloud_id:
|
if cloud_id:
|
||||||
try:
|
try:
|
||||||
_, cloud_id = cloud_id.split(":")
|
_, cloud_id = cloud_id.split(":")
|
||||||
parent_dn, es_uuid = (
|
parent_dn, opensearch_uuid = (
|
||||||
binascii.a2b_base64(cloud_id.encode("utf-8"))
|
binascii.a2b_base64(cloud_id.encode("utf-8"))
|
||||||
.decode("utf-8")
|
.decode("utf-8")
|
||||||
.split("$")[:2]
|
.split("$")[:2]
|
||||||
@@ -110,7 +110,7 @@ class Connection(object):
|
|||||||
except (ValueError, IndexError):
|
except (ValueError, IndexError):
|
||||||
raise ImproperlyConfigured("'cloud_id' is not properly formatted")
|
raise ImproperlyConfigured("'cloud_id' is not properly formatted")
|
||||||
|
|
||||||
host = "%s.%s" % (es_uuid, parent_dn)
|
host = "%s.%s" % (opensearch_uuid, parent_dn)
|
||||||
use_ssl = True
|
use_ssl = True
|
||||||
if http_compress is None:
|
if http_compress is None:
|
||||||
http_compress = True
|
http_compress = True
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class OpenSearchTestCase(TestCase):
|
|||||||
def teardown_method(self, _):
|
def teardown_method(self, _):
|
||||||
# Hidden indices expanded in wildcards in ES 7.7
|
# Hidden indices expanded in wildcards in ES 7.7
|
||||||
expand_wildcards = ["open", "closed"]
|
expand_wildcards = ["open", "closed"]
|
||||||
if self.es_version() >= (7, 7):
|
if self.opensearch_version() >= (7, 7):
|
||||||
expand_wildcards.append("hidden")
|
expand_wildcards.append("hidden")
|
||||||
|
|
||||||
self.client.indices.delete(
|
self.client.indices.delete(
|
||||||
@@ -88,10 +88,10 @@ class OpenSearchTestCase(TestCase):
|
|||||||
)
|
)
|
||||||
self.client.indices.delete_template(name="*", ignore=404)
|
self.client.indices.delete_template(name="*", ignore=404)
|
||||||
|
|
||||||
def es_version(self):
|
def opensearch_version(self):
|
||||||
if not hasattr(self, "_es_version"):
|
if not hasattr(self, "_opensearch_version"):
|
||||||
self._es_version = es_version(self.client)
|
self._opensearch_version = opensearch_version(self.client)
|
||||||
return self._es_version
|
return self._opensearch_version
|
||||||
|
|
||||||
|
|
||||||
def _get_version(version_string):
|
def _get_version(version_string):
|
||||||
@@ -101,5 +101,5 @@ def _get_version(version_string):
|
|||||||
return tuple(int(v) if v.isdigit() else 999 for v in version)
|
return tuple(int(v) if v.isdigit() else 999 for v in version)
|
||||||
|
|
||||||
|
|
||||||
def es_version(client):
|
def opensearch_version(client):
|
||||||
return _get_version(client.info()["version"]["number"])
|
return _get_version(client.info()["version"]["number"])
|
||||||
|
|||||||
@@ -41,4 +41,4 @@ class OpenSearchTestCase(TestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setup_class(cls) -> None: ...
|
def setup_class(cls) -> None: ...
|
||||||
def teardown_method(self, _: Any) -> None: ...
|
def teardown_method(self, _: Any) -> None: ...
|
||||||
def es_version(self) -> Tuple[int, ...]: ...
|
def opensearch_version(self) -> Tuple[int, ...]: ...
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ from os import environ
|
|||||||
from os.path import abspath, dirname, exists, join, pardir
|
from os.path import abspath, dirname, exists, join, pardir
|
||||||
|
|
||||||
|
|
||||||
def fetch_es_repo():
|
def fetch_opensearch_repo():
|
||||||
# user is manually setting YAML dir, don't tamper with it
|
# user is manually setting YAML dir, don't tamper with it
|
||||||
if "TEST_ES_YAML_DIR" in environ:
|
if "TEST_OPENSEARCH_YAML_DIR" in environ:
|
||||||
return
|
return
|
||||||
|
|
||||||
repo_path = environ.get(
|
repo_path = environ.get(
|
||||||
"TEST_ES_REPO",
|
"TEST_OPENSEARCH_REPO",
|
||||||
abspath(join(dirname(__file__), pardir, pardir, "opensearch")),
|
abspath(join(dirname(__file__), pardir, pardir, "opensearch")),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,12 +51,12 @@ def fetch_es_repo():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# set YAML test dir
|
# set YAML test dir
|
||||||
environ["TEST_ES_YAML_DIR"] = join(
|
environ["TEST_OPENSEARCH_YAML_DIR"] = join(
|
||||||
repo_path, "rest-api-spec", "src", "main", "resources", "rest-api-spec", "test"
|
repo_path, "rest-api-spec", "src", "main", "resources", "rest-api-spec", "test"
|
||||||
)
|
)
|
||||||
|
|
||||||
# fetching of yaml tests disabled, we'll run with what's there
|
# fetching of yaml tests disabled, we'll run with what's there
|
||||||
if environ.get("TEST_ES_NOFETCH", False):
|
if environ.get("TEST_OPENSEARCH_NOFETCH", False):
|
||||||
return
|
return
|
||||||
|
|
||||||
from test_opensearch.test_cases import SkipTest
|
from test_opensearch.test_cases import SkipTest
|
||||||
@@ -87,7 +87,7 @@ def run_all(argv=None):
|
|||||||
|
|
||||||
# fetch yaml tests anywhere that's not GitHub Actions
|
# fetch yaml tests anywhere that's not GitHub Actions
|
||||||
if "GITHUB_ACTION" not in environ:
|
if "GITHUB_ACTION" not in environ:
|
||||||
fetch_es_repo()
|
fetch_opensearch_repo()
|
||||||
|
|
||||||
# always insert coverage when running tests
|
# always insert coverage when running tests
|
||||||
if argv is None:
|
if argv is None:
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ from ...test_server.test_rest_api_spec import (
|
|||||||
|
|
||||||
pytestmark = pytest.mark.asyncio
|
pytestmark = pytest.mark.asyncio
|
||||||
|
|
||||||
ES_VERSION = None
|
OPENSEARCH_VERSION = None
|
||||||
|
|
||||||
|
|
||||||
async def await_if_coro(x):
|
async def await_if_coro(x):
|
||||||
@@ -80,15 +80,15 @@ class AsyncYamlRunner(YamlRunner):
|
|||||||
self.section("teardown")
|
self.section("teardown")
|
||||||
await self.run_code(self._teardown_code)
|
await self.run_code(self._teardown_code)
|
||||||
|
|
||||||
async def es_version(self):
|
async def opensearch_version(self):
|
||||||
global ES_VERSION
|
global OPENSEARCH_VERSION
|
||||||
if ES_VERSION is None:
|
if OPENSEARCH_VERSION is None:
|
||||||
version_string = (await self.client.info())["version"]["number"]
|
version_string = (await self.client.info())["version"]["number"]
|
||||||
if "." not in version_string:
|
if "." not in version_string:
|
||||||
return ()
|
return ()
|
||||||
version = version_string.strip().split(".")
|
version = version_string.strip().split(".")
|
||||||
ES_VERSION = tuple(int(v) if v.isdigit() else 999 for v in version)
|
OPENSEARCH_VERSION = tuple(int(v) if v.isdigit() else 999 for v in version)
|
||||||
return ES_VERSION
|
return OPENSEARCH_VERSION
|
||||||
|
|
||||||
def section(self, name):
|
def section(self, name):
|
||||||
print(("=" * 10) + " " + name + " " + ("=" * 10))
|
print(("=" * 10) + " " + name + " " + ("=" * 10))
|
||||||
@@ -211,7 +211,7 @@ class AsyncYamlRunner(YamlRunner):
|
|||||||
min_version, max_version = version.split("-")
|
min_version, max_version = version.split("-")
|
||||||
min_version = _get_version(min_version) or (0,)
|
min_version = _get_version(min_version) or (0,)
|
||||||
max_version = _get_version(max_version) or (999,)
|
max_version = _get_version(max_version) or (999,)
|
||||||
if min_version <= (await self.es_version()) <= max_version:
|
if min_version <= (await self.opensearch_version()) <= max_version:
|
||||||
pytest.skip(reason)
|
pytest.skip(reason)
|
||||||
|
|
||||||
async def _feature_enabled(self, name):
|
async def _feature_enabled(self, name):
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class TestStreamingBulk(OpenSearchTestCase):
|
|||||||
assert False, "exception should have been raised"
|
assert False, "exception should have been raised"
|
||||||
|
|
||||||
def test_different_op_types(self):
|
def test_different_op_types(self):
|
||||||
if self.es_version() < (0, 90, 1):
|
if self.opensearch_version() < (0, 90, 1):
|
||||||
raise SkipTest("update supported since 0.90.1")
|
raise SkipTest("update supported since 0.90.1")
|
||||||
self.client.index(index="i", id=45, body={})
|
self.client.index(index="i", id=45, body={})
|
||||||
self.client.index(index="i", id=42, body={})
|
self.client.index(index="i", id=42, body={})
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ SKIP_TESTS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ES_VERSION = None
|
OPENSEARCH_VERSION = None
|
||||||
RUN_ASYNC_REST_API_TESTS = (
|
RUN_ASYNC_REST_API_TESTS = (
|
||||||
sys.version_info >= (3, 6)
|
sys.version_info >= (3, 6)
|
||||||
and os.environ.get("PYTHON_CONNECTION_CLASS") == "RequestsHttpConnection"
|
and os.environ.get("PYTHON_CONNECTION_CLASS") == "RequestsHttpConnection"
|
||||||
@@ -163,15 +163,15 @@ class YamlRunner:
|
|||||||
self.section("teardown")
|
self.section("teardown")
|
||||||
self.run_code(self._teardown_code)
|
self.run_code(self._teardown_code)
|
||||||
|
|
||||||
def es_version(self):
|
def opensearch_version(self):
|
||||||
global ES_VERSION
|
global OPENSEARCH_VERSION
|
||||||
if ES_VERSION is None:
|
if OPENSEARCH_VERSION is None:
|
||||||
version_string = (self.client.info())["version"]["number"]
|
version_string = (self.client.info())["version"]["number"]
|
||||||
if "." not in version_string:
|
if "." not in version_string:
|
||||||
return ()
|
return ()
|
||||||
version = version_string.strip().split(".")
|
version = version_string.strip().split(".")
|
||||||
ES_VERSION = tuple(int(v) if v.isdigit() else 999 for v in version)
|
OPENSEARCH_VERSION = tuple(int(v) if v.isdigit() else 999 for v in version)
|
||||||
return ES_VERSION
|
return OPENSEARCH_VERSION
|
||||||
|
|
||||||
def section(self, name):
|
def section(self, name):
|
||||||
print(("=" * 10) + " " + name + " " + ("=" * 10))
|
print(("=" * 10) + " " + name + " " + ("=" * 10))
|
||||||
@@ -311,7 +311,7 @@ class YamlRunner:
|
|||||||
min_version, max_version = version.split("-")
|
min_version, max_version = version.split("-")
|
||||||
min_version = _get_version(min_version) or (0,)
|
min_version = _get_version(min_version) or (0,)
|
||||||
max_version = _get_version(max_version) or (999,)
|
max_version = _get_version(max_version) or (999,)
|
||||||
if min_version <= (self.es_version()) <= max_version:
|
if min_version <= (self.opensearch_version()) <= max_version:
|
||||||
pytest.skip(reason)
|
pytest.skip(reason)
|
||||||
|
|
||||||
def run_gt(self, action):
|
def run_gt(self, action):
|
||||||
|
|||||||
Reference in New Issue
Block a user