public inbox for [email protected]  
help / color / mirror / Atom feed
From: Aditya Toshniwal <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin][patch] Use unique DB name in ERD API test cases
Date: Thu, 4 Feb 2021 15:01:54 +0530
Message-ID: <CAM9w-_nuvuEreprufLtAxDVPTXTF1GGP9nZZhX8xpu_QzQ4o4g@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDdN8=rtydpqBxEJF6yjAT-mVOktXW3Xu_muAN00=wPrSw@mail.gmail.com>
References: <CAM9w-_n-NeOB7Z_FY7SaqJFJDfr9DPoS+3Ge_5=7A1yuqZ1=_w@mail.gmail.com>
	<CANxoLDdN8=rtydpqBxEJF6yjAT-mVOktXW3Xu_muAN00=wPrSw@mail.gmail.com>

Hi,

Seems like the test cases are still failing on the build machines.
Attached is the patch to make the connection ids unique by using random.
Please review.

On Wed, Feb 3, 2021 at 4:49 PM Akshay Joshi <[email protected]>
wrote:

> Thanks, patch applied.
>
> On Wed, Feb 3, 2021 at 4:01 PM Aditya Toshniwal <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Attached is the patch to use unique DB names in ERD API test cases to
>> avoid conflict when running test cases in parallel.
>> Please review.
>>
>> --
>> Thanks,
>> Aditya Toshniwal
>> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
>> <http://edbpostgres.com;
>> "Don't Complain about Heat, Plant a TREE"
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] ERD.apitests_v2.patch (7.0K, 3-ERD.apitests_v2.patch)
  download | inline diff:
diff --git a/web/pgadmin/tools/erd/__init__.py b/web/pgadmin/tools/erd/__init__.py
index 8294a31a9..97a04d3da 100644
--- a/web/pgadmin/tools/erd/__init__.py
+++ b/web/pgadmin/tools/erd/__init__.py
@@ -561,6 +561,7 @@ def sql(trans_id, sgid, sid, did):
 @login_required
 def tables(trans_id, sgid, sid, did):
     helper = ERDHelper(trans_id, sid, did)
+    conn = _get_connection(sid, did, trans_id)
     status, tables = helper.get_all_tables()
 
     if not status:
diff --git a/web/pgadmin/tools/erd/tests/test_close.py b/web/pgadmin/tools/erd/tests/test_close.py
index e334bf92a..98c51c5f8 100644
--- a/web/pgadmin/tools/erd/tests/test_close.py
+++ b/web/pgadmin/tools/erd/tests/test_close.py
@@ -8,6 +8,7 @@
 ##########################################################################
 
 import uuid
+import random
 from pgadmin.utils.route import BaseTestGenerator
 from regression.python_test_utils import test_utils as utils
 from regression import parent_node_dict
@@ -33,14 +34,15 @@ class ERDClose(BaseTestGenerator):
         if not db_con["info"] == "Database connected.":
             raise Exception("Could not connect to database to add the schema.")
 
+        trans_id = random.randint(1, 9999999)
         url = '/erd/initialize/{trans_id}/{sgid}/{sid}/{did}'.format(
-            trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            trans_id=trans_id, sgid=self.sgid, sid=self.sid, did=self.did)
 
         response = self.tester.post(url)
         self.assertEqual(response.status_code, 200)
 
         url = '/erd/close/{trans_id}/{sgid}/{sid}/{did}'.format(
-            trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            trans_id=trans_id, sgid=self.sgid, sid=self.sid, did=self.did)
 
         response = self.tester.delete(url)
         self.assertEqual(response.status_code, 200)
diff --git a/web/pgadmin/tools/erd/tests/test_initialize.py b/web/pgadmin/tools/erd/tests/test_initialize.py
index bd6eb2c0c..9eb6163c5 100644
--- a/web/pgadmin/tools/erd/tests/test_initialize.py
+++ b/web/pgadmin/tools/erd/tests/test_initialize.py
@@ -9,6 +9,7 @@
 
 import json
 import uuid
+import random
 from pgadmin.utils.route import BaseTestGenerator
 from regression.python_test_utils import test_utils as utils
 from regression import parent_node_dict
@@ -34,14 +35,15 @@ class ERDInitialize(BaseTestGenerator):
         if not db_con["info"] == "Database connected.":
             raise Exception("Could not connect to database to add the schema.")
 
+        trans_id = random.randint(1, 9999999)
         url = '/erd/initialize/{trans_id}/{sgid}/{sid}/{did}'.format(
-            trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            trans_id=trans_id, sgid=self.sgid, sid=self.sid, did=self.did)
 
         response = self.tester.post(url)
         self.assertEqual(response.status_code, 200)
         response_data = json.loads(response.data.decode('utf-8'))
         self.assertEqual(response_data['data'], {
-            'connId': '123344',
+            'connId': str(trans_id),
             'serverVersion': self.server_information['server_version'],
         })
 
