Skip to content

Commit cbe91d8

Browse files
authored
Merge pull request amazon-archives#22 from zhongnansu/test
Update doc and naming
2 parents 3a2c216 + 118e2bd commit cbe91d8

7 files changed

+111
-69
lines changed

README.md

+11-35
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Open Distro Elasticsearch SQL CLI
22

3+
ODFE: Open Distro for Elasticsearch
34

4-
SQL CLI is a stand alone Python application and can be launched by a wake word `escli`. It serves as a support only for
5-
[Open Distro SQL plugin for Elasticsearch](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/). You can move
6-
it around to other machines without having to install Elasticsearch on them.
5+
ODFE SQL CLI is a stand alone Python application and can be launched by a wake word `odfesql`. It serves as a support only for
6+
[Open Distro SQL plugin for Elasticsearch](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/). You can run
7+
it on any OS we support, and connect to any valid remote endpoint without installing Elasticsearch.
78

89

910
## Installation
10-
- `pip install escli`
11-
- escli is compatible with Python 3, and python 2 is going away soon https://pythonclock.org/
11+
- `pip install odfesql`
12+
- odfe sql cli is compatible with Python 3, because Python 2 is no longer maintained since 01/01/2020 https://pythonclock.org/
1213

1314

1415
## Configuration
@@ -25,10 +26,11 @@ See the file itself for a description of all available options.
2526
- Enable horizontal display (by default) and vertical display when output is too wide
2627
- Pagination for long output
2728
- Syntax highlighting
28-
- Connect to Elasticsearch node/cluster with authentication on either ES localhost, Open Distro ES, or AES,
29+
- Connect to Elasticsearch node/cluster with/without security on either **ES localhost, Open Distro ES, or AWS Elasticsearch Domain**.
30+
Refer to [test plan](./tests/test_plan.md) on how to connect to different instance with/without security
2931
- Load Config file
3032
- Run single query from Command Line with parameters
31-
- *endpoint:* no need to specify a parameter, anything follow by wake word `escli` should be the endpoint.
33+
- *endpoint:* no need to specify a parameter, anything follow by wake word `odfesql` should be the endpoint.
3234
By default, it’s http://localhost:9200
3335
- *--help:* help page for options and params
3436
- *-q:* follow by a single query user wants to run.
@@ -45,7 +47,8 @@ See the file itself for a description of all available options.
4547

4648

