With increasing the popularity of container systems, we had more tools that save our day. Nowadays, almost all of the CI tools can run an application in an isolated container. So that we are able to test our code in different environments.
As you need to connect a real database or some other services in most of the cases while running integration tests, you need to deploy those dependencies somewhere too. Though most of the solutions provide similar features, today we are gonna check how to run integration tests and the service dependencies together in Gitlab-CI.
Let’s assume that you…
Mocking is the easiest way of testing a unit of software by simulating different behaviors of dependencies. So that You can test most of the positive and negative cases by creating mock objects that represent dependencies.
Today we’re gonna check the basic usage of a mocking library in TypeScript called
ts-mockito inspired by
Mockito in Java.
As the package documentation already includes the installation steps, let’s get started directly with a usage example.
As you see, the class we’re gonna write test has three dependencies we need to mock, and besides verifying the parameters passed on the methods of…
In the past, when I was a desktop PC user, I used to record songs I played with some instruments by using a computer at home. Though I usually prefer decent sound cards, even any on-board audio interfaces were efficient enough.
However, after I switched to the laptop, as the USB audio interfaces were not efficient enough and budget point of view the devices that work on faster ports were not so accessible to me, my options ran lower.
Anyway, after tested several USB audio interfaces and struggled enough with latency, I understood that the laptop is not suitable environment…
Because libraries solve some problems in a specific area and allow making something easier, we use tons of libraries/frameworks and internal project components written by us… in order to make an application easier. However, this situation brings other complexities that we need to take care of, like relations between the components. In this article, I would like to mention how to use the technique as known as Dependency Injection in a TypeScript project.
As you know, Github allows us to execute continuous integration pipelines through Actions easily. Today, we are going to see how to deploy your code directly from Github to your server by using Ansible, Docker, and Github Actions.
Ansible is an IT automation tool that communicates to servers via SSH protocol without using any agent mechanism. It allows you to execute commands on remote servers or transferring files to servers from the system where you run the Ansible playbook. So the key problem is being able to access the remote servers from a public system like Github.
We can execute…
In a development environment, one of the biggest problems is finding the occurred problem between the services and it needs that you need to check too many log files in order to find the root cause. You may need to check the web, application, database, cache… etc. server logs even in a simple monolith application.
Today, we’ll see how to aggregate the application logs in one single place that we can follow easily through Docker Compose, Graylog, and Elasticsearch.
As a sample application, I’ve chosen Symfony Demo project written in PHP. It requires PHP, Nginx and MYSQL instances to work…
You may have an application that depends on one or more services that start slowly. So, you must put some extra controls before starting the application, in order to prevent startup errors and run the application smoothly.
Let’s take the following example:
We have an application that directly dependent on RabbitMQ and MySQL services and it connects to both services in application startup. However, the worker container constantly fails because it starts before the other services.
Let’s start first by defining the dependencies between the services in the
docker-compose.yaml to start the worker container after RabbitMQ and MySQL containers.
Sometimes, a message consumer might be failed because of connection issues or other logical reasons. In this case, the application should handle the fail scenario properly and retry the failed message several times based on some rules.
Today, we are gonna see how to retry a failed message in a Symfony application through Messenger Component by referencing the previous post:
Messenger Component, retries a failed message through the
dead letter feature of RabbitMQ in case of RabbitMQ usage. It tries by default 3 times, with 1000 ms delay, and multiplies the duration by 2 in each try.
Most of the API’s requires some authentication mechanisms in order to identify the user and allows to access some resources based on the authorization rules. Although the way of the identity declaration changes, most of the authentication mechanisms requires to perform a request to an authentication endpoint in order to obtain an identifier before going to the actual resource. However, you can’t use that identifier forever.
If you take all this information into consideration, to make even a simple API call requires the following flow:
As you know, message-based asynchronous flows are a significant part of the web applications that allow scaling backend processes. You can move all the long time processes to asynchronous flow and make your user interface faster as much as you could.
Today, we’re gonna see how to use
Messenger component with a simple use case.
I strongly recommend to check out the following document in order to understand the message bus concept and the fundamentals of each component in Messenger: