Produced by Araxis Merge on 10/3/2017 11:16:05 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\utils | operational-sync-spec.js | Tue Jul 25 21:22:00 2017 UTC |
| 2 | ehmp.zip\ehmp\ehmp\product\production\vx-sync\tests\utils | operational-sync-spec.js | Tue Oct 3 13:35:31 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 280 |
| 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-s etup'); | |
| 4 | ||
| 5 | var format = require ('util').f ormat; | |
| 6 | var _ = re quire('und erscore'); | |
| 7 | var async = require( 'async'); | |
| 8 | ||
| 9 | var reques t = requir e('request '); | |
| 10 | ||
| 11 | var siteLi st = proce ss.env.VXS YNC_SITELI ST || ('9E 7A,C877'); | |
| 12 | var timeou tSecs = Nu mber(proce ss.env.VXS YNC_OPD_TI MEOUT_SECS ) || 900; | |
| 13 | var host = process.e nv.JDS_IP || ' IP '; | |
| 14 | var port = Number(pr ocess.env. JDS_PORT) || PORT ; | |
| 15 | var protoc ol = proce ss.env.JDS _PROTOCOL || 'http'; | |
| 16 | ||
| 17 | describe(' Wait for O perational Data Sync hronizatio n', functi on() { | |
| 18 | it ('Verify " patient" e nvironment variable is set to pid or icn ', functio n() { | |
| 19 | expe ct(siteLis t).toBeDef ined(); | |
| 20 | }) ; | |
| 21 | ||
| 22 | it ('Verify " timeoutSec s" is a va lid positi ve number less than 3600', fun ction() { | |
| 23 | expe ct(timeout Secs).toEq ual(jasmin e.any(Numb er)); | |
| 24 | expe ct(timeout Secs).toBe GreaterTha n(0); | |
| 25 | expe ct(timeout Secs).toBe LessThan(3 600); | |
| 26 | }) ; | |
| 27 | ||
| 28 | it ('Verify " port" is a valid pos itive numb er less th an 65536', function( ) { | |
| 29 | expe ct(port).t oEqual(jas mine.any(N umber)); | |
| 30 | expe ct(port).t oBeGreater Than(0); | |
| 31 | expe ct(port).t oBeLessTha n(65536); | |
| 32 | }) ; | |
| 33 | ||
| 34 | it ('Verify " protocol" is "http" or "https" ', functio n() { | |
| 35 | expe ct(protoco l).toMatch (/^http[s] ?$/); | |
| 36 | }) ; | |
| 37 | ||
| 38 | it ('Verify o perational data succ essfully s ynchronize d on ' + h ost + ':' + port + ' within ' + timeoutS ecs + ' se conds for Sites: ' + siteList, function( ) { | |
| 39 | var expectedEr ror; | |
| 40 | var expectedRe sult; | |
| 41 | var syncCheckC alled; | |
| 42 | ||
| 43 | isOp erationalD ataSynchro nized(site List, func tion(error , result) { | |
| 44 | expect edError = error; | |
| 45 | expect edResult = result; | |
| 46 | syncCh eckCalled = true; | |
| 47 | }); | |
| 48 | ||
| 49 | wait sFor(funct ion() { | |
| 50 | return syncCheck Called; | |
| 51 | }, f ormat('syn chronizati on to comp lete for S ites "%s" at %s:%s', siteList, host, por t), timeou tSecs * 10 00); | |
| 52 | ||
| 53 | runs (function( ) { | |
| 54 | expect (expectedE rror).toBe Null(); | |
| 55 | }); | |
| 56 | }) ; | |
| 57 | ||
| 58 | fu nction isO perational DataSynchr onized(sit eList, cal lback) { | |
| 59 | if ( !siteList) { | |
| 60 | return setTimeou t(callback , 0, 'No v alue for s iteList'); | |
| 61 | } | |
| 62 | ||
| 63 | var sites = _. map(_.filt er(siteLis t.split(', '), functi on(site) { | |
| 64 | return site.trim ().length > 0; | |
| 65 | }), function(s ite) { | |
| 66 | return site.trim (); | |
| 67 | }); | |
| 68 | ||
| 69 | if ( _.isEmpty( sites)) { | |
| 70 | return setTimeou t(callback , 0, 'No s ites'); | |
| 71 | } | |
| 72 | ||
| 73 | // N ote: IIFE | |
| 74 | (fun ction fetc hStatus() { | |
| 75 | async. map(sites, fetchSing leSiteStat us, functi on(error, results) { | |
| 76 | if (erro r) { | |
| 77 | return cal lback(erro r); | |
| 78 | } | |
| 79 | ||
| 80 | if (_.is Empty(resu lts)) { | |
| 81 | return cal lback('No results re turned whe n fetching operation al sync st atus'); | |
| 82 | } | |
| 83 | ||
| 84 | var isCo mplete = _ .every(res ults, func tion(siteS tatus) { | |
| 85 | return isS iteStatusC omplete(si teStatus); | |
| 86 | }); | |
| 87 | ||
| 88 | if (isCo mplete) { | |
| 89 | return cal lback(null , 'Operati onal data sync compl ete'); | |
| 90 | } | |
| 91 | ||
| 92 | return s etTimeout( fetchStatu s, 500); | |
| 93 | }); | |
| 94 | })() ; | |
| 95 | ||
| 96 | func tion isSit eStatusCom plete(stat us) { | |
| 97 | if (!s tatus.comp letedStamp ) { | |
| 98 | return f alse; | |
| 99 | } | |
| 100 | ||
| 101 | if (st atus.error ) { | |
| 102 | return f alse; | |
| 103 | } | |
| 104 | ||
| 105 | if (_. isEmpty(st atus)) { | |
| 106 | return f alse; | |
| 107 | } | |
| 108 | ||
| 109 | if (st atus.inPro gress) { | |
| 110 | return f alse; | |
| 111 | } | |
| 112 | ||
| 113 | return true; | |
| 114 | } | |
| 115 | ||
| 116 | func tion fetch SingleSite Status(sit e, callbac k) { | |
| 117 | var ur l = protoc ol + '://' + host + ':' + port + '/statu sod/' + si te; | |
| 118 | var op tions = { | |
| 119 | url: url , | |
| 120 | timeout: 60000 | |
| 121 | }; | |
| 122 | ||
| 123 | reques t(options, function( error, res ponse, bod y) { | |
| 124 | if (erro r) { | |
| 125 | return cal lback(null , format(' Warning: E rror attem pting to g et site op erational sync statu s at: %s - > %j', url , error)); | |
| 126 | } | |
| 127 | ||
| 128 | if (!_.c ontains([2 00, 404], response.s tatusCode) ) { | |
| 129 | return cal lback(null , format(' Warning: E rror attem pting to g et site op erational sync statu s: %s code : %s -> %s ', url, re sponse.sta tusCode, b ody)); | |
| 130 | } | |
| 131 | ||
| 132 | try { | |
| 133 | body = JSO N.parse(bo dy); | |
| 134 | } catch (error) { | |
| 135 | return cal lback(null , format(' Warning: E rror parsi ng operati onal sync status for site at: %s -> %s', url, body )); | |
| 136 | } | |
| 137 | ||
| 138 | return c allback(nu ll, body); | |
| 139 | }); | |
| 140 | } | |
| 141 | } | |
| 142 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.