4749
## Basic Usage
48-
![](./screenshots/usage.gif)
50+
- The CLI supports all types of query that ODFE SQL supports. See [ODFE SQL basic usage](https://github.com/opendistro-for-elasticsearch/sql#basic-usage)
51+
- ![](./screenshots/usage.gif)
4952

5053

5154

@@ -69,30 +72,3 @@ See the [LICENSE](./LICENSE.TXT) file for our project's licensing. We will ask y
6972
## Copyright
7073

7174
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
72-
73-
74-
75-
## Development Guide
76-
### Build the application in development
77-
- `pip install virtualenv`
78-
- `virtualenv venv` to create virtual environment for **Python 3**
79-
- `source ./venv/bin/activate` activate virtual env.
80-
- `cd` into project root folder.
81-
- `pip install --editable .` will install all dependencies from `setup.py`.
82-
83-
### Run CLI
84-
- Start an Elasticsearch instance from either local, Docker with Open Distro SQL plugin, or AWS Elasticsearch
85-
- To launch the cli, use wake word `escli` followed by endpoint of your running ES instance. If not specifying
86-
any endpoint, it uses http://localhost:9200 by default.
87-
88-
### Testing Procedure
89-
- Prerequisites
90-
- Build the application
91-
- Start a local Elasticsearch instance with
92-
[Open Distro SQL plugin for Elasticsearch](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/) installed
93-
and listening at http://localhost:9200.
94-
- `pip install -r requirements-dev.txt` Install test frameworks including Pytest and mock.
95-
- `cd` into `tests` and run `pytest`
96-
97-
### Style
98-
- Use [black](https://github.com/psf/black) to format code, with option of `--line-length 120`

development_guide.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Development Guide
2+
### Development Environment Set Up
3+
- `pip install virtualenv`
4+
- `virtualenv venv` to create virtual environment for **Python 3**
5+
- `source ./venv/bin/activate` activate virtual env.
6+
- `cd` into project root folder.
7+
- `pip install --editable .` will install all dependencies from `setup.py`.
8+
9+
### Run CLI
10+
- Start an Elasticsearch instance from either local, Docker with Open Distro SQL plugin, or AWS Elasticsearch
11+
- To launch the cli, use wake word `odfesql` followed by endpoint of your running ES instance. If not specifying
12+
any endpoint, it uses http://localhost:9200 by default.
13+
14+
### Testing
15+
- Prerequisites
16+
- Build the application
17+
- Start a local Elasticsearch instance (OSS) with
18+
[Open Distro SQL plugin for Elasticsearch](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/) installed
19+
and listening at http://localhost:9200.
20+
- Pytest
21+
- `pip install -r requirements-dev.txt` Install test frameworks including Pytest and mock.
22+
- `cd` into `tests` and run `pytest`
23+
- Refer to [test_plan](./tests/test_plan.md) for manual test guidance.
24+
25+
### Style
26+
- Use [black](https://github.com/psf/black) to format code, with option of `--line-length 120`
27+
28+
## Release guide
29+
30+
- Package Manager: pip
31+
- Repository of software for Python: PyPI
32+
33+
### Workflow
34+
35+
1. Update version number
36+
1. Modify the version number in `_init_.py` under `escli` package. It will be used by `setup.py` for release.
37+
2. Create/Update `setup.py` (if needed)
38+
1. For more details refer to https://packaging.python.org/tutorials/packaging-projects/#creating-setup-py
39+
3. Update README.md, Legal and copyright files(if needed)
40+
1. Update README.md when there is a critical feature added.
41+
2. Update `THIRD-PARTY` files if there is a new dependency added.
42+
4. Generate distribution archives
43+
1. Make sure you have the latest versions of `setuptools` and `wheel` installed: `pip install --user --upgrade setuptools wheel`
44+
2. Run this command from the same directory where `setup.py` is located: `python3 setup.py sdist bdist_wheel`
45+
5. Upload the distribution archives to TestPyPI
46+
1. Register an account on [testPyPI](https://test.pypi.org/)
47+
2. `pip install --user —upgrade twine `
48+
3. `python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*`
49+
6. Install your package from TestPyPI and do manual test
50+
1. `pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple odfe-sql`
51+
7. Upload to PyPI
52+
1. Register an account on [PyPI](https://pypi.org/), note that these are two separate servers and the credentials from the test server are not shared with the main server.
53+
2. Use `twine upload dist/*` to upload your package and enter your credentials for the account you registered on PyPI.
54+
8. Install your package from PyPI using `pip install [your-package-name]`
55+
56+
### Reference
57+
- https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56
58+
- https://packaging.python.org/tutorials/packaging-projects/
59+
- https://packaging.python.org/guides/using-testpypi/

escli/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
"""
15-
__version__ = "1.0.7"
15+
__version__ = "1.0"

escli/essqlcli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646

4747
class ESSqlCli:
48-
"""ESSqlCli instance is used to build and run the ES SQL CLI."""
48+
"""ESSqlCli instance is used to build and run the ODFE SQL CLI."""
4949

5050
def __init__(self, esclirc_file=None, always_use_pager=False):
5151
# Load conf file
@@ -123,7 +123,7 @@ def run_cli(self):
123123

124124
while True:
125125
try:
126-
text = self.prompt_app.prompt(message="escli> ")
126+
text = self.prompt_app.prompt(message="odfesql> ")
127127
except KeyboardInterrupt:
128128
continue # Control-C pressed. Try again.
129129
except EOFError:

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
long_description = fh.read()
4242

4343
setup(
44-
name="escli",
44+
name="odfesql",
4545
author="Zhongnan",
4646
author_email="[email protected]",
4747
version=version,
@@ -53,7 +53,7 @@
5353
long_description=long_description,
5454
long_description_content_type="text/markdown",
5555
install_requires=install_requirements,
56-
entry_points={"console_scripts": ["escli=escli.main:cli"]},
56+
entry_points={"console_scripts": ["odfesql=escli.main:cli"]},
5757
classifiers=[
5858
"Intended Audience :: Developers",
5959
"License :: OSI Approved :: Apache Software License",

tests/test_plan.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Test Plan
2+
The purpose of this checklist is to guide you through the basic usage of ODFE SQL CLI, as well as a manual test process.
3+
4+
## Display
5+
* [ ] Test pagination with different output length / width.
6+
* [ ] Test table formatted output.
7+
* [ ] Test successful conversion from horizontal to vertical display with confirmation.
8+
* [ ] Test warning message when output > 200 rows of data. (Limited by ODFE SQL syntax)
9+
10+
11+
## Connection
12+
* [ ] Test connection to a local Elasticsearch instance
13+
* [ ] Standard Elastic version, with/without authentication by [X-pack security](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/security-getting-started.html)
14+
* [ ] OSS version, no authentication
15+
* [ ] OSS version, install [ODFE Security plugin](https://opendistro.github.io/for-elasticsearch-docs/docs/install/plugins/) to enable authentication and SSL
16+
* [ ] Test connection to [AWS Elasticsearch domain](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-gsg.html) (with ODFE SQL plugin installed by default)
17+
* [ ] Test connection fail when connecting to invalid endpoint
18+
* [ ] Test reconnection when connection lost during execution
19+
20+
21+
## Execution
22+
* [ ] Test successful execution given a query
23+
* [ ] Test unsuccessful execution with an invalid SQL query
24+
* [ ] Test load config file
25+
26+
27+
## Nested commands with params
28+
* [ ] Test dump query result to a file
29+
* [ ] Test explain option `-e`
30+
* [ ] Test query and format option `-q`, `-f`
31+
* [ ] Test vertical option `-v`
32+
33+
34+
## OS and Python compatibility
35+
* [ ] Manually test on Linux(Ubuntu), Windows and mac-os.
36+
* [ ] Test against python 3.X versions

tests/test_plan.wiki

-29
This file was deleted.

0 commit comments

Comments
 (0)