Fix dropping of pgAgent schedules through the Job properties. Fixes #3996

This commit is contained in:
Akshay Joshi 2019-07-12 10:37:41 +01:00 committed by Dave Page
parent ed01274f7b
commit 29fd83dc6c
8 changed files with 194 additions and 18 deletions

View File

@ -28,6 +28,7 @@ Bug fixes
*********
| `Issue #3919 <https://redmine.postgresql.org/issues/3919>`_ - Allow keyboard navigation of all controls on subnode grids.
| `Issue #3996 <https://redmine.postgresql.org/issues/3996>`_ - Fix dropping of pgAgent schedules through the Job properties.
| `Issue #4224 <https://redmine.postgresql.org/issues/4224>`_ - Prevent flickering of large tooltips on the Graphical EXPLAIN canvas.
| `Issue #4389 <https://redmine.postgresql.org/issues/4389>`_ - Fix an error that could be seen when editing column privileges.
| `Issue #4393 <https://redmine.postgresql.org/issues/4393>`_ - Ensure parameter values are quoted when needed when editing roles.

View File

@ -140,7 +140,7 @@ class JobScheduleView(PGChildNodeView):
operations = dict({
'obj': [
{'get': 'properties', 'put': 'update', 'delete': 'delete'},
{'get': 'list', 'post': 'create'}
{'get': 'list', 'post': 'create', 'delete': 'delete'}
],
'nodes': [{'get': 'nodes'}, {'get': 'nodes'}],
'msql': [{'get': 'msql'}, {'get': 'msql'}],
@ -474,17 +474,25 @@ class JobScheduleView(PGChildNodeView):
)
@check_precondition
def delete(self, gid, sid, jid, jscid):
def delete(self, gid, sid, jid, jscid=None):
"""Delete the Job Schedule."""
status, res = self.conn.execute_void(
render_template(
"/".join([self.template_path, 'delete.sql']),
jid=jid, jscid=jscid, conn=self.conn
if jscid is None:
data = request.form if request.form else json.loads(
request.data, encoding='utf-8'
)
)
if not status:
return internal_server_error(errormsg=res)
else:
data = {'ids': [jscid]}
for jscid in data['ids']:
status, res = self.conn.execute_void(
render_template(
"/".join([self.template_path, 'delete.sql']),
jid=jid, jscid=jscid, conn=self.conn
)
)
if not status:
return internal_server_error(errormsg=res)
return make_json_response(success=1)

View File

@ -24,6 +24,7 @@ define('pgadmin.node.pga_schedule', [
type: 'coll-pga_schedule',
columns: ['jscid', 'jscname', 'jscenabled'],
hasStatistics: false,
canDropCascade: false,
});
}

View File

@ -159,7 +159,7 @@ class JobStepView(PGChildNodeView):
operations = dict({
'obj': [
{'get': 'properties', 'put': 'update', 'delete': 'delete'},
{'get': 'list', 'post': 'create'}
{'get': 'list', 'post': 'create', 'delete': 'delete'}
],
'nodes': [{'get': 'nodes'}, {'get': 'nodes'}],
'msql': [{'get': 'msql'}, {'get': 'msql'}],
@ -474,17 +474,25 @@ SELECT EXISTS(
)
@check_precondition
def delete(self, gid, sid, jid, jstid):
def delete(self, gid, sid, jid, jstid=None):
"""Delete the Job step."""
status, res = self.conn.execute_void(
render_template(
"/".join([self.template_path, 'delete.sql']),
jid=jid, jstid=jstid, conn=self.conn
if jstid is None:
data = request.form if request.form else json.loads(
request.data, encoding='utf-8'
)
)
if not status:
return internal_server_error(errormsg=res)
else:
data = {'ids': [jstid]}
for jstid in data['ids']:
status, res = self.conn.execute_void(
render_template(
"/".join([self.template_path, 'delete.sql']),
jid=jid, jstid=jstid, conn=self.conn
)
)
if not status:
return internal_server_error(errormsg=res)
return make_json_response(success=1)

View File

@ -24,6 +24,7 @@ define('pgadmin.node.pga_jobstep', [
'jstonerror',
],
hasStatistics: false,
canDropCascade: false,
});
}

View File

@ -0,0 +1,47 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import uuid
import json
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from . import utils as pgagent_utils
class PgAgentDeleteMultipleTestCase(BaseTestGenerator):
"""This class will test the delete multiple pgAgent job API"""
scenarios = [
('Delete multiple pgAgent job', dict(url='/browser/pga_job/obj/'))
]
def setUp(self):
flag, msg = pgagent_utils.is_valid_server_to_run_pgagent(self)
if not flag:
self.skipTest(msg)
flag, msg = pgagent_utils.is_pgagent_installed_on_server(self)
if not flag:
self.skipTest(msg)
name1 = "test_job1_delete%s" % str(uuid.uuid4())[1:8]
self.job_id1 = pgagent_utils.create_pgagent_job(self, name1)
name2 = "test_job2_delete%s" % str(uuid.uuid4())[1:8]
self.job_id2 = pgagent_utils.create_pgagent_job(self, name2)
def runTest(self):
"""This function will deletes pgAgent job"""
response = self.tester.delete(
'{0}{1}/{2}/'.format(
self.url, str(utils.SERVER_GROUP), str(self.server_id)
),
data=json.dumps({'ids': [self.job_id1, self.job_id2]}),
content_type='html/json'
)
self.assertEquals(response.status_code, 200)
def tearDown(self):
"""Clean up code"""

View File

@ -0,0 +1,56 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import uuid
import json
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from . import utils as pgagent_utils
class PgAgentDeleteMultipleSchedulesTestCase(BaseTestGenerator):
"""This class will test the delete pgAgent job schedule API"""
scenarios = [
('Delete multiple pgAgent schedules',
dict(url='/browser/pga_schedule/obj/'))
]
def setUp(self):
flag, msg = pgagent_utils.is_valid_server_to_run_pgagent(self)
if not flag:
self.skipTest(msg)
flag, msg = pgagent_utils.is_pgagent_installed_on_server(self)
if not flag:
self.skipTest(msg)
name = "test_multi_sc_job_delete%s" % str(uuid.uuid4())[1:8]
self.job_id = pgagent_utils.create_pgagent_job(self, name)
sch1_name = "test_multi_schedule1_delete%s" % str(uuid.uuid4())[1:8]
self.schedule_id1 = pgagent_utils.create_pgagent_schedule(
self, sch1_name, self.job_id)
# Create one more schedule
sch2_name = "test_multi_schedule2_delete%s" % str(uuid.uuid4())[1:8]
self.schedule_id2 = pgagent_utils.create_pgagent_schedule(
self, sch2_name, self.job_id)
def runTest(self):
"""This function will deletes pgAgent job schedule"""
response = self.tester.delete(
'{0}{1}/{2}/{3}/'.format(
self.url, str(utils.SERVER_GROUP), str(self.server_id),
str(self.job_id)
),
data=json.dumps({'ids': [self.schedule_id1, self.schedule_id2]}),
content_type='html/json'
)
self.assertEquals(response.status_code, 200)
def tearDown(self):
"""Clean up code"""
pgagent_utils.delete_pgagent_job(self)

View File

@ -0,0 +1,54 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
import uuid
import json
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils as utils
from . import utils as pgagent_utils
class PgAgentDeleteMultipleStepsTestCase(BaseTestGenerator):
"""This class will test the delete pgAgent job steps API"""
scenarios = [
('Delete multiple pgAgent steps',
dict(url='/browser/pga_jobstep/obj/'))
]
def setUp(self):
flag, msg = pgagent_utils.is_valid_server_to_run_pgagent(self)
if not flag:
self.skipTest(msg)
flag, msg = pgagent_utils.is_pgagent_installed_on_server(self)
if not flag:
self.skipTest(msg)
name = "test_multiple_st_job_delete%s" % str(uuid.uuid4())[1:8]
self.job_id = pgagent_utils.create_pgagent_job(self, name)
step_name1 = "test_multiple_step1_delete%s" % str(uuid.uuid4())[1:8]
self.step_id1 = pgagent_utils.create_pgagent_step(
self, step_name1, self.job_id)
step_name2 = "test_multiple_step2_delete%s" % str(uuid.uuid4())[1:8]
self.step_id2 = pgagent_utils.create_pgagent_step(
self, step_name2, self.job_id)
def runTest(self):
"""This function will deletes pgAgent job schedule"""
response = self.tester.delete(
'{0}{1}/{2}/{3}/'.format(
self.url, str(utils.SERVER_GROUP), str(self.server_id),
str(self.job_id)
),
data=json.dumps({'ids': [self.step_id1, self.step_id2]}),
content_type='html/json'
)
self.assertEquals(response.status_code, 200)
def tearDown(self):
"""Clean up code"""
pgagent_utils.delete_pgagent_job(self)