shunping commented on code in PR #33539:
URL: https://github.com/apache/beam/pull/33539#discussion_r1909017925


##########
sdks/python/apache_beam/io/gcp/gcsio_test.py:
##########
@@ -477,6 +477,59 @@ def test_copy(self):
           'gs://gcsio-test/non-existent',
           'gs://gcsio-test/non-existent-destination')
 
+  @mock.patch('apache_beam.io.gcp.gcsio.MAX_BATCH_OPERATION_SIZE', 3)
+  @mock.patch('time.sleep', mock.Mock())
+  def test_copy_batch(self):
+    src_dest_pairs = [
+        (f'gs://source_bucket/file{i}.txt', f'gs://dest_bucket/file{i}.txt')
+        for i in range(7)
+    ]
+
+    def _fake_responses(status_codes):
+      return mock.Mock(
+          __enter__=mock.Mock(),
+          __exit__=mock.Mock(),
+          _responses=[
+              mock.Mock(
+                  **{
+                      'json.return_value': {
+                          'error': {
+                              'message': 'error'
+                          }
+                      },
+                      'request.method': 'BATCH',
+                      'request.url': 'contentid://None',
+                  },
+                  status_code=code,
+              ) for code in status_codes
+          ],
+      )
+
+    gcs_io = gcsio.GcsIO(
+        storage_client=mock.Mock(
+            batch=mock.Mock(
+                side_effect=[
+                    _fake_responses([200, 404, 429]),
+                    _fake_responses([429]),
+                    _fake_responses([429]),
+                    _fake_responses([200]),
+                    _fake_responses([200, 429, 200]),
+                    _fake_responses([200]),
+                    _fake_responses([200]),

Review Comment:
   Could you also add a test case to cover when a retry error (e.g. timeout) 
happens?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to