Skip to content

Commit

Permalink
Fix "too many clients" error on github actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshmahajan-1903 committed Jan 18, 2024
1 parent 60983a2 commit 5e22b54
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class DebuggerClearAllBreakpoint(BaseTestGenerator):

def setUp(self):
super().setUp()

# This is added because debugger_utils.start_listener() does not return
# any response, hence thread hangs.
# Ref - https://github.com/pgadmin-org/pgadmin4/issues/7136
if PG_DEFAULT_DRIVER == PSYCOPG3:
self.skipTest('Skip for psycopg3.')
if sys.platform == 'win32':
self.skipTest('PSQL disabled for windows')

Expand All @@ -56,7 +60,6 @@ def setUp(self):

if self.init_target:
debugger_utils.initialize_target(self, utils)

debugger_utils.start_listener(self, utils, db_utils)
self.port_no = debugger_utils.messages(self, utils, db_utils)
debugger_utils.start_execution(self, utils, db_utils)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
##########################################################################

import json

from config import PG_DEFAULT_DRIVER
from pgadmin.utils.constants import PSYCOPG3
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from . import utils as debugger_utils
Expand All @@ -28,6 +29,11 @@ class DebuggerExecuteQuery(BaseTestGenerator):

def setUp(self):
super().setUp()
# This is added because debugger_utils.start_listener() does not return
# any response, hence thread hangs.
# Ref - https://github.com/pgadmin-org/pgadmin4/issues/7136
if PG_DEFAULT_DRIVER == PSYCOPG3:
self.skipTest('Skip for psycopg3.')
self.schema_data = parent_node_dict['schema'][-1]
self.server_id = self.schema_data['server_id']
self.db_id = self.schema_data['db_id']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
.tests import utils as funcs_utils
from pgadmin.browser.server_groups.servers.databases.tests import \
utils as db_utils
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.constants import PSYCOPG3


class DebuggerPollExecutionResult(BaseTestGenerator):
Expand All @@ -28,6 +30,13 @@ class DebuggerPollExecutionResult(BaseTestGenerator):

def setUp(self):
super().setUp()

# This is added because debugger_utils.start_listener() does not return
# any response, hence thread hangs.
# Ref - https://github.com/pgadmin-org/pgadmin4/issues/7136
if PG_DEFAULT_DRIVER == PSYCOPG3:
self.skipTest('Skip for psycopg3.')

self.schema_data = parent_node_dict['schema'][-1]
self.server_id = self.schema_data['server_id']
self.db_id = self.schema_data['db_id']
Expand Down
9 changes: 9 additions & 0 deletions web/pgadmin/tools/debugger/tests/test_debugger_poll_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
.tests import utils as funcs_utils
from pgadmin.browser.server_groups.servers.databases.tests import \
utils as db_utils
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.constants import PSYCOPG3


class DebuggerPollResult(BaseTestGenerator):
Expand All @@ -28,6 +30,13 @@ class DebuggerPollResult(BaseTestGenerator):

def setUp(self):
super().setUp()

# This is added because debugger_utils.start_listener() does not return
# any response, hence thread hangs.
# Ref - https://github.com/pgadmin-org/pgadmin4/issues/7136
if PG_DEFAULT_DRIVER == PSYCOPG3:
self.skipTest('Skip for psycopg3.')

self.schema_data = parent_node_dict['schema'][-1]
self.server_id = self.schema_data['server_id']
self.db_id = self.schema_data['db_id']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
.tests import utils as funcs_utils
from pgadmin.browser.server_groups.servers.databases.tests import \
utils as db_utils
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.constants import PSYCOPG3


class DebuggerSetBreakpoint(BaseTestGenerator):
Expand All @@ -28,6 +30,13 @@ class DebuggerSetBreakpoint(BaseTestGenerator):

def setUp(self):
super().setUp()

# This is added because debugger_utils.start_listener() does not return
# any response, hence thread hangs.
# Ref - https://github.com/pgadmin-org/pgadmin4/issues/7136
if PG_DEFAULT_DRIVER == PSYCOPG3:
self.skipTest('Skip for psycopg3.')

self.schema_data = parent_node_dict['schema'][-1]
self.server_id = self.schema_data['server_id']
self.db_id = self.schema_data['db_id']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
.tests import utils as funcs_utils
from pgadmin.browser.server_groups.servers.databases.tests import \
utils as db_utils
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.constants import PSYCOPG3


class DebuggerStartExecution(BaseTestGenerator):
Expand All @@ -28,6 +30,12 @@ class DebuggerStartExecution(BaseTestGenerator):

def setUp(self):
super().setUp()

