Skip to content

Commit f977ed5

Browse files
committed
chore: adding force flag to sweep
1 parent 3080e39 commit f977ed5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

provider/sweeper_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ func testSweepProSubscriptions(region string) error {
152152
func testSweepReadDatabases(client *rediscloudApi.Client, subId int) (bool, []int, error) {
153153
var dbIds []int
154154
list := client.Database.List(context.TODO(), subId)
155+
forceSweep := os.Getenv("FORCE_SWEEP") != ""
155156

156157
for list.Next() {
157158
db := list.Value()
158159

159-
if !redis.TimeValue(db.ActivatedOn).Add(24 * -1 * time.Hour).Before(time.Now()) {
160-
// Subscription _probably_ created within the last day, so assume someone might be
160+
if !forceSweep && !redis.TimeValue(db.ActivatedOn).Add(2 * -1 * time.Hour).Before(time.Now()) {
161+
// Subscription _probably_ created within the last 2 hours, so assume someone might be
161162
// currently running the tests
162163
return false, nil, nil
163164
}
@@ -185,12 +186,13 @@ func testSweepReadDatabases(client *rediscloudApi.Client, subId int) (bool, []in
185186
func testSweepReadEssentialsDatabases(client *rediscloudApi.Client, subId int) (bool, []int, error) {
186187
var dbIds []int
187188
list := client.FixedDatabases.List(context.TODO(), subId)
189+
forceSweep := os.Getenv("FORCE_SWEEP") != ""
188190

189191
for list.Next() {
190192
db := list.Value()
191193

192-
if !redis.TimeValue(db.ActivatedOn).Add(24 * -1 * time.Hour).Before(time.Now()) {
193-
// Subscription _probably_ created within the last day, so assume someone might be
194+
if !forceSweep && !redis.TimeValue(db.ActivatedOn).Add(2 * -1 * time.Hour).Before(time.Now()) {
195+
// Subscription _probably_ created within the last 2 hours, so assume someone might be
194196
// currently running the tests
195197
return false, nil, nil
196198
}

0 commit comments

Comments
 (0)