package test

import "github.com/open-policy-agent/opa/util/test"

Package test contains utilities used in the policy engine's test suite.

Index

Functions

func ArrayIterationBenchmarkModule

func ArrayIterationBenchmarkModule(n int) string

ArrayIterationBenchmarkModule returns a module that iterates an array with `n` elements

func GenerateConcurrencyBenchmarkData

func GenerateConcurrencyBenchmarkData() (string, map[string]interface{})

GenerateConcurrencyBenchmarkData returns a module and data; the module checks some input parameters against that data in a simple API authz scheme.

func GenerateJSONBenchmarkData

func GenerateJSONBenchmarkData(k, v int) map[string]interface{}

GenerateJSONBenchmarkData returns a map of `k` keys and `v` key/value pairs.

func GenerateLargeJSONBenchmarkData

func GenerateLargeJSONBenchmarkData() map[string]interface{}

GenerateLargeJSONBenchmarkData returns a map of 100 keys and 100.000 key/value pairs.

func GenerateVirtualDocsBenchmarkData

func GenerateVirtualDocsBenchmarkData(numTotalRules, numHitRules int) (string, map[string]interface{})

GenerateVirtualDocsBenchmarkData generates a module and input; the numTotalRules and numHitRules create as many rules in the module to match/miss the returned input.

func MakeTempFS

func MakeTempFS(root, prefix string, files map[string]string) (rootDir string, cleanup func(), err error)

MakeTempFS creates a temporary directory structure for test purposes rooted at root. If root is empty, the dir is created in the default system temp location. If the creation fails, cleanup is nil and the caller does not have to invoke it. If creation succeeds, the caller should invoke cleanup when they are done.

func ObjectIterationBenchmarkModule

func ObjectIterationBenchmarkModule(n int) string

ObjectIterationBenchmarkModule returns a module that iterates an object with `n` key/val pairs

func SetIterationBenchmarkModule

func SetIterationBenchmarkModule(n int) string

SetIterationBenchmarkModule returns a module that iterates a set with `n` elements

func WithTempFS

func WithTempFS(files map[string]string, f func(string))

WithTempFS creates a temporary directory structure and invokes f with the root directory path.

Source Files

benchmark.go doc.go tempfs.go

Version
v0.30.0
Published
Jul 1, 2021
Platform
js/wasm
Imports
7 packages
Last checked
3 minutes ago

Tools for package owners.