We collect in rpm WireMock - a utility for creating stubs over web services in Fedora COPR analogue of PPA in Ubuntu

WireMock is a java library utility for creating stubs over web services. It creates an HTTP server that we could connect to as a real web service.







Fedora COPR is a free hosting service for hosting custom repositories (similar to AUR on Arch Linux or PPA on Ubuntu). Of the features, the built-in ability to collect rpm packages by specifying the name of PIP and RubyGems.







In this post I will write how to collect rpm from your repository by committing to Fedora COPR .







For example, take the wiremock-rpm repository in which I created the spec and systemd unit files. When creating your repository, you can take wiremock-rpm as a basis and change what you need. I omit the writing of spec and systemd unit files. I think you know.







Creating a project in Fedora COPR







Go to Fedora COPR .













Project Name : Specify the name of the package. Usually the same as the name of your git repository.







Description : A brief description of the project.







Instructions : How to install your package. Indicate the following:







yum -y install yum-plugin-copr yum copr enable ---fedora-copr/- yum -y install - systemctl start -
      
      





Homepage : Specify the home page of the program that you want to build or your repository.













Build options : In Chroots we indicate under which operating system you want to collect the package.













It turns out as in the screenshot.













Other options : If you need internet, then in the Booleans check the box Enable internet access during builds













After creating the project, go to Packages .













Package name: Specify the name of the package.







Clone url: Specify the git repository.







Subdirectory: This item is better not to use and keep the source and spec file in the root of the project. If you have the sources in one directory and the spec file in another directory, there may be problems with the build.







Spec File: Path to spec file.













Generic package setup : Be sure to check Auto-rebuild













After creating the package, go to Settings , then to Integrations. Below on the page we copy the webhook of the system where your git repository is located.













Go to Settings where your git repository is located. Next for github, go to webhook. Add webhook. Insert Payload URL, select Content type application / json







Now about WireMock.







Install wiremock according to the instructions. The working directory of wiremock in my project is /usr/lib/wiremock



/. This directory contains wiremock.jar and the mappings directory. In the mappings directory there are json files with requests that you send to wiremock and prepared answers.







Example from http://wiremock.org/docs/running-standalone/ :







 { "request": { "method": "GET", "url": "/api/mytest" }, "response": { "status": 200, "body": "More content\n" } }
      
      





We send a request to / api / mytest and get:







 curl http://localhost:8080/api/mytest More content
      
      





An example from my prepared json:







 { "request": { "method": "GET", "url": "/503" }, "response": { "status": 503, "body": "503 Service Unavailable\n" } }
      
      





Let's make a request to / 503







 curl -i -v 172.26.9.123:8080/503 * About to connect() to 172.26.9.123 port 8080 (#0) * Trying 172.26.9.123... * Connected to 172.26.9.123 (172.26.9.123) port 8080 (#0) > GET /503 HTTP/1.1 > User-Agent: curl/7.29.0 > Host: 172.26.9.123:8080 > Accept: */* > < HTTP/1.1 503 Service Unavailable HTTP/1.1 503 Service Unavailable < Matched-Stub-Id: d8b419e1-7e33-4f04-889e-2428f849dc7d Matched-Stub-Id: d8b419e1-7e33-4f04-889e-2428f849dc7d < Transfer-Encoding: chunked Transfer-Encoding: chunked < Server: Jetty(9.2.z-SNAPSHOT) Server: Jetty(9.2.z-SNAPSHOT) < 503 Service Unavailable
      
      





In rpm wiremock added popular http codes. Sources here .








All Articles