Setting up Jenkins with Docker to Test your Joomla! Extension

that was a new sentence for you blah blah okay thank you um hello welcome to the session so it’s it’s about Jenkins docker and testing so what I will give you is the bird’s eye view so we are working in the project longer for setting up a system for our testing and this session is what’s supposed to be the result of all this work but we are didn’t finished Willy’s work so the session is only the bird’s eye view of our plans so we cannot really show you some things that worked at the end that’s working so as I said it’s it’s the bird’s eye view about Jenkins and darker and testing so let us start with Jenkins who knows what is Jenkins okay that’s good Jenkins is continuous integration server great word I will explain what it is later in a few minutes not really later so Jenkins this is open source Jenkins is in some way extendable with plugins we know plugins you can put some functionality in it and it’s written in Java yeah okay so continuous integration so what is what is continuous integration it’s the first question I’m always trying to ask my service is why so why I need this so I need continuous integration for for better quality for the product so the product Joomla should be better it’s not really good when we were we ship version and have to ship the next version two days later because we up something so that’s not really a good idea so we need to do quality also what can we do with continuous integration is that we get fast responses on changes so someone change something and it was our continuous integration service we get a fast response if we break something that’s you and we need our contingent aggression because developer are lazy so you change something oh it should work I do it and then everything goes south so that’s not really good so we need this for this and last bit is we need to eliminate side effects so we change something here and do you think it there should not be really so many side effects but without a continued integration service if you have a good testing then we see oh there are side effects and we need to eliminate that and our to continuous integration service tells us oh there is something wrong so there are a couple of problems we can run into it’s software development you have thousand possibilities to run into problems and I will list a few to to allow you not to run into these problems and to skip all the bad parts and sinking so the first problem is we need to know what is right that’s a problem so what is right we need to a system that tells us or we can define how a system should behave so what is the right functionality the system or this part of the system has and the other way around is also very important what the system should not behave so that’s the why part of what is right and defines is how can we how can we find out if the system behaves right so if we if we do normal developments so we develop something and say okay

this function should do add two numbers and when I put two numbers in it then they should I put one and one in there should come to that’s something you look at it look at the results so it’s testing its manual testing so testing is a is a key to have a way to have an automatic way to find out it’s a system does what it should do and there are a couple of testing types there we go true this testing type suit who knows a bit more about testing very hands-on okay that’s a lot so one test type is unit testing the unit testing is is something you test really a small bit of your application and in in in the best way or in the in the best situation you can do this totally isolated so you have no connections to other classes and and parts of the application so unit tests are typically you test a class class that do something maybe adding two numbers so and you can do it can make a test you say okay when I add two numbers and three numbers are one and one there should be two let’s see results so you make a search and say okay I expect when I do this that is that said that is a result so in any can you compare this I say okay my system behaves right you can do the other way around you say I have two and four and say the two and four is six okay and then you can say okay six is the right result but it shouldn’t be not not six then you do it as already not okay this is garbage okay we go to the next one so the point for unit testing is small pieces of your software isolated testing that’s ooh nest X testing type if functional testing so the idea of this is that it’s not really one part of your system then it’s more than one part two or three parts two classes you’re testing how they work together so you need a bit more and if you can isolate this system or this two classes then it’s pretty good and then you can test if this works will you go together can I be I can something else so this type of testing involves more of your system and the third type is acceptance tests you can name it acceptance test you can name it system tests that are both saying so the acceptance comes from this idea that it’s you implement the feature and to accept this feature it has to pass this test that says caption tests for feature have you spoke this morning about system testing that’s pretty much the same so when you when you look from from mm and more you came down more of your system is involved so when you do acceptance our system tests in the browser is involved errors and networks this network involved there’s a lot of pieces of your application are involved sets the way and maybe you can it’s not easy to to spot that the more of your system is involved the longer tests and more resources are needed to do the tests so problem number two throw responses it doesn’t really make so much sense when you are doing continuous integration and you make a small fix on something and the response that that something was wrong comes three hours or a day later so you usually have forgotten what but I know what I changed so and when you when you make more

