This commit is contained in:
Fred Boniface 2023-01-06 18:48:40 +00:00
parent 8f4cd205ff
commit 81127b7c33
3 changed files with 39 additions and 1 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
dockerfile
.gitignore
LICENSE
README.md

7
dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM python:3.9-alpine
WORKDIR /app
COPY . .
CMD [ "python3", "/app/main.py" ]

29
main.py
View File

@ -1,2 +1,29 @@
# 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.
# 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?