Add Python API tests for execution of external utilities such as pg_dump.

This commit is contained in:
Khushboo Vashi
2018-06-15 11:36:07 +01:00
committed by Dave Page
parent 766b389001
commit d1902cd639
21 changed files with 2455 additions and 40 deletions
+71 -3
View File
@@ -21,6 +21,8 @@ import config
import regression
from regression import test_setup
from pgadmin.utils.preferences import Preferences
SERVER_GROUP = test_setup.config_data['server_group']
file_name = os.path.realpath(__file__)
@@ -68,7 +70,7 @@ def logout_tester_account(tester):
:return: None
"""
response = tester.get('/logout')
tester.get('/logout')
def get_config_data():
@@ -86,7 +88,8 @@ def get_config_data():
"db_password": srv['db_password'],
"role": "",
"sslmode": srv['sslmode'],
"tablespace_path": srv.get('tablespace_path', None)
"tablespace_path": srv.get('tablespace_path', None),
"default_binary_paths": srv.get('default_binary_paths', None)
}
if 'db_type' in srv:
data['db_type'] = srv['db_type']
@@ -444,7 +447,14 @@ def delete_server_with_api(tester, sid):
try:
url = '/browser/server/obj/' + str(SERVER_GROUP) + "/"
# Call API to delete the server
response = tester.delete(url + str(sid))
tester.delete(url + str(sid))
cnt = 0
for s in regression.parent_node_dict["server"]:
if s['server_id'] == int(sid):
del regression.parent_node_dict["server"][cnt]
cnt += 1
except Exception:
traceback.print_exc(file=sys.stderr)
@@ -596,6 +606,64 @@ def get_db_server(sid):
return connection
def set_preference(default_binary_path):
conn = sqlite3.connect(config.TEST_SQLITE_PATH)
cur = conn.cursor()
perf = Preferences.module('paths')
pg_path_pref = perf.preference('pg_bin_dir')
user_pref = cur.execute(
'SELECT pid, uid FROM user_preferences where pid=%s' % pg_path_pref.pid
)
user_pref = user_pref.fetchone()
if user_pref:
cur.execute('UPDATE user_preferences SET value = ? WHERE pid = ?',
(default_binary_path['pg'], pg_path_pref.pid))
else:
pg_pref_details = (pg_path_pref.pid, 1,
default_binary_path['pg'])
cur.execute('INSERT INTO user_preferences(pid, uid, value)'
' VALUES (?,?,?)', pg_pref_details)
ppas_path_pref = perf.preference('ppas_bin_dir')
user_pref = cur.execute(
'SELECT pid, uid FROM user_preferences where pid=%s' %
ppas_path_pref.pid
)
user_pref = user_pref.fetchone()
if user_pref:
cur.execute('UPDATE user_preferences SET value = ? WHERE pid = ? ',
(default_binary_path['ppas'], ppas_path_pref.pid))
else:
ppas_pref_details = (ppas_path_pref.pid, 1,
default_binary_path['ppas'])
cur.execute('INSERT INTO user_preferences(pid, uid, value)'
' VALUES (?,?,?)', ppas_pref_details)
gpdb_path_pref = perf.preference('gpdb_bin_dir')
user_pref = cur.execute(
'SELECT pid, uid FROM user_preferences where pid=%s' %
gpdb_path_pref.pid
)
user_pref = user_pref.fetchone()
if user_pref:
cur.execute('UPDATE user_preferences SET value = ? WHERE pid = ? ',
(default_binary_path['gpdb'], gpdb_path_pref.pid))
else:
gpdb_pref_details = (gpdb_path_pref.pid, 1,
default_binary_path['gpdb'])
cur.execute('INSERT INTO user_preferences(pid, uid, value)'
' VALUES (?,?,?)', gpdb_pref_details)
conn.commit()
def remove_db_file():
"""This function use to remove SQLite DB file"""
if os.path.isfile(config.TEST_SQLITE_PATH):
+6 -1
View File
@@ -114,6 +114,9 @@ test_client = app.test_client()
driver = None
app_starter = None
handle_cleanup = None
app.PGADMIN_RUNTIME = True
if config.SERVER_MODE is True:
app.PGADMIN_RUNTIME = False
setattr(unit_test.result.TestResult, "passed", [])
@@ -234,7 +237,6 @@ def get_test_modules(arguments):
# Sort module list so that test suite executes the test cases sequentially
module_list = TestsGeneratorRegistry.registry.items()
module_list = sorted(module_list, key=lambda module_tuple: module_tuple[0])
return module_list
@@ -393,6 +395,9 @@ if __name__ == '__main__':
# Create test server
server_information = test_utils.create_parent_server_node(server)
if server['default_binary_paths'] is not None:
test_utils.set_preference(server['default_binary_paths'])
suite = get_suite(test_module_list,
server,
test_client,
+6 -1
View File
@@ -23,7 +23,12 @@
"maintenance_db": "postgres",
"sslmode": "prefer",
"tablespace_path": "",
"enabled": true
"enabled": true,
"default_binary_paths": {
"pg": "/opt/PostgreSQL/9.4/bin/",
"ppas": "/opt/edb/as10/bin/",
"gpdb": ""
}
}
],
"server_update_data": [