71
71
declare -r EXE_EXT=" "
72
72
fi
73
73
74
+ BEP_JSON=bep.json
75
+
76
+ function expect_bes_file_uploaded() {
77
+ local file=$1
78
+ if [[ $( cat $BEP_JSON ) =~ ${file} \" ,\" uri\" :\" bytestream://localhost:${worker_port} /blobs/([^/]* ) ]]; then
79
+ if ! remote_cas_file_exist ${BASH_REMATCH[1]} ; then
80
+ cat $BEP_JSON >> $TEST_log && append_remote_cas_files $TEST_log && fail " $file is not uploaded"
81
+ fi
82
+ else
83
+ cat $BEP_JSON > $TEST_log
84
+ fail " $file is not converted to bytestream://"
85
+ fi
86
+ }
87
+
88
+ function expect_bes_file_not_uploaded() {
89
+ local file=$1
90
+ if [[ $( cat $BEP_JSON ) =~ ${file} \" ,\" uri\" :\" bytestream://localhost:${worker_port} /blobs/([^/]* ) ]]; then
91
+ if remote_cas_file_exist ${BASH_REMATCH[1]} ; then
92
+ cat $BEP_JSON >> $TEST_log && append_remote_cas_files $TEST_log && fail " $file is uploaded"
93
+ fi
94
+ else
95
+ cat $BEP_JSON > $TEST_log
96
+ fail " $file is not converted to bytestream://"
97
+ fi
98
+ }
99
+
74
100
function test_upload_minimal_convert_paths_for_existed_blobs() {
75
101
mkdir -p a
76
102
cat > a/BUILD << EOF
84
110
bazel build \
85
111
--remote_executor=grpc://localhost:${worker_port} \
86
112
--experimental_remote_build_event_upload=minimal \
87
- --build_event_json_file=bep.json \
113
+ --build_event_json_file=$BEP_JSON \
88
114
//a:foo >& $TEST_log || fail " Failed to build"
89
115
90
- cat bep.json > $TEST_log
91
- expect_log " a:foo.*bytestream://" || fail " paths for existed blobs should be converted"
92
- expect_log " command.profile.gz.*bytestream://" || fail " should upload profile data"
116
+ expect_bes_file_uploaded foo.txt
117
+ expect_bes_file_uploaded command.profile.gz
93
118
}
94
119
95
120
function test_upload_minimal_doesnt_upload_missing_blobs() {
@@ -106,12 +131,11 @@ EOF
106
131
bazel build \
107
132
--remote_executor=grpc://localhost:${worker_port} \
108
133
--experimental_remote_build_event_upload=minimal \
109
- --build_event_json_file=bep.json \
134
+ --build_event_json_file=$BEP_JSON \
110
135
//a:foo >& $TEST_log || fail " Failed to build"
111
136
112
- cat bep.json > $TEST_log
113
- expect_not_log " a:foo.*bytestream://" || fail " local files are uploaded"
114
- expect_log " command.profile.gz.*bytestream://" || fail " should upload profile data"
137
+ expect_bes_file_not_uploaded foo.txt
138
+ expect_bes_file_uploaded command.profile.gz
115
139
}
116
140
117
141
function test_upload_minimal_respect_no_upload_results() {
@@ -128,12 +152,11 @@ EOF
128
152
--remote_cache=grpc://localhost:${worker_port} \
129
153
--remote_upload_local_results=false \
130
154
--experimental_remote_build_event_upload=minimal \
131
- --build_event_json_file=bep.json \
155
+ --build_event_json_file=$BEP_JSON \
132
156
//a:foo >& $TEST_log || fail " Failed to build"
133
157
134
- cat bep.json > $TEST_log
135
- expect_not_log " a:foo.*bytestream://" || fail " local files are uploaded"
136
- expect_log " command.profile.gz.*bytestream://" || fail " should upload profile data"
158
+ expect_bes_file_not_uploaded foo.txt
159
+ expect_bes_file_uploaded command.profile.gz
137
160
}
138
161
139
162
function test_upload_minimal_respect_no_upload_results_combined_cache() {
@@ -154,12 +177,11 @@ EOF
154
177
--incompatible_remote_results_ignore_disk \
155
178
--remote_upload_local_results=false \
156
179
--experimental_remote_build_event_upload=minimal \
157
- --build_event_json_file=bep.json \
180
+ --build_event_json_file=$BEP_JSON \
158
181
//a:foo >& $TEST_log || fail " Failed to build"
159
182
160
- cat bep.json > $TEST_log
161
- expect_not_log " a:foo.*bytestream://" || fail " local files are uploaded"
162
- expect_log " command.profile.gz.*bytestream://" || fail " should upload profile data"
183
+ expect_bes_file_not_uploaded foo.txt
184
+ expect_bes_file_uploaded command.profile.gz
163
185
remote_cas_files=" $( count_remote_cas_files) "
164
186
[[ " $remote_cas_files " == 1 ]] || fail " Expected 1 remote cas entries, not $remote_cas_files "
165
187
disk_cas_files=" $( count_disk_cas_files $cache_dir ) "
@@ -187,12 +209,11 @@ EOF
187
209
bazel build \
188
210
--remote_executor=grpc://localhost:${worker_port} \
189
211
--experimental_remote_build_event_upload=minimal \
190
- --build_event_json_file=bep.json \
212
+ --build_event_json_file=$BEP_JSON \
191
213
//a:foo-alias >& $TEST_log || fail " Failed to build"
192
214
193
- cat bep.json > $TEST_log
194
- expect_not_log " a:foo.*bytestream://"
195
- expect_log " command.profile.gz.*bytestream://"
215
+ expect_bes_file_not_uploaded foo.txt
216
+ expect_bes_file_uploaded command.profile.gz
196
217
}
197
218
198
219
function test_upload_minimal_trees_doesnt_upload_missing_blobs() {
@@ -204,8 +225,9 @@ def _gen_output_dir_impl(ctx):
204
225
outputs = [output_dir],
205
226
inputs = [],
206
227
command = """
207
- mkdir -p $1/sub; \
208
- index=0; while ((index<10)); do echo $index >$1/$index.txt; index=$(($index+1)); done
228
+ echo 0 > $1/0.txt
229
+ echo 1 > $1/1.txt
230
+ mkdir -p $1/sub
209
231
echo "Shuffle, duffle, muzzle, muff" > $1/sub/bar
210
232
""",
211
233
arguments = [output_dir.path],
@@ -233,13 +255,13 @@ EOF
233
255
bazel build \
234
256
--remote_executor=grpc://localhost:${worker_port} \
235
257
--experimental_remote_build_event_upload=minimal \
236
- --build_event_json_file=bep.json \
258
+ --build_event_json_file=$BEP_JSON \
237
259
//a:foo >& $TEST_log || fail " Failed to build"
238
260
239
- cat bep.json > $TEST_log
240
- expect_not_log " a:foo.*bytestream:// " || fail " local tree files are uploaded "
241
- expect_not_log " a/ dir/.*bytestream:// " || fail " local tree files are uploaded "
242
- expect_log " command.profile.gz.*bytestream:// " || fail " should upload profile data "
261
+ expect_bes_file_not_uploaded dir/0.txt
262
+ expect_bes_file_not_uploaded dir/1.txt
263
+ expect_bes_file_not_uploaded dir/sub/bar
264
+ expect_bes_file_uploaded command.profile.gz
243
265
}
244
266
245
267
function test_upload_minimal_upload_testlogs() {
@@ -259,14 +281,13 @@ EOF
259
281
bazel test \
260
282
--remote_executor=grpc://localhost:${worker_port} \
261
283
--experimental_remote_build_event_upload=minimal \
262
- --build_event_json_file=bep.json \
284
+ --build_event_json_file=$BEP_JSON \
263
285
//a:test >& $TEST_log || fail " Failed to build"
264
286
265
- cat bep.json > $TEST_log
266
- expect_not_log " test.sh.*bytestream://" || fail " test script is uploaded"
267
- expect_log " test.log.*bytestream://" || fail " should upload test.log"
268
- expect_log " test.xml.*bytestream://" || fail " should upload test.xml"
269
- expect_log " command.profile.gz.*bytestream://" || fail " should upload profile data"
287
+ expect_bes_file_not_uploaded test.sh
288
+ expect_bes_file_uploaded test.log
289
+ expect_bes_file_uploaded test.xml
290
+ expect_bes_file_uploaded command.profile.gz
270
291
}
271
292
272
293
function test_upload_minimal_upload_buildlogs() {
@@ -283,13 +304,12 @@ EOF
283
304
bazel build \
284
305
--remote_executor=grpc://localhost:${worker_port} \
285
306
--experimental_remote_build_event_upload=minimal \
286
- --build_event_json_file=bep.json \
307
+ --build_event_json_file=$BEP_JSON \
287
308
//a:foo >& $TEST_log || true
288
309
289
- cat bep.json > $TEST_log
290
- expect_log " stdout.*bytestream://" || fail " should upload stdout"
291
- expect_log " stderr.*bytestream://" || fail " should upload stderr"
292
- expect_log " command.profile.gz.*bytestream://" || fail " should upload profile data"
310
+ expect_bes_file_uploaded stdout
311
+ expect_bes_file_uploaded stderr
312
+ expect_bes_file_uploaded command.profile.gz
293
313
}
294
314
295
315
function test_upload_minimal_upload_profile() {
@@ -306,11 +326,10 @@ EOF
306
326
--remote_executor=grpc://localhost:${worker_port} \
307
327
--experimental_remote_build_event_upload=minimal \
308
328
--profile=mycommand.profile.gz \
309
- --build_event_json_file=bep.json \
329
+ --build_event_json_file=$BEP_JSON \
310
330
//a:foo >& $TEST_log || fail " Failed to build"
311
331
312
- cat bep.json > $TEST_log
313
- expect_log " mycommand.profile.gz.*bytestream://" || fail " should upload profile data"
332
+ expect_bes_file_uploaded " mycommand.profile.gz"
314
333
}
315
334
316
335
run_suite " Remote build event uploader tests"
0 commit comments