Add the ability to run test patterns. (#454)
Signed-off-by: dblock <dblock@amazon.com>
This commit is contained in:
committed by
GitHub
parent
42852d0d53
commit
e022932ed1
@@ -28,7 +28,7 @@ if [[ -z $opensearch_node_name ]]; then
|
||||
|
||||
fi
|
||||
|
||||
export script_path=$(dirname $(realpath -s $0))
|
||||
export script_path=$(dirname $(realpath $0))
|
||||
source $script_path/functions/cleanup.sh
|
||||
source $script_path/functions/wait-for-container.sh
|
||||
trap "cleanup_trap ${network_name}" EXIT
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
# Bootstrap
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
script_path=$(dirname "$(realpath -s "$0")")
|
||||
script_path=$(dirname "$(realpath "$0")")
|
||||
repo=$(realpath "$script_path/../")
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#
|
||||
# Export the NUMBER_OF_NODES variable to start more than 1 node
|
||||
|
||||
script_path=$(dirname $(realpath -s $0))
|
||||
script_path=$(dirname $(realpath $0))
|
||||
source $script_path/functions/imports.sh
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
@@ -38,7 +38,10 @@ docker run \
|
||||
--env "TEST_SUITE=${TEST_SUITE}" \
|
||||
--env "PYTHON_CONNECTION_CLASS=${PYTHON_CONNECTION_CLASS}" \
|
||||
--env "TEST_TYPE=server" \
|
||||
--env "TEST_PATTERN=${TEST_PATTERN}" \
|
||||
--name opensearch-py \
|
||||
--rm \
|
||||
opensearch-project/opensearch-py \
|
||||
python setup.py test
|
||||
|
||||
unset TEST_PATTERN
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ export PYTHON_CONNECTION_CLASS="${PYTHON_CONNECTION_CLASS:=Urllib3HttpConnection
|
||||
export CLUSTER="${CLUSTER:-opensearch}"
|
||||
export SECURE_INTEGRATION="${1:-false}"
|
||||
export OPENSEARCH_VERSION="${2:-latest}"
|
||||
export TEST_PATTERN="${3:-}"
|
||||
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
|
||||
export OPENSEARCH_URL_EXTENSION="https"
|
||||
else
|
||||
@@ -21,7 +22,7 @@ if [[ "$OPENSEARCH_VERSION" == *"SNAPSHOT" ]]; then
|
||||
fi
|
||||
|
||||
echo -e "\033[1m>>>>> Unreleased is $IS_UNRELEASED >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
|
||||
script_path=$(dirname $(realpath -s $0))
|
||||
script_path=$(dirname $(realpath $0))
|
||||
source $script_path/functions/imports.sh
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
- Added samples ([#447](https://github.com/opensearch-project/opensearch-py/pull/447))
|
||||
- Improved CI performance of integration with unreleased OpenSearch ([#318](https://github.com/opensearch-project/opensearch-py/pull/318))
|
||||
- Added k-NN guide and samples ([#449](https://github.com/opensearch-project/opensearch-py/pull/449))
|
||||
- Added the ability to run tests matching a pattern to `.ci/run-tests` ([#454](https://github.com/opensearch-project/opensearch-py/pull/454))
|
||||
### Changed
|
||||
- Moved security from `plugins` to `clients` ([#442](https://github.com/opensearch-project/opensearch-py/pull/442))
|
||||
### Deprecated
|
||||
|
||||
@@ -17,6 +17,8 @@ $ python --version
|
||||
Python 3.11.1
|
||||
```
|
||||
|
||||
You can install dev requirements with `pip install -r dev-requirements.txt`, but it's better to use the docker setup described below.
|
||||
|
||||
Install [Nox](https://nox.thea.codes/en/stable/) for task management.
|
||||
|
||||
```
|
||||
@@ -69,6 +71,16 @@ The following example runs tests against the latest SNAPSHOT build of OpenSearch
|
||||
./.ci/run-tests opensearch false SNAPSHOT
|
||||
```
|
||||
|
||||
You can also run individual tests matching a pattern (`pytest -k [pattern]`).
|
||||
|
||||
```
|
||||
./.ci/run-tests true 1.3.0 test_no_http_compression
|
||||
|
||||
test_opensearchpy/test_connection.py::TestUrllib3Connection::test_no_http_compression PASSED [ 33%]
|
||||
test_opensearchpy/test_connection.py::TestRequestsConnection::test_no_http_compression PASSED [ 66%]
|
||||
test_opensearchpy/test_async/test_connection.py::TestAIOHttpConnection::test_no_http_compression PASSED [100%]
|
||||
```
|
||||
|
||||
Note that integration tests require docker to be installed and running, and downloads quite a bit of data from over the internet and hence take few minutes to complete.
|
||||
|
||||
## Linter
|
||||
|
||||
@@ -6,6 +6,7 @@ mock
|
||||
sphinx<7.1
|
||||
sphinx_rtd_theme
|
||||
jinja2
|
||||
pytz
|
||||
|
||||
# No wheels for Python 3.10 yet!
|
||||
numpy; python_version<"3.10"
|
||||
|
||||
@@ -111,58 +111,63 @@ def run_all(argv=None):
|
||||
if environ.get("OPENSEARCH_URL", "").startswith("https://"):
|
||||
secured = True
|
||||
|
||||
ignores = []
|
||||
# Python 3.6+ is required for async
|
||||
if sys.version_info < (3, 6):
|
||||
ignores.append("test_opensearchpy/test_async/")
|
||||
# check TEST_PATTERN env var for specific test to run
|
||||
test_pattern = environ.get("TEST_PATTERN")
|
||||
if test_pattern:
|
||||
argv.append("-k %s" % test_pattern)
|
||||
else:
|
||||
ignores = []
|
||||
# Python 3.6+ is required for async
|
||||
if sys.version_info < (3, 6):
|
||||
ignores.append("test_opensearchpy/test_async/")
|
||||
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server/",
|
||||
"test_opensearchpy/test_server_secured/",
|
||||
"test_opensearchpy/test_async/test_server/",
|
||||
"test_opensearchpy/test_async/test_server_secured/",
|
||||
]
|
||||
)
|
||||
|
||||
# Jenkins/Github actions, only run server tests
|
||||
if environ.get("TEST_TYPE") == "server":
|
||||
test_dir = abspath(dirname(__file__))
|
||||
if secured:
|
||||
argv.append(join(test_dir, "test_server_secured"))
|
||||
if sys.version_info >= (3, 6):
|
||||
argv.append(join(test_dir, "test_async/test_server_secured"))
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server/",
|
||||
"test_opensearchpy/test_async/test_server/",
|
||||
]
|
||||
)
|
||||
else:
|
||||
argv.append(join(test_dir, "test_server"))
|
||||
if sys.version_info >= (3, 6):
|
||||
argv.append(join(test_dir, "test_async/test_server"))
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server_secured/",
|
||||
]
|
||||
)
|
||||
|
||||
# There are no plugins for unreleased versions of opensearch
|
||||
if environ.get("OPENSEARCH_VERSION") == "SNAPSHOT":
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server/test_plugins/",
|
||||
"test_opensearchpy/test_async/test_server/test_plugins/",
|
||||
"test_opensearchpy/test_server/",
|
||||
"test_opensearchpy/test_server_secured/",
|
||||
"test_opensearchpy/test_async/test_server/",
|
||||
"test_opensearchpy/test_async/test_server_secured/",
|
||||
]
|
||||
)
|
||||
|
||||
if ignores:
|
||||
argv.extend(["--ignore=%s" % ignore for ignore in ignores])
|
||||
# Jenkins/Github actions, only run server tests
|
||||
if environ.get("TEST_TYPE") == "server":
|
||||
test_dir = abspath(dirname(__file__))
|
||||
if secured:
|
||||
argv.append(join(test_dir, "test_server_secured"))
|
||||
if sys.version_info >= (3, 6):
|
||||
argv.append(join(test_dir, "test_async/test_server_secured"))
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server/",
|
||||
"test_opensearchpy/test_async/test_server/",
|
||||
]
|
||||
)
|
||||
else:
|
||||
argv.append(join(test_dir, "test_server"))
|
||||
if sys.version_info >= (3, 6):
|
||||
argv.append(join(test_dir, "test_async/test_server"))
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server_secured/",
|
||||
]
|
||||
)
|
||||
|
||||
# Not in CI, run all tests specified.
|
||||
else:
|
||||
argv.append(abspath(dirname(__file__)))
|
||||
# There are no plugins for unreleased versions of opensearch
|
||||
if environ.get("OPENSEARCH_VERSION") == "SNAPSHOT":
|
||||
ignores.extend(
|
||||
[
|
||||
"test_opensearchpy/test_server/test_plugins/",
|
||||
"test_opensearchpy/test_async/test_server/test_plugins/",
|
||||
]
|
||||
)
|
||||
|
||||
if ignores:
|
||||
argv.extend(["--ignore=%s" % ignore for ignore in ignores])
|
||||
|
||||
# Not in CI, run all tests specified.
|
||||
else:
|
||||
argv.append(abspath(dirname(__file__)))
|
||||
|
||||
exit_code = 0
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user