Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: tools/telemetry/third_party/gsutil/third_party/boto/tests/integration/gs/cb_test_harness.py

Issue 1260493004: Revert "Add gsutil 4.13 to telemetry/third_party" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/third_party/gsutil/third_party/boto/tests/integration/gs/cb_test_harness.py
diff --git a/tools/telemetry/third_party/gsutil/third_party/boto/tests/integration/gs/cb_test_harness.py b/tools/telemetry/third_party/gsutil/third_party/boto/tests/integration/gs/cb_test_harness.py
deleted file mode 100644
index 024b0cf036aa77d8d05b98b430b1f2776b26a539..0000000000000000000000000000000000000000
--- a/tools/telemetry/third_party/gsutil/third_party/boto/tests/integration/gs/cb_test_harness.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright 2010 Google Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish, dis-
-# tribute, sublicense, and/or sell copies of the Software, and to permit
-# persons to whom the Software is furnished to do so, subject to the fol-
-# lowing conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
-# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-
-"""
-Test harness that allows us to raise exceptions, change file content,
-and record the byte transfer callback sequence, to test various resumable
-upload and download cases. The 'call' method of this harness can be passed
-as the 'cb' parameter to boto.s3.Key.send_file() and boto.s3.Key.get_file(),
-allowing testing of various file upload/download conditions.
-"""
-
-import socket
-import time
-
-
-class CallbackTestHarness(object):
-
- def __init__(self, fail_after_n_bytes=0, num_times_to_fail=1,
- exception=socket.error('mock socket error', 0),
- fp_to_change=None, fp_change_pos=None,
- delay_after_change=None):
- self.fail_after_n_bytes = fail_after_n_bytes
- self.num_times_to_fail = num_times_to_fail
- self.exception = exception
- # If fp_to_change and fp_change_pos are specified, 3 bytes will be
- # written at that position just before the first exception is thrown.
- self.fp_to_change = fp_to_change
- self.fp_change_pos = fp_change_pos
- self.delay_after_change = delay_after_change
- self.num_failures = 0
- self.transferred_seq_before_first_failure = []
- self.transferred_seq_after_first_failure = []
-
- def call(self, total_bytes_transferred, unused_total_size):
- """
- To use this test harness, pass the 'call' method of the instantiated
- object as the cb param to the set_contents_from_file() or
- get_contents_to_file() call.
- """
- # Record transfer sequence to allow verification.
- if self.num_failures:
- self.transferred_seq_after_first_failure.append(
- total_bytes_transferred)
- else:
- self.transferred_seq_before_first_failure.append(
- total_bytes_transferred)
- if (total_bytes_transferred >= self.fail_after_n_bytes and
- self.num_failures < self.num_times_to_fail):
- self.num_failures += 1
- if self.fp_to_change and self.fp_change_pos is not None:
- cur_pos = self.fp_to_change.tell()
- self.fp_to_change.seek(self.fp_change_pos)
- self.fp_to_change.write('abc')
- self.fp_to_change.seek(cur_pos)
- if self.delay_after_change:
- time.sleep(self.delay_after_change)
- self.called = True
- raise self.exception

Powered by Google App Engine
This is Rietveld 408576698