Hi, Please find the attached patch to stabilize the pgagent and fix below issues.
- Reverse engineering SQL and MSQL was incorrect when the user added a job schedule with exception Fixes #5356 - Job schedule exception time was not showing correctly in SQL tab. - Identify the job step and schedule if disabled from browser tree, same as pgagent job - Fixes #4636 - Add RE-SQL/MSQL test cases for pgAgent Jobs - Fixes #4623 Do review it and let me know for comments. Thanks, Neel Patel
diff --git a/docs/en_US/release_notes_4_21.rst b/docs/en_US/release_notes_4_21.rst index d2a42eb..9f152ee 100644 --- a/docs/en_US/release_notes_4_21.rst +++ b/docs/en_US/release_notes_4_21.rst @@ -11,6 +11,7 @@ New features | `Issue #2172 <https://redmine.postgresql.org/issues/2172>`_ - Added search object functionality. | `Issue #2186 <https://redmine.postgresql.org/issues/2186>`_ - Added LDAP authentication support. +| `Issue #4636 <https://redmine.postgresql.org/issues/4636>`_ - Added job step and job schedule disable icons to identify it quickly within browser tree. | `Issue #5181 <https://redmine.postgresql.org/issues/5181>`_ - Added support for parameter toast_tuple_target and parallel_workers of the table. | `Issue #5263 <https://redmine.postgresql.org/issues/5263>`_ - Added support of Foreign Tables to the Schema Diff. | `Issue #5264 <https://redmine.postgresql.org/issues/5264>`_ - Added support of Packages, Sequences and Synonyms to the Schema Diff. @@ -21,6 +22,7 @@ Housekeeping ************ | `Issue #4620 <https://redmine.postgresql.org/issues/4620>`_ - Add Reverse Engineered and Modified SQL tests for procedures. +| `Issue #4623 <https://redmine.postgresql.org/issues/4623>`_ - Add Reverse Engineered and Modified SQL tests for pgagent jobs. Bug fixes ********* @@ -57,6 +59,7 @@ Bug fixes | `Issue #5302 <https://redmine.postgresql.org/issues/5302>`_ - Fixed an issue where difference SQL is not seen in the schema diff tool for Types. | `Issue #5314 <https://redmine.postgresql.org/issues/5314>`_ - Ensure that switch cell is in sync with switch control for accessibility. | `Issue #5351 <https://redmine.postgresql.org/issues/5351>`_ - Fixed compilation warnings while building pgAdmin. +| `Issue #5356 <https://redmine.postgresql.org/issues/5356>`_ - Fixed msql creation issue while adding exception in pgaagent job schedule. | `Issue #5361 <https://redmine.postgresql.org/issues/5361>`_ - Fixes an issue where pgAdmin4 GUI does not display properly in IE 11. | `Issue #5362 <https://redmine.postgresql.org/issues/5362>`_ - Fixed an issue where the identical packages and sequences visible as different in the schema diff tool. | `Issue #5366 <https://redmine.postgresql.org/issues/5366>`_ - Added alert message to Reset Layout if any of the panels from Query Tool failed to load. @@ -66,4 +69,4 @@ Bug fixes | `Issue #5387 <https://redmine.postgresql.org/issues/5387>`_ - Fixed an issue where the mode is not shown in the properties dialog of functions/procedures if all the arguments are "IN" arguments. | `Issue #5400 <https://redmine.postgresql.org/issues/5400>`_ - Fixed internal server error when the database server is logged in with non-super user. | `Issue #5409 <https://redmine.postgresql.org/issues/5409>`_ - Fixed validation issue in Synonyms node. -| `Issue #5410 <https://redmine.postgresql.org/issues/5410>`_ - Fixed an issue while removing the package body showing wrong modified SQL. \ No newline at end of file +| `Issue #5410 <https://redmine.postgresql.org/issues/5410>`_ - Fixed an issue while removing the package body showing wrong modified SQL. diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py index 797a6cb..ee87a1a 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/pgagent/__init__.py @@ -10,6 +10,7 @@ """Implements the pgAgent Jobs Node""" from functools import wraps import json +from datetime import datetime, time from flask import render_template, request, jsonify from flask_babelex import gettext as _ @@ -323,7 +324,8 @@ SELECT EXISTS( row['jobid'], sid, row['jobname'], - icon="icon-pga_job" + icon="icon-pga_job" if row['jobenabled'] + else "icon-pga_job-disabled" ) ) @@ -500,6 +502,10 @@ SELECT EXISTS( if schedule['jexid']: idx = 0 for exc in schedule['jexid']: + # Convert datetime.time object to string + if isinstance(schedule['jextime'][idx], time): + schedule['jextime'][idx] = \ + schedule['jextime'][idx].strftime("%H:%M:%S") schedule['jscexceptions'].append({ 'jexid': exc, 'jexdate': schedule['jexdate'][idx], diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py index ad3e7e9..13bd25a 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py @@ -74,6 +74,23 @@ class JobScheduleModule(CollectionNodeModule): return 'pga_job' @property + def csssnippets(self): + """ + Returns a snippet of css to include in the page + """ + snippets = [ + render_template( + "pga_schedule/css/pga_schedule.css", + node_type=self.node_type + ) + ] + + for submodule in self.submodules: + snippets.extend(submodule.csssnippets) + + return snippets + + @property def module_use_template_javascript(self): """ Returns whether Jinja2 template is used for generating the javascript @@ -245,7 +262,8 @@ class JobScheduleView(PGChildNodeView): row['jscid'], row['jscjobid'], row['jscname'], - icon="icon-pga_schedule", + icon="icon-pga_schedule" if row['jscenabled'] else + "icon-pga_schedule-disabled", enabled=row['jscenabled'] ) ) @@ -256,7 +274,8 @@ class JobScheduleView(PGChildNodeView): row['jscid'], row['jscjobid'], row['jscname'], - icon="icon-pga_schedule", + icon="icon-pga_schedule" if row['jscenabled'] else + "icon-pga_schedule-disabled", enabled=row['jscenabled'] ) ) @@ -359,7 +378,8 @@ class JobScheduleView(PGChildNodeView): row['jscid'], row['jscjobid'], row['jscname'], - icon="icon-pga_schedule", + icon="icon-pga_schedule" if row['jscenabled'] else + "icon-pga_schedule-disabled", enabled=row['jscenabled'] ) ) @@ -422,7 +442,8 @@ class JobScheduleView(PGChildNodeView): jscid, jid, row['jscname'], - icon="icon-pga_schedule", + icon="icon-pga_schedule" if row['jscenabled'] else + "icon-pga_schedule-disabled", enabled=row['jscenabled'] ) ) diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/img/pga_schedule-disabled.svg b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/img/pga_schedule-disabled.svg new file mode 100644 index 0000000..8c61a0e --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/img/pga_schedule-disabled.svg @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 24.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"> +<style type="text/css"> + .st0{fill:#E3F3F9;stroke:#BD4949;stroke-width:0.75;stroke-miterlimit:10;} + .st1{fill:#1E50AD;} + .st2{fill:#D0021B;} +</style> +<circle class="st0" cx="8" cy="8.2" r="5.4"/> +<path class="st1" d="M10.7,7.7H8.5V4.6c0-0.3-0.2-0.5-0.5-0.5S7.5,4.3,7.5,4.6v3.6c0,0.3,0.2,0.5,0.5,0.5h2.7c0.3,0,0.5-0.2,0.5-0.5 + S11,7.7,10.7,7.7z"/> +<path class="st2" d="M13.3,3.9l1.5-1.5c0.3-0.3,0.3-0.8,0-1.1s-0.8-0.3-1.1,0l-1.5,1.5l-1.5-1.5c-0.3-0.3-0.8-0.3-1.1,0 + s-0.3,0.8,0,1.1l1.5,1.5L9.7,5.4c-0.3,0.3-0.3,0.8,0,1.1c0.1,0.1,0.3,0.2,0.5,0.2s0.4-0.1,0.5-0.2L12.2,5l1.5,1.5 + c0.1,0.1,0.3,0.2,0.5,0.2s0.4-0.1,0.5-0.2c0.3-0.3,0.3-0.8,0-1.1L13.3,3.9z"/> +</svg> diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js index 75413d9..44d3d45 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js +++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.js @@ -366,13 +366,6 @@ define('pgadmin.node.pga_schedule', [ var res = Backform.FieldsetControl.prototype.render.apply( this, arguments ); - - // $( - // '<div>' + - // gettext('Schedules are specified using a <strong>cron-style</strong> format.<br/><ul><li>For each selected time or date element, the schedule will execute.<br/>e.g. To execute at 5 minutes past every hour, simply select ‘05’ in the Minutes list box.<br/></li><li>Values from more than one field may be specified in order to further control the schedule.<br/>e.g. To execute at 12:05 and 14:05 every Monday and Thursday, you would click minute 05, hours 12 and 14, and weekdays Monday and Thursday.</li><li>For additional flexibility, the Month Days check list includes an extra Last Day option. This matches the last day of the month, whether it happens to be the 28th, 29th, 30th or 31st.</li></ul>') + - // '</div>' - // ).insertBefore(this.$el); - return res; }, }), @@ -498,7 +491,8 @@ define('pgadmin.node.pga_schedule', [ if (_.isUndefined(val) || _.isNull(val) || String(val).replace(/^\s+|\s+$/g, '') == '') { if (val == '') { - this.set('jscend', undefined); + /* Set the default value used in model initialization */ + this.set('jscend', null); } return; } diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/css/pga_schedule.css b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/css/pga_schedule.css index 5910c5e..c3efe35 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/css/pga_schedule.css +++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/templates/pga_schedule/css/pga_schedule.css @@ -6,3 +6,21 @@ vertical-align: middle; height: 1.3em; } + +.icon-pga_schedule-disabled { + background-image: url('{{ url_for('NODE-pga_schedule.static', filename='img/pga_schedule-disabled.svg') }}') !important; + background-repeat: no-repeat; + background-size: 20px !important; + align-content: center; + vertical-align: middle; + height: 1.3em; +} + +.icon-coll-pga_schedule { + background-image: url('{{ url_for('NODE-pga_schedule.static', filename='img/coll-pga_schedule.svg') }}') !important; + background-repeat: no-repeat; + background-size: 20px !important; + align-content: center; + vertical-align: middle; + height: 1.3em; +} diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py index aa4f7f4..320e621 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py @@ -274,7 +274,8 @@ SELECT EXISTS( row['jstid'], row['jstjobid'], row['jstname'], - icon="icon-pga_jobstep", + icon="icon-pga_jobstep" if row['jstenabled'] else + "icon-pga_jobstep-disabled", enabled=row['jstenabled'], kind=row['jstkind'] ) @@ -286,7 +287,8 @@ SELECT EXISTS( row['jstid'], row['jstjobid'], row['jstname'], - icon="icon-pga_jobstep", + icon="icon-pga_jobstep" if row['jstenabled'] else + "icon-pga_jobstep-disabled", enabled=row['jstenabled'], kind=row['jstkind'] ) @@ -383,7 +385,8 @@ SELECT EXISTS( row['jstid'], row['jstjobid'], row['jstname'], - icon="icon-pga_jobstep" + icon="icon-pga_jobstep" if row['jstenabled'] + else "icon-pga_jobstep-disabled" ) ) @@ -469,7 +472,8 @@ SELECT EXISTS( jstid, jid, row['jstname'], - icon="icon-pga_jobstep" + icon="icon-pga_jobstep" if row['jstenabled'] + else "icon-pga_jobstep-disabled" ) ) diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/coll-pga_jobstep.svg b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/coll-pga_jobstep.svg index e38354d..d347471 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/coll-pga_jobstep.svg +++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/coll-pga_jobstep.svg @@ -1 +1,45 @@ -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#def4fd;}.cls-2{fill:#34495e;}.cls-3{fill:#2195e7;}.cls-4{fill:none;stroke:#2195e7;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.75px;}</style></defs><title>coll-pga_jobstep</title><g id="_2" data-name="2"><rect class="cls-1" x="3.89" y="3.38" width="8.23" height="10.25" rx="0.63" ry="0.63"/><path class="cls-2" d="M11.49,3.75a.25.25,0,0,1,.25.25v9a.25.25,0,0,1-.25.25h-7A.25.25,0,0,1,4.26,13V4a.25.25,0,0,1,.25-.25h7m0-.75h-7a1,1,0,0,0-1,1v9a1,1,0,0,0,1,1h7a1,1,0,0,0,1-1V4a1,1,0,0,0-1-1Z"/><path class="cls-1" d="M6.38,3.63V3A.63.63,0,0,1,7,2.38H9A.63.63,0,0,1,9.63,3v.63Z"/><path class="cls-2" d="M9,2.75A.25.25,0,0,1,9.25,3v.25H6.75V3A.25.25,0,0,1,7,2.75H9M9,2H7A1,1,0,0,0,6,3V4h4V3A1,1,0,0,0,9,2Z"/><polygon class="cls-3" points="10.93 5.97 8 5.97 8 6.65 10.93 6.65 10.93 5.97 10.93 5.97"/><polygon class="cls-3" points="10.93 8.54 8 8.54 8 9.22 10.93 9.22 10.93 8.54 10.93 8.54"/><polygon class="cls-3" points="10.93 11.29 8 11.29 8 11.98 10.93 11.98 10.93 11.29 10.93 11.29"/><polyline class="cls-4" points="5.47 6.36 6.13 6.89 7.22 5.41"/><polyline class="cls-4" points="5.47 9.09 6.13 9.62 7.22 8.14"/><polyline class="cls-4" points="5.47 11.54 6.13 12.07 7.22 10.59"/></g></svg> \ No newline at end of file +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 24.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"> +<style type="text/css"> + .st0{fill:#DEF4FD;} + .st1{fill:#34495E;} + .st2{fill:#2195E7;} + .st3{fill:none;stroke:#2195E7;stroke-width:0.6667;stroke-linecap:round;stroke-linejoin:round;} +</style> +<g> + <g id="_2"> + <path class="st0" d="M2.9,2.7h6.2c0.3,0,0.6,0.3,0.6,0.6v8c0,0.3-0.3,0.6-0.6,0.6H2.9c-0.3,0-0.6-0.3-0.6-0.6v-8 + C2.4,3,2.6,2.7,2.9,2.7z"/> + <path class="st1" d="M9.1,3.1c0.1,0,0.2,0.1,0.2,0.2v8c0,0.1-0.1,0.2-0.2,0.2H2.9c-0.1,0-0.2-0.1-0.2-0.2v-8 + c0-0.1,0.1-0.2,0.2-0.2H9.1 M9.2,2.4H2.9C2.4,2.4,2,2.8,2,3.3v8c0,0.5,0.4,0.9,0.9,0.9h6.2c0.5,0,0.9-0.4,0.9-0.9v-8 + C10,2.8,9.6,2.4,9.2,2.4z"/> + <path class="st0" d="M4.6,3V2.4c0-0.3,0.2-0.5,0.6-0.6h1.8c0.3,0,0.6,0.2,0.6,0.6V3H4.6z"/> + <path class="st1" d="M6.9,2C7,2,7.1,2.1,7.1,2.2v0.2H4.9V2.2C4.9,2.1,5,2,5.1,2H6.9 M6.9,1.3H5.1c-0.5,0-0.9,0.4-0.9,0.9v0.9h3.6 + V2.2C7.8,1.7,7.4,1.3,6.9,1.3z"/> + <polygon class="st2" points="8.6,5 6,5 6,5.6 8.6,5.6 8.6,5 "/> + <polygon class="st2" points="8.6,7.3 6,7.3 6,7.9 8.6,7.9 8.6,7.3 "/> + <polygon class="st2" points="8.6,9.8 6,9.8 6,10.4 8.6,10.4 8.6,9.8 "/> + <polyline class="st3" points="3.8,5.4 4.4,5.9 5.3,4.5 "/> + <polyline class="st3" points="3.8,7.8 4.4,8.3 5.3,7 "/> + <polyline class="st3" points="3.8,10 4.4,10.5 5.3,9.1 "/> + </g> + <g id="_2_2_"> + <path class="st0" d="M6.9,5.3h6.2c0.3,0,0.6,0.3,0.6,0.6v8c0,0.3-0.3,0.6-0.6,0.6H6.9c-0.3,0-0.6-0.3-0.6-0.6v-8 + C6.3,5.5,6.5,5.3,6.9,5.3z"/> + <path class="st1" d="M13.1,5.6c0.1,0,0.2,0.1,0.2,0.2v8c0,0.1-0.1,0.2-0.2,0.2H6.8c-0.1,0-0.2-0.1-0.2-0.2v-8 + c0-0.1,0.1-0.2,0.2-0.2H13.1 M13.1,4.9H6.8C6.4,4.9,6,5.3,6,5.8v8c0,0.5,0.4,0.9,0.9,0.9h6.2c0.5,0,0.9-0.4,0.9-0.9v-8 + C14,5.3,13.6,4.9,13.1,4.9z"/> + <path class="st0" d="M8.5,5.5V4.9c0-0.3,0.2-0.5,0.6-0.6h1.8c0.3,0,0.6,0.2,0.6,0.6v0.6H8.5z"/> + <path class="st1" d="M10.8,4.5c0.1,0,0.2,0.1,0.2,0.2v0.2H8.8V4.7c0-0.1,0.1-0.2,0.2-0.2H10.8 M10.8,3.8H9.1 + c-0.5,0-0.9,0.4-0.9,0.9v0.9h3.6V4.7C11.7,4.2,11.3,3.8,10.8,3.8z"/> + <polygon class="st2" points="12.6,7.6 9.9,7.6 9.9,8.2 12.6,8.2 12.6,7.6 "/> + <polygon class="st2" points="12.6,9.9 9.9,9.9 9.9,10.5 12.6,10.5 12.6,9.9 "/> + <polygon class="st2" points="12.6,12.3 9.9,12.3 9.9,12.9 12.6,12.9 12.6,12.3 "/> + <polyline class="st3" points="7.7,7.9 8.3,8.4 9.3,7.1 "/> + <polyline class="st3" points="7.7,10.3 8.3,10.8 9.3,9.5 "/> + <polyline class="st3" points="7.7,12.5 8.3,13 9.3,11.7 "/> + </g> +</g> +</svg> diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/pga_jobstep-disabled.svg b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/pga_jobstep-disabled.svg new file mode 100644 index 0000000..3ea6379 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/static/img/pga_jobstep-disabled.svg @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 24.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"> +<style type="text/css"> + .st0{fill:#DEF4FD;} + .st1{fill:#34495E;} + .st2{fill:#2195E7;} + .st3{fill:#717F8E;} + .st4{fill:none;stroke:#2195E7;stroke-width:0.75;stroke-linecap:round;stroke-linejoin:round;} + .st5{fill:none;stroke:#D0021B;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;} +</style> +<g id="_2"> + <path class="st0" d="M4.5,3.4h7c0.3,0,0.6,0.3,0.6,0.6v9c0,0.3-0.3,0.6-0.6,0.6h-7c-0.3,0-0.6-0.3-0.6-0.6V4 + C3.9,3.7,4.2,3.4,4.5,3.4z"/> + <path class="st1" d="M11.5,3.8c0.1,0,0.2,0.1,0.2,0.2v9c0,0.1-0.1,0.2-0.2,0.2h-7c-0.1,0-0.2-0.1-0.2-0.2V4c0-0.1,0.1-0.2,0.2-0.2 + H11.5 M11.5,3h-7c-0.6,0-1,0.4-1,1v9c0,0.6,0.4,1,1,1h7c0.6,0,1-0.4,1-1V4C12.5,3.4,12.1,3,11.5,3z"/> + <path class="st0" d="M6.4,3.6V3c0-0.3,0.3-0.6,0.6-0.6h2c0.3,0,0.6,0.3,0.6,0.6v0.6H6.4z"/> + <path class="st1" d="M9,2.8c0.1,0,0.2,0.1,0.2,0.2v0.2H6.8V3c0-0.1,0.1-0.2,0.2-0.2H9 M9,2H7C6.4,2,6,2.4,6,3v1h4V3 + C10,2.4,9.6,2,9,2z"/> + <path class="st2" d="M7.7,6.6V5.9h3.2v0.7H7.7z"/> + <path class="st3" d="M7.7,9.2V8.5h3.2v0.7H7.7z"/> + <path class="st3" d="M7.7,12v-0.7h3.2V12H7.7z"/> + <path class="st3" d="M5.6,9.4V8.3h1.1v1.1H5.6z"/> + <path class="st3" d="M5.6,12.1v-1.1h1.1v1.1H5.6z"/> + <polyline class="st4" points="5.5,6.3 6.1,6.9 7.2,5.4 "/> +</g> +<g> + <line class="st5" x1="13.5" y1="2.3" x2="10.5" y2="5.3"/> + <line class="st5" x1="13.5" y1="5.3" x2="10.5" y2="2.3"/> +</g> +</svg> diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/css/pga_step.css b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/css/pga_step.css index f7a4263..417085c 100644 --- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/css/pga_step.css +++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/templates/pga_jobstep/css/pga_step.css @@ -7,6 +7,15 @@ height: 1.3em; } +.icon-pga_jobstep-disabled { + background-image: url('{{ url_for('NODE-pga_jobstep.static', filename='img/pga_jobstep-disabled.svg') }}') !important; + background-repeat: no-repeat; + background-size: 20px !important; + align-content: center; + vertical-align: middle; + height: 1.3em; +} + .icon-coll-pga_jobstep { background-image: url('{{ url_for('NODE-pga_jobstep.static', filename='img/coll-pga_jobstep.svg') }}') !important; background-repeat: no-repeat; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_schedule_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_schedule_all_options.sql new file mode 100644 index 0000000..7598696 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_schedule_all_options.sql @@ -0,0 +1,71 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_batch_job_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 'b'::character(1), + ''::text, ''::name, 'i'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ;-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_2'::text, false , 'b'::character(1), + ''::text, ''::name, 's'::character(1), + 'SELECT 10;'::text, 'job step_2 description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid;-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_2'::text, 'test schedule_2 comment'::text, true, + '2020-04-15 05:11:31-07'::timestamp with time zone, '2020-04-16 05:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,false,false,false,false,false]::boolean[], + -- Month days + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_schedule_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_schedule_all_options_msql.sql new file mode 100644 index 0000000..b4a4e7d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_schedule_all_options_msql.sql @@ -0,0 +1,25 @@ + + +DO $$ +DECLARE + scid integer; +BEGIN +-- Inserting a schedule (jobid: <PGA_JOB_ID>) +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + <PGA_JOB_ID>, 'schedule_2'::text, 'test schedule_2 comment'::text, true, + '2020-04-15 05:11:31 -07:00'::timestamp with time zone, '2020-04-16 05:11:34 -07:00'::timestamp with time zone, + -- Minutes + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,false,false,false,false,false]::boolean[], + -- Month days + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,false,false,false,false,false,false,false,false,false,false]::boolean[] +) RETURNING jscid INTO scid;END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_step_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_step_all_options.sql new file mode 100644 index 0000000..51c6464 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_step_all_options.sql @@ -0,0 +1,54 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_batch_job_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 'b'::character(1), + ''::text, ''::name, 'i'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ;-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_2'::text, false , 'b'::character(1), + ''::text, ''::name, 's'::character(1), + 'SELECT 10;'::text, 'job step_2 description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_step_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_step_all_options_msql.sql new file mode 100644 index 0000000..025ad22 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_batch_job_step_all_options_msql.sql @@ -0,0 +1,11 @@ + +-- Inserting a step (jobid: <PGA_JOB_ID>) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + <PGA_JOB_ID>, 'step_2'::text, false , 'b'::character(1), + ''::text, ''::name, 's'::character(1), + 'SELECT 10;'::text, 'job step_2 description'::text +) RETURNING jstid; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_all_options.sql new file mode 100644 index 0000000..689657b --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_all_options.sql @@ -0,0 +1,95 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 4::integer, 'test_sql_job_local_db_updated_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description updated'::text, 'test_host_updated'::text, false +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 'f'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ;-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_2_added'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 's'::character(1), + 'SELECT 3;'::text, 'job step 2 description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-18', 'YYYY-MM-DD')::date, '01:18:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-19', 'YYYY-MM-DD')::date, '01:19:00'::time without time zone +);-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_2'::text, 'test schedule_2 comment'::text, false, + '2020-04-14 05:11:31-07'::timestamp with time zone, '2020-04-15 05:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[false,false,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-22', 'YYYY-MM-DD')::date, '01:22:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-23', 'YYYY-MM-DD')::date, '01:23:00'::time without time zone +); +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_all_options_msql.sql new file mode 100644 index 0000000..ff79833 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_all_options_msql.sql @@ -0,0 +1,37 @@ + + +DO $$ +DECLARE + scid integer; +BEGIN +-- Inserting a schedule (jobid: <PGA_JOB_ID>) +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + <PGA_JOB_ID>, 'schedule_2'::text, 'test schedule_2 comment'::text, false, + '2020-04-14 05:11:31 -07:00'::timestamp with time zone, '2020-04-15 05:11:34 -07:00'::timestamp with time zone, + -- Minutes + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[false,false,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[false,false,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-22', 'YYYY-MM-DD')::date, '01:22:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-23', 'YYYY-MM-DD')::date, '01:23:00'::time without time zone +);END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_remote_db_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_remote_db_all_options.sql new file mode 100644 index 0000000..a210fa8 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_remote_db_all_options.sql @@ -0,0 +1,71 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_sql_job_remote_db_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + 'host=localhost port=5432 dbname=postgres connect_timeout=10'::text, ''::name, 's'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ;-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_2'::text, false , 's'::character(1), + 'host=localhost port=5434 dbname=postgres connect_timeout=20'::text, ''::name, 'f'::character(1), + 'SELECT 5;'::text, 'job step_2 description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid;-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_2'::text, 'test schedule_2 comment'::text, true, + '2020-04-15 05:11:31-07'::timestamp with time zone, '2020-04-16 05:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Week days + ARRAY[false,false,false,false,false,false,false]::boolean[], + -- Month days + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_remote_db_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_remote_db_all_options_msql.sql new file mode 100644 index 0000000..458450c --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_schedule_remote_db_all_options_msql.sql @@ -0,0 +1,25 @@ + + +DO $$ +DECLARE + scid integer; +BEGIN +-- Inserting a schedule (jobid: <PGA_JOB_ID>) +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + <PGA_JOB_ID>, 'schedule_2'::text, 'test schedule_2 comment'::text, true, + '2020-04-15 05:11:31 -07:00'::timestamp with time zone, '2020-04-16 05:11:34 -07:00'::timestamp with time zone, + -- Minutes + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Week days + ARRAY[false,false,false,false,false,false,false]::boolean[], + -- Month days + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[false,false,false,false,false,false,false,false,false,false,false,false]::boolean[] +) RETURNING jscid INTO scid;END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_all_options.sql new file mode 100644 index 0000000..2d8bd38 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_all_options.sql @@ -0,0 +1,66 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 4::integer, 'test_sql_job_local_db_updated_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description updated'::text, 'test_host_updated'::text, false +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 'f'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ;-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_2_added'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 's'::character(1), + 'SELECT 3;'::text, 'job step 2 description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-18', 'YYYY-MM-DD')::date, '01:18:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-19', 'YYYY-MM-DD')::date, '01:19:00'::time without time zone +); +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_all_options_msql.sql new file mode 100644 index 0000000..ebcb256 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_all_options_msql.sql @@ -0,0 +1,11 @@ + +-- Inserting a step (jobid: <PGA_JOB_ID>) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + <PGA_JOB_ID>, 'step_2_added'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 's'::character(1), + 'SELECT 3;'::text, 'job step 2 description'::text +) RETURNING jstid; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_remote_db_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_remote_db_all_options.sql new file mode 100644 index 0000000..205162d --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_remote_db_all_options.sql @@ -0,0 +1,54 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_sql_job_remote_db_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + 'host=localhost port=5432 dbname=postgres connect_timeout=10'::text, ''::name, 's'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ;-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_2'::text, false , 's'::character(1), + 'host=localhost port=5434 dbname=postgres connect_timeout=20'::text, ''::name, 'f'::character(1), + 'SELECT 5;'::text, 'job step_2 description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_remote_db_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_remote_db_all_options_msql.sql new file mode 100644 index 0000000..2fc1052 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_job_step_remote_db_all_options_msql.sql @@ -0,0 +1,11 @@ + +-- Inserting a step (jobid: <PGA_JOB_ID>) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + <PGA_JOB_ID>, 'step_2'::text, false , 's'::character(1), + 'host=localhost port=5434 dbname=postgres connect_timeout=20'::text, ''::name, 'f'::character(1), + 'SELECT 5;'::text, 'job step_2 description'::text +) RETURNING jstid; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_sql_job_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_sql_job_all_options.sql new file mode 100644 index 0000000..ab0e450 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_sql_job_all_options.sql @@ -0,0 +1,57 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 4::integer, 'test_sql_job_local_db_updated_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description updated'::text, 'test_host_updated'::text, false +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 'f'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-18', 'YYYY-MM-DD')::date, '01:18:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-19', 'YYYY-MM-DD')::date, '01:19:00'::time without time zone +); +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_sql_job_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_sql_job_all_options_msql.sql new file mode 100644 index 0000000..f28a529 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/alter_sql_job_all_options_msql.sql @@ -0,0 +1,3 @@ +UPDATE pgagent.pga_job +SET jobjclid=4::integer, jobname='test_sql_job_local_db_updated_$%{}[]()&*^!@""''`\/#'::text, jobdesc='test_job_step_schedule description updated'::text, jobhostagent='test_host_updated'::text, jobenabled=false +WHERE jobid = <PGA_JOB_ID>; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_batch_job_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_batch_job_with_all_options.sql new file mode 100644 index 0000000..b867e58 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_batch_job_with_all_options.sql @@ -0,0 +1,45 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_batch_job_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 'b'::character(1), + ''::text, ''::name, 'i'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_batch_job_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_batch_job_with_all_options_msql.sql new file mode 100644 index 0000000..4f9815a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_batch_job_with_all_options_msql.sql @@ -0,0 +1,45 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_batch_job_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 'b'::character(1), + ''::text, ''::name, 'i'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31 -07:00'::timestamp with time zone, '2020-04-15 01:11:34 -07:00'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_local_db_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_local_db_with_all_options.sql new file mode 100644 index 0000000..f47288a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_local_db_with_all_options.sql @@ -0,0 +1,57 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_sql_job_local_db_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 'f'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-18', 'YYYY-MM-DD')::date, '01:18:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-19', 'YYYY-MM-DD')::date, '01:19:00'::time without time zone +); +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_local_db_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_local_db_with_all_options_msql.sql new file mode 100644 index 0000000..7fa7600 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_local_db_with_all_options_msql.sql @@ -0,0 +1,57 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_sql_job_local_db_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + ''::text, 'postgres'::name, 'f'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31 -07:00'::timestamp with time zone, '2020-04-15 01:11:34 -07:00'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-18', 'YYYY-MM-DD')::date, '01:18:00'::time without time zone +); +-- Inserting a schedule exception +INSERT INTO pgagent.pga_exception ( + jexscid, jexdate, jextime +) VALUES ( + scid, to_date('2020-04-19', 'YYYY-MM-DD')::date, '01:19:00'::time without time zone +); +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_remote_db_with_all_options.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_remote_db_with_all_options.sql new file mode 100644 index 0000000..ed8050a --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_remote_db_with_all_options.sql @@ -0,0 +1,45 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_sql_job_remote_db_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + 'host=localhost port=5432 dbname=postgres connect_timeout=10'::text, ''::name, 's'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31-07'::timestamp with time zone, '2020-04-15 01:11:34-07'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_remote_db_with_all_options_msql.sql b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_remote_db_with_all_options_msql.sql new file mode 100644 index 0000000..e8e6a71 --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/create_sql_job_remote_db_with_all_options_msql.sql @@ -0,0 +1,45 @@ +DO $$ +DECLARE + jid integer; + scid integer; +BEGIN +-- Creating a new job +INSERT INTO pgagent.pga_job( + jobjclid, jobname, jobdesc, jobhostagent, jobenabled +) VALUES ( + 1::integer, 'test_sql_job_remote_db_$%{}[]()&*^!@""''`\/#'::text, 'test_job_step_schedule description'::text, 'test_host'::text, true +) RETURNING jobid INTO jid; + +-- Steps +-- Inserting a step (jobid: NULL) +INSERT INTO pgagent.pga_jobstep ( + jstjobid, jstname, jstenabled, jstkind, + jstconnstr, jstdbname, jstonerror, + jstcode, jstdesc +) VALUES ( + jid, 'step_1'::text, true, 's'::character(1), + 'host=localhost port=5432 dbname=postgres connect_timeout=10'::text, ''::name, 's'::character(1), + 'SELECT 1;'::text, 'job step description'::text +) ; + +-- Schedules +-- Inserting a schedule +INSERT INTO pgagent.pga_schedule( + jscjobid, jscname, jscdesc, jscenabled, + jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths +) VALUES ( + jid, 'schedule_1'::text, 'test schedule comment'::text, true, + '2020-04-14 01:11:31 -07:00'::timestamp with time zone, '2020-04-15 01:11:34 -07:00'::timestamp with time zone, + -- Minutes + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Hours + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false]::boolean[], + -- Week days + ARRAY[true,true,true,true,true,true,true]::boolean[], + -- Month days + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false]::boolean[], + -- Months + ARRAY[true,true,true,true,true,true,true,true,true,true,true,true]::boolean[] +) RETURNING jscid INTO scid; +END +$$; diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/test_pgagent.json b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/test_pgagent.json new file mode 100644 index 0000000..630ba0f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/pgagent/tests/default/test_pgagent.json @@ -0,0 +1,377 @@ +{ + "scenarios": [ + { + "type": "create", + "name": "Create SQL job with all the options on local database", + "endpoint": "NODE-pga_job.obj", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "data": { + "jobname": "test_sql_job_local_db_$%{}[]()&*^!@\"\"'`\\/#", + "jobenabled": true, + "jobhostagent": "test_host", + "jobjclid": "1", + "jobdesc": "test_job_step_schedule description", + "jsteps": [{ + "jstid":"", + "jstjobid":"", + "jstname":"step_1", + "jstdesc":"job step description", + "jstenabled":true, + "jstkind":true, + "jstconntype":true, + "jstcode":"SELECT 1;", + "jstconnstr":"", + "jstdbname":"postgres", + "jstonerror":"f", + "jstnextrun":"" + }], + "jschedules": [{ + "jscid":"", + "jscjobid":"", + "jscname":"schedule_1", + "jscdesc":"test schedule comment", + "jscenabled":true, + "jscstart":"2020-04-14 01:11:31 -07:00", + "jscend":"2020-04-15 01:11:34 -07:00", + "jscweekdays":[true,true,true,true,true,true,true], + "jscmonthdays":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false], + "jscmonths":[true,true,true,true,true,true,true,true,true,true,true,true], + "jschours":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false], + "jscminutes":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscexceptions":[{"jexdate": "2020-04-18", "jextime": "01:18:00"}, {"jexdate": "2020-04-19", "jextime": "01:19:00"}] + }] + }, + "expected_sql_file": "create_sql_job_local_db_with_all_options.sql", + "expected_msql_file": "create_sql_job_local_db_with_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter job with all the options on local database", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jobname": "test_sql_job_local_db_updated_$%{}[]()&*^!@\"\"'`\\/#", + "jobenabled": false, + "jobjclid": "4", + "jobhostagent": "test_host_updated", + "jobdesc": "test_job_step_schedule description updated" + }, + "expected_sql_file": "alter_sql_job_all_options.sql", + "expected_msql_file": "alter_sql_job_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter job steps with all the options on local database", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jsteps": { + "added": [ + { + "jstid":"", + "jstjobid":"", + "jstname": "step_2_added", + "jstdesc": "job step 2 description", + "jstenabled": true, + "jstkind": true, + "jstconntype": true, + "jstcode": "SELECT 3;", + "jstconnstr": "", + "jstdbname": "postgres", + "jstonerror": "s", + "jstnextrun": "" + } + ] + } + }, + "expected_sql_file": "alter_job_step_all_options.sql", + "expected_msql_file": "alter_job_step_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter job schedule with all the options on local database", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jschedules": { + "added": [ + { + "jscid":"", + "jscjobid":"", + "jscname":"schedule_2", + "jscdesc":"test schedule_2 comment", + "jscenabled":false, + "jscstart":"2020-04-14 05:11:31 -07:00", + "jscend":"2020-04-15 05:11:34 -07:00", + "jscweekdays":[false,false,true,true,true,true,true], + "jscmonthdays":[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false], + "jscmonths":[false,false,true,true,true,true,true,true,true,true,true,true], + "jschours":[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false], + "jscminutes":[false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscexceptions":[{"jexdate": "2020-04-22", "jextime": "01:22:00"}, {"jexdate": "2020-04-23", "jextime": "01:23:00"}] + } + ] + } + }, + "expected_sql_file": "alter_job_schedule_all_options.sql", + "expected_msql_file": "alter_job_schedule_all_options_msql.sql" + }, { + "type": "delete", + "name": "Drop the SQL job scheduled on local database with all the options", + "endpoint": "NODE-pga_job.obj_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "data": { + "name": "test_sql_job_local_db_updated_$%{}[]()&*^!@\"\"'`\\/#" + } + }, { + "type": "create", + "name": "Create SQL job with all the options on remote database", + "endpoint": "NODE-pga_job.obj", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "data": { + "jobname": "test_sql_job_remote_db_$%{}[]()&*^!@\"\"'`\\/#", + "jobenabled": true, + "jobhostagent": "test_host", + "jobjclid": "1", + "jobdesc": "test_job_step_schedule description", + "jsteps": [{ + "jstid":"", + "jstjobid":"", + "jstname":"step_1", + "jstdesc":"job step description", + "jstenabled":true, + "jstkind":true, + "jstconntype":false, + "jstcode":"SELECT 1;", + "jstconnstr":"host=localhost port=5432 dbname=postgres connect_timeout=10", + "jstdbname":"", + "jstonerror":"s", + "jstnextrun":"" + }], + "jschedules": [{ + "jscid":"", + "jscjobid":"", + "jscname":"schedule_1", + "jscdesc":"test schedule comment", + "jscenabled":true, + "jscstart":"2020-04-14 01:11:31 -07:00", + "jscend":"2020-04-15 01:11:34 -07:00", + "jscweekdays":[true,true,true,true,true,true,true], + "jscmonthdays":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false], + "jscmonths":[true,true,true,true,true,true,true,true,true,true,true,true], + "jschours":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false], + "jscminutes":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscexceptions":[] + }] + }, + "expected_sql_file": "create_sql_job_remote_db_with_all_options.sql", + "expected_msql_file": "create_sql_job_remote_db_with_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter job steps with all the options on remote database", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jsteps": { + "added": [ + { + "jstid":"", + "jstjobid":"", + "jstname":"step_2", + "jstdesc":"job step_2 description", + "jstenabled":false, + "jstkind":true, + "jstconntype":false, + "jstcode":"SELECT 5;", + "jstconnstr":"host=localhost port=5434 dbname=postgres connect_timeout=20", + "jstdbname":"", + "jstonerror":"f", + "jstnextrun":"" + } + ] + } + }, + "expected_sql_file": "alter_job_step_remote_db_all_options.sql", + "expected_msql_file": "alter_job_step_remote_db_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter job schedule with all the options on remote database", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jschedules": { + "added": [ + { + "jscid":"", + "jscjobid":"", + "jscname":"schedule_2", + "jscdesc":"test schedule_2 comment", + "jscenabled":true, + "jscstart":"2020-04-15 05:11:31 -07:00", + "jscend":"2020-04-16 05:11:34 -07:00", + "jscweekdays":[false,false,false,false,false,false,false], + "jscmonthdays":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscmonths":[false,false,false,false,false,false,false,false,false,false,false,false], + "jschours":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscminutes":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscexceptions":[] + } + ] + } + }, + "expected_sql_file": "alter_job_schedule_remote_db_all_options.sql", + "expected_msql_file": "alter_job_schedule_remote_db_all_options_msql.sql" + }, { + "type": "delete", + "name": "Drop the SQL job scheduled on remote database with all options", + "endpoint": "NODE-pga_job.obj_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "data": { + "name": "test_sql_job_remote_db_$%{}[]()&*^!@\"\"'`\\/#" + } + }, { + "type": "create", + "name": "Create batch job with all the options", + "endpoint": "NODE-pga_job.obj", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "data": { + "jobname": "test_batch_job_$%{}[]()&*^!@\"\"'`\\/#", + "jobenabled": true, + "jobhostagent": "test_host", + "jobjclid": "1", + "jobdesc": "test_job_step_schedule description", + "jsteps": [{ + "jstid":"", + "jstjobid":"", + "jstname":"step_1", + "jstdesc":"job step description", + "jstenabled":true, + "jstkind":false, + "jstconntype":true, + "jstcode":"SELECT 1;", + "jstconnstr":"", + "jstdbname":"", + "jstonerror":"i", + "jstnextrun":"" + }], + "jschedules": [{ + "jscid":"", + "jscjobid":"", + "jscname":"schedule_1", + "jscdesc":"test schedule comment", + "jscenabled":true, + "jscstart":"2020-04-14 01:11:31 -07:00", + "jscend":"2020-04-15 01:11:34 -07:00", + "jscweekdays":[true,true,true,true,true,true,true], + "jscmonthdays":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false], + "jscmonths":[true,true,true,true,true,true,true,true,true,true,true,true], + "jschours":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false], + "jscminutes":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscexceptions":[] + }] + }, + "expected_sql_file": "create_batch_job_with_all_options.sql", + "expected_msql_file": "create_batch_job_with_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter batch job steps with all the options", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jsteps": { + "added": [ + { + "jstid":"", + "jstjobid":"", + "jstname":"step_2", + "jstdesc":"job step_2 description", + "jstenabled":false, + "jstkind":false, + "jstconntype":true, + "jstcode":"SELECT 10;", + "jstconnstr":"", + "jstdbname":"", + "jstonerror":"s", + "jstnextrun":"" + } + ] + } + }, + "expected_sql_file": "alter_batch_job_step_all_options.sql", + "expected_msql_file": "alter_batch_job_step_all_options_msql.sql" + }, { + "type": "alter", + "name": "Alter batch job schedule with all the options", + "endpoint": "NODE-pga_job.obj_id", + "sql_endpoint": "NODE-pga_job.sql_id", + "msql_endpoint": "NODE-pga_job.msql_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "pga_job_id": "<PGA_JOB_ID>", + "data": { + "jschedules": { + "added": [ + { + "jscid":"", + "jscjobid":"", + "jscname":"schedule_2", + "jscdesc":"test schedule_2 comment", + "jscenabled":true, + "jscstart":"2020-04-15 05:11:31 -07:00", + "jscend":"2020-04-16 05:11:34 -07:00", + "jscweekdays":[true,true,false,false,false,false,false], + "jscmonthdays":[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscmonths":[true,true,false,false,false,false,false,false,false,false,false,false], + "jschours":[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscminutes":[true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false], + "jscexceptions":[] + } + ] + } + }, + "expected_sql_file": "alter_batch_job_schedule_all_options.sql", + "expected_msql_file": "alter_batch_job_schedule_all_options_msql.sql" + }, { + "type": "delete", + "name": "Drop the batch job with all the options", + "endpoint": "NODE-pga_job.obj_id", + "pgagent_test": "True", + "precondition_sql": "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='pgagent' AND table_name='pga_jobstep' AND column_name='jstconnstr'", + "data": { + "name": "test_batch_job_$%{}[]()&*^!@\"\"'`\\/#" + } + } + ] +} diff --git a/web/pgadmin/static/js/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid.pgadmin.js index e196efa..7b1623e 100644 --- a/web/pgadmin/static/js/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid.pgadmin.js @@ -1894,11 +1894,15 @@ define([ this.$el.datetimepicker('destroy'); this.is_closing = false; + /* set the model default value in case of empty or undefined */ + if (_.isUndefined(newValue) || + String(val).replace(/^\s+|\s+$/g, '') == '') { + newValue = null; + } + model.set(column.get('name'), newValue); let command = new Backgrid.Command(ev); - setTimeout(() => { - model.trigger('backgrid:edited', model, column, command); - }, 20); + model.trigger('backgrid:edited', model, column, command); }, }); diff --git a/web/regression/re_sql/tests/test_resql.py b/web/regression/re_sql/tests/test_resql.py index 7666bea..63f3633 100644 --- a/web/regression/re_sql/tests/test_resql.py +++ b/web/regression/re_sql/tests/test_resql.py @@ -86,6 +86,14 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): if not self.db_con['info'] == "Database connected.": raise Exception("Could not connect to database.") + self.test_config_db_conn = utils.get_db_connection( + self.server['db'], + self.server['username'], + self.server['db_password'], + self.server['host'], + self.server['port'] + ) + # Get the application path self.apppath = os.getcwd() # Status of the test case @@ -105,7 +113,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): self.JSON_PLACEHOLDERS = {'schema_id': '<SCHEMA_ID>', 'owner': '<OWNER>', 'timestamptz': '<TIMESTAMPTZ>', - 'password': '<PASSWORD>'} + 'password': '<PASSWORD>', + 'pga_job_id': '<PGA_JOB_ID>'} resql_module_list = create_resql_module_list( BaseTestGenerator.re_sql_module_list, @@ -150,6 +159,7 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): database_utils.disconnect_database( self, self.server_information['server_id'], self.server_information['db_id']) + self.test_config_db_conn.close() def get_db_connection(self): """Get the database connection.""" @@ -222,8 +232,18 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): object_id = None for scenario in scenarios: - if 'precondition_sql' in scenario and \ - not self.check_precondition(scenario['precondition_sql']): + skip_test_case = True + if 'precondition_sql' in scenario: + if 'pgagent_test' in scenario and self.check_precondition( + scenario['precondition_sql'], True): + skip_test_case = False + elif self.check_precondition( + scenario['precondition_sql'], False): + skip_test_case = False + else: + skip_test_case = False + + if skip_test_case: print(scenario['name'] + "... skipped (pre-condition SQL not satisfied)") continue @@ -418,7 +438,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): fp = open(output_file, "r") # Used rstrip to remove trailing \n sql = fp.read().rstrip() - sql = self.preprocess_expected_sql(scenario, sql, resp_sql) + sql = self.preprocess_expected_sql(scenario, sql, resp_sql, + object_id) try: self.assertEquals(sql, resp_sql) except Exception as e: @@ -472,7 +493,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): fp = open(output_file, "r") # Used rstrip to remove trailing \n sql = fp.read().rstrip() - sql = self.preprocess_expected_sql(scenario, sql, resp_sql) + sql = self.preprocess_expected_sql(scenario, sql, resp_sql, + object_id) try: self.assertEquals(sql, resp_sql) except Exception as e: @@ -488,7 +510,8 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): return False elif 'expected_sql' in scenario: exp_sql = scenario['expected_sql'] - exp_sql = self.preprocess_expected_sql(scenario, exp_sql, resp_sql) + exp_sql = self.preprocess_expected_sql(scenario, exp_sql, resp_sql, + object_id) try: self.assertEquals(exp_sql, resp_sql) except Exception as e: @@ -498,15 +521,19 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): return True - def check_precondition(self, precondition_sql): + def check_precondition(self, precondition_sql, use_test_config_db_conn): """ This method executes precondition_sql and returns appropriate result :param precondition_sql: SQL query in format select count(*) from ... :return: True/False depending on precondition_sql result """ precondition_flag = False - self.get_db_connection() - pg_cursor = self.connection.cursor() + if not use_test_config_db_conn: + self.get_db_connection() + pg_cursor = self.connection.cursor() + else: + pg_cursor = self.test_config_db_conn.cursor() + try: pg_cursor.execute(precondition_sql) precondition_result = pg_cursor.fetchone() @@ -624,7 +651,7 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): return data - def preprocess_expected_sql(self, scenario, sql, resp_sql): + def preprocess_expected_sql(self, scenario, sql, resp_sql, object_id): """ This function preprocesses expected sql before comparing it with response sql. @@ -654,6 +681,12 @@ class ReverseEngineeredSQLTestCases(BaseTestGenerator): sql = sql.replace(self.JSON_PLACEHOLDERS['password'], password) + # Replace place holder <owner> with the current username + # used to connect to the database + if 'pga_job_id' in scenario: + sql = sql.replace(self.JSON_PLACEHOLDERS['pga_job_id'], + str(object_id)) + return sql def replace_placeholder_with_id(self, value):