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

@@ -7,10 +7,9 @@
#
# ##########################################################################
import json
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from . import utils as server_utils
class ServersAddTestCase(BaseTestGenerator):
@@ -21,24 +20,17 @@ class ServersAddTestCase(BaseTestGenerator):
('Default Server Node url', dict(url='/browser/server/obj/'))
]
def setUp(self):
@classmethod
def setUpClass(cls):
pass
def runTest(self):
""" This function will add the server under default server group."""
server_group, config_data, pickle_id_dict = utils.get_config_data()
for server_data in config_data:
url = "{0}{1}/".format(self.url, server_group)
response = self.tester.post(url, data=json.dumps(server_data),
content_type='html/json')
server_utils.add_server(self.tester)
self.assertTrue(response.status_code, 200)
response_data = json.loads(response.data.decode())
utils.write_parent_id(response_data, pickle_id_dict)
def tearDown(self):
@classmethod
def tearDownClass(cls):
"""
This function deletes the added server and the 'parent_id.pkl' file
which is created in setup() function.
@@ -46,5 +38,5 @@ class ServersAddTestCase(BaseTestGenerator):
:return: None
"""
utils.delete_server(self.tester)
server_utils.delete_server(cls.tester)
utils.delete_parent_id_file()

View File

@@ -7,12 +7,11 @@
#
# ##################################################################
import json
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import config_data
from regression.test_utils import get_ids
from . import utils as server_utils
class ServerDeleteTestCase(BaseTestGenerator):
@@ -23,7 +22,8 @@ class ServerDeleteTestCase(BaseTestGenerator):
('Default Server Node url', dict(url='/browser/server/obj/'))
]
def setUp(self):
@classmethod
def setUpClass(cls):
"""
This function is used to add the server
@@ -31,28 +31,16 @@ class ServerDeleteTestCase(BaseTestGenerator):
"""
# Firstly, add the server
utils.add_server(self.tester)
server_utils.add_server(cls.tester)
def runTest(self):
""" This function will get all available servers under object browser
and delete the last server using server id."""
srv_grp = config_data['test_server_group']
all_id = get_ids()
server_ids = all_id["sid"]
server_utils.delete_server(self.tester)
url = self.url + str(srv_grp) + "/"
if len(server_ids) == 0:
raise Exception("No server(s) to delete!!!")
# Call api to delete the servers
for server_id in server_ids:
response = self.tester.delete(url + str(server_id))
self.assertTrue(response.status_code, 200)
response_data = json.loads(response.data.decode())
self.assertTrue(response_data['success'], 1)
def tearDown(self):
@classmethod
def tearDownClass(cls):
"""
This function deletes the 'parent_id.pkl' file which is created in
setup() function.

View File

@@ -9,8 +9,7 @@
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import config_data
from regression.test_utils import get_ids
from . import utils as server_utils
class ServersGetTestCase(BaseTestGenerator):
@@ -24,28 +23,23 @@ class ServersGetTestCase(BaseTestGenerator):
('Default Server Node url', dict(url='/browser/server/obj/'))
]
def setUp(self):
@classmethod
def setUpClass(cls):
"""
This function is used to add the server
:return: None
"""
utils.add_server(self.tester)
server_utils.add_server(cls.tester)
def runTest(self):
""" This function will fetch the added servers to object browser. """
all_id = get_ids()
server_ids = all_id["sid"]
srv_grp = config_data['test_server_group']
server_utils.get_server(self.tester)
for server_id in server_ids:
url = "{0}{1}/{2}".format(self.url, srv_grp, server_id)
response = self.tester.get(url, content_type='html/json')
self.assertEquals(response.status_code, 200)
def tearDown(self):
@classmethod
def tearDownClass(cls):
"""
This function deletes the added server and the 'parent_id.pkl' file
which is created in setup() function.
@@ -53,5 +47,5 @@ class ServersGetTestCase(BaseTestGenerator):
:return: None
"""
utils.delete_server(self.tester)
server_utils.delete_server(cls.tester)
utils.delete_parent_id_file()

View File

@@ -8,10 +8,9 @@
# ##########################################################################
import json
from pgadmin.utils.route import BaseTestGenerator
from regression import test_utils as utils
from regression.test_setup import config_data
from . import utils as server_utils
class ServerUpdateTestCase(BaseTestGenerator):
@@ -22,7 +21,8 @@ class ServerUpdateTestCase(BaseTestGenerator):
('Default Server Node url', dict(url='/browser/server/obj/'))
]
def setUp(self):
@classmethod
def setUpClass(cls):
"""
This function perform the four tasks
1. Add the test server
@@ -33,13 +33,16 @@ class ServerUpdateTestCase(BaseTestGenerator):
"""
# Firstly, add the server
utils.add_server(self.tester)
server_utils.add_server(cls.tester)
# Get the server
utils.get_server(self.tester)
server_utils.get_server(cls.tester)
# Connect to server
self.server_connect, self.server_group, self.server_ids = \
utils.connect_server(self.tester)
if len(self.server_connect) == 0:
cls.server_connect, cls.server_group, cls.server_ids = \
server_utils.connect_server(cls.tester)
if len(cls.server_connect) == 0:
raise Exception("No Server(s) connected to update!!!")
def runTest(self):
@@ -48,7 +51,8 @@ class ServerUpdateTestCase(BaseTestGenerator):
for server_id in self.server_ids:
data = {
"comment":
config_data['test_server_update_data'][0]['test_comment'],
server_utils.config_data['server_update_data'][0][
'comment'],
"id": server_id
}
put_response = self.tester.put(
@@ -60,7 +64,8 @@ class ServerUpdateTestCase(BaseTestGenerator):
response_data = json.loads(put_response.data.decode())
self.assertTrue(response_data['success'], 1)
def tearDown(self):
@classmethod
def tearDownClass(cls):
"""
This function deletes the added server and the 'parent_id.pkl' file
which is created in setup() function.
@@ -68,5 +73,5 @@ class ServerUpdateTestCase(BaseTestGenerator):
:return: None
"""
utils.delete_server(self.tester)
server_utils.delete_server(cls.tester)
utils.delete_parent_id_file()

View File

@@ -0,0 +1,160 @@
# ##########################################################################
#
# #pgAdmin 4 - PostgreSQL Tools
#
# #Copyright (C) 2013 - 2016, The pgAdmin Development Team
# #This software is released under the PostgreSQL Licence
#
# ##########################################################################
import json
import os
import pickle
from regression import test_utils as utils
from regression.test_setup import pickle_path, config_data
SERVER_URL = '/browser/server/obj/'
SERVER_CONNECT_URL = 'browser/server/connect/'
def write_server_id(response_data, pickle_id_dict):
"""
This function writes the server's details to file parent_id.pkl
:param response_data: server's data
:type response_data: list of dictionary
:param pickle_id_dict: contains ids of server,database,tables etc.
:type pickle_id_dict: dict
:return: None
"""
server_id = response_data['node']['_id']
if os.path.isfile(pickle_path):
existed_server_id = open(pickle_path, 'rb')
pickle_id_dict = pickle.load(existed_server_id)
pickle_id_dict["sid"].append(str(server_id))
output = open(pickle_path, 'wb')
pickle.dump(pickle_id_dict, output)
output.close()
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 = utils.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')
assert response.status_code == 200
response_data = json.loads(response.data.decode('utf-8'))
write_server_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 = utils.get_ids()
server_ids = all_id["sid"]
for server_id in server_ids:
response = tester.get(SERVER_URL + str(utils.SERVER_GROUP) + '/' +
str(server_id),
follow_redirects=True)
assert response.status_code == 200
def connect_server(tester):
"""
This function used to connect added server
:param tester:test client object
:type tester: flask test object
:param add_db_flag: flag for db add test case
:type add_db_flag: bool
:return: server_connect, server_group, server_id
:rtype: server_connect:dict, server_group:dict, server_id:str
"""
server_connect = []
servers = []
server_config = None
srv_id = utils.get_ids()
server_ids = srv_id["sid"]
# Connect to all servers
for server_id in server_ids:
response = tester.post(SERVER_CONNECT_URL + str(utils.SERVER_GROUP) +
'/' + server_id,
data=dict(
password=config_data
['server_credentials'][0]
['db_password']),
follow_redirects=True)
server_connect_detail = json.loads(response.data.decode('utf-8'))
db_user = server_connect_detail['data']['user']['name']
server_connect_detail['tablespace_path'] = None
# Get the server config of appropriate db user
for config in config_data['server_credentials']:
if db_user == config['db_username']:
server_config = config
if "tablespace_path" in server_config:
server_connect_detail['tablespace_path'] = \
server_config['tablespace_path']
server_connect.append(server_connect_detail)
servers.append(server_id)
return server_connect, utils.SERVER_GROUP, servers
def verify_server(tester, server_group, server_id):
"""This function verifies that server is connecting or not"""
response = tester.post(
'{0}{1}/{2}'.format(SERVER_CONNECT_URL, server_group, server_id),
data=dict(password=config_data
['server_credentials'][0]
['db_password']),
follow_redirects=True)
srv_connect = json.loads(response.data.decode('utf-8'))
return srv_connect
def delete_server(tester):
"""
This function used to delete the added servers
:param tester: test client object
:return: None
"""
all_id = utils.get_ids()
server_ids = all_id["sid"]
url = SERVER_URL + str(utils.SERVER_GROUP) + "/"
if len(server_ids) == 0:
raise Exception("No server(s) to delete!!!")
# 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('utf-8'))
assert response_data['success'] == 1