29 lines
797 B
Python
29 lines
797 B
Python
# A simple script that creates a file of inputted size saved at the inputted destination.
|
|
# aimed at testing storage is functioning on Longhorn running in a kubernetes cluster.
|
|
|
|
import os
|
|
import time
|
|
|
|
# Get env vars:
|
|
print('Fetching configuration from environment')
|
|
size = os.getenv('STOR_SIZE') # In bytes (x1000)
|
|
path = os.getenv('STOR_PATH')
|
|
|
|
print('Path: '+ path + ', Size: ' + size + 'B')
|
|
|
|
def generate(number, path, size):
|
|
filepath = path + '/' + str(number) + 'stor.bin'
|
|
with open(filepath, mode='wb') as out:
|
|
out.write(os.urandom(int(size)))
|
|
|
|
print('File of ' + size + 'B created at ' + filepath)
|
|
pass
|
|
|
|
passes = 0
|
|
while passes < 1000:
|
|
generate(passes,path,size)
|
|
passes += 1
|
|
|
|
while True:
|
|
print("Program running...")
|
|
time.sleep(10) # Is this s or ms? |