onto them and you can get prizes for asking questions and with that are you ready Oh this one hello ok and without I would like to welcome Olga matchick Sharma from code are they talking about accurist welcome hello i will be talking today about a tool for defining and testing rest contracts called accurist so first i will make a short introduction about the tool then i’ll talk a bit about the background why we may did what was the situation what made us think of such tool and then i will talk about the solution ok so i can rest the consumer driven contract verifier it will take as an input very easy to write groove with yourself script and it will work automatically in Gradle to produce both why amok stops and to produce tests for now we have spoke tests and very shortly will also have j unit tests so who could develop from a benefit from the stock definitely any developments working with frest QA engineers working oppressed people interested in the micro service infrastructure and in the challenges it can cause when it comes to the tech stock it’s a Gradle plug-in but some of our contributors would like to make it available for maven so we hope to have it available for maven as well then it’s written in groovy and it supports groovy fully it definitely supports Java we have never tried using it with C C++ or objective-c but as greater supports them it may be possible for you to tweak it a bit and make it work for you and of course it’s open source so you can just it you can tweak it oh you can just get inspired and make a similar solution for your own tech stock so what happened was that the company that we’ve been making a project thing was having a mana life system it was a legacy system it had considerable depth and as any mana later everything was contained a single big application a single logical executable and what happened in that particular system as it was quite old the business process called codon that system was already very entangled and also the modules in that code were very entangled and when you were fixing something you wanted to work in one module you could easily introduce a bug in any other module so the development was resource consuming time-consuming then the testing of this system was also very long and deployment process took a long time it was not a bad really because it had a lot of tests so it felt quite secure but we thought the people the architects fault and they communicated to us that it would be a better solution to split it up so we could work more in a more agile way so we switched to micro services so before maybe we had a client identification client registration different financial operations in the same one big app now we would have a different app for client identification different role for client registration we would have them all set up together and communicating with each other using rest it would also influence the structure the way we worked because before any team would work on that big model system and then after the change what would happen is that anything would just work on one or more micro services so they would be fully responsible for this application to work and they would probably not communicate that much and

not know that much about the exact inside ways of working of other micro services so the new issues and challenges that appeared there there were many of them and people working and developed many tools to make it work smoothly but now i would like to only talk about those related to creating and modifying rest contracts and also testing services communicate using rest because those issues cost the creation of a crest so when it comes to creating and modifying West contract before there was one server it had limited clients and this approach was going to change now we would have many small applications and any given application could be a server for other applications while being a client of any other service so we would have much more rest interactions and we would have to define and modify the rest contracts much more often also we would like all the different teams working on the services to know that anything has been modified and a contract that were using so probably service a was using a REST API of service be but say we see DNA were using that as well so service requested a change now service a has to know that this change has taken place as soon as possible yeah so this changes could also be simultaneous and maybe sometimes clash we would like to work with this efficiently as well and this has brought us to a consumer-driven contracts because if the client is the part that defines how the rest api should look it is generally more efficient it is better designed because with the big server approach usually it is the server team that is taking decisions when it comes to the API because this is the core component so they they are behind the main logic and everything but with this approach we want our clients to define what the contract should look like because they know what will be the best approach for them to use this data and then the second thing we wanted all the consumers to be notified as quickly as possible about any change that has taken place and when it comes to testing this service before with the normal life entrance test what happened was that there were many of them they were quite comprehensive people specially QA team felt that the borders were well a fight because there was a one big test environment and stage environment and on that environment the main server deployed and any limited number of collaborators and the entrance tests would fully use the communication between those applications and they thought that is considerably improved safety probably there were too many of them probably the execution was too slow some code would get cold again and again during those tests but all together it felt quite safe so what could we do now as we were transferring to microservices first idea was just to maintain it let’s have it let’s just deploy all the services at the same time you could do that well in theory you could do that but I would really go against the whole idea because you want the services to be independent so the development is quick the deployment is quick the testing is efficient and if you had them all the plot together only the development would improve this wouldn’t really make sense so then we could make many many many such pipelines with all the collaborators that one pipeline only used to deploy one service but we would test them as we used to with all the communications but we wanted to have many micro services like 50 20 later who knows how many so it would be extremely resource consuming time-consuming and not worth it so the idea what the architects came with was to stop collaborators this is a loan approach use very often however what happened is that stubs do get corroded so you might have written a stop one day and it worked same as your server worked but then somebody has updated the APR on the server deployed the new version you have tested your own service against your stub you don’t even know that the server has changed maybe they’ve told you forgot to change this stub and then what can happen is that your production when you deploy to production the communication can fail even though the test passed so there was so much human element here and the better approach seemed to automate the requirements when it comes to testing were that we would you stop but this stuff should be validated against the real responses of the server so

