Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
isacikgoz committed Jun 11, 2024
1 parent 6656416 commit 2cfc265
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
5 changes: 0 additions & 5 deletions loadtest/control/simulcontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ func getActionList(c *SimulController) []userAction {
run: c.generateUserReport,
frequency: 0.0001,
},
{
name: "SubmitClientPerformanceReport",
run: submitPerformanceReport,
frequency: 0.0001,
},
}

return actions
Expand Down
20 changes: 17 additions & 3 deletions loadtest/control/simulcontroller/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,33 @@ import (

const (
getUsersStatusByIdsInterval = 60 * time.Second
submitClientMetircsInterval = 60 * time.Second
)

func (c *SimulController) periodicActions(wg *sync.WaitGroup) {
defer wg.Done()
st := time.NewTicker(getUsersStatusByIdsInterval)
mt := time.NewTicker(submitClientMetircsInterval)

defer func() {
mt.Stop()
st.Stop()
wg.Done()
}()

for {
select {
case <-time.After(getUsersStatusByIdsInterval):
case <-st.C:
if resp := c.getUsersStatuses(); resp.Err != nil {
c.status <- c.newErrorStatus(resp.Err)
} else {
c.status <- c.newInfoStatus(resp.Info)
}
// We can add more periodic actions here.
case <-mt.C:
if resp := submitPerformanceReport(c.user); resp.Err != nil {
c.status <- c.newErrorStatus(resp.Err)
} else {
c.status <- c.newInfoStatus(resp.Info)
}
case <-c.disconnectChan:
return
}
Expand Down
8 changes: 4 additions & 4 deletions loadtest/store/memstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,15 +1189,15 @@ func (s *MemStore) PostsWithAckRequests() ([]string, error) {
}

func (s *MemStore) SetPerformanceReport(report *model.PerformanceReport) {
s.lock.RLock()
defer s.lock.RUnlock()
s.lock.Lock()
defer s.lock.Unlock()

s.report = report
}

func (s *MemStore) PerformanceReport() (*model.PerformanceReport, error) {
s.lock.RLock()
defer s.lock.RUnlock()
s.lock.Lock()
defer s.lock.Unlock()
if s.report == nil {
return nil, nil
}
Expand Down

0 comments on commit 2cfc265

Please sign in to comment.