Test suite enhancements:

1. The user will specify the tablespace path in test_config.json.in
2.  If tablespace path not found, skip the test cases for that server(Only tablespace test cases)
3.  Add the skipped test summary in the test result. (Now it's showing on console + in log file, but need to update in a final enhanced test summary report. Which is research point we will work on that after finishing all nodes API test cases)
4.  Removed the test_ prefix from the values in the config files.
5. Add tablespace and roles tests
This commit is contained in:
Navnath Gadakh
2016-08-09 16:05:40 +01:00
committed by Dave Page
parent 2b13d55016
commit 81e2bc1e80
34 changed files with 1685 additions and 625 deletions

View File

@@ -75,22 +75,29 @@ General Information
Test Data Details
-----------------
"pgAdmin4 Login Credentials":
"pgAdmin4 Login Credentials" (used to login to pgAdmin):
test_login_username = login id
test_login_password = login password
test_new_password = new login password
login_username = login id
login_password = login password
new_password = new login password
"test_server_credentials":
"pgAdmin4 Test User Credentials" (dummy user used for testing user management):
test_name = Server/database Name
test_db_username = Database Username
test_host = IP Address of Server
test_db_password = Database Password
test_db_port = Database Port
test_maintenance_db = Maintenance Database
test_sslmode = SSL Mode
test_comment = Any Comments to add
login_username = login id
login_password = login password
new_password = new login password
"server_credentials":
name = Server/database Name
db_username = Database Username
host = IP Address of Server
db_password = Database Password
db_port = Database Port
maintenance_db = Maintenance Database
sslmode = SSL Mode
comment = Any Comments to add
tablespace_path = A path under which a tablespace can be created
Execution:

View File

@@ -1,7 +1,7 @@
{
"test_add_database_data": [
"add_database_data": [
{
"test_privileges_acl": [
"privileges_acl": [
{
"grantee": "postgres",
"grantor": "postgres",
@@ -19,9 +19,9 @@
]
}
],
"test_conn_limit": -1,
"test_owner": "postgres",
"test_fun_acl": [
"conn_limit": -1,
"owner": "postgres",
"fun_acl": [
{
"grantee": "postgres",
"grantor": "postgres",
@@ -34,7 +34,7 @@
]
}
],
"test_seq_acl": [
"seq_acl": [
{
"grantee": "postgres",
"grantor": "postgres",
@@ -57,7 +57,7 @@
]
}
],
"test_tbl_acl": [
"tbl_acl": [
{
"grantee": "postgres",
"grantor": "postgres",
@@ -75,7 +75,7 @@
]
}
],
"test_type_acl": [
"type_acl": [
{
"grantee": "postgres",
"grantor": "postgres",
@@ -88,112 +88,60 @@
]
}
],
"test_encoding": "UTF8",
"test_name": "test_db_automation",
"test_privileges": [],
"test_securities": [],
"test_variables": []
},
{
"test_privileges_acl": [
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "C",
"privilege": true,
"with_grant": true
},
{
"privilege_type": "T",
"privilege": true,
"with_grant": false
}
]
}
],
"test_conn_limit": -1,
"test_owner": "enterprisedb",
"test_fun_acl": [
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "X",
"privilege": true,
"with_grant": false
}
]
}
],
"test_seq_acl": [
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "w",
"privilege": true,
"with_grant": false
},
{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}
]
}
],
"test_tbl_acl": [
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "a",
"privilege": true,
"with_grant": true
},
{
"privilege_type": "r",
"privilege": true,
"with_grant": false
}
]
}
],
"test_type_acl": [
{
"grantee": "enterprisedb",
"grantor": "enterprisedb",
"privileges": [
{
"privilege_type": "U",
"privilege": true,
"with_grant": false
}
]
}
],
"test_encoding": "UTF8",
"test_name": "test_db_automation",
"test_privileges": [],
"test_securities": [],
"test_variables": []
}
"encoding": "UTF8",
"name": "test_db_automation",
"privileges": [],
"securities": [],
"variables": []
}
],
"db_update_data": [
{
"comment": "This is db update comment"
}
],
"test_db_update_data": [
{
"test_comment": "This is db update comment"
}
]
"lr_credentials": {
"can_login": "true",
"conn_limit": -1,
"create_role": "true",
"role_inherit": "true",
"role_membership": [],
"lr_name": "testlrg1",
"lr_password": "edb",
"lr_validity": "12/27/2016",
"sec_lable": [],
"variable":[
{"name":"work_mem",
"database":"postgres",
"value":65
}]
},
"lr_update_data": {
"comment": "This is db update comment"
},
"tablespc_credentials":[{
"tblspace_name": "test_tablespace",
"spc_seclable": [],
"spc_acl": [
{
"grantee":"postgres",
"grantor":"postgres",
"privileges":[
{
"privilege_type":"C",
"privilege":true,
"with_grant":false
}
]
}
],
"spc_opts": [],
"spc_user": "postgres"
}],
"tbspc_update_data": {
"comment": "This is tablespace update comment"
}
}

