Skip to content

Commit

Permalink
Merge pull request #15 from atlarge-research/test_folder_restructure
Browse files Browse the repository at this point in the history
Test Folder Restructure
  • Loading branch information
Vlad2000Andrei authored Apr 5, 2024
2 parents a4e76e0 + e76c3fe commit 5b7e272
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ WORKDIR /home/compnet

COPY . /home/compnet/

RUN rm /home/compnet/chat_client_check/client.py \
/home/compnet/dns_check/dns.py \
/home/compnet/server_check/server.py \
/home/compnet/http_server_check/server.py \
/home/compnet/unreliable_chat_check/client.py

RUN pip install -r requirements.txt
6 changes: 4 additions & 2 deletions chat_client_check/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
SERVER_ADDRESS = '127.0.0.1'
SERVER_PORT = 5378

STUDENT_FILE_PATH = "../student/chat_client_check/client.py"

class TestException(Exception):
pass

Expand Down Expand Up @@ -84,7 +86,7 @@ def execute_and_detach(cmd):

def start_script():
expected_output = 'Welcome to Chat Client. Enter your login:'
client_process = pexpect.spawn(f'python3 client.py --address "{SERVER_ADDRESS}" --port {SERVER_PORT}', encoding='utf-8')
client_process = pexpect.spawn(f'python3 {STUDENT_FILE_PATH} --address "{SERVER_ADDRESS}" --port {SERVER_PORT}', encoding='utf-8')

output_buffer = handle_pexpect(client_process, [client_process], expected_output, "", "starting client script")

Expand Down Expand Up @@ -264,7 +266,7 @@ def check_name():
return client_process, output_buffer

def verify_file_for_sendall():
file_path = os.path.join(os.getcwd(), "client.py")
file_path = os.path.join(os.getcwd(), STUDENT_FILE_PATH)

try:
with open(file_path, 'r') as file:
Expand Down
3 changes: 2 additions & 1 deletion dns_check/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
SERVER_ADDRESS = '127.0.0.1'
SERVER_PORT = 8000
IPV4ONLY = False
STUDENT_FILE_PATH = "../student/dns_check/dns.py"

class TestException(Exception):
pass
Expand Down Expand Up @@ -41,7 +42,7 @@ def handle_pexpect(child_process, processes_to_terminate, expect_string, output_
return output_buffer

def start_server():
return execute_and_detach(f'python3 dns.py --ipv4only {IPV4ONLY} --address {SERVER_ADDRESS} --port {SERVER_PORT}')
return execute_and_detach(f'python3 {STUDENT_FILE_PATH} --ipv4only {IPV4ONLY} --address {SERVER_ADDRESS} --port {SERVER_PORT}')


def execute_and_detach(cmd):
Expand Down
3 changes: 2 additions & 1 deletion http_server_check/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

SERVER_ADDRESS = "127.0.0.1"
SERVER_PORT = 8000
STUDENT_FILE_PATH = "../student/http_server_check/server.py"

def generate_name():
return ''.join(random.choice(string.ascii_letters) for _ in range(random.randint(8, 16)))
Expand Down Expand Up @@ -68,7 +69,7 @@ def handle_requests_request(page_path, data):
raise TestException(f'error when requesting {page_path} with method POST: {e}')

def start_server():
server_process = execute_and_detach(f'python3 server.py --address {SERVER_ADDRESS} --port {SERVER_PORT}')
server_process = execute_and_detach(f'python3 {STUDENT_FILE_PATH} --address {SERVER_ADDRESS} --port {SERVER_PORT}')
EXPECTED_OUTPUT = f'Serving HTTP on port {SERVER_PORT}'

output_buffer = handle_pexpect(server_process, [server_process], EXPECTED_OUTPUT, "", "starting a server")
Expand Down
5 changes: 3 additions & 2 deletions server_check/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
CLIENT_FOLDER_PATH = './'
ADDRESS = "127.0.0.1"
PORT = 5378
STUDENT_FILE_PATH = "../student/server_check/server.py"

def generate_name():
return ''.join(random.choice(string.ascii_letters) for _ in range(random.randint(8, 16)))
Expand Down Expand Up @@ -50,7 +51,7 @@ def handle_pexpect(child_process, processes_to_terminate, expect_string, output_
return output_buffer

def start_server():
server_process = execute_and_detach(f'python3 server.py --address "{ADDRESS}" --port {PORT}')
server_process = execute_and_detach(f'python3 {STUDENT_FILE_PATH} --address "{ADDRESS}" --port {PORT}')
expected_output = "Server is on"

output_buffer = handle_pexpect(server_process, [server_process], expected_output, "", "starting a server")
Expand Down Expand Up @@ -281,7 +282,7 @@ def send_message_to_unknown():
return client_process, output_buffer

def verify_file_for_sendall():
file_path = os.path.join(os.getcwd(), "server.py")
file_path = os.path.join(os.getcwd(), STUDENT_FILE_PATH)

try:
with open(file_path, 'r') as file:
Expand Down
5 changes: 3 additions & 2 deletions unreliable_chat_check/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TestException(Exception):
SERVER_DIRECTORY = "./"
SERVER_ADDRESS = "127.0.0.1"
SERVER_PORT = 5382
STUDENT_FILE_PATH = "../student/unreliable_chat_check/client.py"

def generate_name():
return ''.join(random.choice(string.ascii_letters) for _ in range(random.randint(8, 16)))
Expand Down Expand Up @@ -88,7 +89,7 @@ def execute_and_detach(cmd):

def start_script():
expected_output = f'Welcome to Chat Client. Enter your login:'
client_process = pexpect.spawn(f'python3 client.py --address "{SERVER_ADDRESS}" --port {SERVER_PORT}', encoding='utf-8')
client_process = pexpect.spawn(f'python3 {STUDENT_FILE_PATH} --address "{SERVER_ADDRESS}" --port {SERVER_PORT}', encoding='utf-8')

output_buffer = handle_pexpect(client_process, [client_process], f'{expected_output}', "", "starting the client script")

Expand Down Expand Up @@ -272,7 +273,7 @@ def check_name():
return client_process, output_buffer

def verify_file_for_sendall():
file_path = os.path.join(os.getcwd(), "client.py")
file_path = os.path.join(os.getcwd(), STUDENT_FILE_PATH)

try:
with open(file_path, 'r') as file:
Expand Down

0 comments on commit 5b7e272

Please sign in to comment.