changes then you do figure out what’s what’s really wrong it’s not so easy to spot so the sooner you get a response about your change the better it is so what’s what are the reasons for for slow responses so one one reason can get me that’s tests taking too long so you wrote a test and this test does a couple of sayings and it but it takes time and it runs and runs it runs it runs this takes long so that’s one one reason another reason is you have back side bets the documentation so your tests are not splitted into into parts that you can run them parallel that’s also a reason so and you do it in the wrong order I would come to this point later and also to this one later the process is not planned well so if you look at this for bullet points and you can see that the three so why is this bolt the point is bold but okay that’s great crazy that’s kinky say that key no job the this reprocess not plant well wrong order and back segmentation sir there are something you have you have in your hand so you can use this better well test taking too long you did all your best to to make the tests work and test what you like to test so it’s not so much you can do we come to problem number three one is too many variants of your tests and I will show you all and not so I will show y’all so you see there are a couple of PHP versions at the moment for Joomla you have many many PHP configuration settings you can do memory limit very low and and all this all these ideas you can have so you can different databases you can different web servers there are more and here for joomla 2.5 3.3 3.4 I did put unifor in it but it’s not there really okay so come and catch me in a few minutes so I have to – so one thing and sets we come more to the to the solution part is I will tell you a bit about docker not so much who knows docker who knows virtual machines that’s more ok so docker is some kind of service virtualization so you you make a docker container for Apache for example or you make a docker container for MySQL so so the words are darker so why doctor is cool servants so you might guessed I’m a fan of this when you see they said that’s a normal virtual machine it’s a big box and they’re all services are in and it’s doing the job and it’s doing Apache and swim MySQL is doing PHP is to do all the stuff you need to them you need so um docker in this case is yes we have also a world of machine but on top of this virtual machine you set up set up containers so the containers here share a bit of the virtual machine and the good part of this is that you can run a lot of more containers on the server then you can run virtual machines so you use your hardware better and one thing I was already cool with docker is there are booted very fast so there are there there are up in no time so you can can run a lot of talkers in in in a short period of time and then they do that the job they are supposed to do and now we come to to the process the process of of your testing of your continuous

integration the first thing I will tell you is stop at the first failure wow that’s cool you know T no just kidding me here ok so it stopped at the first tell you why I don’t know how many people contributing to you to Joomla really to contributing with with github so sending polycrystal and so on okay so how many of you have get response or or have written committed to make Travis happy how many of you okay cool so usually it is because you have forgotten space a comma oh whatever so this small small problem so and because Travis runs through all of this works through all unit tests it usually takes ten ten minutes to get a response but to know that you’re had some coding styles to check this needs I think a minute to give you this response so when you when you do these cheap things first like code star checking’s or syntax checks then you get as developer and you stop when when it fails and you get fast response make it all fun so I can’t use this year and put comma and hosen oh maybe I should run run code styling checks locally maybe not okay I committed ah you know that’s that’s what happens so that should be the first thing in the process get your fast response use cheap things first and then go to the next part and that’s usually the unit tests they you are testing all isolated a powerful system and that means that there are also fast so I’m not pretty I’m not sure how long is the unit tests run on my machine I think it’s it’s five minutes or something so when you do this then and unit tests run through also good if you have functional tests we don’t have this at the moment really in in jula torture test we have some unit tests and we have system tests so there are it’s not really something between so then the exceptions test come into their take very long and to make and to make this really work so and here fits together is you need to split your acceptance tests into chunks and let them run parallel on different docker containers then you can speed up your whole process and how long takes the takes the system system tests two hours I think okay so on my machine is free hours on but I have a big big one so it’s two two or two or three hours something yeah yeah so when you split this let us go from two hours so and we target that we maybe would get a response within ten minutes then you have to split it in in twelve parts if you can so system tests are a bit bit complicated because you need to install Joomla first and then you can run the system tests so it’s to create your world to make tests it will take some time so that’s so until then nothing Rustom run in parallel and then you can save time you get a better response time and you and you get better responses and fast response on your changes okay it’s a jeweler testing setup so thankfully two one and one that’s about not not reason why I use this this one and one example for unit test though but thankfully one and one say they gave up gave us three root servers and what we did is we have set up a Jenkins master and we are set up to Jenkins slave so it’s it’s not really complicated to do this so because the only we have to install the Jenkins master and the Jenkins slave it must only be unique and usually UNIX installation

