Skip to content
Snippets Groups Projects
Commit 551f6dbf authored by Neil-Jocelyn Schark's avatar Neil-Jocelyn Schark
Browse files

basic setup

parent 18905b29
No related branches found
No related tags found
1 merge request!215Simple longevity tests
Pipeline #224106 passed
This commit is part of merge request !215. Comments created here will be created in the context of that merge request.
......@@ -27,3 +27,5 @@ gostructs.go
*.out
.gosdnc.toml
longevity-tests/akms*
......@@ -118,6 +118,8 @@ integration-test-debug-compose-down:
longevity-test: generate-gokms-certs build-images install-gosdnc
rm -r longevity-tests/akms1-logs
rm -r longevity-tests/akms2-logs
docker compose -f longevity-tests/docker-compose.yml down
docker compose -f longevity-tests/docker-compose.yml up -d
echo "Will add devices, can take a while"
......
......@@ -87,9 +87,17 @@ services:
akms-receiver01:
image: akms-simulator
ports:
- "127.0.0.1:4444:4444"
volumes:
- ./akms1-logs:/logs
akms-receiver02:
image: akms-simulator
ports:
- "127.0.0.1:4445:4444"
volumes:
- ./akms2-logs:/logs
qkdn-controller:
image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller:qkdn-main
......@@ -111,7 +119,7 @@ services:
plugin-registry:
image: registry.code.fbi.h-da.de/demoquandt/qkdn-controller/plugin-registry:qkdn-main
mongo:
mongodb:
image: mongo:7
environment:
MONGO_INITDB_ROOT_USERNAME: root
......
import http.client
import json
import time
import argparse
import random
def sleepRandomTime(min_time: int, max_time: int):
time.sleep(random.randint(min_time, max_time))
def requestMode(baseURL: str, min_time: int, max_time: int):
endpoint = "/api/v1/keys/ksa_key_req"
request_id = 0
while True:
request_id += 1
print(f"requestId: {request_id}")
data = {
"receiving_CKMS_ID": "968fd594-b0e7-41f0-ba4b-de259047a933",
"request_ID": str(request_id),
"key_properties": {
"number": 1,
"key_length": 256,
"timeout": 20,
"TTL": 24
}
}
headers = {
"Content-Type": "application/json"
}
# Create a connection
conn = http.client.HTTPConnection(baseURL)
# Convert data to JSON
json_data = json.dumps(data)
# Make the POST request
conn.request("POST", endpoint, body=json_data, headers=headers)
# Check the return code
response = conn.getresponse()
if response.status != 204:
print(f"Request failed with status code {response.status}")
print(response.read().decode())
# Close the connection
conn.close()
sleepRandomTime(min_time, max_time)
def readFile(fileURL: str):
with open(fileURL, 'r') as file:
lines = file.readlines()
parsed_lines = []
for line in lines:
data = json.loads(line.strip())
parsed_line = {
"source": data["source"],
"request_ID": data["body"]["request_ID"],
"process_ID": data["body"]["process_ID"],
"ksa_keys": data["body"]["ksa_keys"]
}
parsed_lines.append(parsed_line)
return parsed_lines
def analyzeMode(fileURLs: list):
data = []
for fileURL in fileURLs:
fileData = readFile(fileURL)
data.append(fileData)
for i, log in enumerate(data):
if len(log) == len(data[0]):
print("Logs are the same length!")
def main():
# Parse the command line arguments --mode, --min_time, --max_time and --base_url
parser = argparse.ArgumentParser(description="Longevity test script")
parser.add_argument("--mode", type=str, required=False,
help="Mode of operation. Can be 'request' or 'analyze'.")
parser.add_argument("--min_time", type=int,
required=False, help="Minimum time in seconds")
parser.add_argument("--max_time", type=int,
required=False, help="Maximum time in seconds")
parser.add_argument("--base_url", type=str, required=False,
help="Base URL for the requests")
args = parser.parse_args()
mode = args.mode
min_time = args.min_time
max_time = args.max_time
base_url = args.base_url
# Set default values
if mode is None:
mode = "request"
if min_time is None:
min_time = 10
if max_time is None:
max_time = 240
if base_url is None:
base_url = "127.0.0.1:9696"
if mode == "request":
print("Running in request mode")
requestMode(base_url, min_time, max_time)
elif mode == "analyze":
print("Running in analyze mode")
analyzeMode(["longevity-tests/akms1-logs/akms-simulator.log", "longevity-tests/akms2-logs/akms-simulator.log"])
if __name__ == "__main__":
main()
#!/bin/bash
kms1AkmsURL="127.0.0.1:9696"
url="https://${kms1AkmsURL}/api/v1/keys/ksa_key_req"
# Loop for ever and increase a requestId variable
requestId=0
while true; do
requestId=$((requestId+1))
echo "requestId: $requestId"
url="https://${kms1AkmsURL}/api/v1/keys/ksa_key_req"
data=$(
)
curl -X POST "$url" \
-H "Content-Type: application/json" \
-d "$data" {
"ReceivingCKMSID": "5e41c291-6121-4335-84f6-41e04b8bdaa2",
"RequestID": "${requestId}",
"KeyProperties": { \
"Number": 1, \
"KeyLength": 256, \
"Timeout": 20, \
"TTL": 24 \
} \
}
curl -X POST -H "Content-Type: application/json" -d '{
"receiving_CKMS_ID": "968fd594-b0e7-41f0-ba4b-de259047a933",
"request_ID": "${requestId}",
"key_properties": {
"number": 1,
"key_length": 256,
"timeout": 20,
"TTL": 24
}
}' 'http://127.0.0.1:9696/api/v1/keys/ksa_key_req'
sleep 1
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment