Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
db750a09
Commit
db750a09
authored
2 years ago
by
benjamin
Browse files
Options
Downloads
Patches
Plain Diff
hacked dummy message sender ramp down after sending 20 messages
parent
4dd4ba27
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!510
Release
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
dummy/manager.go
+4
-0
4 additions, 0 deletions
dummy/manager.go
dummy/manager_test.go
+1
-0
1 addition, 0 deletions
dummy/manager_test.go
dummy/send.go
+15
-1
15 additions, 1 deletion
dummy/send.go
dummy/utils_test.go
+2
-0
2 additions, 0 deletions
dummy/utils_test.go
with
22 additions
and
1 deletion
dummy/manager.go
+
4
−
0
View file @
db750a09
...
...
@@ -61,6 +61,8 @@ type Manager struct {
// Pauses/Resumes the dummy send thread when triggered
statusChan
chan
bool
totalSent
*
uint64
// Interfaces
net
cmix
.
Client
store
storage
.
Session
...
...
@@ -96,6 +98,7 @@ func NewManager(maxNumMessages int,
// function is a helper function for NewManager.
func
newManager
(
maxNumMessages
int
,
avgSendDelta
,
randomRange
time
.
Duration
,
net
cmix
.
Client
,
store
storage
.
Session
,
rng
*
fastRNG
.
StreamGenerator
)
*
Manager
{
numSent
:=
uint64
(
8
)
return
&
Manager
{
maxNumMessages
:
maxNumMessages
,
avgSendDelta
:
avgSendDelta
,
...
...
@@ -105,6 +108,7 @@ func newManager(maxNumMessages int, avgSendDelta, randomRange time.Duration,
net
:
net
,
store
:
store
,
rng
:
rng
,
totalSent
:
&
numSent
,
}
}
...
...
This diff is collapsed.
Click to expand it.
dummy/manager_test.go
+
1
−
0
View file @
db750a09
...
...
@@ -35,6 +35,7 @@ func Test_newManager(t *testing.T) {
statusChanLen
,
cap
(
received
.
statusChan
))
}
received
.
statusChan
=
expected
.
statusChan
received
.
totalSent
=
nil
if
!
reflect
.
DeepEqual
(
expected
,
received
)
{
t
.
Errorf
(
"New manager does not match expected."
+
...
...
This diff is collapsed.
Click to expand it.
dummy/send.go
+
15
−
1
View file @
db750a09
...
...
@@ -21,7 +21,12 @@ import (
// Error messages for the Manager.sendThread and its helper functions.
const
(
numMsgsRngErr
=
"failed to generate random number of messages to send: %+v"
numMsgsRngErr
=
"failed to generate random number of messages to send: %+v"
overrideAvgSendDelta
=
10
*
time
.
Minute
overrideRandomRange
=
8
*
time
.
Minute
overrideMaxNumMessages
=
2
numSendsToOverride
=
20
)
// sendThread is a thread that sends the dummy messages at random intervals.
...
...
@@ -32,6 +37,13 @@ func (m *Manager) sendThread(stop *stoppable.Single) {
nextSendChanPtr
:=
&
(
nextSendChan
)
for
{
if
numSent
:=
atomic
.
LoadUint64
(
m
.
totalSent
);
numSent
>
numSendsToOverride
{
m
.
avgSendDelta
=
overrideAvgSendDelta
m
.
randomRange
=
overrideRandomRange
m
.
maxNumMessages
=
overrideMaxNumMessages
}
select
{
case
status
:=
<-
m
.
statusChan
:
if
status
{
...
...
@@ -71,6 +83,8 @@ func (m *Manager) sendThread(stop *stoppable.Single) {
err
:=
m
.
sendMessages
()
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to send dummy messages: %+v"
,
err
)
}
else
{
atomic
.
AddUint64
(
m
.
totalSent
,
1
)
}
}()
case
<-
stop
.
Quit
()
:
...
...
This diff is collapsed.
Click to expand it.
dummy/utils_test.go
+
2
−
0
View file @
db750a09
...
...
@@ -40,6 +40,7 @@ func newTestManager(maxNumMessages int, avgSendDelta, randomRange time.Duration,
t
*
testing
.
T
)
*
Manager
{
store
:=
storage
.
InitTestingSession
(
t
)
payloadSize
:=
store
.
GetCmixGroup
()
.
GetP
()
.
ByteLen
()
n
:=
uint64
(
0
)
m
:=
&
Manager
{
maxNumMessages
:
maxNumMessages
,
avgSendDelta
:
avgSendDelta
,
...
...
@@ -48,6 +49,7 @@ func newTestManager(maxNumMessages int, avgSendDelta, randomRange time.Duration,
store
:
store
,
net
:
newMockCmix
(
payloadSize
),
rng
:
fastRNG
.
NewStreamGenerator
(
1000
,
10
,
csprng
.
NewSystemRNG
),
totalSent
:
&
n
,
}
return
m
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment