Skip to content

Commit

Permalink
simplify loadtester code (#23)
Browse files Browse the repository at this point in the history
* reconcile subscriptions

* simplify loadtest

* add subscriptions

* synchronize id generation

* change base config

* code cleanup

* add unit test github action

* add build action

* check if events get sent during test
  • Loading branch information
k15r authored Aug 12, 2023
1 parent 834d224 commit e01483b
Show file tree
Hide file tree
Showing 16 changed files with 644 additions and 676 deletions.
62 changes: 8 additions & 54 deletions internal/loadtest/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,17 @@ package config
import (
"flag"
"fmt"
"strings"
"time"
)

// Config represents environment config.
type Config struct {
ServerAddress string
PublishEndpoint string `config:"publish_endpoint"`
UseLegacyEvents bool `config:"use_legacy_events"`
EventSource string `config:"event_source"`
MaxInflightMessages0 string `config:"max_inflight_messages_0"`
MaxInflightMessages1 string `config:"max_inflight_messages_1"`
EventName0 string `config:"event_name_0"`
EventName1 string `config:"event_name_1"`
VersionFormat string `config:"version_format"`
GenerateCount0 int `config:"generate_count_0"`
GenerateCount1 int `config:"generate_count_1"`
EpsStart0 int `config:"eps_start_0"`
EpsStart1 int `config:"eps_start_1"`
EpsIncrement0 int `config:"eps_increment_0"`
EpsIncrement1 int `config:"eps_increment_1"`
EpsLimit int `config:"eps_limit"`
Workers int `config:"workers"`
MaxIdleConns int `config:"max_idle_conns"`
MaxConnsPerHost int `config:"max_conns_per_host"`
MaxIdleConnsPerHost int `config:"max_idle_conns_per_host"`
IdleConnTimeout time.Duration `config:"idle_conn_timeout"`
ServerAddress string
PublishHost string `config:"publish_host"`
MaxIdleConns int `config:"max_idle_conns"`
MaxConnsPerHost int `config:"max_conns_per_host"`
MaxIdleConnsPerHost int `config:"max_idle_conns_per_host"`
IdleConnTimeout time.Duration `config:"idle_conn_timeout"`
}

func New() *Config {
Expand All @@ -39,39 +23,9 @@ func New() *Config {
return c
}

// IsVersionFormatEmpty returns true if event version is empty.
func (c *Config) IsVersionFormatEmpty() bool {
return len(strings.TrimSpace(c.VersionFormat)) == 0
}

// IsEventName0Empty returns true if event name 0 is empty.
func (c *Config) IsEventName0Empty() bool {
return len(strings.TrimSpace(c.EventName0)) == 0
}

// IsEventName1Empty returns true if event name 1 is empty.
func (c *Config) IsEventName1Empty() bool {
return len(strings.TrimSpace(c.EventName1)) == 0
}

// ComputeEventsCount returns the count of events to generate.
func (c *Config) ComputeEventsCount() int {
count := 0
if c.IsVersionFormatEmpty() {
return count
}
if !c.IsEventName0Empty() {
count += c.GenerateCount0
}
if !c.IsEventName1Empty() {
count += c.GenerateCount1
}
return count
}

func (c *Config) String() string {
return fmt.Sprintf(
"ServerAddress: %v PublishEndpoint: %v MaxInflightMessages0: %v MaxInflightMessages1: %v EventFormat0: %v EventFormat1: %v GenerateCount0: %v GenerateCount1: %v EpsStart0: %v EpsStart1: %v EpsIncrement0: %v EpsIncrement1: %v EpsLimit: %v Workers: %v MaxIdleConns: %v MaxConnsPerHost : %v MaxIdleConnsPerHost: %v IdleConnTimeout: %v",
c.ServerAddress, c.PublishEndpoint, c.MaxInflightMessages0, c.MaxInflightMessages1, c.EventName0, c.EventName1, c.GenerateCount0, c.GenerateCount1, c.EpsStart0, c.EpsStart1, c.EpsIncrement0, c.EpsIncrement1, c.EpsLimit, c.Workers, c.MaxIdleConns, c.MaxConnsPerHost, c.MaxIdleConnsPerHost, c.IdleConnTimeout,
"ServerAddress: %v PublishHost: %v MaxIdleConns: %v MaxConnsPerHost : %v MaxIdleConnsPerHost: %v IdleConnTimeout: %v",
c.ServerAddress, c.PublishHost, c.MaxIdleConns, c.MaxConnsPerHost, c.MaxIdleConnsPerHost, c.IdleConnTimeout,
)
}
6 changes: 6 additions & 0 deletions internal/loadtest/config/notifiable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package config

import corev1 "k8s.io/api/core/v1"

type Notifiable interface {
AddNotifiable
UpdateNotifiable
DeleteNotifiable
}

type AddNotifiable interface {
NotifyAdd(*corev1.ConfigMap)
}
Expand Down
203 changes: 0 additions & 203 deletions internal/loadtest/events/GenericEvent/events.go

This file was deleted.

58 changes: 0 additions & 58 deletions internal/loadtest/events/GenericFactory/factory.go

This file was deleted.

30 changes: 0 additions & 30 deletions internal/loadtest/events/events.go

This file was deleted.

Loading

0 comments on commit e01483b

Please sign in to comment.