while showing you accurist I will talk about the bog client and server and of course as I’ve told you we can have many clients and server service in this infrastructure but now at any given time I will just refer to a client has the part that is using the rest api and serve as the part that has the rest api so how do we work with oculist first the consumer team the team working on the client service submits are groovy their cell scripts that will shortly see at the poor request to the team that is working on the server so scripts are used to automatically generate while mock stops but they also generate server test and these tests fail if they do not have the same implementation so new server version cannot be deployed until the stops and and the really implementation of the rest api are same so they cannot merge this code and they cannot deploy until they have implemented the change or they can just reject the pull request if they do not agree with this change or if another team has made a similar request on the same a point they want to introduce another field in the body they can merge it but they have to make it consistent and now we’ll go through this process so first the client submit the script and this is what an acrid script looks like as you can see is quite similar to why i mock script or any Jason but it’s simpler in the syntax at least it seems off to us and it’s written in groovy but as you see you don’t need to know any group we’d be able to work comfortably of those scripts so you have the request part and the response part and the request part you have of course the method the URL the body of course you do not need to have a body in the request it’s optional you can put many headers as you need and then in the response part you have status and also body and head us now what happens the survey team has this pull request so they can run clean build with Gradle and these steps will be generated from those script so this is a simple wire mocked up and it exactly matches the structure of our script so we have the request and in the request of course we have URL method and then the body part is changed to body patterns and we are using Jason paths to check if if it’s the response that you want to send a response for and of course we check all of the headers and then we just passed the response i don’t know how many of you have ever worked with wire Mook okay so why a mock allows you to run stops during your test and you just give Jason’s and it will set up a kind of test server where it will put these stops and if you send the request that will match the request in this button here the response will be submitted so just you don’t have to have set up to talking artifacts and you substitute the rest api of one of them with this and i also recommend using why a mock for any different purposes well not necessarily evacuates the very useful tool okay so then you have the body and the headers ok so the servicing team has this but as I’ve told they can’t do anything really they can’t deploy this thing they can merge the bunch because they also have the test and the test she’ll fail so this is what the test looks like the nice thing is that it is automatically generated and it will be always in keeping with the script so you have one input and to output that have to be in keeping in this test we use rest assured library it is a nice library for testing any rest interactions and all these methods like Co or creating the request will be done using a rest assured so it’s from a different library so we have the script and we use the body and the header parts of the script to create the request and then we use the information in method

