Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9baf15d
Refactor benchmark command to make it easier to extend
marc-gr Apr 4, 2023
e66cb0e
Add new command and read config
marc-gr Apr 17, 2023
6471a04
Set up service and generator
marc-gr Apr 20, 2023
2c1ca74
Improve policy creation and add docker service deployer
marc-gr Apr 20, 2023
7e9431d
Bump es api version
marc-gr Apr 22, 2023
3ecb122
Add new options
marc-gr Apr 22, 2023
8c7317a
Add new reportable types
marc-gr Apr 22, 2023
1365b73
Collect and report summary metrics
marc-gr Apr 22, 2023
18907a7
Add documentation
marc-gr Apr 24, 2023
eb81501
Add system benchmark test
marc-gr Apr 24, 2023
2a212ee
Save report file
marc-gr Apr 24, 2023
a23cf93
Ensure all data is generated previous to agents being assigned
marc-gr Apr 24, 2023
5b8685f
Save file indented
marc-gr Apr 24, 2023
7a00403
Update readme
marc-gr Apr 24, 2023
6248280
Lint
marc-gr Apr 24, 2023
c2a739c
Make test faster
marc-gr Apr 24, 2023
c31f346
Go back to 7.17 client
marc-gr Apr 24, 2023
100ab02
fix tests
marc-gr Apr 24, 2023
a562da9
Change comments
marc-gr Apr 24, 2023
c40e3f4
Add monitoringenabled option
marc-gr Apr 24, 2023
db19c61
Update report.go
marc-gr Apr 24, 2023
4c6c957
Merge remote-tracking branch 'upstream/main' into system-benchmarks
marc-gr May 11, 2023
8bb217f
Delete outputs.go from kibana
marc-gr Jun 12, 2023
0f14a26
Rename reports payload property
marc-gr Jun 12, 2023
6216dbc
Remove pkg/errors from ingest, kibana, and servicedeployer
marc-gr Jun 12, 2023
fa40496
Amend const and comment
marc-gr Jun 12, 2023
678f402
Avoid overriding configs unadvertedly
marc-gr Jun 12, 2023
73d321c
Change byte replace to strings.Replacer
marc-gr Jun 12, 2023
07867cc
Undo change in report benchmark command
marc-gr Jun 12, 2023
94f8fd4
Merge remote-tracking branch 'upstream/main' into system-benchmarks
marc-gr Jun 12, 2023
fc37e66
Use policy template name to generate input name
marc-gr Jun 12, 2023
c992308
Fix readme
marc-gr Jun 20, 2023
eaf6b75
Add corpora file to report
marc-gr Jun 20, 2023
6e3009e
Cleanup corpora generated data
marc-gr Jun 20, 2023
44d40e7
Merge remote-tracking branch 'upstream/main' into system-benchmarks
marc-gr Jun 20, 2023
42cb4a0
Fix lint error
marc-gr Jun 20, 2023
d226d8d
Fix test package format
marc-gr Jun 20, 2023
83b46b7
Fix lint errors
marc-gr Jun 20, 2023
e6cce98
Fix processor error return
marc-gr Jun 20, 2023
6052777
Merge remote-tracking branch 'upstream/main' into system-benchmarks
marc-gr Jun 22, 2023
2538ae5
Rename folder to accomodate to spec
marc-gr Jun 22, 2023
223e1ac
Add prefix check
marc-gr Jun 22, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure all data is generated previous to agents being assigned
  • Loading branch information
marc-gr committed Apr 24, 2023
commit a23cf933d9ae10b50b3dc11f726a8b532c7918f3
101 changes: 56 additions & 45 deletions internal/benchrunner/runners/system/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type runner struct {
scenario *scenario

ctxt servicedeployer.ServiceContext
benchPolicy *kibana.Policy
runtimeDataStream string
pipelinePrefix string
generator genlib.Generator
Expand Down Expand Up @@ -154,6 +155,7 @@ func (r *runner) setUp() error {
if err != nil {
return err
}
r.benchPolicy = policy

// Delete old data
logger.Debug("deleting old data in data stream...")
Expand Down Expand Up @@ -209,51 +211,6 @@ func (r *runner) setUp() error {
return err
}

agents, err := r.checkEnrolledAgents()
if err != nil {
return fmt.Errorf("can't check enrolled agents: %w", err)
}

handlers := make([]func() error, len(agents))
for i, agent := range agents {
origPolicy := kibana.Policy{
ID: agent.PolicyID,
Revision: agent.PolicyRevision,
}

// Assign policy to agent
handlers[i] = func() error {
logger.Debug("reassigning original policy back to agent...")
if err := r.options.KibanaClient.AssignPolicyToAgent(agent, origPolicy); err != nil {
return fmt.Errorf("error reassigning original policy to agent %s: %w", agent.ID, err)
}
return nil
}

policyWithDataStream, err := r.options.KibanaClient.GetPolicy(policy.ID)
if err != nil {
return fmt.Errorf("could not read the policy with data stream: %w", err)
}

logger.Debug("assigning package data stream to agent...")
if err := r.options.KibanaClient.AssignPolicyToAgent(agent, *policyWithDataStream); err != nil {
return fmt.Errorf("could not assign policy to agent: %w", err)
}
}

r.resetAgentPolicyHandler = func() error {
var merr multierror.Error
for _, h := range handlers {
if err := h(); err != nil {
merr = append(merr, err)
}
}
if len(merr) == 0 {
return nil
}
return merr
}

return nil
}

Expand Down Expand Up @@ -297,6 +254,11 @@ func (r *runner) run() (report reporters.Reportable, err error) {
}
}

// once data is generated, enroll agents and assign policy
if err := r.enrollAgents(); err != nil {
return nil, err
}

// Signal to the service that the agent is ready (policy is assigned).
if r.scenario.Corpora.InputService != nil && r.scenario.Corpora.InputService.Signal != "" {
if err = service.Signal(r.scenario.Corpora.InputService.Signal); err != nil {
Expand Down Expand Up @@ -669,6 +631,55 @@ func (r *runner) waitUntilBenchmarkFinishes() error {
return err
}

func (r *runner) enrollAgents() error {
agents, err := r.checkEnrolledAgents()
if err != nil {
return fmt.Errorf("can't check enrolled agents: %w", err)
}

handlers := make([]func() error, len(agents))
for i, agent := range agents {
origPolicy := kibana.Policy{
ID: agent.PolicyID,
Revision: agent.PolicyRevision,
}

// Assign policy to agent
handlers[i] = func() error {
logger.Debug("reassigning original policy back to agent...")
if err := r.options.KibanaClient.AssignPolicyToAgent(agent, origPolicy); err != nil {
return fmt.Errorf("error reassigning original policy to agent %s: %w", agent.ID, err)
}
return nil
}

policyWithDataStream, err := r.options.KibanaClient.GetPolicy(r.benchPolicy.ID)
if err != nil {
return fmt.Errorf("could not read the policy with data stream: %w", err)
}

logger.Debug("assigning package data stream to agent...")
if err := r.options.KibanaClient.AssignPolicyToAgent(agent, *policyWithDataStream); err != nil {
return fmt.Errorf("could not assign policy to agent: %w", err)
}
}

r.resetAgentPolicyHandler = func() error {
var merr multierror.Error
for _, h := range handlers {
if err := h(); err != nil {
merr = append(merr, err)
}
}
if len(merr) == 0 {
return nil
}
return merr
}

return nil
}

func getTotalHits(esapi *elasticsearch.API, dataStream string) (int, error) {
resp, err := esapi.Count(
esapi.Count.WithIndex(dataStream),
Expand Down