View File

@@ -1,35 +1,31 @@
{
"pgAdmin4_login_credentials": {
"test_new_password": "NEWPASSWORD",
"test_login_password": "PASSWORD",
"test_login_username": "USER@EXAMPLE.COM"
"new_password": "NEWPASSWORD",
"login_password": "PASSWORD",
"login_username": "USER@EXAMPLE.COM"
},
"test_server_group": 1,
"test_server_credentials": [
"pgAdmin4_test_user_credentials": {
"new_password": "NEWPASSWORD",
"login_password": "PASSWORD",
"login_username": "USER@EXAMPLE.COM"
},
"server_group": 1,
"server_credentials": [
{
"test_name": "PostgreSQL 9.4",
"test_comment": "PostgreSQL 9.4 Server (EDB Installer)",
"test_db_username": "postgres",
"test_host": "localhost",
"test_db_password": "PASSWORD",
"test_db_port": 5432,
"test_maintenance_db": "postgres",
"test_sslmode": "prefer"
},
{
"test_name": "Postgres Plus Advanced Server 9.4",
"test_comment": "Postgres Plus Advanced 9.4 Server (EDB Installer)",
"test_db_username": "enterprisedb",
"test_host": "localhost",
"test_db_password": "edb",
"test_db_port": 5444,
"test_maintenance_db": "edb",
"test_sslmode": "prefer"
}
"name": "PostgreSQL 9.4",
"comment": "PostgreSQL 9.4 Server (EDB Installer)",
"db_username": "postgres",
"host": "localhost",
"db_password": "PASSWORD",
"db_port": 5432,
"maintenance_db": "postgres",
"sslmode": "prefer",
"tablespace_path": ""
}
],
"test_server_update_data": [
"server_update_data": [
{
"test_comment": "This is test update comment"
"comment": "This is test update comment"
}
]
}

View File

@@ -12,10 +12,24 @@ import os
CURRENT_PATH = os.path.dirname(os.path.realpath(__file__))
with open(CURRENT_PATH + '/test_config.json') as data_file:
config_data = json.load(data_file)
# with open(CURRENT_PATH + '/test_config.json') as data_file:
# config_data = json.load(data_file)
#
# with open(CURRENT_PATH + '/test_advanced_config.json') as data_file:
# advanced_config_data = json.load(data_file)
with open(CURRENT_PATH + '/test_advanced_config.json') as data_file:
advanced_config_data = json.load(data_file)
try:
with open(CURRENT_PATH + '/test_config.json') as data_file:
config_data = json.load(data_file)
except:
with open(CURRENT_PATH + '/test_config.json.in') as data_file:
config_data = json.load(data_file)
try:
with open(CURRENT_PATH + '/test_advanced_config.json') as data_file:
advanced_config_data = json.load(data_file)
except:
with open(CURRENT_PATH + '/test_advanced_config.json.in') as data_file:
advanced_config_data = json.load(data_file)
pickle_path = os.path.join(CURRENT_PATH, 'parent_id.pkl')

View File

@@ -9,16 +9,24 @@
import os
import pickle
import json
import uuid
from test_setup import config_data, advanced_config_data, \
pickle_path
from test_setup import config_data, pickle_path
SERVER_URL = '/browser/server/obj/'
SERVER_CONNECT_URL = 'browser/server/connect/'
DATABASE_URL = '/browser/database/obj/'
DATABASE_CONNECT_URL = 'browser/database/connect/'
SERVER_GROUP = config_data['server_group']
def get_pickle_id_dict():
"""This function returns the empty dict of server config data"""
pickle_id_dict = {
"sid": [], # server
"did": [], # database
"lrid": [], # role
"tsid": [], # tablespace
"scid": [] # schema
}
return pickle_id_dict
def get_ids(url=pickle_path):
@@ -34,43 +42,9 @@ def get_ids(url=pickle_path):
output = open(url, 'rb')
ids = pickle.load(output)
output.close()
return ids
def verify_database(tester, server_group, server_id, db_id):
"""
This function verifies that database is exists and whether it connect
successfully or not
:param tester: test client
:type tester: flask test client object
:param server_group: server group id
:type server_group: int
:param server_id: server id
:type server_id: str
:param db_id: database id
:type db_id: str
:return: temp_db_con
:rtype: list
"""
# Connect to server
response = tester.post('{0}{1}/{2}'.format(
SERVER_CONNECT_URL, server_group, server_id), data=dict(
password=config_data['test_server_credentials'][0][
'test_db_password']),
follow_redirects=True)
# Connect to database
con_response = tester.post('{0}{1}/{2}/{3}'.format(
DATABASE_CONNECT_URL, server_group, server_id, db_id),
follow_redirects=True)
temp_db_con = json.loads(con_response.data.decode('utf-8'))
return temp_db_con
def test_getnodes(tester=None):
# Connect to server and database.
@@ -81,53 +55,14 @@ def test_getnodes(tester=None):
server_ids = all_id["sid"]
db_ids_dict = all_id["did"][0]
srv_grp = config_data['test_server_group']
db_con = []
for server_id in server_ids:
db_id = db_ids_dict[int(server_id)]
db_con.append(verify_database(tester, srv_grp, server_id, db_id))
db_con.append(verify_database(tester, SERVER_GROUP, server_id, db_id))
return db_con
def get_db_data(server_connect_data):
"""
This function is used to get advance config test data for appropriate
server
:param server_connect_data: list of server details
:return data: database details
:rtype: dict
"""
adv_config_data = None
data = None
db_user = server_connect_data['data']['user']['name']
# Get the config data of appropriate db user
for config_test_data in advanced_config_data['test_add_database_data']:
if db_user == config_test_data['test_owner']:
adv_config_data = config_test_data
if adv_config_data is not None:
data = {
"datacl": adv_config_data['test_privileges_acl'],
"datconnlimit": adv_config_data['test_conn_limit'],
"datowner": adv_config_data['test_owner'],
"deffuncacl": adv_config_data['test_fun_acl'],
"defseqacl": adv_config_data['test_seq_acl'],
"deftblacl": adv_config_data['test_tbl_acl'],
"deftypeacl": adv_config_data['test_type_acl'],
"encoding": adv_config_data['test_encoding'],
"name": str(uuid.uuid4())[1:8],
"privileges": adv_config_data['test_privileges'],
"securities": adv_config_data['test_securities'],
"variables": adv_config_data['test_variables']
}
return data
def login_tester_account(tester):
"""
This function login the test account using credentials mentioned in
@@ -139,9 +74,9 @@ def login_tester_account(tester):
"""
email = \
config_data['pgAdmin4_login_credentials']['test_login_username']
config_data['pgAdmin4_login_credentials']['login_username']
password = \
config_data['pgAdmin4_login_credentials']['test_login_password']
config_data['pgAdmin4_login_credentials']['login_password']
response = tester.post('/login', data=dict(
email=email, password=password), follow_redirects=True)
@@ -158,6 +93,7 @@ def logout_tester_account(tester):
response = tester.get('/logout')
# Config data for parent_id.pkl
def get_config_data():
"""
This function get the data related to server group and database
@@ -168,23 +104,18 @@ def get_config_data():
"""
db_data = []
pickle_id_dict = get_pickle_id_dict()
server_group = config_data['server_group']
pickle_id_dict = {
"sid": [], # server
"did": [] # database
}
server_group = config_data['test_server_group']
for srv in config_data['test_server_credentials']:
data = {"name": srv['test_name'],
for srv in config_data['server_credentials']:
data = {"name": srv['name'],
"comment": "",
"host": srv['test_host'],
"port": srv['test_db_port'],
"db": srv['test_maintenance_db'],
"username": srv['test_db_username'],
"host": srv['host'],
"port": srv['db_port'],
"db": srv['maintenance_db'],
"username": srv['db_username'],
"role": "",
"sslmode": srv['test_sslmode']}
"sslmode": srv['sslmode']}
db_data.append(data)
return server_group, db_data, pickle_id_dict
@@ -205,40 +136,12 @@ def write_parent_id(response_data, pickle_id_dict):
existed_server_id = open(pickle_path, 'rb')
pickle_id_dict = pickle.load(existed_server_id)
pickle_id_dict["sid"].append(server_id)
pickle_id_dict["sid"].append(str(server_id))
output = open(pickle_path, 'wb')
pickle.dump(pickle_id_dict, output)
output.close()
def write_db_parent_id(response_data):
"""
This function writes the server and database related data like server
name, server id , database name, database id etc.
:param response_data: server and databases details
:type response_data: dict
:return: None
"""
db_id = response_data['node']['_id']
server_id = response_data['node']['_pid']
if os.path.isfile(pickle_path):
existing_server_id = open(pickle_path, 'rb')
tol_server_id = pickle.load(existing_server_id)
pickle_id_dict = tol_server_id
if 'did' in pickle_id_dict:
if pickle_id_dict['did']:
# Add the db_id as value in dict
pickle_id_dict["did"][0].update({server_id: db_id})
else:
# Create new dict with server_id and db_id
pickle_id_dict["did"].append({server_id: db_id})
db_output = open(pickle_path, 'wb')
pickle.dump(pickle_id_dict, db_output)
db_output.close()
def delete_parent_id_file():
"""
This function deletes the file parent_id.pkl which contains server and
@@ -250,148 +153,3 @@ def delete_parent_id_file():
if os.path.isfile(pickle_path):
os.remove(pickle_path)
def add_server(tester):
"""
This function add the server in the existing server group
:param tester: test object
:type tester: flask test object
:return:None
"""
server_group, db_data, pickle_id_dict = get_config_data()
url = "{0}{1}/".format(SERVER_URL, server_group)
for db_detail in db_data:
response = tester.post(url, data=json.dumps(db_detail),
content_type='html/json')
response_data = json.loads(response.data.decode())
write_parent_id(response_data, pickle_id_dict)
def get_server(tester):
"""
This function gets the added serer details
:param tester: test client object
:type tester: flask test object
:return: response_data
:rtype: list
"""
all_id = get_ids()
server_ids = all_id["sid"]
server_group = config_data['test_server_group']
for server_id in server_ids:
response = tester.get(SERVER_URL + str(server_group) + '/' +
str(server_id),
follow_redirects=True)
response_data = json.loads(response.data.decode())
def connect_server(tester):
"""
This function used to connect added server
:param tester:test client object
:type tester: flask test object
:return: server_connect, server_group, server_id
:rtype: server_connect:dict, server_group:dict, server_id:str
"""
server_connect = []
servers = []
srv_id = get_ids()
server_ids = srv_id["sid"]
server_group = config_data['test_server_group']
# Connect to all servers
for server_id in server_ids:
response = tester.post(SERVER_CONNECT_URL + str(server_group) +
'/' + server_id,
data=dict(
password=config_data
['test_server_credentials'][0]
['test_db_password']),
follow_redirects=True)
server_connect_detail = json.loads(response.data.decode())
connect_database(tester, server_connect_detail, server_id,
server_group)
server_connect.append(server_connect_detail)
servers.append(server_id)
return server_connect, server_group, servers
def connect_database(tester, server_connect, server_id, server_group):
"""
This function is used to connect database and writes it's details to
file 'parent_id.pkl'
:param tester: test client object
:type tester: flask test client object
:param server_connect: server's data
:type server_connect: dict
:param server_id: server id
:type server_id: str
:param server_group: server group name
:type server_group: str
:return: None
"""
if server_connect['data']['connected']:
db_data = get_db_data(server_connect)
db_response = tester.post(
DATABASE_URL + str(server_group) + "/" + server_id + "/",
data=json.dumps(db_data),
content_type='html/json')
response_data = json.loads(db_response.data.decode())
write_db_parent_id(response_data)
def delete_server(tester):
"""
This function used to delete the added servers
:param tester: test client object
:return: None
"""
srv_grp = config_data['test_server_group']
all_id = get_ids()
server_ids = all_id["sid"]
url = SERVER_URL + str(srv_grp) + "/"
# Call api to delete the servers
for server_id in server_ids:
response = tester.delete(url + str(server_id))
assert response.status_code == 200
response_data = json.loads(response.data.decode())
assert response_data['success'] == 1
def delete_database(tester):
"""
This function used to delete the added databases
:param tester: test client object
:return: None
"""
srv_grp = config_data['test_server_group']
all_id = get_ids()
server_ids = all_id["sid"]
db_ids_dict = all_id['did'][0]
db_con = test_getnodes(tester)
if len(db_con) == 0:
raise Exception("No database(s) to delete.")
for server_id in server_ids:
db_id = db_ids_dict[int(server_id)]
response = tester.delete(DATABASE_URL + str(srv_grp) + '/' +
str(server_id) + '/' + str(db_id),
follow_redirects=True)
assert response.status_code == 200
response_data = json.loads(response.data.decode('utf-8'))
assert response_data['success'] == 1