@@ -14,6 +14,7 @@ import (
14
14
"os"
15
15
"strings"
16
16
"testing"
17
+ "time"
17
18
18
19
gcs "cloud.google.com/go/storage"
19
20
"github.com/cockroachdb/cockroach/pkg/base"
@@ -25,6 +26,7 @@ import (
25
26
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
26
27
"github.com/cockroachdb/cockroach/pkg/util/ioctx"
27
28
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
29
+ "github.com/cockroachdb/cockroach/pkg/util/log"
28
30
"github.com/cockroachdb/cockroach/pkg/util/uuid"
29
31
"github.com/stretchr/testify/require"
30
32
"golang.org/x/oauth2/google"
@@ -297,6 +299,49 @@ func TestGCSAssumeRole(t *testing.T) {
297
299
})
298
300
}
299
301
302
+ func TestGCSFaultInjection (t * testing.T ) {
303
+ defer leaktest .AfterTest (t )()
304
+
305
+ if ! cloudtestutils .IsImplicitAuthConfigured () {
306
+ skip .IgnoreLint (t , "implicit auth is not configured" )
307
+ }
308
+
309
+ bucket := os .Getenv ("GOOGLE_BUCKET" )
310
+ if bucket == "" {
311
+ skip .IgnoreLint (t , "GOOGLE_BUCKET env var must be set" )
312
+ }
313
+
314
+ // Enable cloud transport logging.
315
+ defer log .Scope (t ).Close (t )
316
+ prevVModule := log .GetVModule ()
317
+ defer func () { _ = log .SetVModule (prevVModule ) }()
318
+ require .NoError (t , log .SetVModule ("cloud_logging_transport=1" ))
319
+
320
+ testID := cloudtestutils .NewTestID ()
321
+ uri := fmt .Sprintf ("gs://%s/%d-fault-injection-test?AUTH=implicit" , bucket , testID )
322
+
323
+ // Inject faults for 15-45 seconds after the storage is opened.
324
+ middleware := cloudtestutils .BrownoutMiddleware (time .Second * 15 , time .Second * 45 )
325
+
326
+ conf , err := cloud .ExternalStorageConfFromURI (uri , username .RootUserName ())
327
+ require .NoError (t , err )
328
+
329
+ args := cloud.EarlyBootExternalStorageContext {
330
+ IOConf : base.ExternalIODirConfig {},
331
+ Settings : cluster .MakeTestingClusterSettings (),
332
+ Options : nil ,
333
+ Limiters : nil ,
334
+ MetricsRecorder : cloud .NilMetrics ,
335
+ HttpMiddleware : middleware ,
336
+ }
337
+
338
+ storage , err := makeGCSStorage (context .Background (), args , conf )
339
+ require .NoError (t , err )
340
+ defer storage .Close ()
341
+
342
+ cloudtestutils .RunCloudNemesisTest (t , storage )
343
+ }
344
+
300
345
func TestAntagonisticGCSRead (t * testing.T ) {
301
346
defer leaktest .AfterTest (t )()
302
347
0 commit comments