Raspberry Pi : Mini-Server Setup for Automation Projects Part 1

What is Raspberry Pi?

  • Raspberry Pi is an engine for creativity, learning and innovation

  • It is a high-performance, low-cost, general-purpose computing platform in the hands of enthusiasts and engineers all over the world

  • It is a credit card size all-in-one device that has a motherboard and all basic peripherals like USB ports, LAN ports, HDMI ports, VGA ports and so on.

Why do we need one?

We all use our personal computers or laptops for our day-to-day use or learning technology stuff. However, with cloud computing everywhere, we use lots of cloud technologies that need dedicated machines to be up and running all the time.

It is not possible to have our personal computer keep running 24/7 due to many reasons, also paying for cloud providers for pet projects or learning sometimes seems a bit overkill.

Here comes Raspberry Pi, an affordable, low energy and efficient mini-computer, that needs no peripherals to be connected except LAN or WiFi for internet.
It can run on a power bank or with a simple mobile phone adaptor.
It can run 24/7 unattended and it is proven to be robust and is used by many enthusiasts worldwide. Sounds cool right?

That is interesting, but tell me how can it help in terms of Test automation?

Good question. While there are endless use cases to use it, I will try to share some practical use cases that may help us leverage this tiny device.

  1. Deploying a Sample API service with few endpoints (GET, POST, PUT etc ).

    1. Using it as a practice application to learn, and experiment with API Testing or Automation.

    2. But we already have so many public APIs right? But this one is different as you will have full control of the code and you can manipulate the behaviour of API as you like. The whole codebase is under your control

    3. This gives you an extra edge to play around with APIs in test automation to see how robust is your test scripts and how they behave to failures.

    4. However this needs a bit of technical expertise to build and deploy API service on your own, but that is not so difficult. We can use chatGPT to build API using Javascript, Spring Boot or Python.
      We will cover this use case in the coming article in this series.

  2. Deploying a mock API service

    1. If the above use case seems complex then there is another way to configure a mock API and run it as a service.

    2. This is super easy to do and we have many libraries and tools for such. Some of them are

      1. Wiremock ( Java )

      2. https://my-json-server.typicode.com/ ( No Coding needed )

    3. This has lots of benefits as we can use this API in test automation, working with any frontend integration

    4. I have a video about how to use Wiremock, do watch it here if you are interested.

  3. Deploying WEB Application for practice purposes

    1. Building a simple static website is not so difficult with advanced frontend frameworks like React, NextJS, or even as simple as Express JS.

    2. We can even clone any open source frontend app host it in Raspberry Pi and run it as a service. For the same reason of have full control of the app to use it for our test automation purposes.

    3. Imagine reproducing some scenarios like button missing, image missing, locator change, and so on. How will you mock such failures in public dummy websites? That is why having full control over the whole ecosystem gives us an edge in building robust test automation solutions.
      We will cover this use case in the coming article in this series.

  4. Running Health checks for your APIs, and websites periodically and sending an alert

    1. If you have a website or some application hosted somewhere else, but you would like to ensure they are up and running all the time and if they go down you want an alert.

    2. This can be easily done but simply configuring a CRON job that will keep running to check the services periodically.

    3. Along with this, we can set up an email notification service for failure detection.
      We will cover this use case in the coming article in this series.

Like I said earlier in the post, the possibilities are endless.
Do you use a Raspberry Pi or any dedicated cloud machine for your projects? Please share your use cases, suggestions, articles or links in the comments, I would love to explore.

See you in the next article.