then you need to root password and then you can add this as slave and Jenkins will handle the rest for you and can start processes and other things other slaves so what are the steps so it runs this way that when when pull request is Maidan on our repository set get up contacts the Jenkins server and starts a process that’s the thing what happens Jenkins picks up this change and then he cloned the repository for exactly this commit copy it to to the machine and then it’s more or less done so then it’s then we would start a simple darker machine for the code styling checks to have this out of the way and then checking for syntax errors for example so you can PHP minus l4 checking on syntax errors you can do this for different PHP versions so is that that’s easy easy to do next will be our unit tests and then we will run our assistant test in parallel and last thing we will do is is maybe do some codes metric calculation to have a view what we changed in the time and and how is our code coverage and all the things so that we have some well use where we can say this is how our system or our code is getting better so you can can do a lot of this with code metrics I want to go into this is sets I think also we talked about this one so and and the last thing we need to do is send combined results and and set the Stadion in get happens and we are done with with our tests so and only and so it’s it’s the process is designed that you can go out of this process at every line so that you get fast results and don’t need really there’s a system test we will would have a lot of a lot of we need a lot of resources so we I didn’t have this on my on my slides before the system test what makes it also a bit complicated is you need to test also with different screen resolutions and all that stuff so there is when we have our our system tests may be split in in in twenty twenty pieces so then we have to run it this twenty pieces for different screen resolutions and that will take a time so that’s a process and so I will will end up with with three points with three points I would give you on your way and it is a long way to do it so I think Xavier is working on the system testing for two years or three years and we had units testing unit tests coats prints and worked on this so it’s going it takes a long time to do to do it and but you never will be finished with something when you don’t start so start with with doing it start doing it for your components for small pieces you have I know it’s it’s really hard with Joomla to do unit testing because there if you if you use J table you are include pretty much every single of the system in your in your chest and that’s not really fun so make as a less isolated test in Joomla is not really so easy but finally when you when you finish or when you on the way and see some of your results I think he will sleep better for any change so and so that’s exactly the moment you can alway cup and I’m finished with my presentation and I

thank you for it for coming so if you have questions and I would give my best to answer so no it’s not really planned so yeah it would be good to do it yeah for sure yeah I know that said that we know this yeah I can remember some some changes that made it a bit slower yeah it would be good so I’m but I think when we when we go a bit further with the code matrix things so maybe then we are doing some checking how long something takes so maybe there we can figure out a bit better say so but it’s not really planned now I didn’t because it’s it’s for for our proposed it doesn’t makes any sense to do it so we need to really we need a couple of machines we know that we have big system tests and so I didn’t try it I know it’s it’s it’s possible to do there are a couple of packages out with with docker containers and Jenkins in it so I think it’s easy to do it but for our proposed for Joomla testing we need really I don’t think we will really we need more war machines I think we will not you know machines will not be enough so more questions it’s not it’s not so easy it’s done maybe double can can say more you said upstairs it’s a docker container for the system testing I think there are a couple of examples and and yeah that’s the bad part of the internet so there’s so many people trying and st. changing a bit on it and then you have a new version so when you look for on docker hub for for specific service then you get results over results or results so and it’s not really easy to find sirs or the right container so what I do why I try to find someone that fulfills my needs and yeah yeah yeah I know I know I know why I do it I know yeah I think they’re praying uses a docker to make the docker containers very early and then they are at the moment I think they are working on on all this management stuff tools to make it better for people to set it up so I think it’s ansible is also it no it’s it’s not really three four machines is a bit of a bit more I think those PHP version screen we need and all the stuff

so I think we will have a lot more machine so more questions I can try to answer so it’s on top of this yeah so it’s it’s like this so it’s one with the Machine and then you put it on on top more questions on yeah yeah I can say it how are you sir so tomorrow we have a session in to make it happen and we are trying to do writing more tests and and stuff like like this so if you would like to draw to join find Xavier tomorrow so yeah and I think it depends so if you try to to test for example for different MySQL versions as example sir then it might be easier to have to have a container with Apache and your PHP but you separates a MySQL and can connect to this one so I think it depends on your on your situation so thank you very much you