public inbox for [email protected]
help / color / mirror / Atom feedFrom: Priyanka Shendge <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Cc: Kanchan Mohitey <[email protected]>
Cc: Khushboo Vashi <[email protected]>
Subject: Re: pgAdmin IV API test cases patch
Date: Thu, 14 Jul 2016 17:20:48 +0530
Message-ID: <CAKmZXFRD=eUCML8ecERuS52F+TRMUJUgBKyRnmg2cKV994LjFw@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxozmKWcLkthAqd-1jue1RFEjq1ZtCO1U9k+rQE3sgp8MFA@mail.gmail.com>
References: <CAKmZXFQ2Hj1-OZpSGFEBB-vOypQ_=1b4Yr_VytZ-E1=CBw9Yhw@mail.gmail.com>
<CA+OCxow8Q83e7Tm+BC2bxq=oqwd-m4JS3y2KpzgFemc=wX=f=A@mail.gmail.com>
<CAKmZXFTX9D_qOXGrvPa9sfFjc1A6VPebcpBn7vyzPEOH4pWfEg@mail.gmail.com>
<CAKmZXFRj8yY91TTxwQQ01eOQE8Rc7FPWuxGcjxaVY+QcWpgWDg@mail.gmail.com>
<CA+OCxoyqfK8pUGGmeO=5pyC=MOizNMOnfshAfgQ5NjMRnkjgmA@mail.gmail.com>
<CAKmZXFSgdtd9NDE=TysR68_tcwqFB2Sv-h+qK4K4i1HjxOd5ng@mail.gmail.com>
<CAKmZXFRWXd7ZrUhpJt-rD_YOE1xcK5haE1CwAj8DMVyS9Fs6yA@mail.gmail.com>
<CA+OCxoyiNMAem5bYAZ1XM16vK4wJETCCPncRgKYbVdmH2m4Ocg@mail.gmail.com>
<CAKmZXFRvn8JDL52ooxZYtrf0Aw+bMz6=spXmyP9Q7fq8kWjuDA@mail.gmail.com>
<CA+OCxowzMWyATh1_eEQ7hnrseaxuq8T3_+FDsCETLm=WaoRNEw@mail.gmail.com>
<CAKmZXFT34JxCPw=UbZ27jU8uL0KzFa3Lfpmge2V14F7GynGLWw@mail.gmail.com>
<CAKmZXFRfX+Us9Bg2ACFGvGLTjjW02XETLEj3h5cHnZZBAbZwEQ@mail.gmail.com>
<CA+OCxow+V_RU2y1q07R07UzZOmxLh+3WouSpwMXkYiz4v_V=qw@mail.gmail.com>
<CAKmZXFTSYiZxVNe6FYkL-eDYk=yzpnLxdotGcek6zmp9f5S41g@mail.gmail.com>
<[email protected]>
<CAKmZXFRfZ6Y0eJK8k1FdvWX_V6A8bCdxJzBuWaJ0-nRWDsaOQA@mail.gmail.com>
<CA+OCxozaBcEgbEou9sizQ8RTiCLHZqtpwH+iwbjf8sjAVAhsfQ@mail.gmail.com>
<CAKmZXFQztUyBj0eOWZFOS-KcM19vdoqeRokX7ZdOMB4ATji2ig@mail.gmail.com>
<CA+OCxowmy0nD8JzAWwYrzTHc274WJSsdA5gLJ2YuRpR_pfKvrA@mail.gmail.com>
<CAKmZXFSn6LfpDm4xzrFppJOfHwWeSyP4fpF9z3dFzVATxn-X5w@mail.gmail.com>
<CA+OCxoz9yyovU4vb3ZT9q=JQD1NjrdnVp9JExVZ1_QtaEef4xg@mail.gmail.com>
<CAKmZXFQw7CQsJ9YF3ja15njHfDRC5bHnGLbmCXB1UHCzKCc9Lg@mail.gmail.com>
<CAFOhELdqD6+RD_4EmpS7nAYwq5OpJH78CZiq1yo3xrr9hk00BA@mail.gmail.com>
<CA+OCxozmKWcLkthAqd-1jue1RFEjq1ZtCO1U9k+rQE3sgp8MFA@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi Dave,
I have added more debug statements to older patch. New patch attached.
Also, i removed database deletion test case from current patch so that we
can analyse
if database is added or not.
I have added few more debug statements to database add test case. After
running the testsuite
can you please confirm whether the database is created or not under server
node?
Could you please re-run the attached patch and send me the logs and output?
On 12 July 2016 at 17:34, Dave Page <[email protected]> wrote:
> On Tue, Jul 12, 2016 at 5:14 AM, Khushboo Vashi
> <[email protected]> wrote:
> >
> >
> > On Mon, Jul 11, 2016 at 7:15 PM, Priyanka Shendge
> > <[email protected]> wrote:
> >>
> >>
> >>
> >> On 11 July 2016 at 18:35, Dave Page <[email protected]> wrote:
> >>>
> >>> On Mon, Jul 11, 2016 at 1:25 PM, Priyanka Shendge
> >>> <[email protected]> wrote:
> >>> > Sorry, by mistake i copied incomplete query. There is an OID present
> >>> > for
> >>> > added database.
> >>> >
> >>> > SELECT
> >>> > db.oid as did, db.datname, db.datallowconn,
> >>> > pg_encoding_to_char(db.encoding) AS serverencoding,
> >>> > has_database_privilege(db.oid, 'CREATE') as cancreate,
> >>> > datlastsysoid
> >>> > FROM
> >>> > pg_database db
> >>> > WHERE db.oid = 158579
> >>>
> >>> There's nothing wrong with that query. Can you work with Khushboo to
> >>> see if she can reproduce or help figure it out please?
> >>
> >>
> >> I had work with Khushboo, she also tried to reproduce the issue at her
> >> it's working fine for her.
> >> Khushboo also tried to troubleshoot/trace the issue but not able to
> figure
> >> out where exactly its failing;
> >> as issue was not reproducible.
> >>
> >> @Khushboo:
> >> Please add if i am missing anything.
> >>>
> >>>
> >
> >
> > We have tried to reproduce this issue at our end several times with the
> > different scenarios but every attempt was unsuccessful.
> >
> > Here the newly created database connection is failing which should not as
> > the database is created properly as per the log.
> > The above query (mentioned by Priyanka) executes from the psycopg2 driver
> > and could fail in 2 scenarios, either the database has been dropped
> before
> > this particular test-case runs or the database is not created properly
> > through the 'create database test-case'. But as per the log, the 'delete
> > database test-case' runs after this test-case and the database is created
> > properly.
> >
> > Can any privilege issue prevent the database connection in this scenario?
>
> Not on my system, that I can think of.
>
> If there was a connection error like that though, shouldn't we see a
> message from libpq at least? If not, that implies that there are error
> reporting issues to be fixed.
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Best,
Priyanka
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] test_db_connection.patch (37.8K, 3-test_db_connection.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/tests/__init__.py
new file mode 100644
index 0000000..60ed4c7
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/__init__.py
@@ -0,0 +1,16 @@
+# ##########################################################################
+#
+# #pgAdmin 4 - PostgreSQL Tools
+#
+# #Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# #This software is released under the PostgreSQL Licence
+#
+# ##########################################################################
+
+from pgadmin.utils.route import BaseTestGenerator
+
+
+class DatabaseGenerateTestCase(BaseTestGenerator):
+
+ def runTest(self):
+ return
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_add.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_add.py
new file mode 100644
index 0000000..b85be0a
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_add.py
@@ -0,0 +1,106 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data, advance_config_data, pickle_path
+from pgadmin.browser.tests.test_login import LoginTestCase
+import json
+import pickle
+import uuid
+import os
+from regression.test_utils import get_ids
+
+
+class DatabaseAddTestCase(LoginTestCase):
+ """
+ This class will check server group node present on the object browser's
+ tree node by response code.
+ """
+ priority = 7
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node URL', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will add database under 1st server of tree node. """
+
+ srv_id = get_ids()
+
+ server_id = srv_id["sid"][0]
+ srv_grp = config_data['test_server_group']
+
+ response = self.tester.post('browser/server/connect/' + str(srv_grp) +
+ '/' + server_id,
+ data=dict(
+ password=config_data
+ ['test_server_credentials'][0]
+ ['test_db_password']),
+ follow_redirects=True)
+
+ self.assertEquals(response.status_code, 200)
+
+ srv_connect = json.loads(response.data.decode())
+
+ if srv_connect['data']['connected']:
+
+ data = {
+ "datacl": advance_config_data['test_add_database_data']
+ ['test_privileges_acl'],
+ "datconnlimit": advance_config_data
+ ['test_add_database_data']['test_conn_limit'],
+ "datowner": advance_config_data
+ ['test_add_database_data']['test_owner'],
+ "deffuncacl": advance_config_data
+ ['test_add_database_data']['test_fun_acl'],
+ "defseqacl": advance_config_data
+ ['test_add_database_data']['test_seq_acl'],
+ "deftblacl": advance_config_data
+ ['test_add_database_data']['test_tbl_acl'],
+ "deftypeacl": advance_config_data
+ ['test_add_database_data']['test_type_acl'],
+ "encoding": advance_config_data
+ ['test_add_database_data']['test_encoding'],
+ "name": str(uuid.uuid4())[1:8],
+ "privileges": advance_config_data
+ ['test_add_database_data']['test_privileges'],
+ "securities": advance_config_data
+ ['test_add_database_data']['test_securities'],
+ "variables": advance_config_data
+ ['test_add_database_data']['test_variables']
+ }
+
+ db_response = self.tester.post(self.url + str(srv_grp) + "/" +
+ server_id + "/",
+ data=json.dumps(data),
+ content_type='html/json')
+
+ print("\nDatabase Response after Addition.........")
+ print(db_response.data.decode())
+
+ self.assertTrue(db_response.status_code, 200)
+
+ respdata = json.loads(db_response.data.decode())
+
+ db_id = respdata['node']['_id']
+
+ if os.path.isfile(pickle_path):
+
+ exst_server_id = open(pickle_path, 'rb')
+
+ tol_server_id = pickle.load(exst_server_id)
+ pickle_id_dict = tol_server_id
+
+ pickle_id_dict["did"].append(db_id)
+ print("\nDatabase id adding into pickle:",
+ pickle_id_dict["did"][0])
+
+ db_output = open(pickle_path, 'wb')
+ pickle.dump(pickle_id_dict, db_output)
+ db_output.close()
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_get.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_get.py
new file mode 100644
index 0000000..79f7877
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_get.py
@@ -0,0 +1,48 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data
+from pgadmin.browser.tests.test_login import LoginTestCase
+from regression.test_nodes import test_getnodes
+from regression.test_utils import get_ids
+
+
+class DatabasesGetTestCase(LoginTestCase):
+ """
+ This class will fetch added database under server node.
+ """
+ priority = 8
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node URL', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will fetch added database. """
+
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print('\n')
+ print("db id in get database from pickle:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ db_con = test_getnodes(node=self)
+
+ if db_con['data']["connected"]:
+
+ response = self.tester.get(self.url + str(srv_grp) + '/' +
+ str(server_id) + '/' + str(db_id),
+ follow_redirects=True)
+ print('\n')
+ print("database get response", response.data.decode())
+
+ self.assertEquals(response.status_code, 200)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_put.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_put.py
new file mode 100644
index 0000000..9993390
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_put.py
@@ -0,0 +1,55 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data, advance_config_data
+from pgadmin.browser.tests.test_login import LoginTestCase
+import json
+from regression.test_utils import get_ids
+from regression.test_nodes import test_getnodes
+
+
+class DatabasesUpdateTestCase(LoginTestCase):
+ """
+ This class will update the database under last added server.
+ """
+ priority = 9
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will update the comments field of database."""
+
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print('\n')
+ print("db id in update database from pickle:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ db_con = test_getnodes(node=self)
+
+ if db_con['data']["connected"]:
+
+ data = {
+ "comments": advance_config_data["test_db_update_data"]
+ ["test_comment"],
+ "id": db_id
+ }
+
+ put_response = self.tester.put(self.url + str(srv_grp) + '/' +
+ str(server_id) + '/' + str(db_id),
+ data=json.dumps(data),
+ follow_redirects=True)
+ print("database put response", put_response.data.decode())
+
+ self.assertEquals(put_response.status_code, 200)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/tests/__init__.py
index 28cdb94..4fd2066 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/__init__.py
@@ -12,4 +12,4 @@ from pgadmin.utils.route import BaseTestGenerator
class ServerGenerateTestCase(BaseTestGenerator):
def runTest(self):
- print ("In ServerGenerateTestCase...")
+ return
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py
index 0af13d3..499c0a0 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py
@@ -8,16 +8,14 @@
# ##########################################################################
import json
-
+import pickle
+import os
from pgadmin.browser.tests.test_login import LoginTestCase
-from regression.config import config_data
+from regression.config import config_data, pickle_path
class ServersAddTestCase(LoginTestCase):
- """
- This class will add the servers under default server group and verify with
- server's name.
- """
+ """ This class will add the servers under default server group. """
priority = 4
@@ -27,14 +25,19 @@ class ServersAddTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will add the server under default server group.
- Verify the added server with response code as well as server name.
- """
+ """ This function will add the server under default server group."""
+
+ # Storing parent id's into pickle dict
+ pickle_id_dict = \
+ {
+ "sid": [], # server
+ "did": [] # database
+ }
srv_grp = config_data['test_server_group']
for srv in config_data['test_server_credentials']:
+
data = {"name": srv['test_name'],
"comment": "",
"host": srv['test_host'],
@@ -44,10 +47,22 @@ class ServersAddTestCase(LoginTestCase):
"role": "",
"sslmode": srv['test_sslmode']}
- url = self.url + str(srv_grp) + "/"
-
- response = self.tester.post(url, data=json.dumps(data),
+ response = self.tester.post(self.url + str(srv_grp) + "/",
+ data=json.dumps(data),
content_type='html/json')
+
self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
- self.assertTrue(respdata['node']['label'], srv['test_name'])
+ respdata = json.loads(response.data.decode())
+
+ server_id = respdata['node']['_id']
+
+ if os.path.isfile(pickle_path):
+ exst_server_id = open(pickle_path, 'rb')
+ pickle_id_dict = pickle.load(exst_server_id)
+
+ pickle_id_dict["sid"].append(server_id)
+ print("\nServer id in server add", pickle_id_dict["sid"][0])
+
+ output = open(pickle_path, 'wb')
+ pickle.dump(pickle_id_dict, output)
+ output.close()
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py
index 329d74f..997308e 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py
@@ -8,17 +8,14 @@
# ##################################################################
import json
-
from pgadmin.browser.tests.test_login import LoginTestCase
from regression.config import config_data
-class ServersDeleteTestCase(LoginTestCase):
- """
- This class will check server node present on the object browser's tree node
- by response code.
- """
- priority = 7
+class ServerDeleteTestCase(LoginTestCase):
+ """ This class will delete the last server present under tree node."""
+
+ priority = 99
scenarios = [
# Fetching the default url for server node
@@ -26,32 +23,22 @@ class ServersDeleteTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will get all available servers under object browser
- and delete the servers using server id.
- """
+ """ 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']
- for srv in config_data['test_server_credentials']:
-
- data = {"name": srv['test_name'],
- "host": srv['test_host'],
- "port": srv['test_db_port'],
- "db": srv['test_maintenance_db'],
- "username": srv['test_db_username'],
- "role": "",
- "sslmode": srv['test_sslmode']}
+ url = self.url + str(srv_grp) + "/"
- url = self.url + str(srv_grp) + "/"
+ response = self.tester.get(url)
+ respdata = json.loads(response.data.decode())
- response = self.tester.get(url, data=json.dumps(data),
- content_type='html/json')
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
+ if len(respdata) == 0:
+ raise Exception("No server(s) to delete.")
- for server in respdata:
- response = self.tester.delete(url + json.dumps(server['id']))
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
- self.assertTrue(respdata['success'], 1)
+ # delete last server
+ server = respdata[-1]
+ response = self.tester.delete(url + str(server['id']))
+ self.assertTrue(response.status_code, 200)
+ respdata = json.loads(response.data.decode())
+ self.assertTrue(respdata['success'], 1)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py
index 050843e..163fef3 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py
@@ -7,15 +7,14 @@
#
# ##########################################################################
-import json
-
from pgadmin.browser.tests.test_login import LoginTestCase
from regression.config import config_data
+from regression.test_utils import get_ids
class ServersGetTestCase(LoginTestCase):
"""
- This class will check server node present on the object browser's tree node
+ This class will fetch added servers under default server group
by response code.
"""
@@ -27,23 +26,16 @@ class ServersGetTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will get all available servers present under
- object browser.
- """
+ """ This function will fetch the added servers to object browser. """
+ all_id = get_ids()
+ server_id = all_id["sid"]
srv_grp = config_data['test_server_group']
- for srv in config_data['test_server_credentials']:
- data = {"name": srv['test_name'],
- "host": srv['test_host'],
- "port": srv['test_db_port'],
- "db": srv['test_maintenance_db'],
- "username": srv['test_db_username'],
- "role": "",
- "sslmode": srv['test_sslmode']}
-
- url = self.url + str(srv_grp) + "/"
- response = self.tester.get(url, data=json.dumps(data),
+ for srv in server_id:
+
+ response = self.tester.get(self.url + str(srv_grp) + '/' +
+ str(srv),
content_type='html/json')
- self.assertTrue(response.status_code, 200)
+
+ self.assertEquals(response.status_code, 200)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py
index 306bb03..35d7c03 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py
@@ -8,16 +8,13 @@
# ##########################################################################
import json
-
from pgadmin.browser.tests.test_login import LoginTestCase
from regression.config import config_data
+from regression.test_utils import get_ids
-class ServersUpdateTestCase(LoginTestCase):
- """
- This class will check server node present on the object browser's tree node
- by response code.
- """
+class ServerUpdateTestCase(LoginTestCase):
+ """ This class will update server's comment field. """
priority = 6
@@ -27,39 +24,41 @@ class ServersUpdateTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will edit and update the server's comment field
- by the server id.
- """
+ """ This function will update the server's comment field. """
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
srv_grp = config_data['test_server_group']
- for srv in config_data['test_server_credentials']:
+ response = self.tester.get(self.url + str(srv_grp) + '/' +
+ str(server_id),
+ follow_redirects=True)
- data = {"name": srv['test_name'],
- "host": srv['test_host'],
- "port": srv['test_db_port'],
- "db": srv['test_maintenance_db'],
- "username": srv['test_db_username'],
- "role": "",
- "sslmode": srv['test_sslmode']}
+ con_response = self.tester.post('browser/server/connect/{0}/{1}'.format
+ (srv_grp, server_id),
+ data=dict(password=
+ config_data
+ ['test_server_credentials'][0]
+ ['test_db_password']),
+ follow_redirects=True)
- url = self.url + str(srv_grp) + "/"
+ srv_con = json.loads(con_response.data.decode())
- response = self.tester.get(url, data=json.dumps(data),
- content_type='html/json')
+ if len(srv_con) == 0:
+ raise Exception("No Server(s) connected to update.")
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
+ data = \
+ {
+ "comment": config_data
+ ['test_server_update_data'][0]['test_comment'],
+ "id": server_id
+ }
- for server in respdata:
+ put_response = self.tester.put(self.url + str(srv_grp) + '/' +
+ str(server_id), data=json.dumps(data),
+ content_type='html/json')
- url = self.url + str(srv_grp) + "/" + json.dumps(server['id'])
+ self.assertEquals(put_response.status_code, 200)
- for server in config_data['test_server_update_data']:
- data = {"comment": server['test_comment']}
- response = self.tester.put(url, data=json.dumps(data),
- content_type='html/json')
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
- self.assertTrue(respdata['success'], 1)
+ respdata = json.loads(put_response.data.decode())
+ self.assertTrue(respdata['success'], 1)
diff --git a/web/pgadmin/browser/server_groups/tests/test_sg_get.py b/web/pgadmin/browser/server_groups/tests/test_sg_get.py
new file mode 100644
index 0000000..c552d8e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/tests/test_sg_get.py
@@ -0,0 +1,36 @@
+###########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+###########################################################################
+
+import json
+from pgadmin.browser.tests.test_login import LoginTestCase
+from regression.config import config_data
+
+
+class SgGetTestCase(LoginTestCase):
+ """
+ This class will check available server groups in pgAdmin.
+ """
+
+ priority = 3
+
+ scenarios = [
+ # Fetching the default url for server group node
+ ('Check Server Group Node', dict(url='/browser/server-group/obj/'))
+ ]
+
+ def runTest(self):
+ """This function will check available server groups."""
+
+ srv_grp = config_data['test_server_group']
+
+ response = self.tester.get(self.url + str(srv_grp),
+ content_type='html/json')
+ self.assertEquals(response.status_code, 200)
+ respdata = json.loads(response.data.decode())
+ self.assertTrue(respdata['id'], srv_grp)
diff --git a/web/pgadmin/browser/tests/__init__.py b/web/pgadmin/browser/tests/__init__.py
index 2381efd..4470711 100644
--- a/web/pgadmin/browser/tests/__init__.py
+++ b/web/pgadmin/browser/tests/__init__.py
@@ -11,5 +11,6 @@ from pgadmin.utils.route import BaseTestGenerator
class BrowserGenerateTestCase(BaseTestGenerator):
+
def runTest(self):
- print ("In BrowserGenerateTestCase...")
+ return
diff --git a/web/pgadmin/browser/tests/test_change_password.py b/web/pgadmin/browser/tests/test_change_password.py
index dedb7d9..5c4930d 100644
--- a/web/pgadmin/browser/tests/test_change_password.py
+++ b/web/pgadmin/browser/tests/test_change_password.py
@@ -85,10 +85,10 @@ class ChangePasswordTestCase(LoginTestCase):
"""This function will check change password functionality."""
response = self.tester.get('/change', follow_redirects=True)
- self.assertIn('pgAdmin 4 Password Change', response.data)
+ self.assertIn('pgAdmin 4 Password Change', response.data.decode('utf8'))
response = self.tester.post('/change', data=dict(
password=self.password,
new_password=self.new_password,
new_password_confirm=self.new_password_confirm),
follow_redirects=True)
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
diff --git a/web/pgadmin/browser/tests/test_login.py b/web/pgadmin/browser/tests/test_login.py
index 7c2b796..d272a63 100644
--- a/web/pgadmin/browser/tests/test_login.py
+++ b/web/pgadmin/browser/tests/test_login.py
@@ -8,7 +8,6 @@
##########################################################################
import uuid
-
from pgadmin.utils.route import BaseTestGenerator
from regression.config import config_data
@@ -67,7 +66,9 @@ class LoginTestCase(BaseTestGenerator):
['test_login_username']),
password=(config_data['pgAdmin4_login_credentials']
['test_login_password']),
- respdata='You are currently running version'))
+ respdata='Gravatar image for %s' %
+ config_data['pgAdmin4_login_credentials']
+ ['test_login_username']))
]
def runTest(self):
@@ -76,4 +77,4 @@ class LoginTestCase(BaseTestGenerator):
response = self.tester.post('/login', data=dict(
email=self.email, password=self.password),
follow_redirects=True)
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
diff --git a/web/pgadmin/browser/tests/test_logout.py b/web/pgadmin/browser/tests/test_logout.py
index 8971e72..d9611ae 100644
--- a/web/pgadmin/browser/tests/test_logout.py
+++ b/web/pgadmin/browser/tests/test_logout.py
@@ -14,14 +14,13 @@ from regression.config import config_data
class LogoutTest(LoginTestCase):
"""
This class verifies the logout functionality; provided the user is already
- logged-in. Dictionary parameters define the scenario appended by test
- name.
+ logged-in.
"""
- priority = 3
+ priority = 100
scenarios = [
- # This test case validate the logout page
+ # This test case validate the logout page.
('Logging Out', dict(respdata='Redirecting...'))
]
@@ -29,7 +28,7 @@ class LogoutTest(LoginTestCase):
"""This function checks the logout functionality."""
response = self.tester.get('/logout')
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
def tearDown(self):
"""
diff --git a/web/pgadmin/browser/tests/test_reset_password.py b/web/pgadmin/browser/tests/test_reset_password.py
index 030b182..31a3992 100644
--- a/web/pgadmin/browser/tests/test_reset_password.py
+++ b/web/pgadmin/browser/tests/test_reset_password.py
@@ -41,8 +41,9 @@ class ResetPasswordTestCase(BaseTestGenerator):
"""This function checks reset password functionality."""
response = self.tester.get('/reset')
- self.assertIn('Recover pgAdmin 4 Password', response.data)
+ self.assertIn('Recover pgAdmin 4 Password',
+ response.data.decode('utf8'))
response = self.tester.post(
'/reset', data=dict(email=self.email),
follow_redirects=True)
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py
index fb9de69..a2cd1eb 100644
--- a/web/pgadmin/utils/route.py
+++ b/web/pgadmin/utils/route.py
@@ -52,8 +52,10 @@ class TestsGeneratorRegistry(ABCMeta):
from werkzeug.utils import find_modules
for module_name in find_modules(pkg, False, True):
- module = import_module(module_name)
-
+ try:
+ module = import_module(module_name)
+ except ImportError:
+ pass
import six
diff --git a/web/regression/README b/web/regression/README
index e0003e4..0751661 100644
--- a/web/regression/README
+++ b/web/regression/README
@@ -40,23 +40,25 @@ General Information
3. test_server_get.py
4. test_server_update.py
-2) The pgAdmin4 source tree includes a file template for the server configuration
- named ‘test_config.json.in' in the ‘pgAdmin4/web/regression’ directory. After
- completing the pgAdmin4 configuration, you must make a working copy of the
- template called test_config.json before modifying the file contents.
+2) The pgAdmin4 source tree includes 2 different configuration file templates.
+ One file template for the server configuration named ‘test_config.json.in'
+ and another for test configuration named 'test_advanced_config.json.in' in
+ the ‘pgAdmin4/web/regression’ directory. After completing the pgAdmin4
+ configuration, you must make a working copy of the templates called
+ test_config.json and test_advance_config.json before modifying the file contents.
2a) The following command copies the test_config.json.in file, creating a
- configuration file named test_config.json
+ configuration file named test_config.json (same way user can copy
+ test_advance_config.json.in file into test_advance_config.json)
# cp pgadmin4/web/regression/test_config.json.in \
pgadmin4/web/regression/test_config.json
- 2b) After creating the server configuration file, add (or modify)
- parameter values as per requirements. The configuration
- files are owned by root/user. The pgAdmin4 regression framework expects
- to find the files in the directory '/<installation dir>/web/regression/'.
- If you move the file to another location, you must create a symbolic link
- that specifies the new location.
+ 2b) After creating the server and test configuration file, add (or modify)
+ parameter values as per requirements. The pgAdmin4 regression framework
+ expects to find the files in the directory
+ '/<installation dir>/web/regression/'. If you move the file to another
+ location, you must create a symbolic link that specifies the new location.
2c) Specifying Server Configuration file:
@@ -64,6 +66,13 @@ General Information
server details and connection properties as per their local setup. The
test_config file is in json format and property values are case-sensitive.
+ 2d) Specifying the Test Configuration file:
+
+ The user can add/change test data as per their need. The
+ test_advanced_config file is in json format and property values are
+ case-sensitive.
+
+
Test Data Details
-----------------
diff --git a/web/regression/config.py b/web/regression/config.py
index bef65fb..f48eade 100644
--- a/web/regression/config.py
+++ b/web/regression/config.py
@@ -14,3 +14,8 @@ root = os.path.dirname(os.path.realpath(__file__))
with open(root + '/test_config.json') as data_file:
config_data = json.load(data_file)
+
+with open(root + '/test_advance_config.json') as data_file:
+ advance_config_data = json.load(data_file)
+
+pickle_path = os.path.join(root, 'parent_id.pkl')
diff --git a/web/regression/test_advance_config.json.in b/web/regression/test_advance_config.json.in
new file mode 100644
index 0000000..e415876
--- /dev/null
+++ b/web/regression/test_advance_config.json.in
@@ -0,0 +1,103 @@
+{
+ "test_add_database_data":
+ {
+ "test_privileges_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "C",
+ "privilege": true,
+ "with_grant": true
+ },
+ {
+ "privilege_type": "T",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_conn_limit": -1,
+ "test_owner": "postgres",
+ "test_fun_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "X",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_seq_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "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": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "a",
+ "privilege": true,
+ "with_grant": true
+ },
+ {
+ "privilege_type": "r",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_type_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "U",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_encoding": "UTF8",
+ "test_name": "test_db_automation",
+ "test_privileges": [],
+ "test_securities": [],
+ "test_variables": []
+ },
+
+ "test_db_update_data":
+ {
+ "test_comment": "This is db update comment"
+ }
+
+}
diff --git a/web/regression/test_nodes.py b/web/regression/test_nodes.py
new file mode 100644
index 0000000..e3617e4
--- /dev/null
+++ b/web/regression/test_nodes.py
@@ -0,0 +1,52 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data
+import json
+from regression.test_utils import get_ids
+
+
+def test_getnodes(node=None):
+ # Connect to server and database.
+
+ if not node:
+ return None
+
+ all_id = get_ids()
+
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print("Database Details From pickle: id in test nodes:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ # Connect to server
+ response = node.tester.post('browser/server/connect/{0}/{1}'.format
+ (srv_grp, server_id),
+ data=dict(password=config_data
+ ['test_server_credentials'][0]
+ ['test_db_password']), follow_redirects=True)
+ print('\n')
+ print("Server Connection Response After Database Addition in test nodes",
+ response.data.decode())
+
+ # Connect to database
+ con_response = node.tester.post('browser/database/connect/'
+ '{0}/{1}/{2}'.format
+ (srv_grp, server_id, db_id),
+ follow_redirects=True)
+ print('\n')
+ print("Database Connection Response After Database Addition in test nodes",
+ con_response.data.decode())
+
+ db_con = json.loads(con_response.data.decode())
+
+ print("\nDatabase Connection Response in test nodes", db_con)
+
+ return db_con
diff --git a/web/regression/test_utils.py b/web/regression/test_utils.py
new file mode 100644
index 0000000..c68744f
--- /dev/null
+++ b/web/regression/test_utils.py
@@ -0,0 +1,20 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+import pickle
+from regression.config import pickle_path
+
+
+def get_ids(url=pickle_path):
+ # This function will read parent nodes id's from pickle and return it.
+
+ output = open(url, 'rb')
+ ids = pickle.load(output)
+ output.close()
+ return ids
diff --git a/web/regression/testsuite.py b/web/regression/testsuite.py
index 75d437b..e8dd586 100644
--- a/web/regression/testsuite.py
+++ b/web/regression/testsuite.py
@@ -13,7 +13,8 @@ them to TestSuite. """
import os
import sys
import unittest
-
+import operator
+import logging
from testscenarios.scenarios import generate_scenarios
# We need to include the root directory in sys.path to ensure that we can
@@ -51,6 +52,21 @@ TestsGeneratorRegistry.load_generators('pgadmin')
# application. We can trigger test request to the application.
test_client = app.test_client()
+class StreamToLogger(object):
+ def __init__(self, logger, log_level=logging.INFO):
+ self.terminal = sys.stderr
+ self.logger = logger
+ self.log_level = log_level
+ self.linebuf = ''
+
+ def write(self, buf):
+ self.terminal.write(buf)
+ for line in buf.rstrip().splitlines():
+ self.logger.log(self.log_level, line.rstrip())
+
+ def flush(self):
+ pass
+
def suite():
""" Defining test suite which will execute all the testcases present in
@@ -65,6 +81,8 @@ def suite():
modules.insert(gen.priority, gen)
+ modules.sort(key=operator.attrgetter('priority'))
+
for m in modules:
obj = m()
obj.setTestClient(test_client)
@@ -75,5 +93,24 @@ def suite():
if __name__ == '__main__':
+
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s:%(levelname)s:%(name)s:%(message)s',
+ filename="logger.log",
+ filemode='w')
+
+ stderr_logger = logging.getLogger('STDERR')
+ sl = StreamToLogger(stderr_logger, logging.ERROR)
+ sys.stderr = sl
+
suite = suite()
- tests = unittest.TextTestRunner(descriptions=True, verbosity=2).run(suite)
+ tests = unittest.TextTestRunner(descriptions=True, verbosity=2,
+ stream=sys.stderr).run(suite)
+
+ print("Please check output in file: logger.log placed at", current_path)
+
+ try:
+ os.remove("parent_id.pkl")
+
+ except IOError:
+ pass
view thread (27+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: pgAdmin IV API test cases patch
In-Reply-To: <CAKmZXFRD=eUCML8ecERuS52F+TRMUJUgBKyRnmg2cKV994LjFw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox