Skip to content

Commit

Permalink
chore(GODT-1570): Cleanup flag names to avoid conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeernaertProton committed Aug 10, 2022
1 parent 73a7d85 commit b57cfc9
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 83 deletions.
10 changes: 5 additions & 5 deletions benchmarks/gluon_bench/flags/imap_benchmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package flags
import "flag"

var (
RemoteServer = flag.String("remote-server", "", "IP address and port of the remote IMAP server to run against. E.g. 127.0.0.1:1143.")
MessageCount = flag.Uint("msg-count", 1000, "Number of messages to add to the mailbox before each benchmark")
RandomSeqSetIntervals = flag.Bool("random-seqset-intervals", false, "When set, generate random sequence intervals rather than single numbers.")
UIDMode = flag.Bool("uid-mode", false, "When set, will run benchmarks in UID mode if available.")
ParallelClients = flag.Uint("parallel-clients", 1, "Set the number of clients to be run in parallel during the benchmark.")
IMAPRemoteServer = flag.String("imap-remote-server", "", "IP address and port of the remote IMAP server to run against. E.g. 127.0.0.1:1143.")
IMAPMessageCount = flag.Uint("imap-msg-count", 1000, "Number of messages to add to the mailbox before each benchmark")
IMAPRandomSeqSetIntervals = flag.Bool("imap-random-seqset-intervals", false, "When set, generate random sequence intervals rather than single numbers.")
IMAPUIDMode = flag.Bool("imap-uid-mode", false, "When set, will run benchmarks in UID mode if available.")
IMAPParallelClients = flag.Uint("imap-parallel-clients", 1, "Set the number of clients to be run in parallel during the benchmark.")
)
2 changes: 1 addition & 1 deletion benchmarks/gluon_bench/gluon_benchmarks/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewSync() benchmark.Benchmark {
}

func (s *Sync) Name() string {
return "sync"
return "gluon-sync"
}

