 So, hello everyone, I am Irfan. I work as a lead QA in one of the education start-ups in Mumbai, called as Upgrad.com. Basically, we are an online learning platform. We help other start-ups grow and learn. So, if you are planning to do that, just browse us sometime. This is my Twitter handle, Kritikar. So, the icon is one of the tools related to Docker. He is just a very naughty octopus. He is just trying to catch these Elenium tools and he is trying to pack it in containers so that he can actually ship things properly. How many of you have worked with Docker? Let's work with Docker. So, I think we can start now. So, you might have heard a lot about testing as a practice, then testing as a service, testing as a container. So, what is it? Something new or the same thing, just wrapping in new words. Let's see and find out. So, why do I need to think about Docker? Why should I even think about it? What is the use for me? Or for you, like you guys are coming? What is the use? What will happen to you after this talk or demo? So, we are here. We all are Gangadhar. So, this is a normal guy like me. I have a bad side. I have a good side. Nothing is focused. Like, I have a lot of energy but nothing is focused. I have a lot of things but nothing is packaged into right format. Now, if I know something, how many of you know about Shaktimaan? So, in 97, 98, I used to be a fan of Shaktimaan. I used to wonder what makes Shaktimaan different from Gangadhar. Like, he is the same person. And what I came to know after a few years of my childhood research is, it's all about packaging. Because everybody is made up of some components, some elements. And so, what Shaktimaan did was, he just practiced meditation and packaged his all chakras into the right format. Took away all the evil parts, only the good parts. And he became Shaktimaan. So, you all are Gangadhar also. And you can become Shaktimaan. Like, I wish I could become Shaktimaan. But I need to know packaging. So, when we say testing as a container, it's all about how we package stuff. How we package to ship the things forward. For people who have joined here, they're going to transform Gangadhar into Shaktimaan after this talk. So, I'll discuss the outline. I'm in very brief. Like, why do we need Docker or containers? What container is about? So, how does it work? And how testers can actually use it? Many people think that it's using testing, but not for testers. And, like, it really works. So, we'll see demo. And, okay, I learned this. So, what next, what I can do? So, this is our outline for next 30 minutes. So, the first is challenges. How many testers here? Everybody. I'm scared now. Testers do, like, okay, I'm scared. So, what are the challenges in your testing? Like, what are the challenges you face? Testing environments. Anything other than that? Time. There's data. There's flakiness, yes. So, I think it's very similar to the research I did on, like, some 12, 13 people. And what they said is that they are failing to test because it slows down the deployment process. Like, they don't want to slow down their process because of doing a lot of testing. The time constraint came here. Second thing was slow test. So, slow down deployment means a lot of checks and validation things and doing high-level check kind of stuff. Second thing that a lot of people said, and it's like the same kind of opinions I got here, is that slow test and setup, like setting up the tests along with test data like you mentioned and the environments, everything is very cumbersome and bulky. And people say like, okay, to the extent we can do it, we will do it. Otherwise, we'll skip the test. The third is very dangerous. Actually, it's an ineffective test. Somebody mentioned flaky test. So, it comes into that. When people in your company, they start, they stop losing, you know, they have no hope on a test. They're like, sometime it pass, sometime it fail. So, the test becomes ineffective. Again, reason somewhere lying because of some problem with, not with the test cases. In this case, it doesn't change. But some problem with the test environment and other stuff. And then like 5% like maybe 70 months, they think that they don't need it. So, is container a new term? It's a new thing that we just really invented few years back. No, obviously. So, the shipping industry has a problem. They used to have a problem from ages. They were supposed to carry goods. And the goods were available in different, different shapes as you can see. Like we have spherical, we have circular, we have large stuff. Like just imagine you're shipping your house, everything. When you're shipping your house from one place to another, how do the packers and movers or you pack your stuff? Like you carry easting, like you carry your piano and then you carry your fridge. How do you ship it? You package it in containers. Every package looks same because the person who is shipping it, his job is just shipping it. So, the container helps. So, from there, we took this concept of containerization. And we said like, it sounds very similar to the software terms also. We have like, every software is different. But then when we have to ship it, we have to ship it in some format which just works. You know, whenever, like when I was a kid, some relative used to come to my house and then they used to say like, okay, they used to give me a gift. Some people used to give me a gift of like, they used to give me garments, not shirt. So, I was, I don't used to be like happy. Do I like, okay, I have to go to tailor and then I have to give measurements and then I have to like wear it. It will take like three, four months. But if someone gives me a ready made t-shirt or a shirt, I am happy. Because I can just use it, I can show like this is how. So, if something works just out of box, this is what container is about. So, we have a similar problem in software also that we have software of different, we have software of different kinds, we have web servers, databases. Everything had different needs, requirements and all are to be shipped on different places. Like if I have an application, I need it shipped on the production servers, like huge clusters. I have to ship it on my local machine which is a Mac or Windows. I have to ship it on test environments which may be a slightly lower configuration server. Everywhere I do. And I don't have to think about it. So, we took the practice of shipping and shipping industry and say like, okay, we will use in software. Like the mature industry. You can see that how easy it is to ship things. So, okay, so next session was like, next it was about containers. So, what are containers? In simple word, containers is something that software that does works. It has everything. It has code. It has libraries, dependencies. It has got the code plus configuration, everything packaged together. And you just can build and run it. It's a portable runtime environment. Maybe a different... So, this presentation is all about change in mindset. We don't have to... Like as a tester, you don't have to ship just your code. And like, you can say like, this is my code and it may work after you do some configuration. No, you can... This is my image. Go and just run it. It will just work. So, you have to think out of containers. Because inside container it's all messy. So, okay. Docker is something which helps us to build container, to spawn containers and to maintain it. So, it's... If you go to docker.io website, you say it's a platform for... Like, I like this thing, like build, ship and run. Like, making things simple. So, that is what Docker does. Docker has got three components. The first two are the client and the docker engine. So, these two have to be installed on your machine, whichever machine you work. It can be your local machine or any server. It contains a client and a docker host. And then there's something called as registry where you ship those images. Where you code and everything is shipped on those images. So, this is how image and registry. This is how docker hub looks like. You might have... everybody might know about github. So, yeah, docker hub is the answer of github for docker. Like, it's... it works not exactly the same. But, like, if you have worked with github, it works similar to that. It is working on that. It works layers by layers. So, if you want my code, if you want some application code, you can clone it from github. Similar to that, if you want my image and just make it work, you have to clone it from docker hub. And it works on layers like they are tagging everything feature. It's awesome. So, you might have worked with or you might have seen about virtual machines. And you say, like, so two years before, we just entered into virtual machine now something else container. Why? Like, why do we need containers and how it's different? The difference is that you can say in very simple words, it's a lightweight virtual machine. So, what happens is every VM, it comes with its own OS. Like, if I have three services in my application, so I have to install, if I want to keep them separate, I have to have, like, three different OSes and install those applications. Whereas container removes that hypervisor part or the OS for that and replaces it with a docker engine. And each of these applications work as a container. It's a lightweight VM, you can say. Yes, it shares the kernel OS. I'm not going into too much detail, but you can just understand it like a lot of stuff is being shared. And it's very light more than using a virtual machine. So, if you are using virtual machine, a lot of people also confuse between vagrant and docker. So, if you're using vagrant, so it is used for managing the virtual machine. Whereas containers, docker is used for managing containers. Which is way more lightweight than I am. You can use both together because you may need both of them. But these two are actually different things. Yeah, so how these components fit together. Like, we saw in registry that there is something called as docker image. We just go back, we see that it's docker image. So, container is something like... So, you know about the class and object thing. The class is just an instance of an object. So, the image is the static snapshot of your code plus configuration. And from that, you spawn container. So, I have an image for like NGX server. So, I can have multiple containers. I can spawn it up. So, that is a docker image. So, how does it all fit together? Is that you have your OS and kernel. Then, there is a host OS. Over that, you have your images. And then, there is a docker image over that. And then, over the docker image, your container is up list. So, we may come back to after like, after demo we can come after this. And we can look together. So, what's the life cycle? How an image is built? And how container is spawned? Like, it can become an egg problem. Like, it comes in first and which is used to build what? So, we have first... We build first container. So, if I have an app and it is not based on container. It's not based on... There is no image for that. What I will do is... Suppose I have a application which works on NGX or Apache. So, I have an official image of Apache. I will make changes. I will create a container. What I will do next is, after making this changes in the image, I will again store it. I will again push it and create another image. I will push it to registry or any other place. Like, you may not need registry. You want to be like... You have a new image. You can share it and then again keep the change and commit cycle. This is how actually the entire cycle works. Yeah. So, when you work with Docker in images, how it works is that... Suppose you have an app that you want to ship to another person. So, you give the image name. Just like you give your GitHub ID, an image name. So, how it works is that you install Docker. You will say Docker run. It looks for that particular image in your local. If it's not found, if it's not installed, it will look on the Docker registry. It will put it from there and it will install. And then it goes here saying run it. So, when you say run, it will spawn a new instance and it can container. So, this is how it works. So, how many of you are aware of DevOps? What is DevOps and what is the principle behind DevOps? What does it say? How it is different from... Like, what is something which is new in DevOps? Okay. So, at what point you will say that, okay, I have started this DevOps culture. Ownership and collaboration. So, you have basically one of the principles of DevOps. So, DevOps is that everything should be code. Like, your application should be code. Your infrastructure should be code. Your test should be code. Everything should be code. Specification should be code. So, when everything is code, it's very easy to move from version 1 to 2 and 3 and then to come back, okay, no, not 3 and 2. It's very easy to do that. It improves the entire process. So, one of the principles is that. And so, how do you do it? Like, how do you create images? How do you create containers? So, one of the simplest things is Dockerfile. So, if you want to write... If you want to code your configuration, you have to use Dockerfile. One of the simplest things is... It's a configuration file with build instruction. So, you might have seen on GitHub, like, there are projects like Selenium also. You clone the code and then you see, okay, these are the requirements. I have to install Java first, okay, this version. And then I have to install this first. It's not working. Oh, I installed Maven, everything. So, it's written there. So, that you have to code in Dockerfile. This is one of the examples. So, basically, you take the references from the existing images on the registry. And whatever is new and whatever is depending on... Whatever is new in your application, you just write in... There's a syntax for it. It's very, very simple. Gangadhar can do it, I think. You can also do it. So, you just keep adding these stuff. Like, this is for simple Python-based web app. So, we're just adding those dependencies, requirement.txt, if you install them. So, that it will do. So, from Dockerfile, you create images, containers, and then you store and create images. But what happens is, any small application also, it is not just a one single application, a one service. It has backend and front-end. There's a lot of other. So, Docker works on people like every process should be a different container. It has that, you can say, a feature of limitation, a feature of bargain. So, in that case, you have to manage multiple containers. So, the simplest tool to manage multiple containers is Docker Compose, where you mention that these are my processes, like my service is missing to this PostgreSQL database on this port. So, all these things are specified with Docker Compose. So, it's managing the, it's a tool for defining and running multi-container Docker application. Even in fact, in like, even the simplest of the application will require Docker Compose. It's a file. Yeah, it's a YML file. YML file is basically, Docker Compose is a tool and Docker Compose.YML is a file. So, if you see this example here, it is a new version of Docker Compose 2.0. As for that, you mention those, if you're building it, you add your build command. In our case, it is, it's already on registry. You can see refund edge, slash example, voting app. The image is already there on the registry. So, we just give a link and then we save what all things are getting connected to it. We'll see in this demo what exactly each and everything means, but this is what it exactly looks like. Okay, so we reach the demo. Can we, sorry, can we do this after demo? Maybe it get resolved automatically. So, you have to install a tool called as Docker in your Mac. There's few things in demo itself. So, there are some prerequisites. The only prerequisites, in the older Docker or the current Docker, you need to have a virtual box and you need to download Docker tool box. You click on this link and after you install it, this is for the old Docker. There is one new beta for Docker. It is released like two months back, it was released and it is in beta phase. So, I think it will take few more months to become stable. So, what they have done is now it is getting completely compatible to all platforms, Windows and everything. And you don't need another virtual machine either like virtual box. But, yeah. Yes. For this, because this is something which what I wanted was that if you're coming here, so you can just do hands on everything. So, this is what exactly you will have. So, we'll go with the older one, the current one. So, after this, there is an example voting app which we will test. It's a real-time voting app based on Python flag. It just, whenever you have conflict in mind, you just have to do like it's a bug or feature so depending on that you can decide it's a bug or feature. Simple web app. It has these components. So, every component will be a container. We have a database. We have back-end, and a web worker voicing. Each of these will become a container. As a tester, I have a problem statement that I don't want to really understand how this application is and I don't need to get scared. I'm already scared actually, but I don't need to get scared more. I want to test in this mine local machine. I don't have any server like I'm working in a I don't have a server for this. I want to work. I want to test this entire in my local machine and this is the task given to me that to deliver the below test as a container to test the voting app Docker image. So, what the developers have done is they have delivered me this voting app. They have given me a Docker image for this and I have to give Docker image for my tests. API test, web headless and Selenium grid test. So, once you start it this will give you a sign you a default image it creates for the first time when you do it it takes little more time like three minutes or something more. It creates an image on your virtual box called as default and so this is the VM and all the containers will be inside this by default like for this at least example because it will be all known by default. So, you have this default the IP is here and you can just say Docker machine and then there are lot of commands here you can just play with it, you can start and you can shut down, you can log in and like I can check the simple things environment, URL versions and there is another command line another command line called as Docker so you have lot of options to play with so Docker is you can do a lot of things with that you can build and you can check the process so Docker is something which manages to container whereas Docker machine manages everything with your virtual machine that you saw on the virtual box so I will write Docker PS2 so something is running something was running if I just check okay there is just one image if I okay so it tells what all Docker instances are you can do a lot of things like you can Docker SSH with this IP you can log in, you can check SSH into each and every of these containers and you can check what is happening there so we have a repository we have the repository where I have written the tests there is a Docker file I have kept the Docker file so there are some dependencies which are very specific to this test framework and there are some things which are already available so whatever things are already available I do not need to write my Docker file for it there are few things that I need my test framework is based on it is a simple framework based on cucumber and ruby so whatever things are specific to my project from ruby later so it takes the ruby from which is related and then I need for headless I need the phantom version I need to install this dependency and then these are just unique commands and whatever comes after run it is just unique commands so it is actually just creating a directory and mounting it to a particular electric structure and then bundler is used for building a ruby app so that we need to do so these are the instructions that I do what are the things that you do before running your app this is what I did for the first time this is my first time configuration so I have mentioned it in my Docker file so after this I created an image and I have pushed it on the Docker hub and there is a so you saw the example app so in the example app you have a voting app it has got image I have mentioned the image here I have mounted it on volume app it is working on port 5000 80 so this is basically 5000 is inside the container 80 is mapped to the virtual machine then it is linked to other components like this particular voting app back end is connected only to redis it is linked to redis and it can access different tier and back tier so front tier and back tier these are two different services so all these things so these voting app result app these are all the components that were given me by the developer right these are not built by me and this is what we are using for test we are writing one service called as hub you can give any name and then you specify the image there is a project called as Selenium Docker are you aware of it it is awesome so it is so awesome that if you just need Selenium you do not have to write a Docker file or compose anything for that purpose if you have any dependency other than Selenium then you can start writing Docker file for it and writing a Docker file for Selenium is not recommended because it is already there and it works very good so we have taken from Selenium project Docker it is mapped to the standard code and we want to see how it works so we have two debug nodes for Chrome debug and five these are two images and then there will be lot of data also it will be shared between all these services so that will be in volume and mentioned it here and then this name of the networks which are being shared between these so that is it I think because this Docker compose is helping us to manage dependencies between all the containers application container or test container we can go on adding our own other components also to do that so to do Docker compose so to run Docker to run all these containers at once and to do activities on that use command Docker compose so Docker machine Docker and all compose these are the three very useful and mostly use commands so all the activities that you do with Docker you can do with Docker compose also yes good question so test will come on data I will just bring up all the components and I will go through the test also yeah I am just bringing up the application on the test yeah that is it so I am kind of just bringing up the application itself along with that the Selenium and my Docker file everything yes no test is being run so I can mention that here too but but that is something that like compose is just about you can add it here also but yes we want to run independently so I am not mentioned here because it is not mentioned here like you can try doing that but it is simpler to keep it separate because the test having you do not want everything the application also because you want to understand how we are running test as separate container along with application as a set of containers so how container interact with you want to understand yes yes this part only no no we will come after this come so we will just so all these services which are mentioned here this will come up the grid starts here only because grid is something which keeps running and you just connect to it so so we will see is something local also it should work this is our app you can create multiple sessions and you can just attach to it so I will say bug and then I get results here I am getting updated some of the data like some of the attempts that I made earlier it is also coming up which is storing the data so this is the application and our grid is working on this board you can see you browse the sessions here it is very easy to scale up and down like you can have lot of sessions but you just want to play with the couple of them so this is the application I will say smooth so that is it your application and your grid now how the tests are being managed so you saw the docker file so apart from docker file this is being shipped in the form of image so there is a docker script for it for starters it is a very good thing basically when your infrastructure expands you need to use tools like automatic provisioning tools like property.share something else but for starters it is very good to have some shell scripts to manage those containers you need to bring up you need to make sure that it gets shut down properly so what this script does is basically it executes and it tells at what location our test is being stored that is actually the script does it in simple words so we have the features we are writing three types of tests web api web and api two types of tests whether it will run on grid it does not matter so these features are here what I am doing is as a single user I am voting and I am checking that I am able to vote on both of these pages and when apis are also I should see that when I am hitting those apis I should get the response as shown in a pretty simple test case to make things work so these are our two tests then the page objects are maintained on pages four directly it is mapped on this structure you know about page objects so we have elements here and then setting work and getting title for verification then we have page objects for app also for apis also we have two apis one is I have hardcoded the url not a good practice but I have done it here so I mentioned here the parameters so it is just like a page object model for api also this is pages and then implementation is here loading the page both and setting the choices and I am taking a screen shot to that set I think not too many things to test but just making sure that everything works and you can try it out we have an environment file on people use cucumber just I was curious so in case of web test we have different browser we are using capybara to manage selenium and we can use firefox pro locally or we can use a driver register we can register a driver selenium which works on the grid this is the url for the grid that we are using or you can use a poltergeist which is a wrapper for headless browser phantomjs and you can also run it on browser stack if you have your id you can try it it will just simply work and there is drivers every time I do some check in it gets executed on it runs some test api test that makes sure that things are fine simple and then I have a rake file so I mention the server name in case of api test I just mention them server name and so in case you want to do local execution I do not mention docker otherwise I mention docker so what it does is it invokes a docker script docker script brings up the image and creates a container out of the docker file that we mention and what it does it it execute the task so whatever task we are mentioning web or web app web app is basically a different task to run it on grid and web is the one which runs on the headless board so if you want to try this so we see here the compose is working then if you want to see our test if you want to see our web test you just write so we have a readme file where everything is mentioned it is very interesting that if you want to setup without docker there is whole repository it will take you like one hour if you have good connection internet it has so many dependencies especially if you have to install APM also but if you have to do like without docker so it is just docker compose up and then this v command so it will still take time like 30 minutes but it won't you don't have to stay there so you want to run our API test so we will say rake so what is happening is basically yeah rake yes hit understand so basically the rake is something you can use rake is something a build tool for ruby so it is just used for like mentioned task and those tasks will map to some command it is just simplifying the you can use gradle or something else using java so what it does is it looks for the image which is mentioned it finds out it is already exist so we just run the container and it says do we have already a container existing so we don't make a new container we just bring that up and here we have started the execution and so we will like do test fast if you want to run so you want to see the web version of this you want to see the real how it is happening you need to install vnc i am using real vnc it takes some time to any questions if you want to use in real in practice so in practice you use some provisioning tool along with it like you use some thing callers you can write in that case things are so much dynamic in lot of cases things are not so dynamic because so you use some provisioning tool to handle those things like we have just used shell script here so that does the work of and that replaces and creates a new docker compose file every time but this is how it being composed it's not different from traditional CI system only is how you set up the things because what pain you like i have a couple of friends who used to work together we have set up our tests locally on mac when there was one guy who set up on windows then our CI was actually a Linux and then our production was a little different we have to do setups every time we have to do something changes with our infrastructure part of it we have to make changes everywhere that just help us to do we just have to like who is developing it just we have to change the mentality that don't just sequence complete image yes, yes same everything is same everything is same just shipping method changes yes just make work easy so just you need to have that URL mentioned we can access the localhost also then it's also perfectly fine best ideal case will be everything is container but it may happen that some developer is not giving you images and you are not going to build it so in case if it's not there then I will just give the links if it is there I will be happy and I will just make it part of my dog compost so how does you do like currently how does you manage currently no but I think it's same thing it is actually out of scope of Docker because it needs all those links and inputs that what it needs to connect basically this any other question yeah you can just have that one command like scale 10 and you have like 10 new two browser sessions in the same grid so currently it works same way how it used to work traditionally traditionally also like you are spinning up a lot of browser it will slow down so I could not able to show the grid part demo but is that you saw that node Chrome and code debug these two are actually different containers so if you have like two more tests to run each of one each of these will have a different container