2. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/3/2017 11:52:35 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.

2.1 Files compared

# Location File Last Modified
1 job-framework.zip\job-framework\tests\unit\publish-strategies publish-multi-tube-strategy-spec.js Wed Nov 16 18:40:08 2016 UTC
2 job-framework.zip\job-framework\tests\unit\publish-strategies publish-multi-tube-strategy-spec.js Tue Oct 3 16:48:45 2017 UTC

2.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 492
Changed 1 2
Inserted 0 0
Removed 0 0

2.3 Comparison options

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

2.4 Active regular expressions

No regular expressions were active.

2.5 Comparison detail

  1   'use stric t';
  2  
  3   var _ = re quire('und erscore');
  4  
  5   var Beanst alkClient  = require( '../../../ src/beanst alk-client ');
  6   var strate gy = requi re('../../ ../src/pub lish-strat egies/publ ish-multi- tube-strat egy');
  7  
  8   var jobSta tusUpdater  = {
  9       create JobStatus:  function( job, callb ack) { ret urn callba ck(); },
  10       comple teJobStatu s: _.noop,
  11       startJ obStatus:  _.noop,
  12       errorJ obStatus:  _.noop
  13   };
  14  
  15   var logger  = {
  16       fields : {
  17           na me: 'dummy -log'
  18       },
  19       child:  function( ) {
  20           re turn this;
  21       },
  22       trace:  function( ) {},
  23       debug:  function( ) {},
  24       info:  function()  {},
  25       warn:  function()  {},
  26       error:  function( ) {},
  27       fatal:  function( ) {},
  28       consol e: {
  29           tr ace: conso le.log,
  30           de bug: conso le.log,
  31           in fo: consol e.log,
  32           wa rn: consol e.log,
  33           er ror: conso le.log,
  34           fa tal: conso le.log
  35       }
  36   };
  37  
  38   describe(' publisher- multi-tube -strategy. js', funct ion() {
  39       descri be('getTub eIndex', f unction()  {
  40           it ('return e xcepted tu be index w hen tube d etails are  not in pr iority ord er ', func tion() {
  41                var bean stalkJobTy peConfig =  {tubeDeta ils: [{pri ority: {st artValue:  51, endVal ue: 100}},  {priority : {startVa lue: 1, en dValue: 50 }}]};
  42  
  43                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 50)) .toBe(2);
  44                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 1)). toBe(2);
  45                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 25)) .toBe(2);
  46                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 80)) .toBe(1);
  47                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 100) ).toBe(1);
  48                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 51)) .toBe(1);
  49           }) ;
  50  
  51           it ('return e xcepted tu be index w hen tube d etails con tain gaps  in priorit y', functi on() {
  52                var bean stalkJobTy peConfig =  {tubeDeta ils: [{pri ority: {st artValue:  10, endVal ue: 20}},  {priority:  {startVal ue: 40, en dValue: 60 }}]};
  53  
  54                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 50)) .toBe(2);
  55                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 1)). toBe(1);
  56                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 21)) .toBe(1);
  57                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 30)) .toBe(1);
  58                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 31)) .toBe(2);
  59                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 51)) .toBe(2);
  60                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 80)) .toBe(2);
  61                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 100) ).toBe(2);
  62           }) ;
  63  
  64           it ('return f irst tube  index when  tube deta ils contai ning overl apping pri orities ',  function( ) {
  65                var bean stalkJobTy peConfig =  {tubeDeta ils: [{pri ority: {st artValue:  1, endValu e: 50}}, { priority:  {startValu e: 40, end Value: 100 }}]};
  66  
  67                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 50)) .toBe(1);
  68           }) ;
  69  
  70           it ('return e xpected tu be index w hen priori ty is out  of expecte d 1 to 100  range', f unction()  {
  71                var bean stalkJobTy peConfig =  {tubeDeta ils: [{pri ority: {st artValue:  1, endValu e: 50}}, { priority:  {startValu e: 40, end Value: 100 }}]};
  72  
  73                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, -100 00)).toBe( 1);
  74                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, -1)) .toBe(1);
  75                expect(s trategy._g etTubeInde x(beanstal kJobTypeCo nfig, 101) ).toBe(2);
  76           }) ;
  77       });
  78  
  79       descri be('getTub eName', fu nction() {
  80           it ('get tube Name for t ubename an d job prio rity when  multiple t ubes are s upported',  function( ) {
  81                var publ isher = {b eanstalkJo bTypeConfi g: {tubena me: 'multi -tube',
  82                    tube Details: [ {priority:  {startVal ue: 1, end Value: 50} }, {priori ty: {start Value: 51,  endValue:  100}}]}};
  83  
  84                expect(s trategy._g etTubeName .call(publ isher, {}) ).toEqual( 'multi-tub e1');
  85                expect(s trategy._g etTubeName .call(publ isher, {pr iority: 10 })).toEqua l('multi-t ube1');
  86                expect(s trategy._g etTubeName .call(publ isher, {pr iority: 60 })).toEqua l('multi-t ube2');
  87                expect(s trategy._g etTubeName .call(publ isher, {pr iority: 0} )).toEqual ('multi-tu be1');
  88                expect(s trategy._g etTubeName .call(publ isher, {pr iority: 10 1})).toEqu al('multi- tube2');
  89           }) ;
  90       });
  91  
  92       descri be('publis h', functi on() {
  93           va r beanstal kClient, p ublisherMo ckInstance , done;
  94           va r options  = {priorit y: 1, dela y: 0, ttr:  120};
  95           va r job = {p riority: 6 0, type: ' multi-tube ', jobId:  1};
  96  
  97           be foreEach(f unction()  {
  98                  beanstalkC lient = Be anstalkCli ent(logger , ' IP        ', 5000);
  99  
  100                publishe rMockInsta nce = {log ger: logge r,
  101                    metr ics: {info : function  () {}},
  102                    clie nt: beanst alkClient,
  103                    queu e: undefin ed,
  104                    isCo nnected: f alse,
  105                    bean stalkJobTy peConfig:  {tubename:  'multi-tu be',
  106                         tubeDetail s: [{prior ity: {star tValue: 1,  endValue:  50}}, {pr iority: {s tartValue:  51, endVa lue: 100}} ]}
  107                };
  108  
  109                publishe rMockInsta nce.connec t = functi on(callbac k) {
  110                    stra tegy.conne ct.call(pu blisherMoc kInstance,  callback) ;
  111                }
  112           }) ;
  113  
  114           it ('job publ ished succ essfully',  function( ) {
  115                strategy  = strateg y.createQu eue(publis herMockIns tance);
  116  
  117                spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) {
  118                    retu rn callbac k();
  119                });
  120                spyOn(be anstalkCli ent, 'use' ).andCallF ake(functi on(tubeNam e, callbac k) {
  121                    retu rn callbac k(null, tu beName);
  122                });
  123                spyOn(be anstalkCli ent, 'put' ).andCallF ake(functi on(priorit y, delay,  ttr, job,  callback)  {
  124                    retu rn callbac k(null, 1) ;
  125                });
  126  
  127                runs(fun ction() {
  128                    done  = false;
  129  
  130                    stra tegy.publi sh.call(pu blisherMoc kInstance,  options,  jobStatusU pdater, jo b, functio n(err, res ult) {
  131                         expect(err ).toBeFals y();
  132                         expect(res ult).toBe( 1);
  133                         done = tru e;
  134                    })
  135                });
  136  
  137                waitsFor (function( ) {return  done;}, 'D one', 1000 );
  138  
  139                runs(fun ction() {
  140                    expe ct(beansta lkClient.c onnect).to HaveBeenCa lled();
  141                    expe ct(beansta lkClient.u se).toHave BeenCalled ();
  142                    expe ct(beansta lkClient.u se.mostRec entCall.ar gs[0]).toB e('multi-t ube2');
  143                    expe ct(beansta lkClient.p ut).toHave BeenCalled ();
  144                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[0]).toB e(1);
  145                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[1]).toB e(0);
  146                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[2]).toB e(120);
  147                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[3]).toE qual(JSON. stringify( job));
  148                });
  149           }) ;
  150  
  151           it ('job not  published  because of  an error  connecting  to beanst alk', func tion() {
  152                strategy  = strateg y.createQu eue(publis herMockIns tance);
  153  
  154                spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) {
  155                    retu rn callbac k('CONNECT ION REFUSE D.');
  156                });
  157                spyOn(be anstalkCli ent, 'use' );
  158                spyOn(be anstalkCli ent, 'put' );
  159  
  160                runs(fun ction() {
  161                    done  = false;
  162  
  163                    stra tegy.publi sh.call(pu blisherMoc kInstance,  options,  jobStatusU pdater, jo b, functio n(err, res ult) {
  164                         expect(err ).toEqual( 'CONNECTIO N REFUSED. ');
  165                         expect(res ult).toBeF alsy();
  166                         done = tru e;
  167                    })
  168                });
  169  
  170                waitsFor (function( ) {return  done;}, 'D one', 100) ;
  171  
  172                runs(fun ction() {
  173                    expe ct(beansta lkClient.c onnect).to HaveBeenCa lled();
  174                    expe ct(beansta lkClient.u se).not.to HaveBeenCa lled();
  175                    expe ct(beansta lkClient.p ut).not.to HaveBeenCa lled();
  176                });
  177           }) ;
  178  
  179           it ('job not  published  because of  an error  selecting  the tube i n beanstal k', functi on() {
  180                strategy  = strateg y.createQu eue(publis herMockIns tance);
  181  
  182                spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) {
  183                    retu rn callbac k();
  184                });
  185                spyOn(be anstalkCli ent, 'use' ).andCallF ake(functi on(tubeNam e, callbac k) {
  186                    retu rn callbac k('INTERNA L ERROR.') ;
  187                });
  188                spyOn(be anstalkCli ent, 'put' );
  189  
  190                runs(fun ction() {
  191                    done  = false;
  192  
  193                    stra tegy.publi sh.call(pu blisherMoc kInstance,  options,  jobStatusU pdater, jo b, functio n(err, res ult) {
  194                         expect(err ).toEqual( 'INTERNAL  ERROR.');
  195                         expect(res ult).toBeF alsy();
  196                         done = tru e;
  197                    })
  198                });
  199  
  200                waitsFor (function( ) {return  done;}, 'D one', 100) ;
  201  
  202                runs(fun ction() {
  203                    expe ct(beansta lkClient.c onnect).to HaveBeenCa lled();
  204                    expe ct(beansta lkClient.u se).toHave BeenCalled ();
  205                    expe ct(beansta lkClient.u se.mostRec entCall.ar gs[0]).toB e('multi-t ube2');
  206                    expe ct(beansta lkClient.p ut).not.to HaveBeenCa lled();
  207                });
  208           }) ;
  209  
  210           it ('job not  published  because of  an error  putting th e job in t he tube on  beanstalk ', functio n() {
  211                strategy  = strateg y.createQu eue(publis herMockIns tance);
  212  
  213                spyOn(be anstalkCli ent, 'conn ect').andC allFake(fu nction(cal lback) {
  214                    retu rn callbac k();
  215                });
  216                spyOn(be anstalkCli ent, 'use' ).andCallF ake(functi on(tubeNam e, callbac k) {
  217                    retu rn callbac k(null, tu beName);
  218                });
  219                spyOn(be anstalkCli ent, 'put' ).andCallF ake(functi on(priorit y, delay,  ttr, job,  callback)  {
  220                    retu rn callbac k('JOB_TOO _BIG');
  221                });
  222  
  223                runs(fun ction() {
  224                    done  = false;
  225  
  226                    stra tegy.publi sh.call(pu blisherMoc kInstance,  options,  jobStatusU pdater, jo b, functio n(err, res ult) {
  227                         expect(err ).toEqual( 'JOB_TOO_B IG');
  228                         expect(res ult).toBeF alsy();
  229                         done = tru e;
  230                    })
  231                });
  232  
  233                waitsFor (function( ) {return  done;}, 'D one', 100) ;
  234  
  235                runs(fun ction() {
  236                    expe ct(beansta lkClient.c onnect).to HaveBeenCa lled();
  237                    expe ct(beansta lkClient.u se).toHave BeenCalled ();
  238                    expe ct(beansta lkClient.u se.mostRec entCall.ar gs[0]).toB e('multi-t ube2');
  239                    expe ct(beansta lkClient.p ut).toHave BeenCalled ();
  240                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[0]).toB e(1);
  241                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[1]).toB e(0);
  242                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[2]).toB e(120);
  243                    expe ct(beansta lkClient.p ut.mostRec entCall.ar gs[3]).toE qual(JSON. stringify( job));
  244                });
  245           }) ;
  246       });
  247   });