@@ -17,6 +17,7 @@ import (
17
17
"github.com/golang/mock/gomock"
18
18
"github.com/stretchr/testify/require"
19
19
20
+ "golang.org/x/sync/semaphore"
20
21
"google.golang.org/grpc/codes"
21
22
"google.golang.org/grpc/status"
22
23
)
@@ -89,13 +90,13 @@ func TestNaiveBuildDirectorySuccess(t *testing.T) {
89
90
fileFetcher .EXPECT ().GetFile (
90
91
gomock .Any (),
91
92
digest .MustNewDigest ("netbsd" , remoteexecution .DigestFunction_SHA256 , "9999999999999999999999999999999999999999999999999999999999999999" , 512 ),
92
- buildDirectory ,
93
+ gomock . Any () ,
93
94
path .MustNewComponent ("non-executable" ),
94
95
false ).Return (nil )
95
96
fileFetcher .EXPECT ().GetFile (
96
97
gomock .Any (),
97
98
digest .MustNewDigest ("netbsd" , remoteexecution .DigestFunction_SHA256 , "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" , 512 ),
98
- buildDirectory ,
99
+ gomock . Any () ,
99
100
path .MustNewComponent ("executable" ),
100
101
true ).Return (nil )
101
102
buildDirectory .EXPECT ().Symlink (gomock .Any (), path .MustNewComponent ("link-to-executable" )).
@@ -105,7 +106,7 @@ func TestNaiveBuildDirectorySuccess(t *testing.T) {
105
106
require .Equal (t , "executable" , targetPath .GetUNIXString ())
106
107
})
107
108
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
108
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
109
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
109
110
110
111
err := inputRootPopulator .MergeDirectoryContents (
111
112
ctx ,
@@ -127,7 +128,7 @@ func TestNaiveBuildDirectoryInputRootNotInStorage(t *testing.T) {
127
128
buildDirectory := mock .NewMockDirectoryCloser (ctrl )
128
129
fileFetcher := mock .NewMockFileFetcher (ctrl )
129
130
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
130
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
131
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
131
132
132
133
err := inputRootPopulator .MergeDirectoryContents (
133
134
ctx ,
@@ -173,7 +174,7 @@ func TestNaiveBuildDirectoryMissingInputDirectoryDigest(t *testing.T) {
173
174
helloDirectory .EXPECT ().Close ()
174
175
fileFetcher := mock .NewMockFileFetcher (ctrl )
175
176
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
176
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
177
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
177
178
178
179
err := inputRootPopulator .MergeDirectoryContents (
179
180
ctx ,
@@ -224,7 +225,7 @@ func TestNaiveBuildDirectoryDirectoryCreationFailure(t *testing.T) {
224
225
helloDirectory .EXPECT ().Close ()
225
226
fileFetcher := mock .NewMockFileFetcher (ctrl )
226
227
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
227
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
228
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
228
229
229
230
err := inputRootPopulator .MergeDirectoryContents (
230
231
ctx ,
@@ -276,7 +277,7 @@ func TestNaiveBuildDirectoryDirectoryEnterDirectoryFailure(t *testing.T) {
276
277
helloDirectory .EXPECT ().Close ()
277
278
fileFetcher := mock .NewMockFileFetcher (ctrl )
278
279
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
279
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
280
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
280
281
281
282
err := inputRootPopulator .MergeDirectoryContents (
282
283
ctx ,
@@ -322,7 +323,7 @@ func TestNaiveBuildDirectoryMissingInputFileDigest(t *testing.T) {
322
323
helloDirectory .EXPECT ().Close ()
323
324
fileFetcher := mock .NewMockFileFetcher (ctrl )
324
325
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
325
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
326
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
326
327
327
328
err := inputRootPopulator .MergeDirectoryContents (
328
329
ctx ,
@@ -373,12 +374,12 @@ func TestNaiveBuildDirectoryFileCreationFailure(t *testing.T) {
373
374
fileFetcher .EXPECT ().GetFile (
374
375
gomock .Any (),
375
376
digest .MustNewDigest ("netbsd" , remoteexecution .DigestFunction_SHA256 , "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" , 87 ),
376
- helloDirectory ,
377
+ gomock . Any () ,
377
378
path .MustNewComponent ("World" ),
378
379
false ).Return (status .Error (codes .DataLoss , "Disk on fire" ))
379
380
helloDirectory .EXPECT ().Close ()
380
381
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
381
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
382
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
382
383
383
384
err := inputRootPopulator .MergeDirectoryContents (
384
385
ctx ,
@@ -432,7 +433,7 @@ func TestNaiveBuildDirectorySymlinkCreationFailure(t *testing.T) {
432
433
helloDirectory .EXPECT ().Close ()
433
434
fileFetcher := mock .NewMockFileFetcher (ctrl )
434
435
contentAddressableStorage := mock .NewMockBlobAccess (ctrl )
435
- inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , contentAddressableStorage )
436
+ inputRootPopulator := builder .NewNaiveBuildDirectory (buildDirectory , directoryFetcher , fileFetcher , semaphore . NewWeighted ( 1 ), contentAddressableStorage )
436
437
437
438
err := inputRootPopulator .MergeDirectoryContents (
438
439
ctx ,
@@ -453,7 +454,9 @@ func TestNaiveBuildDirectoryUploadFile(t *testing.T) {
453
454
buildDirectory ,
454
455
directoryFetcher ,
455
456
fileFetcher ,
456
- contentAddressableStorage )
457
+ semaphore .NewWeighted (1 ),
458
+ contentAddressableStorage ,
459
+ )
457
460
458
461
helloWorldDigest := digest .MustNewDigest ("default-scheduler" , remoteexecution .DigestFunction_MD5 , "3e25960a79dbc69b674cd4ec67a72c62" , 11 )
459
462
digestFunction := helloWorldDigest .GetDigestFunction ()
0 commit comments