2021-08-06 12:59:39 +05:30
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
# The OpenSearch Contributors require contributions made to
|
|
|
|
|
# this file be licensed under the Apache-2.0 license or a
|
|
|
|
|
# compatible open source license.
|
|
|
|
|
#
|
|
|
|
|
# Modifications Copyright OpenSearch Contributors. See
|
|
|
|
|
# GitHub history for details.
|
|
|
|
|
#
|
2020-07-02 13:15:25 -05:00
|
|
|
# Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
|
# license agreements. See the NOTICE file distributed with
|
|
|
|
|
# this work for additional information regarding copyright
|
|
|
|
|
# ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
|
# the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
|
# under the License.
|
2020-04-23 11:22:08 -05:00
|
|
|
|
2022-10-04 00:15:18 +05:30
|
|
|
|
2020-03-10 12:08:03 -05:00
|
|
|
from unittest import SkipTest
|
2021-01-13 14:21:04 -06:00
|
|
|
|
2021-09-16 14:59:29 +05:30
|
|
|
from opensearchpy.helpers import test
|
|
|
|
|
from opensearchpy.helpers.test import OpenSearchTestCase as BaseTestCase
|
2013-05-27 23:02:38 +02:00
|
|
|
|
2014-01-18 21:08:15 +01:00
|
|
|
client = None
|
2013-05-27 23:02:38 +02:00
|
|
|
|
2019-05-10 09:16:33 -06:00
|
|
|
|
2016-07-12 18:02:46 +02:00
|
|
|
def get_client(**kwargs):
|
2014-01-18 21:08:15 +01:00
|
|
|
global client
|
2020-03-10 12:08:03 -05:00
|
|
|
if client is False:
|
|
|
|
|
raise SkipTest("No client is available")
|
2016-07-12 18:02:46 +02:00
|
|
|
if client is not None and not kwargs:
|
2014-01-18 21:08:15 +01:00
|
|
|
return client
|
2013-05-27 23:02:38 +02:00
|
|
|
|
2013-11-23 19:20:44 +01:00
|
|
|
# try and locate manual override in the local environment
|
|
|
|
|
try:
|
2021-09-16 14:59:29 +05:30
|
|
|
from test_opensearchpy.local import get_client as local_get_client
|
2019-05-10 09:16:33 -06:00
|
|
|
|
2016-07-12 18:02:46 +02:00
|
|
|
new_client = local_get_client(**kwargs)
|
2013-11-23 19:20:44 +01:00
|
|
|
except ImportError:
|
|
|
|
|
# fallback to using vanilla client
|
2020-03-10 12:08:03 -05:00
|
|
|
try:
|
|
|
|
|
new_client = test.get_test_client(**kwargs)
|
|
|
|
|
except SkipTest:
|
|
|
|
|
client = False
|
|
|
|
|
raise
|
2014-04-23 01:00:20 +02:00
|
|
|
|
2016-07-12 18:02:46 +02:00
|
|
|
if not kwargs:
|
|
|
|
|
client = new_client
|
|
|
|
|
|
|
|
|
|
return new_client
|
2013-09-28 15:50:14 +02:00
|
|
|
|
2013-05-27 23:02:38 +02:00
|
|
|
|
2020-05-14 16:09:24 -05:00
|
|
|
def setup_module():
|
2014-01-18 21:08:15 +01:00
|
|
|
get_client()
|
2013-08-01 14:47:34 +02:00
|
|
|
|
2019-05-10 09:16:33 -06:00
|
|
|
|
2021-08-13 15:51:50 +05:30
|
|
|
class OpenSearchTestCase(BaseTestCase):
|
2014-04-23 01:00:20 +02:00
|
|
|
@staticmethod
|
2016-07-12 18:02:46 +02:00
|
|
|
def _get_client(**kwargs):
|
|
|
|
|
return get_client(**kwargs)
|