func (s *Sync) Setup(ctx context.Context, benchmarkDir string) error {
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/gluon_bench/imap_benchmarks/append.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ func NewAppend() benchmark.Benchmark {
}

func (a *Append) Name() string {
return "append"
return "imap-append"
}

func (a *Append) Setup(ctx context.Context, addr net.Addr) error {
if *flags.MessageCount == 0 {
if *flags.IMAPMessageCount == 0 {
return fmt.Errorf("invalid message count")
}

return WithClient(addr, func(cl *client.Client) error {
for i := uint(0); i < *flags.ParallelClients; i++ {
for i := uint(0); i < *flags.IMAPParallelClients; i++ {
if _, err := a.createRandomMBox(cl); err != nil {
return err
}
Expand All @@ -44,7 +44,7 @@ func (a *Append) TearDown(ctx context.Context, addr net.Addr) error {

func (a *Append) Run(ctx context.Context, addr net.Addr) error {
RunParallelClients(addr, func(c *client.Client, u uint) {
if err := BuildMailbox(c, a.MBoxes[u], int(*flags.MessageCount)); err != nil {
if err := BuildMailbox(c, a.MBoxes[u], int(*flags.IMAPMessageCount)); err != nil {
panic(err)
}
})
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/gluon_bench/imap_benchmarks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,16 @@ type MailboxInfo struct {
}

func RunParallelClientsWithMailbox(addr net.Addr, mbox string, readOnly bool, fn func(*client.Client, uint)) {
mailboxes := make([]MailboxInfo, *flags.ParallelClients)
for i := uint(0); i < *flags.ParallelClients; i++ {
mailboxes := make([]MailboxInfo, *flags.IMAPParallelClients)
for i := uint(0); i < *flags.IMAPParallelClients; i++ {
mailboxes[i] = MailboxInfo{Name: mbox, ReadOnly: readOnly}
}

RunParallelClientsWithMailboxes(addr, mailboxes, fn)
}

func RunParallelClientsWithMailboxes(addr net.Addr, mailboxes []MailboxInfo, fn func(*client.Client, uint)) {
if len(mailboxes) != int(*flags.ParallelClients) {
if len(mailboxes) != int(*flags.IMAPParallelClients) {
panic("Mailbox count doesn't match worker count")
}

Expand All @@ -186,7 +186,7 @@ func RunParallelClientsWithMailboxes(addr net.Addr, mailboxes []MailboxInfo, fn
func RunParallelClients(addr net.Addr, fn func(*client.Client, uint)) {
wg := sync.WaitGroup{}

for i := uint(0); i < *flags.ParallelClients; i++ {
for i := uint(0); i < *flags.IMAPParallelClients; i++ {
wg.Add(1)

go func(index uint) {
Expand All @@ -206,11 +206,11 @@ func RunParallelClients(addr net.Addr, fn func(*client.Client, uint)) {
}

func FillMailbox(cl *client.Client, mbox string) error {
if *flags.MessageCount == 0 {
if *flags.IMAPMessageCount == 0 {
return fmt.Errorf("message count can't be 0")
}

return BuildMailbox(cl, mbox, int(*flags.MessageCount))
return BuildMailbox(cl, mbox, int(*flags.IMAPMessageCount))
}

func WithClient(addr net.Addr, fn func(*client.Client) error) error {
Expand Down
18 changes: 9 additions & 9 deletions benchmarks/gluon_bench/imap_benchmarks/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

var (
copyCountFlag = flag.Uint("copy-count", 0, "Total number of messages to copy during copy benchmarks.")
copyListFlag = flag.String("copy-list", "", "Use a list of predefined sequences to copy rather than random generated.")
copyAllFlag = flag.Bool("copy-all", false, "If set, perform a copy of the all messages.")
copyCountFlag = flag.Uint("imap-copy-count", 0, "Total number of messages to copy during copy benchmarks.")
copyListFlag = flag.String("imap-copy-list", "", "Use a list of predefined sequences to copy rather than random generated.")
copyAllFlag = flag.Bool("imap-copy-all", false, "If set, perform a copy of the all messages.")
)

type Copy struct {
Expand All @@ -29,7 +29,7 @@ func NewCopy() benchmark.Benchmark {
}

func (*Copy) Name() string {
return "copy"
return "imap-copy"
}

func (c *Copy) Setup(ctx context.Context, addr net.Addr) error {
Expand All @@ -44,16 +44,16 @@ func (c *Copy) Setup(ctx context.Context, addr net.Addr) error {

copyCount := uint32(*copyCountFlag)
if copyCount == 0 {
copyCount = uint32(*flags.MessageCount / 2)
copyCount = uint32(*flags.IMAPMessageCount / 2)
}

seqSets, err := NewParallelSeqSet(copyCount,
*flags.ParallelClients,
*flags.IMAPParallelClients,
*copyListFlag,
*copyAllFlag,
*flags.RandomSeqSetIntervals,
*flags.IMAPRandomSeqSetIntervals,
false,
*flags.UIDMode)
*flags.IMAPUIDMode)

if err != nil {
return err
Expand All @@ -75,7 +75,7 @@ func (c *Copy) Run(ctx context.Context, addr net.Addr) error {

RunParallelClientsWithMailbox(addr, srcMBox, true, func(cl *client.Client, index uint) {
var copyFn func(*client.Client, *imap.SeqSet, string) error
if *flags.UIDMode {
if *flags.IMAPUIDMode {
copyFn = func(cl *client.Client, set *imap.SeqSet, mailbox string) error {
return cl.UidCopy(set, mailbox)
}
Expand Down
32 changes: 16 additions & 16 deletions benchmarks/gluon_bench/imap_benchmarks/expunge.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
)

var (
expungeCountFlag = flag.Uint("expunge-count", 0, "Total number of messages to expunge during expunge benchmarks.")
expungeSameMBoxFlag = flag.Bool("expunge-same-mbox", false, "When true run all the expunge test on the same inbox rather than separate ones in parallel.")
expungeListFlag = flag.String("expunge-list", "", "Use a list of predefined sequences to expunge rather than random generated. Only works when -expunge-same-mbox is not set.")
expungeAllFlag = flag.Bool("expunge-all", false, "If set, perform a expunge of the all messages. Only works when -expunge-same-mbox is not set.")
expungeCountFlag = flag.Uint("imap-expunge-count", 0, "Total number of messages to expunge during expunge benchmarks.")
expungeSameMBoxFlag = flag.Bool("imap-expunge-same-mbox", false, "When true run all the expunge test on the same inbox rather than separate ones in parallel.")
expungeListFlag = flag.String("imap-expunge-list", "", "Use a list of predefined sequences to expunge rather than random generated. Only works when -expunge-same-mbox is not set.")
expungeAllFlag = flag.Bool("imap-expunge-all", false, "If set, perform a expunge of the all messages. Only works when -expunge-same-mbox is not set.")
)

type Expunge struct {
Expand All @@ -31,7 +31,7 @@ func NewExpunge() benchmark.Benchmark {
}

func (*Expunge) Name() string {
return "expunge"
return "imap-expunge"
}

func (e *Expunge) Setup(ctx context.Context, addr net.Addr) error {
Expand All @@ -43,33 +43,33 @@ func (e *Expunge) Setup(ctx context.Context, addr net.Addr) error {

expungeCount := uint32(*expungeCountFlag)
if expungeCount == 0 {
expungeCount = uint32(*flags.MessageCount) / 2
expungeCount = uint32(*flags.IMAPMessageCount) / 2
}

e.seqSets = NewParallelSeqSetExpunge(expungeCount,
*flags.ParallelClients,
*flags.RandomSeqSetIntervals,
*flags.UIDMode,
*flags.IMAPParallelClients,
*flags.IMAPRandomSeqSetIntervals,
*flags.IMAPUIDMode,
)

e.mboxInfo = make([]MailboxInfo, *flags.ParallelClients)
e.mboxInfo = make([]MailboxInfo, *flags.IMAPParallelClients)
for i := 0; i < len(e.mboxInfo); i++ {
e.mboxInfo[i] = MailboxInfo{Name: e.MBoxes[0], ReadOnly: false}
}
} else {
for i := uint(0); i < *flags.ParallelClients; i++ {
for i := uint(0); i < *flags.IMAPParallelClients; i++ {
if _, err := e.createAndFillRandomMBox(cl); err != nil {
return err
}
}

seqSets, err := NewParallelSeqSet(uint32(*flags.MessageCount),
*flags.ParallelClients,
seqSets, err := NewParallelSeqSet(uint32(*flags.IMAPMessageCount),
*flags.IMAPParallelClients,
*expungeListFlag,
*expungeAllFlag,
*flags.RandomSeqSetIntervals,
*flags.IMAPRandomSeqSetIntervals,
true,
*flags.UIDMode)
*flags.IMAPUIDMode)

if err != nil {
return err
Expand All @@ -92,7 +92,7 @@ func (e *Expunge) TearDown(ctx context.Context, addr net.Addr) error {
func (e *Expunge) Run(ctx context.Context, addr net.Addr) error {
RunParallelClientsWithMailboxes(addr, e.mboxInfo, func(cl *client.Client, index uint) {
var expungeFn func(*client.Client, *imap.SeqSet) error
if *flags.UIDMode {
if *flags.IMAPUIDMode {
expungeFn = func(cl *client.Client, set *imap.SeqSet) error {
if err := UIDStore(cl, set, "+FLAGS", true, imap.DeletedFlag); err != nil {
return err
Expand Down
20 changes: 10 additions & 10 deletions benchmarks/gluon_bench/imap_benchmarks/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

var (
fetchCountFlag = flag.Uint("fetch-count", 0, "Total number of messages to fetch during fetch benchmarks.")
fetchListFlag = flag.String("fetch-list", "", "Use a list of predefined sequences to fetch rather than random generated.")
fetchReadOnly = flag.Bool("fetch-read-only", false, "If set, perform fetches in read-only mode.")
fetchAllFlag = flag.Bool("fetch-all", false, "If set, perform one fetch for all messages.")
fetchCountFlag = flag.Uint("imap-fetch-count", 0, "Total number of messages to fetch during fetch benchmarks.")
fetchListFlag = flag.String("imap-fetch-list", "", "Use a list of predefined sequences to fetch rather than random generated.")
fetchReadOnly = flag.Bool("imap-fetch-read-only", false, "If set, perform fetches in read-only mode.")
fetchAllFlag = flag.Bool("imap-fetch-all", false, "If set, perform one fetch for all messages.")
)

type Fetch struct {
Expand All @@ -28,7 +28,7 @@ func NewFetch() benchmark.Benchmark {
}

func (*Fetch) Name() string {
return "fetch"
return "imap-fetch"
}

func (f *Fetch) Setup(ctx context.Context, addr net.Addr) error {
Expand All @@ -39,16 +39,16 @@ func (f *Fetch) Setup(ctx context.Context, addr net.Addr) error {

fetchCount := uint32(*fetchCountFlag)
if fetchCount == 0 {
fetchCount = uint32(*flags.MessageCount) / 2
fetchCount = uint32(*flags.IMAPMessageCount) / 2
}

seqSets, err := NewParallelSeqSet(fetchCount,
*flags.ParallelClients,
*flags.IMAPParallelClients,
*fetchListFlag,
*fetchAllFlag,
*flags.RandomSeqSetIntervals,
*flags.IMAPRandomSeqSetIntervals,
false,
*flags.UIDMode)
*flags.IMAPUIDMode)

if err != nil {
return err
Expand All @@ -66,7 +66,7 @@ func (f *Fetch) TearDown(ctx context.Context, addr net.Addr) error {
func (f *Fetch) Run(ctx context.Context, addr net.Addr) error {
RunParallelClientsWithMailbox(addr, f.MBoxes[0], *fetchReadOnly, func(cl *client.Client, index uint) {
var fetchFn func(*client.Client, *imap.SeqSet) error
if *flags.UIDMode {
if *flags.IMAPUIDMode {
fetchFn = func(cl *client.Client, set *imap.SeqSet) error {
return UIDFetchMessage(cl, set, imap.FetchAll)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (i *IMAPBenchmarkRunner) TearDown(ctx context.Context) error {
func NewIMAPBenchmarkRunner(bench IMAPBenchmark) benchmark.Benchmark {
var serverBuilder server.ServerBuilder

if len(*flags.RemoteServer) != 0 {
builder, err := server.NewRemoteServerBuilder(*flags.RemoteServer)
if len(*flags.IMAPRemoteServer) != 0 {
builder, err := server.NewRemoteServerBuilder(*flags.IMAPRemoteServer)
if err != nil {
panic(fmt.Sprintf("Invalid Server address: %v", err))
}
Expand Down
28 changes: 14 additions & 14 deletions benchmarks/gluon_bench/imap_benchmarks/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
)

var (
moveListFlag = flag.String("move-list", "", "Use a list of predefined sequences to move rather than random generated.")
moveAllFlag = flag.Bool("move-all", false, "If set, perform a move of the all messages.")
moveIntoSameDstFlag = flag.Bool("move-into-same-dst", false, "If set, rather than moving each unique mailbox into separate unique mailboxes, move all messages into one common destination mailbox.")
moveListFlag = flag.String("imap-move-list", "", "Use a list of predefined sequences to move rather than random generated.")
moveAllFlag = flag.Bool("imap-move-all", false, "If set, perform a move of the all messages.")
moveIntoSameDstFlag = flag.Bool("imap-move-into-same-dst", false, "If set, rather than moving each unique mailbox into separate unique mailboxes, move all messages into one common destination mailbox.")
)

type Move struct {
Expand All @@ -32,19 +32,19 @@ func NewMove() benchmark.Benchmark {
}

func (*Move) Name() string {
return "move"
return "imap-move"
}

func (m *Move) Setup(ctx context.Context, addr net.Addr) error {
if *flags.MessageCount == 0 {
if *flags.IMAPMessageCount == 0 {
return fmt.Errorf("move benchmark requires a message count > 0")
}

return WithClient(addr, func(cl *client.Client) error {
m.srcMailboxes = make([]string, 0, *flags.ParallelClients)
m.dstMailboxes = make([]string, 0, *flags.ParallelClients)
m.srcMailboxes = make([]string, 0, *flags.IMAPParallelClients)
m.dstMailboxes = make([]string, 0, *flags.IMAPParallelClients)

for i := uint(0); i < *flags.ParallelClients; i++ {
for i := uint(0); i < *flags.IMAPParallelClients; i++ {
mbox, err := m.createAndFillRandomMBox(cl)
if err != nil {
return err
Expand All @@ -57,7 +57,7 @@ func (m *Move) Setup(ctx context.Context, addr net.Addr) error {
if *moveIntoSameDstFlag {
dstMboxCount = 1
} else {
dstMboxCount = *flags.ParallelClients
dstMboxCount = *flags.IMAPParallelClients
}

for i := uint(0); i < dstMboxCount; i++ {
Expand All @@ -69,13 +69,13 @@ func (m *Move) Setup(ctx context.Context, addr net.Addr) error {
m.dstMailboxes = append(m.dstMailboxes, mbox)
}

seqSets, err := NewParallelSeqSet(uint32(*flags.MessageCount),
*flags.ParallelClients,
seqSets, err := NewParallelSeqSet(uint32(*flags.IMAPMessageCount),
*flags.IMAPParallelClients,
*moveListFlag,
*moveAllFlag,
*flags.RandomSeqSetIntervals,
*flags.IMAPRandomSeqSetIntervals,
true,
*flags.UIDMode)
*flags.IMAPUIDMode)

if err != nil {
return err
Expand All @@ -101,7 +101,7 @@ func (m *Move) Run(ctx context.Context, addr net.Addr) error {

RunParallelClientsWithMailboxes(addr, mboxInfos, func(cl *client.Client, index uint) {
var moveFn func(*client.Client, *imap.SeqSet, string) error
if *flags.UIDMode {
if *flags.IMAPUIDMode {
moveFn = func(cl *client.Client, set *imap.SeqSet, mailbox string) error {
return cl.UidMove(set, mailbox)
}
Expand Down
Loading

0 comments on commit b57cfc9

Please sign in to comment.