Skip to main content

Events

Tesmon provides a powerful event-driven architecture to help you integrate your tests and gain insights into their execution. The expect task in TesmonLang allows you to validate the occurrence of an event within a specified timeframe.

Flow Diagram

Secure and Private

In order to protect sensitive data, Tesmon does not store the actual event data in its cloud. Instead, Tesmon only stores masked event data, and the actual data is processed within the Test run engine in the customer environment. After processing, the actual data is discarded immediately to ensure the privacy and security of your data.

Scalability

Test Run Engine can handle up to 1 million events per second.

Publishing events

Sources

Tesmon supports publishing events from a wide range of sources, such as:

  1. Clients: You can emit events from various client applications, including iOS, Android, and Web.
  2. Microservices: Events can be emitted from your microservices, enabling you to track and monitor important actions and behaviors.
  3. Batch Processing Jobs: Tesmon allows you to emit events from your batch processing jobs, providing visibility into the progress and status of these jobs.
  4. Streaming or Data Pipelines: If you have streaming or data pipelines in your architecture, Tesmon can capture events from these pipelines, helping you gain insights into the data flow and processing.

This allows you to build an end-to-end testing strategy, and even validate logic that may not be accessible through APIs or databases.

Methods

Tesmon offers multiple ways to publish events:

  1. HTTP Request: You can publish events to Tesmon by making HTTP requests to the Tesmon Test Run Engine events API endpoint. This allows you to send event data programmatically from your applications or systems.
POST <Tesmon_Test_Run_Engine_URL>/v1/events HTTP/1.1
Content-Type: application/json

{
"eventKey": "<YOUR_EVENT_KEY>",
"eventBody": "<YOUR_EVENT_BODY>",
"createdAt": <UNIX_EPOCH_TIMESTAMP_IN_MILLISECONDS>
}
  1. Tesmon SDK: Tesmon provides SDKs for various programming languages that simplify the process of publishing events. By using the SDK, you can integrate Tesmon directly into your code.

The package is available on Maven Central.

Usage

TesmonEventClient tesmonEventClient = new DefaultTesmonEventClient("<Tesmon_Test_Run_Engine_URL>");

tesmonEventClient.send_event(<eventKey>, <eventBody>);

Dependency

Maven

<dependencies>
<dependency>
<groupId>io.tesmon</groupId>
<artifactId>tesmon-java-sdk</artifactId>
<version>X.X.X</version>
</dependency>
</dependencies>
  1. Logging: Another method to publish events to Tesmon is through logging.

Using Application Logging

Using logs to publish events is a simple and effective approach. It requires configuring your logging infrastructure to emit logs in a specific format.

To publish events via logging, you need to define an appender that sends logs to Tesmon's Test Run Engine (TRE). Here is an example configuration for Log4j2 in XML format:

Example log4j2 setup

log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Http name="tesmonEvents" url="<Tesmon_Test_Run_Engine_URL>/v1/events" method="POST" ignoreExceptions="false">
<JsonLayout compact="true" eventEol="true" />
</Http>
</Appenders>
<Loggers>
<Logger name="tesmonEventLogger" level="INFO" additivity="false">
<AppenderRef ref="tesmonEvents" />
</Logger>
<Root level="ERROR">
<AppenderRef ref="tesmonEvents" />
</Root>
</Loggers>
</Configuration>

In this example, we define an appender named "tesmonEvents" that sends HTTP POST requests to Tesmon's TRE endpoint. The JsonLayout specifies that logs should be formatted as JSON.

Once you have defined your appender, you can use your logging framework to emit events. Here is an example in Java that logs an event using the configured "tesmonEventLogger":

Usage

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger LOGGER = LoggerFactory.getLogger("tesmonEventLogger");

// Create the event JSON
String eventJson = "{ \"eventId\": \"event123\", \"eventKey\": \"b074b045-b611-490d-b4ed-af7ba56ad777\", \"createdAt\": 1619025480000, \"event\": { \"sampleKey\": \"sampleValue\", \"anotherKey\": 123 } }";

// Log the event as JSON
LOGGER.info(eventJson);

Event Properties