From 848f2b7676c2704e43f5e353c25d05951f731821 Mon Sep 17 00:00:00 2001 From: twfb Date: Tue, 17 Nov 2020 17:14:32 +0800 Subject: [PATCH 1/3] Fix symbol error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace "—" with "--". --- sql-cli/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql-cli/README.md b/sql-cli/README.md index 2f24128176..fd69975b9e 100644 --- a/sql-cli/README.md +++ b/sql-cli/README.md @@ -60,7 +60,7 @@ To install the SQL CLI: 1. To launch the CLI, run: ``` - odfesql https://localhost:9200 --username admin —password admin + odfesql https://localhost:9200 --username admin --password admin ``` By default, the `odfesql` command connects to [http://localhost:9200](http://localhost:9200/). @@ -90,7 +90,7 @@ For a list of all available configurations, see [clirc](https://github.com/opend 2. Index the sample data. ``` - curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u admin:admin --insecure —data-binary "@accounts.json" + curl -H "Content-Type: application/x-ndjson" -POST https://localhost:9200/data/_bulk -u admin:admin --insecure --data-binary "@accounts.json" ``` From f26883dc90c42475c54344ae058301337d413ef8 Mon Sep 17 00:00:00 2001 From: twfb Date: Tue, 17 Nov 2020 17:29:33 +0800 Subject: [PATCH 2/3] Fix SSLError when connect es. [why] Execute "odfesql https://localhost:9200 -u admin -w admin", Then raise "SSLError('N/A', '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)', SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)')))" --- sql-cli/src/odfe_sql_cli/esconnection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql-cli/src/odfe_sql_cli/esconnection.py b/sql-cli/src/odfe_sql_cli/esconnection.py index ec4559e0d9..032dd1c562 100644 --- a/sql-cli/src/odfe_sql_cli/esconnection.py +++ b/sql-cli/src/odfe_sql_cli/esconnection.py @@ -80,7 +80,8 @@ def get_open_distro_client(self): ssl_context.verify_mode = ssl.CERT_NONE open_distro_client = Elasticsearch( - [self.endpoint], http_auth=self.http_auth, verify_certs=False, ssl_context=ssl_context + [self.endpoint], http_auth=self.http_auth, verify_certs=False, ssl_context=ssl_context, + connection_class=RequestsHttpConnection ) return open_distro_client From 90a4a6fdcec81f86bc0829b989d5b613d8330b96 Mon Sep 17 00:00:00 2001 From: twfb Date: Wed, 18 Nov 2020 15:14:32 +0800 Subject: [PATCH 3/3] Add "connection_class" parameter to "assert_called_with". [why] Because I modify "sql-cli/src/odfe_sql_cli/esconnection.py", and add "connection_class" parameter when get es client. to fix SSLError when connect es. But the test raise " AssertionError: expected call not found." [how] Add "connection_class" parameter to "assert_called_with". --- sql-cli/tests/test_esconnection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql-cli/tests/test_esconnection.py b/sql-cli/tests/test_esconnection.py index 95d30f6426..45d40b9870 100644 --- a/sql-cli/tests/test_esconnection.py +++ b/sql-cli/tests/test_esconnection.py @@ -130,7 +130,8 @@ def test_get_od_client(self): od_test_executor.get_open_distro_client() mock_es.assert_called_with( - [OPEN_DISTRO_ENDPOINT], http_auth=AUTH, verify_certs=False, ssl_context=od_test_executor.ssl_context + [OPEN_DISTRO_ENDPOINT], http_auth=AUTH, verify_certs=False, ssl_context=od_test_executor.ssl_context, + connection_class=RequestsHttpConnection ) def test_get_aes_client(self):