Skip to content

Commit 18db5de

Browse files
committed
Testing convenience: build DSN out of URL (#260)
In case the '-p' parameter provides a URL to connect to a running Elasticsearch instance, use that to construct a testing DSN, so another (and possibly conflicting) '-c' paramter won't need to. This also fixes a defect where trying to run the integration suite in non-indexing mode fails due to missing meta-data. (cherry picked from commit a4f123c)
1 parent 21c1380 commit 18db5de

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

test/integration/data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ def _delete_if_needed(self, index_name, template=False, pipeline=False):
517517
self._del_resource(url)
518518

519519
def _load_tableau_sample(self, file_name, index_name, template, pipeline=None):
520+
# function will build meta-data, needed also for the MODE_NOINDEX testing
521+
ndjsons = self._get_csv_as_ndjson(TABLEAU_DATASET_BASE_URL, file_name, index_name)
520522
if self._mode <= self.MODE_NOINDEX:
521523
return
522524
self._delete_if_needed(index_name, True, pipeline is not None)
@@ -534,7 +536,6 @@ def _load_tableau_sample(self, file_name, index_name, template, pipeline=None):
534536
raise Exception("PUT %s pipeline failed with code: %s (content: %s) " % (index_name,
535537
req.status_code, req.text))
536538

537-
ndjsons = self._get_csv_as_ndjson(TABLEAU_DATASET_BASE_URL, file_name, index_name)
538539
self._post_ndjson(ndjsons, index_name, index_name if pipeline else None)
539540
self._wait_for_results(index_name)
540541

test/integration/testing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import struct
1212
import ctypes
13+
import urllib3
1314

1415
from elasticsearch import Elasticsearch
1516
from data import TestData, BATTERS_TEMPLATE
@@ -27,12 +28,14 @@ class Testing(unittest.TestCase):
2728
def __init__(self, es, test_data, catalog, dsn=None):
2829
super().__init__()
2930
uid, pwd = es.credentials()
31+
es_url = urllib3.util.parse_url(es.base_url())
3032

3133
self._uid = uid
3234
self._data = test_data
3335
self._catalog = catalog
3436

35-
conn_str = "Driver={%s};UID=%s;PWD=%s;Secure=0;" % (DRIVER_NAME, uid, pwd)
37+
conn_str = "Driver={%s};UID=%s;PWD=%s;Server=%s;Port=%s;Secure=%s;" % (DRIVER_NAME, uid, pwd, es_url.host,
38+
es_url.port, "1" if es_url.scheme.lower() == "https" else "0")
3639
if dsn:
3740
if "Driver=" not in dsn:
3841
self._dsn = conn_str + dsn

0 commit comments

Comments
 (0)