and URL to really make the call and then what we have to do we have to verify if the server is giving us the same response that we have put in our stop so we verify all the parts we verify the status code all of the headers then accurist uses Jason path to verify if all the body parts that was specified where are available so the only thing that you really have to do is set up a base taste class and tell Acuras this is my base test class and all the acronyms generated test will extend this base test class and to set it up if you are we work out the whispering so it supports rest assured more can be seen if you have if you’re in spring you can just do something like this so you put standalone set up and you give any amount any amount of controllers that you need to launch you launch them there or you can just have a fully running application you need to run it here we’re running it using web integration tests a notation from spring we also support Jack service so that’s what you have to do you have to set it up sometimes have to add some walks if you want to walk up the behavior if you don’t want to launch the entire application or just use rest assured so now we have and now the server team has those tests enough passing so they will implement the change in their rest api and in their functions to make them pass once that’s done the clean build will end up in success and they can deploy and it’s very important while using accurist to connect the deployment of the new version of the server with the deployment of the steps you can deploy the steps to any artifact repository it’s up to you where and you can use any tool that you use usually you would use for deploying things so ingredients for example maven published plugin and it’s very important to do this together so now any client any other micro service you can use those stops and they can be reasonably sure that if they are testing against of stops the deployed version of the other service of the server will behave in the same way as those tubs so I also like to talk to you about regular expression support we have more features but this is the feature that I find extremely important when oculus was created the why was one of the first users and the first request we had okay you need to implement regular expression support without this we cannot use it because when you are when you are self assembly when you’re making a stop a wire mock stop what you expect to have or you are just working with stubs and what you want to have is that for example you will stand in your request a client ID and some other value like your loan amount that you want to take and you expect a certain response but it does not really matter if your ID is one two three four of five six seven eight or whatever other ID it just has to match a certain pattern same if you’re registering a client you give request with client data and you expect a response from the server and maybe in your response you expect a client ID a UID whatever and it’s not really important I should always be the same it will never be the same normally but it’s very important if it’s supposed to be you ID it should match the UID pattern so then you want to change a check over verify all cervical send request using a pattern and not a value but as you know accurist also uses this data to create tests so in a test you cannot have a pattern if you say create a body with this field and i’ll check that the body has this field and then you want to make a call to the server and passing or let’s say my client is and you can i just say i am passing to you a client and you know this client matches this regular expression or you have to say in the request i making a call and in the body the client has a real ID so that’s why it was very important to introduce a different handling for the stubs and the test so the stub will just know that you can be sending anything which matches a button but in the test you will submit a

value so this is how we do this with a crest we use a value method and we can give a different definition on this top part and on the test part and then you will usually put a reg ex and stop part and in the test part just a value and when we are talking about response it’s generally opposite so you are expecting a response with a field of a certain type of a certain pattern not necessarily some different value sometimes yes most of the time no so this this script that I’ve shown you will translate to this stop well if you see instead of the two equal signs that were checking for equal we have now a different sign that is checking for matching pattern and in the test you just have the value that we specified so we can make a call using a very there’s some other interesting functionalities that are supported so we do have query parameters that can be useful for some of you as optional fields are supported that maybe not that often use but some people wanted to have fields that they may or may not have in the body in the response then you can execute custom methods on the server so say in that previous example instead of just giving the value 1 2 3 4 for the test for your client ID you could just write execute generate client ID and in your base test class you implemented method execute or generate client ID and also accurist use particularly well with nested structures so when you know that you will have bodies that have many nested elements which is very often true accurist will work out of the box with that you don’t need to worry it will just resolve its maps and it will make it work so this is very useful now I would like to tell you something about the possible issues so we have found it to work very easy be easily and out of the box and with minimal setup in the real microservices that were very small application but we were then quite enthusiastic and we tried using it in this complex legacy system as well until it has been decoupled into micro services and this has proved to be complex because there was a lot of things we didn’t want to launch this application each time because it was too having so we had to mock it there were many machs and the problem was that currently accurist only supports one base taste class so you had to have all those mugs in one class or in some class that the other class was extending it had been the same hierarchy and we had many modules that was quite problematic this is probably a room for improvement for changing it yeah and then the greatest setup if you had multi-module Gradle project the setup can sometimes get very complex especially if you have a lot of things happening in the Gradle itself as bridle allows big liberty and writing it and changing the ways that the bids are done and using dynamic functions so in that project that was already so complex that setting it up with accuracy was a hassle and some other possible issues it’s a young solution I think it has been there for a year or so so the can still be bugs the good thing is that the acuras team is working very much on the box so the support is constant and we try to fix any bugs that there may be and we try to introduce new functionalities that people need so that’s the part that thing about good thing yeah now I’d like to show you a demo no pay so here we have a very simple demo project it has only been written for the demo so please don’t put that much attention to the functionality itself and it has two smaller Gradle projects so this too small a graded project we can imagine that just two different jars deployed somewhere in the

