@@ -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"
@@ -1783,17 +1784,23 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
1783
1784
ownerDialBarrier .Add (int (ownerUserCount ))
1784
1785
regularDialBarrier .Add (int (regularUserCount ))
1785
1786
1787
+ expectedNotifications := map [uuid.UUID ]chan time.Time {
1788
+ notificationsLib .TemplateUserAccountCreated :make (chan time.Time ,1 ),
1789
+ notificationsLib .TemplateUserAccountDeleted :make (chan time.Time ,1 ),
1790
+ }
1791
+
1786
1792
configs := make ([]notifications.Config ,0 ,userCount )
1787
1793
for range ownerUserCount {
1788
1794
config := notifications.Config {
1789
1795
User : createusers.Config {
1790
1796
OrganizationID :me .OrganizationIDs [0 ],
1791
1797
},
1792
- IsOwner :true ,
1793
- NotificationTimeout :notificationTimeout ,
1794
- DialTimeout :dialTimeout ,
1795
- DialBarrier :ownerDialBarrier ,
1796
- Metrics :metrics ,
1798
+ IsOwner :true ,
1799
+ NotificationTimeout :notificationTimeout ,
1800
+ DialTimeout :dialTimeout ,
1801
+ DialBarrier :ownerDialBarrier ,
1802
+ ExpectedNotifications :expectedNotifications ,
1803
+ Metrics :metrics ,
1797
1804
}
1798
1805
if err := config .Validate ();err != nil {
1799
1806
return xerrors .Errorf ("validate config: %w" ,err )
@@ -1878,6 +1885,7 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
1878
1885
slog .F ("email" ,triggerEmail ),
1879
1886
slog .F ("org_id" ,me .OrganizationIDs [0 ]))
1880
1887
1888
+ createTime := time .Now ()
1881
1889
testUser ,err := client .CreateUserWithOrgs (ctx , codersdk.CreateUserRequestWithOrgs {
1882
1890
OrganizationIDs : []uuid.UUID {me .OrganizationIDs [0 ]},
1883
1891
Username :triggerUsername ,
@@ -1888,14 +1896,17 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
1888
1896
logger .Error (ctx ,"create test user" ,slog .Error (err ))
1889
1897
return
1890
1898
}
1899
+ expectedNotifications [notificationsLib .TemplateUserAccountCreated ]<- createTime
1891
1900
1901
+ deleteTime := time .Now ()
1892
1902
err = client .DeleteUser (ctx ,testUser .ID )
1893
1903
if err != nil {
1894
1904
logger .Error (ctx ,"delete test user" ,slog .Error (err ))
1895
1905
return
1896
1906
}
1897
-
1898
- logger .Info (ctx ,"test user created and deleted successfully" )
1907
+ expectedNotifications [notificationsLib .TemplateUserAccountDeleted ]<- deleteTime
1908
+ close (expectedNotifications [notificationsLib .TemplateUserAccountCreated ])
1909
+ close (expectedNotifications [notificationsLib .TemplateUserAccountDeleted ])
1899
1910
}()
1900
1911
1901
1912
th := harness .NewTestHarness (timeoutStrategy .wrapStrategy (harness.ConcurrentExecutionStrategy {}),cleanupStrategy .toStrategy ())