josephxsxn

s3BreakerTest.py

Oct 17th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import boto3
  2. import time
  3. import sys
  4. data = 'this is some test string'
  5.  
  6. goodpass = 0
  7. badpass = 0
  8. badpass2 = 0
  9.  
  10. #make s3 object
  11. s3 = boto3.resource('s3')
  12. print("Running s3 Breaker")
  13. for c in range(int(sys.argv[1])):
  14.     s3.Bucket('ectestapi').put_object(Key='test.txt', Body=data)
  15.     try:
  16.         boto3.client('s3').delete_object("ectestapi", "test.txt")
  17.         boto3.client('s3').download_file("ectestapi", "test.txt", "tmp.txt")
  18.         #print("bad pass 1")
  19.         badpass += 1
  20.         boto3.client('s3').download_file("ectestapi", "test.txt", "tmp.txt")
  21.         #print("bad pass 2 sleeping for 2 seconds")
  22.         badpass2 += 1
  23.         time.sleep(2)
  24.     except:
  25.         #print("good pass")
  26.         goodpass += 1
  27.  
  28. print("total good passes: " + str(goodpass))
  29. print("total bad-1 passes: " +str(badpass))
  30. print("total bad-2 passes: " + str(badpass2))
Advertisement
Add Comment
Please, Sign In to add comment