utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncMaps = template.FuncMap{
	"split": func(s any, sep string, i int) string {
		switch v := s.(type) {
		case string:
			parts := strings.Split(v, sep)
			if len(parts) > i {
				return parts[i]
			}
			return parts[0]
		default:
			return ""
		}
	},
	"randInt": func(sep string, n ...int) string {
		result := make([]string, len(n))
		for i := range n {
			result[i] = strconv.Itoa(rand.Intn(n[i]))
		}

		return strings.Join(result, sep)
	},
	"join": func(sep string, s ...any) string {
		result := make([]string, len(s))
		for i := range s {
			result[i] = fmt.Sprintf("%v", s[i])
		}
		return strings.Join(result, sep)
	},
}

Functions

func DoStats

func DoStats(ch <-chan *Stats)

func ReadYAMLFiles

func ReadYAMLFiles(folderPath string) (map[string]*Scenario, error)

func RunScenario added in v1.1.2

func RunScenario(ctx context.Context, wg *sync.WaitGroup, statCh chan<- *Stats, round int, scenario *Scenario)

func ShowStats

func ShowStats(scenarios map[string]*Scenario)

Types

type Scenario

type Scenario struct {
	Name        string                   `yaml:"name"`
	Concurrency int                      `yaml:"concurrency"`
	SilentRun   bool                     `yaml:"silent"`
	Iteration   int                      `yaml:"iteration"`
	Steps       map[string]*ScenarioStep `yaml:"steps"`
	Verbose     bool                     `yaml:"verbose"`
	// contains filtered or unexported fields
}

func (*Scenario) Sorted

func (s *Scenario) Sorted() []*SortInfo

type ScenarioStep

type ScenarioStep struct {
	Order     int               `yaml:"order"`
	URL       string            `yaml:"url"`
	Verb      string            `yaml:"verb"`
	Pause     time.Duration     `yaml:"pause"`
	Variables map[string]any    `yaml:"variables"`
	Headers   map[string]string `yaml:"headers"`
	Body      map[string]any    `yaml:"body"`
}

type SortInfo

type SortInfo struct {
	Order int
	Name  string
}

type Stats

type Stats struct {
	Scenario string
	Step     string
	Status   string
}

Jump to

Keyboard shortcuts

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