network infrastructure so the first project is a loan application service it’s very simple and it will just use make a request to a fraud detection service that we will see shortly and interpret the answer and it’s very simple either the answer can be okay or the answer can be fraud so if it’s okay the loans is processed and if it’s fraud the launch is rejected and then you have the another service called fraud detection service this is what we are making the cause it has extremely small API has one controller and currently in only only returns okay and the functionality that the client is expecting is the commented out that it should also reply that amount is too high if it’s higher than 5000 and then it should reply that this client is a fraud so this is not implemented so what happens now and also there are no script yet and no stops and basically nothing and the loan application service has a test these are some spoke tests so basically it expects either a server to be running the fraud detection service or using the wire makrooh having stubs loaded to the wire move to the wire lock and also replying same as the server would reply so now what will happen if we just run clean build our loan application service test should fail because they are trying to communicate with the other service which is not there okay it filed loan application service tests have failed and if we see why they fell it is because once again because as we expected there was no response from the server so what we will do we will now add some scripts and the scripts have been already previously added so we just need to reset gate and we can see the script here so if we go to mappings we have the nearly the same scripts that I’ve been showing so we have the scripts the stops will get generated the test should get generated and one of those tests should fail because the implementation is commented out so if we do run it now effectively one of the test has failed and we can see the report here yeah so it’s expecting to get fraud it’s getting okay and let me show you that what really was generated so and build we see generated sources here are tests and the first one is obviously the one fails it expects fraud in the body there’s no fraud and then here we will have the script so this is the way that this solution works and I would also like to suggest you to if you got entrusted if you think you might use it in your project to check out first of all accurist code and see if it’s useful for you if you need this for some different tech stock maybe check if you can do something similar if you want to

use it by you see some problems or there’s something lacking make a pull request or just make a bob on your issue and then you can check out the project with the examples that I’ve been showing it has many branches with different stages of the setup in every branch so if you like to check it out you can play with it and if you have any issues you can approach me I’ll be in the conference and I will be ready to help you with that and yeah you can contact me about this and now if you have any questions that’s the good time to ask them I have a question about a whole youth and that software like accurist do youth accurist yes we have we have definitely especially we have one accusers from the financial sector and they use accurist a lot and mainly to their requests and their bugs that they they made we have improved it but now we are also getting more and more users from different companies because there’s a whole movement of switching from only two macro services many companies are going to that approach and acuras really has little alternatives there are some alternative frameworks but they are more difficult to use normally they’re more complicated so we have we’re getting more enterprise users okay one question rest is not only about HTTP protocol do you plan to support also different transport protocols other than HTTP 444 now we have been concentrating on HTTP but as I’ve told this is being developed very intensely and we are happy to make things that will users make more comfortable so if anybody you will need something you can just make an issue and will be definitely considered and if there are no major reasons not to do that that will probably be implemented also if you want to implement it everybody is invited to participate it’s open source okay and do you have any road map for the project what do you plan to implement in future do you have any road map for the project and apply what will be implemented in near and far future yeah for now the main functionalities that we need it and we are using in our work were implemented but so for now what we want to do is j unit we very much want to support the unit and it’s in the branch it should be supported soon and what also we have done was switching to Jason paths because some time ago we had our own written validation of the Jason’s and then we realized that maybe didn’t make that much sense if there was something very good and already does so we switch to that and we are also getting many issues from users so we are just fixing it so I think for now it’s g-unit when it comes to things that we want to add and also they are as I’ve said some contributors that would like to make it available from maven so we very much hope for it to also come and to maven thanks okay okay so there and no more questions you can always come and ask me if you have later on questions or you just don’t want to ask them now I will be here today and tomorrow all day long and feel free to come feel free to check out our code and comment about this Thanks thank you thank you haha i would like to remind all of you to go sign up or at least vote for lightning talks their support in the end of main hall thank you yep yeah what about this i’m

sorry i forgot the big book I remember one of it yeah this one but the other one I don’t remember I’m sorry I just forgot about them yeah I think do I have wronged watch because I got five minutes before and I thought we started in 9 15 meters like five minutes for question okay naman yeah ya know for now no do you think it would be valid snootily straße battery last batteries I

Trevor Groth latrine honey

so hello every everybody there was

changing schedule next presentation it’s going to be about network manager and