https://github.com/itpey/taz
A simple yet powerful load testing framework for Go.
https://github.com/itpey/taz
api attack bugbounty ddos go high-performance load-testing penetration-testing pentesting pentesting-tools testing unit-test unittesting
Last synced: 13 days ago
JSON representation
A simple yet powerful load testing framework for Go.
- Host: GitHub
- URL: https://github.com/itpey/taz
- Owner: itpey
- License: apache-2.0
- Created: 2023-10-23T20:57:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T22:04:29.000Z (about 2 years ago)
- Last Synced: 2025-03-05T04:42:58.353Z (over 1 year ago)
- Topics: api, attack, bugbounty, ddos, go, high-performance, load-testing, penetration-testing, pentesting, pentesting-tools, testing, unit-test, unittesting
- Language: Go
- Homepage: https://github.com/itpey/taz
- Size: 49.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[//]: # "Title: taz"
[//]: # "Author: itpey"
[//]: # "Attendees: itpey"
[//]: # "Tags: #itpey #go #load #golang #go-lang #test #api #http #tazmani"
Taz - A Go Load Testing Framework
A simple yet powerful load testing framework for Go, designed to help you simulate and measure the performance of your applications under various loads.
# Features
- **Configurability:** Taz allows you to fine-tune your load tests by specifying the number of worker goroutines, desired requests per second, and the total number of requests to send.
- **Response Times:** Measure the response times for each request to gain insights into your application's performance.
- **Error Handling:** Track and report errors encountered during load testing to help identify potential issues.
- **Context Support:** Utilize Go's context package to manage the load test's lifecycle and control its execution.
## Getting Started
## Installation
To start using Taz in your Go project, follow these simple steps:
```bash
go get github.com/itpey/taz
```
## Usage
Import the Taz package in your code:
```go
import "github.com/itpey/taz"
```
Create a LoadTestConfig to configure your load test:
```go
config := taz.LoadTestConfig{
WorkerCount: 10,
RequestsPerSecond: 100,
TotalRequests: 1000,
LoadTestFunc: func() error {
// Your workload simulation logic here
return nil
},
}
```
Execute the load test using the RunLoadTest function:
```go
result, err := taz.RunLoadTest(context.Background(), config)
if err is not nil {
// Handle errors
}
```
# Configuration
Taz offers several configuration options to customize your load tests:
- **WorkerCount:** The number of worker goroutines to use in the load test.
- **RequestsPerSecond:** The desired rate of requests to be sent per second.
- **TotalRequests:** The total number of requests to send during the load test.
- **LoadTestFunc:** A user-defined function that simulates the workload for each request.
# Results
The RunLoadTest function returns a LoadTestResult structure that contains important information:
- **ResponseTimes:** An array of response times for each request, allowing you to analyze performance.
- **Errors:** An array of errors encountered during the load test, helping you identify potential issues.
# Error Handling
Proper error handling is crucial when working with Taz. Check the Errors array in the LoadTestResult to identify and troubleshoot any issues that may have occurred during the load test.
# Examples
Here's an example of a simple load test using Taz:
```go
package main
import (
"context"
"fmt"
"math/rand"
"github.com/itpey/taz"
"time"
)
func main() {
// Define the load test configuration
config := taz.LoadTestConfig{
WorkerCount: 10,
RequestsPerSecond: 100,
TotalRequests: 1000,
LoadTestFunc: simulateWorkload,
}
// Create a context
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Run
result, err := taz.RunLoadTest(ctx, config)
// Check for errors
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
// Output load test results
fmt.Printf("Load Test Results:\n")
fmt.Printf("Total Requests: %d\n", config.TotalRequests)
fmt.Printf("Successful Requests: %d\n", config.TotalRequests-uint64(len(result.Errors)))
fmt.Printf("Failed Requests: %d\n", len(result.Errors))
fmt.Printf("Average Response Time: %s\n", calculateAverageResponseTime(result.ResponseTimes))
}
// Simulate a workload by sleeping for a random duration (representing the work being done).
func simulateWorkload() error {
// Simulate a workload by sleeping for a random duration between 100ms and 500ms.
sleepDuration := time.Duration(rand.Intn(400)+100) * time.Millisecond
time.Sleep(sleepDuration)
return nil
}
// Calculate the average response time from the list of response times.
func calculateAverageResponseTime(responseTimes []time.Duration) time.Duration {
if len(responseTimes) == 0 {
return 0
}
var total time.Duration
for _, rt := range responseTimes {
total += rt
}
return total / time.Duration(len(responseTimes))
}
```
# Running Tests
To run tests for Taz, use the following command:
```bash
go test github.com/itpey/taz
```
# Feedback and Contributions
If you encounter any issues or have suggestions for improvement, please [open an issue](https://github.com/itpey/taz/issues) on GitHub.
We welcome contributions! Fork the repository, make your changes, and submit a pull request.
# License
Taz is open-source software released under the Apache License, Version 2.0. You can find a copy of the license in the [LICENSE](https://github.com/itpey/taz/blob/main/LICENSE) file.
# Author
Taz was created by [itpey](https://github.com/itpey)