@@ -29,6 +29,7 @@ import (
29
29
30
30
"github.com/coder/coder/v2/cli/cliui"
31
31
"github.com/coder/coder/v2/coderd/httpapi"
32
+ notificationsLib"github.com/coder/coder/v2/coderd/notifications"
32
33
"github.com/coder/coder/v2/coderd/tracing"
33
34
"github.com/coder/coder/v2/codersdk"
34
35
"github.com/coder/coder/v2/codersdk/workspacesdk"
@@ -2018,17 +2019,23 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2018
2019
ownerDialBarrier .Add (int (ownerUserCount ))
2019
2020
regularDialBarrier .Add (int (regularUserCount ))
2020
2021
2022
+ expectedNotifications := map [uuid.UUID ]chan time.Time {
2023
+ notificationsLib .TemplateUserAccountCreated :make (chan time.Time ,1 ),
2024
+ notificationsLib .TemplateUserAccountDeleted :make (chan time.Time ,1 ),
2025
+ }
2026
+
2021
2027
configs := make ([]notifications.Config ,0 ,userCount )
2022
2028
for range ownerUserCount {
2023
2029
config := notifications.Config {
2024
2030
User : createusers.Config {
2025
2031
OrganizationID :me .OrganizationIDs [0 ],
2026
2032
},
2027
- IsOwner :true ,
2028
- NotificationTimeout :notificationTimeout ,
2029
- DialTimeout :dialTimeout ,
2030
- DialBarrier :ownerDialBarrier ,
2031
- Metrics :metrics ,
2033
+ IsOwner :true ,
2034
+ NotificationTimeout :notificationTimeout ,
2035
+ DialTimeout :dialTimeout ,
2036
+ DialBarrier :ownerDialBarrier ,
2037
+ ExpectedNotifications :expectedNotifications ,
2038
+ Metrics :metrics ,
2032
2039
}
2033
2040
if err := config .Validate ();err != nil {
2034
2041
return xerrors .Errorf ("validate config: %w" ,err )
@@ -2113,6 +2120,7 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2113
2120
slog .F ("email" ,triggerEmail ),
2114
2121
slog .F ("org_id" ,me .OrganizationIDs [0 ]))
2115
2122
2123
+ createTime := time .Now ()
2116
2124
testUser ,err := client .CreateUserWithOrgs (ctx , codersdk.CreateUserRequestWithOrgs {
2117
2125
OrganizationIDs : []uuid.UUID {me .OrganizationIDs [0 ]},
2118
2126
Username :triggerUsername ,
@@ -2123,14 +2131,17 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
2123
2131
logger .Error (ctx ,"create test user" ,slog .Error (err ))
2124
2132
return
2125
2133
}
2134
+ expectedNotifications [notificationsLib .TemplateUserAccountCreated ]<- createTime
2126
2135
2136
+ deleteTime := time .Now ()
2127
2137
err = client .DeleteUser (ctx ,testUser .ID )
2128
2138
if err != nil {
2129
2139
logger .Error (ctx ,"delete test user" ,slog .Error (err ))
2130
2140
return
2131
2141
}
2132
-
2133
- logger .Info (ctx ,"test user created and deleted successfully" )
2142
+ expectedNotifications [notificationsLib .TemplateUserAccountDeleted ]<- deleteTime
2143
+ close (expectedNotifications [notificationsLib .TemplateUserAccountCreated ])
2144
+ close (expectedNotifications [notificationsLib .TemplateUserAccountDeleted ])
2134
2145
}()
2135
2146
2136
2147
th := harness .NewTestHarness (timeoutStrategy .wrapStrategy (harness.ConcurrentExecutionStrategy {}),cleanupStrategy .toStrategy ())