Skip to content

Commit 0d63b01

Browse files
authored
Deletes users slowly during the integration tests. (#375)
There's currently a 1qps limitation on this API. When deleting users at full speed, the the integration tests occasionally hit that limit and fail.
1 parent f26af19 commit 0d63b01

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

integration/auth/user_mgt_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,17 @@ func TestDeleteUser(t *testing.T) {
509509
}
510510

511511
func TestDeleteUsers(t *testing.T) {
512+
// Deletes users slowly. There's currently a 1qps limitation on this API.
513+
// Without this helper, the integration tests occasionally hit that limit
514+
// and fail.
515+
//
516+
// TODO(rsgowman): Remove this function when/if the 1qps limitation is
517+
// relaxed.
518+
slowDeleteUsers := func(ctx context.Context, uids []string) (*auth.DeleteUsersResult, error) {
519+
time.Sleep(1 * time.Second)
520+
return client.DeleteUsers(ctx, uids)
521+
}
522+
512523
// Ensures the specified users don't exist. Expected to be called after
513524
// deleting the users to ensure the delete method worked.
514525
ensureUsersNotFound := func(t *testing.T, uids []string) {
@@ -546,7 +557,7 @@ func TestDeleteUsers(t *testing.T) {
546557
newUserWithParams(t).UID, newUserWithParams(t).UID, newUserWithParams(t).UID,
547558
}
548559

549-
result, err := client.DeleteUsers(context.Background(), uids)
560+
result, err := slowDeleteUsers(context.Background(), uids)
550561
if err != nil {
551562
t.Fatalf("DeleteUsers([valid_ids]) error %v; want nil", err)
552563
}
@@ -566,7 +577,7 @@ func TestDeleteUsers(t *testing.T) {
566577

567578
t.Run("deletes users that exist even when non-existing users also specified", func(t *testing.T) {
568579
uids := []string{newUserWithParams(t).UID, "uid-that-doesnt-exist"}
569-
result, err := client.DeleteUsers(context.Background(), uids)
580+
result, err := slowDeleteUsers(context.Background(), uids)
570581
if err != nil {
571582
t.Fatalf("DeleteUsers(uids) error %v; want nil", err)
572583
}
@@ -586,7 +597,7 @@ func TestDeleteUsers(t *testing.T) {
586597

587598
t.Run("is idempotent", func(t *testing.T) {
588599
deleteUserAndEnsureSuccess := func(t *testing.T, uids []string) {
589-
result, err := client.DeleteUsers(context.Background(), uids)
600+
result, err := slowDeleteUsers(context.Background(), uids)
590601
if err != nil {
591602
t.Fatalf("DeleteUsers(uids) error %v; want nil", err)
592603
}

0 commit comments

Comments
 (0)