# This is added because debugger_utils.start_listener() does not return
# any response, hence thread hangs.
if PG_DEFAULT_DRIVER == PSYCOPG3:
self.skipTest('Skip for psycopg3.')

self.schema_data = parent_node_dict['schema'][-1]
self.server_id = self.schema_data['server_id']
self.db_id = self.schema_data['db_id']
Expand Down
6 changes: 4 additions & 2 deletions web/pgadmin/tools/debugger/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import json
import time
import uuid


Expand Down Expand Up @@ -80,6 +81,7 @@ def add_extension(self, utils, del_function=True, db_utils=None):
)

connection.commit()
connection.close()
except Exception as e:
print(
"============================================================="
Expand All @@ -88,7 +90,7 @@ def add_extension(self, utils, del_function=True, db_utils=None):
)
if del_function:
delete_function(self, utils)

connection.close()
db_utils.disconnect_database(self, self.server_id, self.db_id)
self.skipTest('The debugger plugin is not installed.')

Expand Down Expand Up @@ -126,7 +128,7 @@ def initialize_target(self, utils, close_debugger_instance=True):


def start_listener(self, utils, db_utils):
response = self.tester.get(
response = self.tester.post(
'debugger/start_listener/' + str(self.trans_id),
content_type='application/json')
if response.status_code != 200:
Expand Down
3 changes: 2 additions & 1 deletion web/pgadmin/tools/psql/tests/test_backend_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ def runTest(self):
}
self.test_client.emit('socket_input', input_data, namespace='/pty')
self.test_client.get_received('/pty')
self.test_client.disconnect(namespace='/pty')

def tearDown(self):
self.test_client.emit('disconnect', namespace='/pty')
connection = utils.get_db_connection(self.server['db'],
self.server['username'],
self.server['db_password'],
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
1 change: 1 addition & 0 deletions web/pgadmin/tools/psql/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ def tearDown(self):
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
1 change: 1 addition & 0 deletions web/pgadmin/tools/psql/tests/test_psql_disabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ def tearDown(self):
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
3 changes: 2 additions & 1 deletion web/pgadmin/tools/psql/tests/test_psql_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def setUp(self):
self.sid = parent_node_dict["server"][-1]["server_id"]
self.sgid = config_data["server_group"]
config.ENABLE_PSQL = True
self.server_con = server_utils.connect_server(self, self.sid)

def runTest(self):
if sys.platform == 'win32':
Expand Down Expand Up @@ -143,9 +142,11 @@ def runTest(self):
self.test_client.get_received('/pty')

def tearDown(self):
self.test_client.emit('disconnect', namespace='/pty')
connection = utils.get_db_connection(self.server['db'],
self.server['username'],
self.server['db_password'],
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
5 changes: 2 additions & 3 deletions web/pgadmin/tools/psql/tests/test_resize_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def setUp(self):
self.sid = parent_node_dict["server"][-1]["server_id"]
self.sgid = config_data["server_group"]
config.ENABLE_PSQL = True
self.server_con = server_utils.connect_server(self, self.sid)

def runTest(self):
if sys.platform == 'win32':
Expand Down Expand Up @@ -50,12 +49,12 @@ def runTest(self):

self.test_client.emit('resize', self.input_data, namespace='/pty')

self.test_client.disconnect(namespace='/pty')

def tearDown(self):
self.test_client.emit('disconnect', namespace='/pty')
connection = utils.get_db_connection(self.server['db'],
self.server['username'],
self.server['db_password'],
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
1 change: 1 addition & 0 deletions web/pgadmin/tools/psql/tests/test_socket_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ def tearDown(self):
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
4 changes: 2 additions & 2 deletions web/pgadmin/tools/psql/tests/test_socket_disconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def runTest(self):
self.test_client.emit('start_process', data, namespace='/pty')
self.test_client.get_received('/pty')

self.test_client.disconnect(namespace='/pty')

def tearDown(self):
self.test_client.emit('disconnect', namespace='/pty')
connection = utils.get_db_connection(self.server['db'],
self.server['username'],
self.server['db_password'],
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
3 changes: 1 addition & 2 deletions web/pgadmin/tools/psql/tests/test_start_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def setUp(self):
self.sgid = config_data["server_group"]
config.ENABLE_PSQL = True

self.server_con = server_utils.connect_server(self, self.sid)

def runTest(self):
if sys.platform == 'win32':
self.skipTest('PSQL disabled for windows')
Expand Down Expand Up @@ -55,3 +53,4 @@ def tearDown(self):
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()
1 change: 1 addition & 0 deletions web/pgadmin/tools/psql/tests/test_start_process_fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ def tearDown(self):
self.server['host'],
self.server['port'])
utils.drop_database(connection, self.db_name)
connection.close()

0 comments on commit 5e22b54

Please sign in to comment.