init unit testing

This commit is contained in:
Aryan Singh committed 2026-09-12 22:22:17 -05:00
1 parent 47a389ca80
commit bebba25ef4
2 files changed
+15 -6

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
import random
machine_num = input("Enter the machine number: ")
machine_num = int(sys.argv[1])
machine_log_file = f"machine.{machine_num}.test.log"
num_lines = int(input("Enter the number of log lines to generate: "))
num_lines = int(sys.argv[2])
log_level = ["TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "AUDIT"]
+13 -4
View File
@@ -1,5 +1,5 @@
import pytest
import subprocess
import random
PORT = 5055
ALL_IPS = [
@@ -16,14 +16,23 @@ ALL_IPS = [
]
#generate log files on all the machines before running this test
print("Generating log files on all machines...")
for i, ip in enumerate(ALL_IPS):
subprocess.run(["ssh", "asing@{ip}", "python3", "generate_log.py", str(i + 1), "100"])
subprocess.run(["vpn", "ssh", f"asing271@{ip}", "cd ~/fa26_cs425_.group-mp_.team-01/MP1 && python3 generate_log.py {i + 1} 100"])
#start the server on all the machines before running this test
print("Starting server on all machines...")
for i, ip in enumerate(ALL_IPS):
subprocess.run(["ssh", "asing@{ip}", "python3", "server.py"])
subprocess.run(["vpn", "ssh", f"asing271@{ip}", "cd ~/fa26_cs425_.group-mp_.team-01/MP1 && python3 server.py &"])
#ssh into one machine at randome
print("Running grep command on a random machine...")
machine_num = random.randint(1, len(ALL_IPS))
result = subprocess.run(["ssh", f"asing@{ALL_IPS[machine_num - 1]}", "grep", "ERROR", f"./machine.{machine_num}.test.log"], capture_output=True, text=True)
result = subprocess.run(["vpn", "ssh", f"asing271@{ALL_IPS[machine_num - 1]}", "cd ~/fa26_cs425_.group-mp_.team-01/MP1 && grep 'ERROR' f'./machine.{machine_num}.test.log'"], capture_output=True, text=True)
print(f"Machine {machine_num} grep result:\n{result.stdout}")
#delete log files on all the machines after running this test
print("Deleting log files on all machines...")
for i, ip in enumerate(ALL_IPS):
subprocess.run(["vpn", "ssh", f"asing271@{ip}", "cd ~/fa26_cs425_.group-mp_.team-01/MP1 && rm -f ./machine.*.test.log"])