diff --git a/web/pgadmin/tools/erd/tests/test_panel.py b/web/pgadmin/tools/erd/tests/test_panel.py
index 63601cb3d..44adf906b 100644
--- a/web/pgadmin/tools/erd/tests/test_panel.py
+++ b/web/pgadmin/tools/erd/tests/test_panel.py
@@ -8,6 +8,7 @@
 ##########################################################################
 
 import uuid
+import random
 from pgadmin.utils.route import BaseTestGenerator
 from regression.python_test_utils import test_utils as utils
 from regression import parent_node_dict
@@ -25,9 +26,11 @@ class ERDPanel(BaseTestGenerator):
         self.sgid = config_data["server_group"]
 
     def runTest(self):
+        trans_id = random.randint(1, 9999999)
         url = '/erd/panel/{trans_id}?sgid={sgid}&sid={sid}&server_type=pg' \
               '&did={did}&gen=false'.\
-            format(trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            format(trans_id=trans_id, sgid=self.sgid, sid=self.sid,
+                   did=self.did)
 
         response = self.tester.post(
             url, data={"title": "panel_title", "close_url": "the/close/url"},
diff --git a/web/pgadmin/tools/erd/tests/test_prequisite.py b/web/pgadmin/tools/erd/tests/test_prequisite.py
index 926280d41..138ab74c0 100644
--- a/web/pgadmin/tools/erd/tests/test_prequisite.py
+++ b/web/pgadmin/tools/erd/tests/test_prequisite.py
@@ -9,6 +9,7 @@
 
 import json
 import uuid
+import random
 from pgadmin.utils.route import BaseTestGenerator
 from regression.python_test_utils import test_utils as utils
 from regression import parent_node_dict
@@ -34,8 +35,9 @@ class ERDPrequisite(BaseTestGenerator):
         if not db_con["info"] == "Database connected.":
             raise Exception("Could not connect to database to add the schema.")
 
+        trans_id = random.randint(1, 9999999)
         url = '/erd/prequisite/{trans_id}/{sgid}/{sid}/{did}'.format(
-            trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            trans_id=trans_id, sgid=self.sgid, sid=self.sid, did=self.did)
 
         response = self.tester.get(url)
         self.assertEqual(response.status_code, 200)
diff --git a/web/pgadmin/tools/erd/tests/test_sql.py b/web/pgadmin/tools/erd/tests/test_sql.py
index 8240397f3..15276c1cd 100644
--- a/web/pgadmin/tools/erd/tests/test_sql.py
+++ b/web/pgadmin/tools/erd/tests/test_sql.py
@@ -9,6 +9,7 @@
 
 import json
 import uuid
+import random
 from pgadmin.utils.route import BaseTestGenerator
 from regression.python_test_utils import test_utils as utils
 from regression import parent_node_dict
@@ -62,8 +63,9 @@ class ERDSql(BaseTestGenerator):
         if not db_con["info"] == "Database connected.":
             raise Exception("Could not connect to database to add the schema.")
 
+        trans_id = random.randint(1, 9999999)
         url = '/erd/sql/{trans_id}/{sgid}/{sid}/{did}'.format(
-            trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            trans_id=trans_id, sgid=self.sgid, sid=self.sid, did=self.did)
 
         curr_dir = path.dirname(__file__)
 
diff --git a/web/pgadmin/tools/erd/tests/test_tables.py b/web/pgadmin/tools/erd/tests/test_tables.py
index 8c3794eaf..8bf754c0b 100644
--- a/web/pgadmin/tools/erd/tests/test_tables.py
+++ b/web/pgadmin/tools/erd/tests/test_tables.py
@@ -9,6 +9,7 @@
 
 import json
 import uuid
+import random
 from pgadmin.utils.route import BaseTestGenerator
 from regression.python_test_utils import test_utils as utils
 from regression import parent_node_dict
@@ -64,8 +65,9 @@ class ERDTables(BaseTestGenerator):
         if not db_con["info"] == "Database connected.":
             raise Exception("Could not connect to database to add the schema.")
 
+        trans_id = random.randint(1, 9999999)
         url = '/erd/tables/{trans_id}/{sgid}/{sid}/{did}'.format(
-            trans_id=123344, sgid=self.sgid, sid=self.sid, did=self.did)
+            trans_id=trans_id, sgid=self.sgid, sid=self.sid, did=self.did)
 
         response = self.tester.get(url)
         self.assertEqual(response.status_code, 200)


view thread (4+ 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]
  Subject: Re: [pgAdmin][patch] Use unique DB name in ERD API test cases
  In-Reply-To: <CAM9w-_nuvuEreprufLtAxDVPTXTF1GGP9nZZhX8xpu_QzQ4o4g@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