Produced by Araxis Merge on 10/3/2017 11:16:04 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\utils\error-processing | error-processing-algorithm-spec.js | Mon Jul 10 17:46:22 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\unittests\utils\error-processing | error-processing-algorithm-spec.js | Tue Oct 3 13:23:09 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1158 |
| Changed | 1 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | require('. ./../../.. /env-setup '); | |
| 4 | ||
| 5 | var logger = require (global.VX _DUMMIES + 'dummy-lo gger'); | |
| 6 | // NOTE: b e sure nex t line is commented out before pushing | |
| 7 | // log = r equire('bu nyan').cre ateLogger( { | |
| 8 | // nam e: 'poller -utils-spe c', | |
| 9 | // lev el: 'debug ' | |
| 10 | // }); | |
| 11 | ||
| 12 | var errorP rocessingA pi = requi re(global. VX_UTILS + 'error-pr ocessing/e rror-proce ssing-api' ); | |
| 13 | var errorP rocessingA lgorithm = require(g lobal.VX_U TILS + 'er ror-proces sing/error -processin g-algorith m'); | |
| 14 | var JdsCli entDummy = require(g lobal.VX_D UMMIES + ' jds-client -dummy'); | |
| 15 | var Publis herRouter = require( global.VX_ JOBFRAMEWO RK).Publis herRouter; | |
| 16 | ||
| 17 | var enviro nment = {m etrics: {} , jobStatu sUpdater: {}}; | |
| 18 | ||
| 19 | var config = { | |
| 20 | jds: { | |
| 21 | pr otocol: 'h ttp', | |
| 22 | host: ' IP ', | |
| 23 | port: PORT | |
| 24 | }, | |
| 25 | vxsync Environmen ts: { | |
| 26 | 'v xsync-unit -test': { | |
| 27 | vxsync: { | |
| 28 | bean stalk: { | |
| 29 | jobTypes: { | |
| 30 | 'unit- test': {} | |
| 31 | } | |
| 32 | } | |
| 33 | } | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | }; | |
| 38 | ||
| 39 | describe(' error-proc essing-alg orithm', f unction() { | |
| 40 | ||
| 41 | descri be('delete Lock', fun ction() { | |
| 42 | va r context, called; | |
| 43 | ||
| 44 | va r errorRec ord = {uid : '1'}; | |
| 45 | ||
| 46 | be foreEach(f unction() { | |
| 47 | environm ent.jds = new JdsCli entDummy(l ogger, con fig); | |
| 48 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 49 | ||
| 50 | called = false; | |
| 51 | }) ; | |
| 52 | ||
| 53 | it ('error un locking re cord', fun ction() { | |
| 54 | environm ent.jds._s etResponse Data(['Con nection Er ror'], [nu ll], null) ; | |
| 55 | ||
| 56 | runs(fun ction() { | |
| 57 | erro rProcessin gAlgorithm ._deleteLo ck(context , errorRec ord, funct ion(error) { | |
| 58 | expect(err or).toBeTr uthy(); | |
| 59 | ||
| 60 | called = t rue; | |
| 61 | }); | |
| 62 | }); | |
| 63 | ||
| 64 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 65 | }) ; | |
| 66 | ||
| 67 | it ('jds erro r unlockin g record', function( ) { | |
| 68 | environm ent.jds._s etResponse Data([null ], [{statu sCode: 500 }], {error : 'error'} ); | |
| 69 | ||
| 70 | runs(fun ction() { | |
| 71 | erro rProcessin gAlgorithm ._deleteLo ck(context , errorRec ord, funct ion(error) { | |
| 72 | expect(err or).toBeTr uthy(); | |
| 73 | ||
| 74 | called = t rue; | |
| 75 | }); | |
| 76 | }); | |
| 77 | ||
| 78 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 79 | }) ; | |
| 80 | ||
| 81 | it ('unlockin g record s uccessful' , function () { | |
| 82 | environm ent.jds._s etResponse Data([null ], [{statu sCode: 200 }], [null] ); | |
| 83 | ||
| 84 | runs(fun ction() { | |
| 85 | erro rProcessin gAlgorithm ._deleteLo ck(context , errorRec ord, funct ion(error) { | |
| 86 | expect(err or).toBeFa lsy(); | |
| 87 | ||
| 88 | called = t rue; | |
| 89 | }); | |
| 90 | }); | |
| 91 | ||
| 92 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 93 | }) ; | |
| 94 | }); | |
| 95 | ||
| 96 | descri be('delete ErrorJob', function( ) { | |
| 97 | va r context, called; | |
| 98 | ||
| 99 | va r errorRec ord = {uid : '1'}; | |
| 100 | ||
| 101 | be foreEach(f unction() { | |
| 102 | environm ent.jds = new JdsCli entDummy(l ogger, con fig); | |
| 103 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 104 | ||
| 105 | called = false; | |
| 106 | }) ; | |
| 107 | ||
| 108 | it ('error de leting err or record' , function () { | |
| 109 | environm ent.jds._s etResponse Data(['Con nection Er ror'], [nu ll], null) ; | |
| 110 | ||
| 111 | runs(fun ction() { | |
| 112 | erro rProcessin gAlgorithm ._deleteEr rorJob(con text, erro rRecord, f unction(er ror) { | |
| 113 | expect(err or).toBeTr uthy(); | |
| 114 | ||
| 115 | called = t rue; | |
| 116 | }); | |
| 117 | }); | |
| 118 | ||
| 119 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 120 | }) ; | |
| 121 | ||
| 122 | it ('jds erro r deleting error rec ord', func tion() { | |
| 123 | environm ent.jds._s etResponse Data([null ], [{statu sCode: 500 }], {error : 'error'} ); | |
| 124 | ||
| 125 | runs(fun ction() { | |
| 126 | erro rProcessin gAlgorithm ._deleteEr rorJob(con text, erro rRecord, f unction(er ror) { | |
| 127 | expect(err or).toBeTr uthy(); | |
| 128 | ||
| 129 | called = t rue; | |
| 130 | }); | |
| 131 | }); | |
| 132 | ||
| 133 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 134 | }) ; | |
| 135 | ||
| 136 | it ('unlockin g record s uccessful' , function () { | |
| 137 | environm ent.jds._s etResponse Data([null ], [{statu sCode: 200 }], [null] ); | |
| 138 | ||
| 139 | runs(fun ction() { | |
| 140 | erro rProcessin gAlgorithm ._deleteEr rorJob(con text, erro rRecord, f unction(er ror) { | |
| 141 | expect(err or).toBeFa lsy(); | |
| 142 | ||
| 143 | called = t rue; | |
| 144 | }); | |
| 145 | }); | |
| 146 | ||
| 147 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 148 | }) ; | |
| 149 | }); | |
| 150 | ||
| 151 | descri be('getPub lishConfig uration', function() { | |
| 152 | va r context; | |
| 153 | ||
| 154 | va r errorRec ord = { | |
| 155 | uid: '1' , | |
| 156 | jobType: 'unit-tes t', | |
| 157 | vxsyncEn vironmentN ame: 'vxsy nc-unit-te st' | |
| 158 | }; | |
| 159 | ||
| 160 | be foreEach(f unction() { | |
| 161 | var conf igCopy = J SON.parse( JSON.strin gify(confi g)); | |
| 162 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , configCo py, enviro nment, {}) ; | |
| 163 | }) ; | |
| 164 | ||
| 165 | it ('vxsyncEn vironments not found in config ', functio n() { | |
| 166 | context. config.vxs yncEnviron ments = un defined; | |
| 167 | ||
| 168 | expect(f unction() { errorPro cessingAlg orithm._ge tPublishCo nfiguratio n(context, errorReco rd); }).to Throw(); | |
| 169 | }) ; | |
| 170 | ||
| 171 | it ('vxsyncEn vironmentN ame not fo und on job ', functio n() { | |
| 172 | var conf igErrorRec ord = JSON .parse(JSO N.stringif y(errorRec ord)); | |
| 173 | configEr rorRecord. vxsyncEnvi ronmentNam e = undefi ned; | |
| 174 | ||
| 175 | expect(f unction() { errorPro cessingAlg orithm._ge tPublishCo nfiguratio n(context, configErr orRecord); }).toThro w(); | |
| 176 | }) ; | |
| 177 | ||
| 178 | it ('config d eep copy f ailed', fu nction() { | |
| 179 | context. config.vxs yncEnviron ments = '\ "\"fsdfs\" '; | |
| 180 | ||
| 181 | expect(f unction() { errorPro cessingAlg orithm._ge tPublishCo nfiguratio n(context, errorReco rd); }).to Throw(); | |
| 182 | ||
| 183 | }) ; | |
| 184 | ||
| 185 | it ('job vxsy nc environ ment not f ound in co nfig', fun ction() { | |
| 186 | var conf igErrorRec ord = JSON .parse(JSO N.stringif y(errorRec ord)); | |
| 187 | configEr rorRecord. vxsyncEnvi ronmentNam e = 'unit- test'; | |
| 188 | ||
| 189 | expect(f unction() { errorPro cessingAlg orithm._ge tPublishCo nfiguratio n(context, configErr orRecord); }).toThro w(); | |
| 190 | }) ; | |
| 191 | ||
| 192 | it ('job type not found in enviro nment conf ig', funct ion() { | |
| 193 | var conf igErrorRec ord = JSON .parse(JSO N.stringif y(errorRec ord)); | |
| 194 | configEr rorRecord. jobType = 'failed-te st'; | |
| 195 | ||
| 196 | expect(f unction() { errorPro cessingAlg orithm._ge tPublishCo nfiguratio n(context, configErr orRecord); }).toThro w(); | |
| 197 | }) ; | |
| 198 | ||
| 199 | it ('returns valid conf ig for job ', functio n() { | |
| 200 | var publ ishConfig = errorPro cessingAlg orithm._ge tPublishCo nfiguratio n(context, errorReco rd); | |
| 201 | ||
| 202 | expect(p ublishConf ig.beansta lk.jobType s['unit-te st']).toBe Defined(); | |
| 203 | }) ; | |
| 204 | }); | |
| 205 | ||
| 206 | descri be('increm entRetryCo unt', func tion() { | |
| 207 | it ('job retr yCount not defined', function( ) { | |
| 208 | var erro rRecord = {job: {}}; | |
| 209 | ||
| 210 | errorPro cessingAlg orithm._in crementRet ryCount(er rorRecord) ; | |
| 211 | expect(e rrorRecord .job.retry Count).toB e(1); | |
| 212 | }) ; | |
| 213 | ||
| 214 | it ('job retr yCount exi sts', func tion() { | |
| 215 | var erro rRecord = {job: {ret ryCount: 4 }}; | |
| 216 | ||
| 217 | errorPro cessingAlg orithm._in crementRet ryCount(er rorRecord) ; | |
| 218 | expect(e rrorRecord .job.retry Count).toB e(5); | |
| 219 | }) ; | |
| 220 | }); | |
| 221 | ||
| 222 | descri be('publis hErrorJob' , function () { | |
| 223 | va r context, called, e rrorRecord , publishS py; | |
| 224 | ||
| 225 | be foreEach(f unction() { | |
| 226 | errorRec ord = {uid : '1'}; | |
| 227 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 228 | ||
| 229 | called = false; | |
| 230 | ||
| 231 | publishS py = spyOn (Publisher Router.pro totype, 'p ublish').a ndCallFake (function( job, callb ack) { | |
| 232 | setT imeout(cal lback, 0, null, 'suc cess'); | |
| 233 | }); | |
| 234 | }) ; | |
| 235 | ||
| 236 | it ('do not p ublish if the error record is not a job error', fu nction() { | |
| 237 | runs(fun ction() { | |
| 238 | erro rProcessin gAlgorithm ._publishE rrorJob(co ntext, err orRecord, function(e rror, resu lts) { | |
| 239 | expect(err or).toBeFa lsy(); | |
| 240 | expect(res ults).toBe Falsy(); | |
| 241 | ||
| 242 | expect(pub lishSpy).n ot.toHaveB eenCalled( ); | |
| 243 | ||
| 244 | called = t rue; | |
| 245 | }); | |
| 246 | }); | |
| 247 | ||
| 248 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 249 | }) ; | |
| 250 | ||
| 251 | it ('do not p ublish if the delete Only flag is true in the proce ssing cont ext', func tion() { | |
| 252 | context. deleteOnly = true; | |
| 253 | ||
| 254 | runs(fun ction() { | |
| 255 | erro rProcessin gAlgorithm ._publishE rrorJob(co ntext, err orRecord, function(e rror, resu lts) { | |
| 256 | expect(err or).toBeFa lsy(); | |
| 257 | expect(res ults).toBe Falsy(); | |
| 258 | ||
| 259 | expect(pub lishSpy).n ot.toHaveB eenCalled( ); | |
| 260 | ||
| 261 | called = t rue; | |
| 262 | }); | |
| 263 | }); | |
| 264 | ||
| 265 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 266 | }) ; | |
| 267 | ||
| 268 | it ('error th rown tryin g to get p ublisher c onfigurati on', funct ion() { | |
| 269 | errorRec ord.job = {}; | |
| 270 | ||
| 271 | runs(fun ction() { | |
| 272 | erro rProcessin gAlgorithm ._publishE rrorJob(co ntext, err orRecord, function(e rror, resu lts) { | |
| 273 | expect(err or).toBeTr uthy(); | |
| 274 | expect(res ults).toBe Falsy(); | |
| 275 | ||
| 276 | expect(pub lishSpy).n ot.toHaveB eenCalled( ); | |
| 277 | ||
| 278 | called = t rue; | |
| 279 | }); | |
| 280 | }); | |
| 281 | ||
| 282 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 283 | }) ; | |
| 284 | ||
| 285 | it ('successf ully publi shed the j ob from th e error re cord', fun ction() { | |
| 286 | errorRec ord.job = {}; | |
| 287 | errorRec ord.jobTyp e = 'unit- test'; | |
| 288 | errorRec ord.vxsync Environmen tName = 'v xsync-unit -test'; | |
| 289 | ||
| 290 | runs(fun ction() { | |
| 291 | erro rProcessin gAlgorithm ._publishE rrorJob(co ntext, err orRecord, function(e rror, resu lts) { | |
| 292 | expect(err or).toBeFa lsy(); | |
| 293 | expect(res ults).toBe Falsy(); | |
| 294 | ||
| 295 | expect(pub lishSpy).t oHaveBeenC alled(); | |
| 296 | ||
| 297 | called = t rue; | |
| 298 | }); | |
| 299 | }); | |
| 300 | ||
| 301 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 302 | }) ; | |
| 303 | }); | |
| 304 | ||
| 305 | descri be('lockEr rorJob', f unction() { | |
| 306 | va r context, called; | |
| 307 | ||
| 308 | va r errorRec ord = {uid : '1'}; | |
| 309 | ||
| 310 | be foreEach(f unction() { | |
| 311 | environm ent.jds = new JdsCli entDummy(l ogger, con fig); | |
| 312 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 313 | ||
| 314 | called = false; | |
| 315 | }) ; | |
| 316 | ||
| 317 | it ('error lo cking reco rd', funct ion() { | |
| 318 | environm ent.jds._s etResponse Data(['Con nection Er ror'], [nu ll], null) ; | |
| 319 | ||
| 320 | runs(fun ction() { | |
| 321 | erro rProcessin gAlgorithm ._lockErro rJob(conte xt, errorR ecord, fun ction(erro r, results ) { | |
| 322 | expect(err or).toBeTr uthy(); | |
| 323 | expect(res ults).toBe Falsy(); | |
| 324 | ||
| 325 | called = t rue; | |
| 326 | }); | |
| 327 | }); | |
| 328 | ||
| 329 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 330 | }) ; | |
| 331 | ||
| 332 | it ('jds erro r locking record', f unction() { | |
| 333 | environm ent.jds._s etResponse Data([ | |
| 334 | {typ e:'transie nt-excepti on',messag e:'{\\\"er ror\\\":{\ \\"code\\\ ":500,\\\" errors\\\" :[{\\\"mes sage\\\":\ \\"Record already lo cked\\\",\ \\"reason\ \\":272}], \\\"messag e\\\":\\\" Bad Reques t\\\",\\\" request\\\ ":\\\"PUT \\\\/vxsyn cerr\\\\/l ock\\\\/ur n:va:vxsyn cerr:TEST5 \\\"}}\"} ' | |
| 335 | }], [{statusCo de: 500}], [null]); | |
| 336 | ||
| 337 | runs(fun ction() { | |
| 338 | erro rProcessin gAlgorithm ._lockErro rJob(conte xt, errorR ecord, fun ction(erro r, results ) { | |
| 339 | expect(err or).toBeTr uthy(); | |
| 340 | expect(err or).toBe(' SKIP'); | |
| 341 | expect(res ults).toBe Falsy(); | |
| 342 | ||
| 343 | called = t rue; | |
| 344 | }); | |
| 345 | }); | |
| 346 | ||
| 347 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 348 | }) ; | |
| 349 | ||
| 350 | it ('locking record suc cessful', function() { | |
| 351 | environm ent.jds._s etResponse Data([null ], [{statu sCode: 201 }], [null] ); | |
| 352 | ||
| 353 | runs(fun ction() { | |
| 354 | erro rProcessin gAlgorithm ._lockErro rJob(conte xt, errorR ecord, fun ction(erro r) { | |
| 355 | expect(err or).toBeFa lsy(); | |
| 356 | ||
| 357 | called = t rue; | |
| 358 | }); | |
| 359 | }); | |
| 360 | ||
| 361 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 362 | }) ; | |
| 363 | }); | |
| 364 | ||
| 365 | descri be('maxRet riesReache d', functi on() { | |
| 366 | va r context, errorReco rd; | |
| 367 | ||
| 368 | be foreEach(f unction() { | |
| 369 | errorRec ord = {uid : '1'}; | |
| 370 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 371 | }) ; | |
| 372 | ||
| 373 | it ('max retr ies ignore d because ignoreRetr y flag is true in pr ocessing c ontext', f unction() { | |
| 374 | context. ignoreRetr y = true; | |
| 375 | ||
| 376 | expect(e rrorProces singAlgori thm._maxRe triesReach ed(context , errorRec ord)).toBe (false); | |
| 377 | }) ; | |
| 378 | ||
| 379 | it ('use defa ult max re tries of 3 if errorR etryLimit not found in config' , function () { | |
| 380 | errorRec ord.job = {retryCoun t: 3}; | |
| 381 | ||
| 382 | expect(e rrorProces singAlgori thm._maxRe triesReach ed(context , errorRec ord)).toBe (true); | |
| 383 | }) ; | |
| 384 | ||
| 385 | it ('retry co unt is zer o if the e rror recor d job does not have a retryCou nt propert y', functi on() { | |
| 386 | expect(e rrorProces singAlgori thm._maxRe triesReach ed(context , errorRec ord)).toBe (false); | |
| 387 | }) ; | |
| 388 | ||
| 389 | it ('retry co unt has re ached the maximum', function() { | |
| 390 | errorRec ord.job = {retryCoun t: 4}; | |
| 391 | ||
| 392 | expect(e rrorProces singAlgori thm._maxRe triesReach ed(context , errorRec ord)).toBe (true); | |
| 393 | }) ; | |
| 394 | ||
| 395 | it ('retry co unt has NO T reached the maximu m', functi on() { | |
| 396 | errorRec ord.job = {retryCoun t: 2}; | |
| 397 | ||
| 398 | expect(e rrorProces singAlgori thm._maxRe triesReach ed(context , errorRec ord)).toBe (false); | |
| 399 | }) ; | |
| 400 | }); | |
| 401 | ||
| 402 | descri be('proces sErrorReco rd', funct ion() { | |
| 403 | va r context, called, e rrorRecord , publishS py; | |
| 404 | ||
| 405 | be foreEach(f unction() { | |
| 406 | environm ent.jds = new JdsCli entDummy(l ogger, con fig); | |
| 407 | errorRec ord = {uid : '1'}; | |
| 408 | ||
| 409 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 410 | ||
| 411 | called = false; | |
| 412 | ||
| 413 | publishS py = spyOn (Publisher Router.pro totype, 'p ublish').a ndCallFake (function( job, callb ack) { | |
| 414 | setT imeout(cal lback, 0, null, 'suc cess'); | |
| 415 | }); | |
| 416 | }) ; | |
| 417 | ||
| 418 | it ('max retr ies reache d for erro r record', function( ) { | |
| 419 | errorRec ord.job = {retryCoun t: 4}; | |
| 420 | ||
| 421 | runs(fun ction() { | |
| 422 | erro rProcessin gAlgorithm ._processE rrorRecord (context, errorRecor d, functio n() { | |
| 423 | expect(con text.error s.length). toBe(0); | |
| 424 | expect(con text.resul ts.length) .toBe(1); | |
| 425 | expect(con text.resul ts[0]).toB e('Success fully proc essed erro r record 1 with stat us: Max re tries reac hed.'); | |
| 426 | ||
| 427 | expect(pub lishSpy).n ot.toHaveB eenCalled( ); | |
| 428 | ||
| 429 | called = t rue; | |
| 430 | }); | |
| 431 | }); | |
| 432 | ||
| 433 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 434 | }) ; | |
| 435 | ||
| 436 | it ('keepReco rd flag is true duri ng error p rocess the n unlock r ecord inst ead of del eting it', function( ) { | |
| 437 | spyOn(co ntext.jdsC lient, 'de leteErrorR ecordByUid '); | |
| 438 | spyOn(co ntext.jdsC lient, 'un lockErrorR ecord').an dCallThrou gh(); | |
| 439 | ||
| 440 | environm ent.jds._s etResponse Data( | |
| 441 | [nul l, null], | |
| 442 | [{st atusCode: 201}, {sta tusCode: 2 00}], | |
| 443 | [nul l, null]); | |
| 444 | ||
| 445 | errorRec ord.job = {}; | |
| 446 | errorRec ord.jobTyp e = 'unit- test'; | |
| 447 | errorRec ord.vxsync Environmen tName = 'v xsync-unit -test'; | |
| 448 | ||
| 449 | context. keepRecord = true; | |
| 450 | ||
| 451 | runs(fun ction() { | |
| 452 | erro rProcessin gAlgorithm ._processE rrorRecord (context, errorRecor d, functio n(error, r esults) { | |
| 453 | expect(err or).toBeFa lsy(); | |
| 454 | expect(res ults).toBe Falsy(); | |
| 455 | ||
| 456 | expect(con text.jdsCl ient.unloc kErrorReco rd).toHave BeenCalled (); | |
| 457 | expect(con text.jdsCl ient.delet eErrorReco rdByUid).n ot.toHaveB eenCalled( ); | |
| 458 | ||
| 459 | called = t rue; | |
| 460 | }); | |
| 461 | }); | |
| 462 | ||
| 463 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 464 | }) ; | |
| 465 | ||
| 466 | it ('an error occurred locking er ror record during re cord proce ssing', fu nction() { | |
| 467 | environm ent.jds._s etResponse Data( | |
| 468 | ['Co nnection E rror', nul l], | |
| 469 | [nul l, {status Code: 200} ], | |
| 470 | [nul l, null]); | |
| 471 | ||
| 472 | errorRec ord.job = {retryCoun t: 1}; | |
| 473 | ||
| 474 | runs(fun ction() { | |
| 475 | erro rProcessin gAlgorithm ._processE rrorRecord (context, errorRecor d, functio n() { | |
| 476 | expect(con text.error s.length). toBe(1); | |
| 477 | expect(con text.error s[0]).toBe ('Error pr ocessing r ecord 1 wi th error: "Connectio n Error"') ; | |
| 478 | expect(con text.resul ts.length) .toBe(0); | |
| 479 | ||
| 480 | expect(pub lishSpy).n ot.toHaveB eenCalled( ); | |
| 481 | ||
| 482 | called = t rue; | |
| 483 | }); | |
| 484 | }); | |
| 485 | ||
| 486 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 487 | }) ; | |
| 488 | ||
| 489 | it ('the erro r record i s being pr ocessed by another p rocess so it is skip ped', func tion() { | |
| 490 | environm ent.jds._s etResponse Data( | |
| 491 | [{ty pe:'transi ent-except ion',messa ge:'{\\\"e rror\\\":{ \\\"code\\ \":500,\\\ "errors\\\ ":[{\\\"me ssage\\\": \\\"Record already l ocked\\\", \\\"reason \\\":272}] ,\\\"messa ge\\\":\\\ "Bad Reque st\\\",\\\ "request\\ \":\\\"PUT \\\\/vxsy ncerr\\\\/ lock\\\\/u rn:va:vxsy ncerr:TEST 5 \\\"}}\" }' | |
| 492 | }, n ull], | |
| 493 | [{st atusCode: 500}, {sta tusCode: 2 00}], | |
| 494 | [nul l, null]); | |
| 495 | ||
| 496 | errorRec ord.job = {retryCoun t: 1}; | |
| 497 | ||
| 498 | runs(fun ction() { | |
| 499 | erro rProcessin gAlgorithm ._processE rrorRecord (context, errorRecor d, functio n() { | |
| 500 | expect(con text.error s.length). toBe(0); | |
| 501 | expect(con text.resul ts.length) .toBe(1); | |
| 502 | expect(con text.resul ts[0]).toB e('Success fully proc essed erro r record 1 with stat us: Skippe d.'); | |
| 503 | ||
| 504 | expect(pub lishSpy).n ot.toHaveB eenCalled( ); | |
| 505 | ||
| 506 | called = t rue; | |
| 507 | }); | |
| 508 | }); | |
| 509 | ||
| 510 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 511 | }) ; | |
| 512 | ||
| 513 | it ('the erro r record w as success fully proc essed', fu nction() { | |
| 514 | environm ent.jds._s etResponse Data( | |
| 515 | [nul l, null], | |
| 516 | [{st atusCode: 201}, {sta tusCode: 2 00}], | |
| 517 | [nul l, null]); | |
| 518 | ||
| 519 | errorRec ord.job = {}; | |
| 520 | errorRec ord.jobTyp e = 'unit- test'; | |
| 521 | errorRec ord.vxsync Environmen tName = 'v xsync-unit -test'; | |
| 522 | ||
| 523 | runs(fun ction() { | |
| 524 | erro rProcessin gAlgorithm ._processE rrorRecord (context, errorRecor d, functio n() { | |
| 525 | expect(con text.error s.length). toBe(0); | |
| 526 | expect(con text.resul ts.length) .toBe(1); | |
| 527 | expect(con text.resul ts[0]).toB e('Success fully proc essed erro r record 1 with stat us: Proces sing compl ete.'); | |
| 528 | ||
| 529 | expect(pub lishSpy).t oHaveBeenC alled(); | |
| 530 | ||
| 531 | called = t rue; | |
| 532 | }); | |
| 533 | }); | |
| 534 | ||
| 535 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 536 | }) ; | |
| 537 | }); | |
| 538 | ||
| 539 | descri be('proces sErrorReco rds', func tion() { | |
| 540 | va r context, called, e rrorRecord , publishS py; | |
| 541 | ||
| 542 | be foreEach(f unction() { | |
| 543 | environm ent.jds = new JdsCli entDummy(l ogger, con fig); | |
| 544 | errorRec ord = {uid : '1'}; | |
| 545 | ||
| 546 | context = errorPro cessingApi .ErrorProc essingCont ext(logger , config, environmen t, {}); | |
| 547 | ||
| 548 | called = false; | |
| 549 | ||
| 550 | publishS py = spyOn (Publisher Router.pro totype, 'p ublish').a ndCallFake (function( job, callb ack) { | |
| 551 | setT imeout(cal lback, 0, null, 'suc cess'); | |
| 552 | }); | |
| 553 | }) ; | |
| 554 | ||
| 555 | it ('error re cord proce ssing comp leted succ essfully', function( ) { | |
| 556 | environm ent.jds._s etResponse Data( | |
| 557 | [nul l, null], | |
| 558 | [{st atusCode: 201}, {sta tusCode: 2 00}], | |
| 559 | [nul l, null]); | |
| 560 | ||
| 561 | errorRec ord.job = {}; | |
| 562 | errorRec ord.jobTyp e = 'unit- test'; | |
| 563 | errorRec ord.vxsync Environmen tName = 'v xsync-unit -test'; | |
| 564 | ||
| 565 | runs(fun ction() { | |
| 566 | erro rProcessin gAlgorithm ._processE rrorRecord s([errorRe cord], con text, func tion() { | |
| 567 | expect(con text.error s.length). toBe(0); | |
| 568 | expect(con text.resul ts.length) .toBe(1); | |
| 569 | expect(con text.resul ts[0]).toB e('Success fully proc essed erro r record 1 with stat us: Proces sing compl ete.'); | |
| 570 | ||
| 571 | expect(pub lishSpy).t oHaveBeenC alled(); | |
| 572 | ||
| 573 | called = t rue; | |
| 574 | }); | |
| 575 | }); | |
| 576 | ||
| 577 | waitsFor (function( ) {return called;}, 'should be called', 500); | |
| 578 | ||
| 579 | }) ; | |
| 580 | }); | |
| 581 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.