sim

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CollectionName = "examples"

CollectionName -

View Source
var SimDBName = fmt.Sprintf("_KEYHOLE_%X", 1024+1024*rand.Intn(1024))

SimDBName - db name for simulation

Functions

func GetSchemaFromCollection

func GetSchemaFromCollection(client *mongo.Client, dbName string, collection string) (string, error)

GetSchemaFromCollection returns a masked first doc of a collection

func PopulateData

func PopulateData(uri string, sslCAFile string, sslPEMKeyFile string) error

PopulateData - Insert docs to evaluate performance/bandwidth

{
	favorites: {
		sports: []
		cities: []
	}
	favoriteSports: []
	favoriteSports1
	favoriteSports2
	favoriteSports3
}

Types

type Feeder

type Feeder struct {
	// contains filtered or unexported fields
}

Feeder seeds feeder

func NewFeeder

func NewFeeder() *Feeder

NewFeeder establish seeding parameters

func (*Feeder) SeedAllDemoData

func (f *Feeder) SeedAllDemoData(client *mongo.Client)

SeedAllDemoData - seed data for demo

 models: {
   "_id": string
  "name": string,
  "description": string
  "year": integer
}
robots: {
  "_id": string
  "modelId": string
  "notes": string,
  "batteryPct": float,
  "tasks": [{"for": string, "minutesUsed": integer}]
}

func (*Feeder) SeedCars

func (f *Feeder) SeedCars(client *mongo.Client)

SeedCars seeds cars collection

func (*Feeder) SeedData

func (f *Feeder) SeedData(client *mongo.Client) error

SeedData seeds all demo data

func (*Feeder) SeedFavorites

func (f *Feeder) SeedFavorites(client *mongo.Client)

SeedFavorites seeds demo data of collection favorites

func (*Feeder) SetCollection

func (f *Feeder) SetCollection(collection string)

SetCollection set collection

func (*Feeder) SetDatabase

func (f *Feeder) SetDatabase(database string)

SetDatabase set database

func (*Feeder) SetFile

func (f *Feeder) SetFile(file string)

SetFile set file

func (*Feeder) SetIsDrop

func (f *Feeder) SetIsDrop(isDrop bool)

SetIsDrop set isDrop

func (*Feeder) SetShowProgress

func (f *Feeder) SetShowProgress(showProgress bool)

SetShowProgress set showProgress

func (*Feeder) SetTotal

func (f *Feeder) SetTotal(total int)

SetTotal set total

type Model

type Model struct {
	ID          string `json:"_id" bson:"_id"`
	Name        string
	Description string
	Year        int
}

Model - robot model

type Robot

type Robot struct {
	ID         string  `json:"_id" bson:"_id"`
	ModelID    string  `json:"modelId,omitempty" bson:"modelId,omitempty"`
	Notes      string  `json:"notes" bson:"notes"`
	BatteryPct float32 `json:"batteryPct,omitempty" bson:"batteryPct,omitempty"`
	Tasks      []Task  `json:"tasks" bson:"tasks"`
}

Robot -

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner -

func NewRunner

func NewRunner(uri string, sslCAFile string, sslPEMKeyFile string) (*Runner, error)

NewRunner - Constructor

func (*Runner) Cleanup

func (rn *Runner) Cleanup() error

Cleanup drops the temp database

func (*Runner) CollectDBStats

func (rn *Runner) CollectDBStats(client *mongo.Client, channel chan string, dbName string, uri string)

CollectDBStats collects dbStats every 10 seconds

func (*Runner) CollectServerStatus

func (rn *Runner) CollectServerStatus(uri string, channel chan string)

CollectServerStatus collects db.serverStatus() every minute

func (*Runner) CreateIndexes

func (rn *Runner) CreateIndexes(docs []bson.M) error

CreateIndexes creates indexes

func (*Runner) PrintServerStatus

func (rn *Runner) PrintServerStatus(uri string, span int) (string, error)

PrintServerStatus prints serverStatusDocs summary for the duration

func (*Runner) ReplSetGetStatus

func (rn *Runner) ReplSetGetStatus(uri string, channel chan string)

ReplSetGetStatus collects {replSetGetStatus: 1} every minute

func (*Runner) SetDropFirstMode

func (rn *Runner) SetDropFirstMode(mode bool)

SetDropFirstMode -

func (*Runner) SetMonitorMode

func (rn *Runner) SetMonitorMode(mode bool)

SetMonitorMode -

func (*Runner) SetNumberConnections

func (rn *Runner) SetNumberConnections(num int)

SetNumberConnections -

func (*Runner) SetPeekMode

func (rn *Runner) SetPeekMode(mode bool)

SetPeekMode -

func (*Runner) SetSimOnlyMode

func (rn *Runner) SetSimOnlyMode(mode bool)

SetSimOnlyMode -

func (*Runner) SetSimulationDuration

func (rn *Runner) SetSimulationDuration(duration int)

SetSimulationDuration -

func (*Runner) SetTPS

func (rn *Runner) SetTPS(tps int)

SetTPS set transaction per second

func (*Runner) SetTemplateFilename

func (rn *Runner) SetTemplateFilename(filename string)

SetTemplateFilename -

func (*Runner) SetTransactionTemplateFilename

func (rn *Runner) SetTransactionTemplateFilename(filename string)

SetTransactionTemplateFilename -

func (*Runner) SetVerbose

func (rn *Runner) SetVerbose(verbose bool)

SetVerbose -

func (*Runner) Simulate

func (rn *Runner) Simulate(duration int, transactions []Transaction, thread int)

Simulate simulates CRUD for load tests

func (*Runner) Start

func (rn *Runner) Start() error

Start process requests

type Task

type Task struct {
	For         string `json:"for" bson:"for"`
	MinutesUsed int    `json:"minutesUsed" bson:"minutesUsed"`
}

Task - robot task

type Transaction

type Transaction struct {
	C      string   `json:"c"`
	Filter bson.M   `json:"filter"`
	Op     bson.M   `json:"op"`
	Pipe   []bson.M `json:"pipe"`
}

Transaction -

type TransactionDoc

type TransactionDoc struct {
	Transactions []Transaction `json:"transactions" bson:"transactions"`
	Indexes      []bson.M      `json:"indexes" bson:"indexes"`
}

TransactionDoc -

func GetTransactions

func GetTransactions(filename string) TransactionDoc

GetTransactions -

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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