Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Testing Fuse Fabric with Pax Exam

1.075 Aufrufe

Veröffentlicht am

Veröffentlicht in: Technologie
  • If you are looking for customer-oriented academic and research paper writing service try ⇒⇒⇒ WRITE-MY-PAPER.net ⇐⇐⇐ liked them A LOTTT Really nice solutions for the last-day papers
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1url.pw/j9Rtb ◀ ◀ ◀ ◀
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Testing Fuse Fabric with Pax Exam

  1. 1. Testing Fuse Fabric with Pax Exam Brought to you by Henryk Konsek / @hekonsek
  2. 2. This talk 1. Our goals 2. Pax Exam 3. Case studies
  3. 3. 1. Our goals
  4. 4. Our problems OSGi ;) it works on my computer aka responsibility ping-pong creating repeatable middleware proof of concepts is difficult going production without proper testing
  5. 5. Our goals repeatable tests of middleware - infracoding OSGi issues detected and fixed as soon as possible educated customers sending us runnable and repeatable examples
  6. 6. 2. Pax Exam
  7. 7. What is Pax Exam JUnit friendly framework for running tests in real Karaf containers Exam deploys JUnit test case as a bundle if the bundle can be successfully tested with the Exam, then it can be successfully deployed to Karaf
  8. 8. Exam hello world! Project structure m-r jc ypo e t m -r jc -e v cs y p oe ts ri e m -r jc -o t s y p oe tr ue .. . m -r jc -u d e y p oe tb nl m -r jc -t s y p oe ti et
  9. 9. Exam hello world! JUnit class @ uW t( aE a.l s) R ni h Px xmca s p bi c as MK rf et e tn sA sr { u lc l s ya a Ts x ed se t @n et Ij c MO gS ri em O gS ri e ys i ev c ys ie v c; @o fg rt o Cn i ua in pb i Ot o[ c ni ua in ) { ul c pi n] o fg r to ( .. . } @ et Ts p bi v i s o lR tr Rs o s( { u l c o d hu de u ne pn e) .. . } }
  10. 10. Exam hello world! Karaf configuration @ of gr to C ni u ai n p bi O to [ c n iu ai n) { u lc p in ] of gr t o( rt r nw Ot o[ { eu n e pi n ] k rf it iu i no fg rt o ( a a Ds rb to Cn i ua in ) .r mw rU l f ae ok r ( m vn )g o pd"r .p c ek rf )a tf c I( aa h- aa " ae (. ru I(o ga ah .a a" . ri at d" p ce kr f) .y e " i ". es o ( 2 33 ). t p( zp)v r in". ." ) kr fe s o( 23 3)n m( Aa h Kr f) a aV ri n" . .".a e " pc e aa " . na ki e tr(e F l( tr e/ a ") up cD rc oyn w i e "a gt px ) . sD po F le(a s) k eR ni e od r) ue el yo drf le , ep ut mF le ( , c ni ue os l ( . go eo a Cn oe )i nr R mt Se l ) o f gr Cn oe )i n rL cl os l(. go ee oe h l( , m vn ud e) g op d " o. x ml ". ri at d"y po et bn l ". a e Bn l( .r uI ( cm ea pe )a t fc I(m- r jc -u de ) vr in sn r jc (} e so AI Po et ); }
  11. 11. Exam hello world! Testing OSGi service @ uW t( aE a.l s) R ni h Px xmca s p bi c as MK rf et e tn sA sr { u lc l s ya a Ts x ed se t @ ne t Ijc M Og Sr ie m Og Sr ie y s ie vc y si e vc ; @ of gr to C n iu ai n p bi O to [ cn iu ai n ){ u l c p in ] of g rt o( .. . } @ et Ts p bi v i s o lR tr Rs o s( { u l c o d hu de u ne pn e) as rE ul ( Hl o" m Og Sr ie h lo ol () s et qa s" el !, y s ie vc .e lW r d) ; } }
  12. 12. Exam hello world! Testing OSGi Camel service @ uW t( aE a.l s) R ni h Px xmca s p bi c as MD po eC m le t e tn sA s r { u lc l s ye l yd ae Ts xe d se t @n et Ij c Cm lo tx c ml ot x ; ae C ne t a e Cn et @o fg rt o Cn i ua in pb i Ot o[ c ni ua in ) {. } ul c pi n] o fg r to ( .. @e t Ts pb i vi so l Rt rR so s ( { ul c od h ud eu n ep ne ) S rn r so s =c ml ot x .r ae rd cr e pa e) t i g e pn e a e Cn et ce tP o ue Tm lt ( . rq et oy " m: uu " "s " Sr n.ls ) e us Bd (j sq e e, m g, ti gca s; a sr Eu l(H lo " rs os ) s e tq as "e l ! , ep n e ; } }
  13. 13. 3. Case studies
  14. 14. Case #1: Hello world! Arm your POM < eo io is r ps t re > <e oi oy rp s tr > < dj os fs - a/ d i > bs -u ee <i > < r>tp :/ e oi oy jo s og nx sc ne t go p/ a/ r> u lht s/ rp st r .b s. r/ eu / ot n/ ru s e< ul <r ps tr > /e o io y < rp st re > / eo i oi s Engineering guys deploy here. < rp ri s p oe t e> <a rc vr in 1 00 rd a- 4<f bi -e so > fb i -e so >. .. e ht 30/a rc v ri n < po et e> / rp r is Pick up some bleeding edge yet stable version of Fabric test API.
  15. 15. Case #1: Hello world! Arm your POM < ee dn y d pn e c> <r ui > o fb i 8/ ru i> go p di .a rc <g o pd <r ia td fb i 8k rf /r i at d at f ci >a rc -a a <a tf ci > <e so >{ ar c vr in <v r in vr i n $ fb i- es o }/ es o> <y e z p/ ye tp > i< tp > < dp ne c> / ee d ny Download Fabric distribution. < ee dn y d pn e c> <r ui >o fb i 8i et <g o pd go p d i .a rc .t s s/ ru i> <r ia td fb i -t ss cm o <a tf ci > at f ci >a rc ie t -o mn /r ia t d <e so >{ ar c vr in <v r in vr i n $ fb i- es o }/ es o> < dp ne c> / ee d ny Include Fabric test API (and nothing more!).
  16. 16. Case #1: Hello world! Tested Camel route p bi c as Nt yt po t et n sR ue ul e { u lc l s et H tR ue x ed o tB i dr @ vr ie O e rd p bi v i c n iu e) tr w Ec pi n { u l c o d of gr ( h os x et o fo (n ty h t: tp /l c lo t1 00 ". r m" et -t ph t :/ oa hs :8 8 /) s to y) c nt n(Hl o wr d" ; eB d( .o sa t"e l ol ! ) } }
  17. 17. Case #1: Hello world! Base test class i pr i .a rc .t ss p xx ms po tF b iT sS po t m ot o fb i8 i et .a ea . up r. ar ce t up r; .. . @ uW t( Ui 4e t un rc as R ni h Jn tT sR ne . ls) @ xm ec oS rt g(l Cn ie S ae Ra tr at r .l s) E aR a tr ta ey Al o fn dt gd ec o Fc oy ca s p bi c as Sm lF bi T s e t nsFb iT sS p ot { u lc l s ip e ar ce t xe d ar c et up r @o fg rt o Cn i ua in pb i Ot o[ c ni ( { ul c pi n] o fg ) r tr n wO to [{ e u n e p i n] nw Df ut o ps tO to ( ar ci ti ui n of gr to () e e al Cm oi e pi nf bi Ds r bt oC ni u ai n) , m vn ud e "o mn -o ,"o mn -o )v r in sn rj c( ae Bn l( cm o si " cm os i ". es oA I Po et ) } ; } .. . } almost no config? Buy Ioannis a beer for creating the FabricTestSupport ;) yeah, this is the old and ugly Pax Exam 2.x API... you need to configure everything you use in the test bundle
  18. 18. Case #1: Hello world! Deploying Camel route i pr s ai jv . ag Ss e. r; m ot t tc a al n. y tm er @ et Ts p bi v i s ol C et Cm lo t r) tr w Ec pi n{ u lc o d hu dr ae a eR ue ( ho s xe t o er pi tnee u eo mn (f b i: ra e- ") r. r nl(x ct Cm a d" ar cc et n); er pi tn ee u eo mn ( f b i: rf l- ra e "+ r. r nl(x ct Cm a d" ar cp oi e ce t " -a et f au ec m ln ty ht -e v r); - p rn s e t r- ae e t -t ps re ") er pi tnee u eo mn (f b i: rf l- dt " + r. r nl(x ct Cm a d" ar cp oi e ei " -e tr sc m ln ty ht n ty ht - ev r); - f au e ae -e t -t p et -t ps re " ) er pi tnee u eo mn (f b i: rf l- dt - bn ls "+ r. r nl(x ct Cm a d" ar cp oi e ei - ud e " v: o. xm l /y po et b nl /. -N PH T nt yh t- ev r); m n cm ea pe m- r jc -u de 10 S AS O et - tp sr e") Cn an ru le . ra e) ot i eB id rc et ( . w tN m( ru e -o ti e" . ih rf ls "e t -t ps re ". i h ae "o tr cn a nr )w tP oi e (n ty ht - ev r) a sr Po ii n nR sl ( . u l( ; s e tr vs oi ge u t) bi d) / . . as ri n / . se to s } String output = executeCommand("some:karafCommand"); assertProvisioningResult == block until container is ready
  19. 19. Case #1: Hello world! Testing deployed route @ et Ts p bi v i s ol C et Cm lo t r) tr w Ec pi n{ u lc o d hu dr ae a eR ue ( ho s xe t o / . . ce tn c na nr / . ra ig o ti e Ip tt em ip t te m= nu S ra n uS ra n wU L" tp / lc lo t1 0 0" .p nt em ) e R( ht :/ oa h s: 88 /) oe S ra (; Sr n rs os = IU is tS r n( nu Sr a) ti g ep ne Ot l .o ti gi pt t em ; as rE ul (H l ow rd " rs os ) se t qa s" el o l !, e pn e; } a poor-man's HTTP client
  20. 20. Case #1: Hello world! User friendly output f bi :r ae a rc c et n U ig se ii dz o ep rp sw r :d i s n p cf e ok ee as od am n f bi :r fl -r a e- pr ns f au ec ml nt y ht -e vr a rc p oi ec et - a et e tr -a e e t- tp s re f bi :r fl -d t -f au e cm ln ty h t n t yh t- ev r a rc p oi ee i -e t rs a e- et -t p et -t p sr e A dn f au ec ml nt y ht t po ie n ty ht -e v rv ri n1 0 d ig e tr :a e -e t- tp o r fl :e t- t ps re e so : . f bi :r fl -d t -b nl s. . nt yh t- ev r a rc p oi ee i -u d e . et -t p sr e A dn b nl :v :. t p oi en ty ht - ev rv ri n 10 d ig u de mn . . o r fl : et -t ps re es o: . W ii gf rc na n r: [r ue - ot ie 1] t sc es u l p oi i n a tn o ot ie s ot rc na nr o u cs fl y rv so C na nr ru e- o ti e1 Ai e fl eS au :S H UL nl o ti e :o tr cn an r l v: as t t s S R: u l C na nr ru e- o ti e1 Ai e tu Sa u :n lz n SH UL .. o ti e :o tr cn an r l v: re t ts aa y ig S R :. C na nr ru e- o ti e1 Ai e tu Sa u :o no dn S HU L. . o ti e :o tr cn an r l v: re t ts dw l ai g S R: . C na nr ru e- o ti e1 Ai e tu Sa u :i ai ig S HU L. . o ti e :o tr cn an r l v: re t ts fn l zn S R :. C na nr ru e- o ti e1 Ai e tu Sa u :u cs S HU L. . o ti e :o tr cn an r l v: re t ts sc e s S R: . output partially omitted (SSH address!) very similar to the output from the real Karaf session
  21. 21. Case #2: Hacking child containers with SSH C na nr cn an r =( ot ie ) ce t( .i ha e "o tr cn an r ) o ti e o ti e C n an r ra e) w tN m(ru e -o ti e" . wt Po ie (n t yh t- ev r) ih r fl s" et -t p sr e". as rP oi in n Rs l( .u l (. tr tr)n x(; se t rv so ig eu t )b id ) i ea o ( . et ) S rn [ cn an rs Ul = cn an rg ts U l) sl t" "; t ig ] ot ie S hr ot i e. eS hr ( . p i( :) S rn c na nr ot =c n an rs Ul 0; t ig o ti eH s ot ie S hr [] S rn c na nr ot =c n an rs Ul 1; t ig o ti eP r ot ie S hr [] S rn b nl sn ot ie = ee u eo mn (o mt t ig u de OC n an r x ct Cm ad f ra ( "s - % - % - % % og : it , sh l s P s p s s s il s" "d i" " di " cn an ro t cn an r ot am n , a mn , ot i eP r, o ti eH s ); ) a sr Tu (u de O Cn an rc n an(c ml nt y ht ") s et r eb nl sn ot i e. ot is "a e -e t- tp ); running Karaf container can be accessed via SSH client we can execute any remote Karaf command via ssh
  22. 22. Case #3: Fabric Master component test many customers request singleton Camel route in the clustered environment Fabric Master FTW! it is difficult to provide proof of concept for the customer Pax Exam + Fabric Master = no brainer demo
  23. 23. Case #3: Fabric Master component test p bi c as Ms eR ue e tn sR ue ul e { u lc l s at r ot x ed ot Bi dr @v ri e Oe r d pb i vi cn i ue ) t rw E cp in { ul c od o fg r( ho s xe to f o(ms e: e t- at rn t yh t: tp /l c lo t1 01 " . r m"a tr nt ym s e: et -t ph t :/ oa hs : 88 / ) st oy )c n tn (m se " ; e Bd (. os at " at r) } } the clustered route we want to test only single Netty instance should handle requests at given moment
  24. 24. Case #3: Fabric Master component test f bi :r ae a rc c et n f bi :r fl -r a e- pr nsf au ec ml ms e -e t a rc p oi ec et - a et e tr -a e a tr nt y f bi :r fl -d t -f au e cm ln ty h t m s e- et a rc p oi ee i -e t rs a e- et -t p at rn t y f bi :r fl -d t a rc p oi ee i -b nl sm nc m ea pe m- r jc-u de 10 S AS O ms e- et -u d e v: o. xm l /y po etbn l /. -N PH T at rn t y Booooring...
  25. 25. Case #3: Fabric Master component test C na nr ms e =C na n ru le .r ae ) o ti e a tr ot ie Bi d rc et (. wt Nm (m se ".i hr fl s "a tr nt y ) ih a e" at r)wt P oi e (ms e- e t" . as rP oi in n Rs l( .u l (; se t rv so ig eu t )b id ) I pt te mi pt t em = n uS r a nu Sr a nw UL "t p/ l cl ot 10 1 ". pn te m) e R (h t: /o ah s :8 8/ )o eS r a( ; S rn r so s = I Ui st Sr n(n uS ra ) t ig e pn e O tl . ot igip tt e m ; a sr Eu l( ms e " r s os ) s et q as "a tr , ep ne ; creating first Netty router container in the cluster first router must be the master
  26. 26. Case #3: Fabric Master component test C na nr sa e= C na nr ul e.r ae ) o ti e l v o ti e Bi drce t ( . w tN m( sa e )w tP oi e (m se -e t" . i h ae "l v" .i h rf ls "a tr n ty ) a sr Po ii n nR sl ( . u l( ; s e tr vs oi ge u t) bi d) no port conflicts? That's good - only the single master node is running.
  27. 27. Case #3: Fabric Master component test C na nr ms e =. . o ti e a tr .; .. . m se .e to (; a tr d sr y) I pt te mi pt t em = n uS r a nu Sr a nw UL "t p/ l cl ot 10 1 ". pn te m) e R (h t: /o ah s :8 8/ )o eS r a( ; S rn r so s = I Ui st Sr n (n uS ra ) t ig e pn e O tl . ot ig ip tt e m; a sr Eu l( ms e " r s os ) s et q as "a tr , ep ne ; we are still receiving correct response slave has been nominated to the master
  28. 28. Examples https://github.com/hekonsek/fuse-pocs/tree/master/fuse-pocsfabric
  29. 29. Many thanks!

×