logjamm

package module
v0.0.0-...-0ca564c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 7 Imported by: 0

README

logjamm

Go Report Card

E2E Load Testing Framework

!! CURRENTLY UNDER CONSTRUCTION !!

Features

How it works

N/A

Simplest Working Example

package main

import (
	"fmt"

	"github.com/logjammdev/logjamm"
	"github.com/mxschmitt/playwright-go"
)

var options = logjamm.Options{
	Vus:        1,
	Duration:   10,
	Iterations: 0,
}

var requests = []logjamm.Request{
	{
		Method:  "GET",
		URL:     "https://httpbin.org/get",
		Headers: nil,
		Body:    nil,
	},
	{
		Method: "POST",
		URL:    "https://httpbin.org/post",
		Headers: map[string][]string{
			"Accept": {"application/json"},
		},
		Body: map[string]string{
			"name":  "Test API Guy",
			"email": "testapiguy@email.com",
		},
	},
}

var test = func() map[string]int64 {

	timings := make(map[string]int64)

	pw, _ := playwright.Run()

	browser, _ := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
		Headless: playwright.Bool(true),
	})

	page, _ := browser.NewPage()

	label, duration, _ := logjamm.Step("Navigate to logjamm.io", func(page playwright.Page) playwright.Page {
		_, _ = page.Goto("https://logjamm.io")
		return page
	}, page)

	timings[label] = duration

	browser.Close()

	pw.Stop()

	return timings
}

func main() {
	responses, timings := logjamm.Run(options, requests, test)

	fmt.Println(responses)
	fmt.Println(timings)
}

Simplest Working Example (Just Batch Request Functionality)

package main

import (
	"fmt"

	"github.com/logjammdev/logjamm"
)

var options = logjamm.Options{
	Vus:        1,
	Duration:   0,
	Iterations: 5,
}

var requests = []logjamm.Request{
	{
		Method:  "GET",
		URL:     "https://httpbin.org/get",
		Headers: nil,
		Body:    nil,
	},
	{
		Method: "POST",
		URL:    "https://httpbin.org/post",
		Headers: map[string][]string{
			"Accept": {"application/json"},
		},
		Body: map[string]string{
			"name":  "Test API Guy",
			"email": "testapiguy@email.com",
		},
	},
}

func main() {
	responses := logjamm.Batch(options, requests)

	fmt.Println(responses)
}

Simplest Working Example (Just Web Test Functionality)

package main

import (
	"fmt"

	"github.com/logjammdev/logjamm"
	"github.com/mxschmitt/playwright-go"
)

var options = logjamm.Options{
	Vus:        0,
	Duration:   0,
	Iterations: 5,
}

var test = func() map[string]int64 {

	timings := make(map[string]int64)

	pw, _ := playwright.Run()

	browser, _ := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
		Headless: playwright.Bool(true),
	})

	page, _ := browser.NewPage()

	label, duration, _ := logjamm.Step("Navigate to logjamm.io", func(page playwright.Page) playwright.Page {
		_, _ = page.Goto("https://logjamm.io")
		return page
	}, page)

	timings[label] = duration

	browser.Close()

	pw.Stop()

	return timings
}

func main() {
	responses, timings := logjamm.WebTest(options, test)

	fmt.Println(timings)
}

To-Do

  • Implement WebDriver Functionality
  • Add How it works details
  • Add Simplest Working Examples
  • Add Request per Second to Options for Duration and Possibly Iteration (Batch Functionality)
  • Add Capture and Report End User Metrics/Timings API as Wrapper Function(WebDriver Functionality)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Batch

func Batch(options Options, requests []Request) []string

Batch is a function to send batch requests based on specified load test configuration options

func Run

func Run(options Options, requests []Request, test Test) ([]string, []map[string]int64)

func Step

func Step(label string, f func(page playwright.Page) playwright.Page, page playwright.Page) (string, int64, playwright.Page)

func WebTest

func WebTest(options Options, test Test) []map[string]int64

Types

type Options

type Options struct {
	Vus        int
	Duration   int
	Iterations int
}

Options struct specifies the number of virtual users, test duration, or request iterations. In other words, the load tests cofiguration options.

type Request

type Request = httpbatch.Request

Request struct mimicking the one found in the httpbatch library

type Test

type Test func() map[string]int64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL