@@ -2013,8 +2013,10 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2013
2013
2014
2014
_ ,_ = fmt .Fprintln (inv .Stderr ,"Creating users..." )
2015
2015
2016
- dialBarrier := & sync.WaitGroup {}
2017
- dialBarrier .Add (int (userCount ))
2016
+ ownerDialBarrier := & sync.WaitGroup {}
2017
+ regularDialBarrier := & sync.WaitGroup {}
2018
+ ownerDialBarrier .Add (int (ownerUserCount ))
2019
+ regularDialBarrier .Add (int (regularUserCount ))
2018
2020
2019
2021
configs := make ([]notifications.Config ,0 ,userCount )
2020
2022
for range ownerUserCount {
@@ -2025,7 +2027,7 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2025
2027
IsOwner :true ,
2026
2028
NotificationTimeout :notificationTimeout ,
2027
2029
DialTimeout :dialTimeout ,
2028
- DialBarrier :dialBarrier ,
2030
+ DialBarrier :ownerDialBarrier ,
2029
2031
Metrics :metrics ,
2030
2032
}
2031
2033
if err := config .Validate ();err != nil {
@@ -2041,7 +2043,8 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2041
2043
IsOwner :false ,
2042
2044
NotificationTimeout :notificationTimeout ,
2043
2045
DialTimeout :dialTimeout ,
2044
- DialBarrier :dialBarrier ,
2046
+ DialBarrier :regularDialBarrier ,
2047
+ OwnerDialBarrier :ownerDialBarrier ,
2045
2048
Metrics :metrics ,
2046
2049
}
2047
2050
if err := config .Validate ();err != nil {
@@ -2051,31 +2054,55 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2051
2054
}
2052
2055
2053
2056
go func () {
2054
- logger .Info (ctx ,"waiting forall users to connect" )
2057
+ logger .Info (ctx ,"waiting forowner users to connect" )
2055
2058
2056
- //Create timeout context forthe entire trigger operation
2057
- waitCtx ,cancel := context .WithTimeout (ctx ,dialTimeout + 30 * time .Second )
2059
+ //Wait forowner users to connect
2060
+ ownerWaitCtx ,cancel := context .WithTimeout (ctx ,dialTimeout + 30 * time .Second )
2058
2061
defer cancel ()
2059
2062
2060
- // Wait for all runners to reach the barrier
2061
- done := make (chan struct {})
2063
+ ownerDone := make (chan struct {})
2062
2064
go func () {
2063
- dialBarrier .Wait ()
2064
- close (done )
2065
+ ownerDialBarrier .Wait ()
2066
+ close (ownerDone )
2065
2067
}()
2066
2068
2067
2069
select {
2068
- case <- done :
2069
- logger .Info (ctx ,"all users connected" )
2070
- case <- waitCtx .Done ():
2071
- if waitCtx .Err ()== context .DeadlineExceeded {
2072
- logger .Error (ctx ,"timeout waiting forall users to connect" )
2070
+ case <- ownerDone :
2071
+ logger .Info (ctx ,"allowner users connected" )
2072
+ case <- ownerWaitCtx .Done ():
2073
+ if ownerWaitCtx .Err ()== context .DeadlineExceeded {
2074
+ logger .Error (ctx ,"timeout waiting forowner users to connect" )
2073
2075
}else {
2074
- logger .Info (ctx ,"context canceled while waiting for users" )
2076
+ logger .Info (ctx ,"context canceled while waiting forowner users" )
2075
2077
}
2076
2078
return
2077
2079
}
2078
2080
2081
+ // Wait for regular users to connect
2082
+ logger .Info (ctx ,"waiting for regular users to connect" )
2083
+ regularWaitCtx ,cancel := context .WithTimeout (ctx ,dialTimeout + 30 * time .Second )
2084
+ defer cancel ()
2085
+
2086
+ regularDone := make (chan struct {})
2087
+ go func () {
2088
+ regularDialBarrier .Wait ()
2089
+ close (regularDone )
2090
+ }()
2091
+
2092
+ select {
2093
+ case <- regularDone :
2094
+ logger .Info (ctx ,"all regular users connected" )
2095
+ case <- regularWaitCtx .Done ():
2096
+ if regularWaitCtx .Err ()== context .DeadlineExceeded {
2097
+ logger .Error (ctx ,"timeout waiting for regular users to connect" )
2098
+ }else {
2099
+ logger .Info (ctx ,"context canceled while waiting for regular users" )
2100
+ }
2101
+ return
2102
+ }
2103
+
2104
+ logger .Info (ctx ,"all users connected, triggering notifications" )
2105
+
2079
2106
const (
2080
2107
triggerUsername = "scaletest-trigger-user"
2081
2108
triggerEmail = "scaletest-trigger@example.com"