Skip to content

Commit

Permalink
72-add-bash-script-to-pull-and-run-protocol-verifier (#73)
Browse files Browse the repository at this point in the history
* add bash script to pull and run latest tagged version protocol veridier

* change script bin/bash

* add sudo into docker compose commands

* update bash script to get host network through user input

* update bash script

* update sed command for config.config file

* update protocol-verifier tag in default config file

* update default config to use kafka

* update default config protocol verifier tag

* update default test timeout time

* add flask-cors to enable upload to homeserver from local machine

* add CORS after Swagger

* add flask-cors to requirements.txt

* update flask cors version

* update flask cors 4.0.1

* Update documentation to explain CORS

* update comments within bash script

* update CORS to accept from localhost

* 69-update-readme_v2 (#74)

* update README to improve Windows installation

* update stdout after docker compose up

* add extra steps for windows systems to make install script executable

* remove a windowds instruction when in dev container, add run tests

* update curl commands for windows

* update readmev2 with changes

* further updates to readme

* add screenshot ref reopening in dev container

* remove windows commands when in dev container

* small change
  • Loading branch information
AdrianMontaguSmartDCSIT authored Jun 26, 2024
1 parent 6e98bfe commit 3664d27
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 17 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ antlr4-python3-runtime~=4.13.1
antlr4-tools~=0.2
dask~=2024.4.2
Flask~=3.0.2
Flask-Cors~=4.0.1
flasgger~=0.9.5
flatdict~=4.0.1
hypothesis~=6.86.2
Expand Down
55 changes: 55 additions & 0 deletions scripts/install_and_run_protocol_verifier.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# This script automates the process of pulling the latest tagged version of the protocol verifier,
# updating necessary files, and running the protocol verifier using Docker Compose. It ensures
# that the setup is configured correctly to pass functional and performance tests.

# If using the test harness and protocol verifier on an external server, to access the Swagger UI
# you must port forward when gaining ssh access
# ssh -L 8800:localhost:8800 <user_name>@<host_ip_address>

# NOTE: This script should be run within the root directory of erebus
# ./scripts/install_and_run_protocol_verifier.sh

# Get user input for IP address of where protocol verifier is being hosted
echo "Please enter the IP address of the host network:"
read host_network

# Change working directory to root and pull munin repo
git clone https://github.com/xtuml/munin.git
cd munin

# returns latest tag sorted by date in the form refs/tags/<tag_name>
latest_pv_tag_ref=$(git for-each-ref --sort=creatordate --format '%(refname)' refs/tags | tail -1)

# format latest tag to just <tag_name>
latest_pv_tag=${latest_pv_tag_ref:10}

echo "Checking out latest tag: $latest_pv_tag"
git checkout tags/$latest_pv_tag

# Copy specific files over to munin repo to get tests to pass
echo "Copying over required property files to munin"
cd ..
cp ./end_to_end_test_files/log-pv-files.properties ./munin/deploy/config/log-pv-files.properties
cp ./end_to_end_test_files/log-pv-kafka.properties ./munin/deploy/config/log-pv-kafka.properties

echo "Replacing docker compose file within munin /deploy"
cp ./end_to_end_test_files/docker-compose.prod.yml ./munin/deploy/docker-compose.yml

mkdir -p ./config

echo "Copying config file"
cp ./test_harness/config/default_config.config ./config/config.config

# Update config file with host network IP address
sed -i "s/host.docker.internal/$host_network/g" ./config/config.config

# Update IP address for KAFKA_ADVERTISED_LISTENERS within copied docker-compose
sed -i "s/172.17.0.1/$host_network/g" ./munin/deploy/docker-compose.yml

echo "Starting up the protocol verifier"
sudo docker compose -f ./munin/deploy/docker-compose.yml up -d

echo "Starting up the test harness"
sudo docker compose -f ./docker-compose.yml up -d
17 changes: 11 additions & 6 deletions test_harness/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
Creates the test harness app
"""
import os
from typing import Mapping, Optional, Callable, Union, Any, Generator
from uuid import uuid4
from ctypes import c_int, c_bool
from contextlib import contextmanager
import traceback
import glob
import shutil
import traceback
from uuid import uuid4
from zipfile import ZipFile
import glob
from ctypes import c_int, c_bool
from multiprocessing import Value
from contextlib import contextmanager
from typing import Mapping, Optional, Callable, Union, Any, Generator
from flask_cors import CORS

from tempfile import TemporaryDirectory
from configparser import ConfigParser
Expand Down Expand Up @@ -612,6 +613,10 @@ def create_app(
}

Swagger(app)
# Enable cross site origin requests from localhost
# This allows us to run test harness on a host server, port forward
# to our local machine and use Swagger UI to run tests
CORS(app, origins=["http://localhost", "http://127.0.0.1"])

if test_config is None:
# load the instance config, if it exists, when not testing
Expand Down
20 changes: 9 additions & 11 deletions test_harness/config/default_config.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,38 @@
requests_max_retries = 5
requests_timeout = 10

metrics_from_kafka = False
metrics_from_kafka = True
kafka_metrics_host = host.docker.internal:9092
kafka_metrics_topic = BenchmarkingProbe_service0
kafka_metrics_collection_interval = 1

message_bus_protocol = HTTP
message_bus_protocol = KAFKA3
kafka_message_bus_host = host.docker.internal:9092
kafka_message_bus_topic = Protocol_Verifier_Reception

testing_external_app = False

[non-default]

[protcol-verifier]
[protocol-verifier]
# `log_calc_interval_time` will soon be deprecated and moved to test config
log_calc_interval_time = 5
aer_log_file_prefix = Reception
ver_log_file_prefix = Verifier
ver_log_file_prefix = pv

get_log_file_url = http://host.docker.internal:9000/download/log-file
get_log_file_names_url = http://host.docker.internal:9000/download/log-file-names

pv_send_url = http://host.docker.internal:9000/upload/events
pv_send_as_pv_bytes = False
send_json_without_length_prefix = False
pv_send_as_pv_bytes = True

send_json_without_length_prefix = True

pv_send_job_defs_url = http://host.docker.internal:9000/upload/job-definitions

pv_config_update_time = 60

# This should be greater than or equal to the job complete time in the config of the protocol verifier
# `pv_finish_interval` will soon be deprecated and moved to test config
pv_finish_interval = 30
# `pv_test_timeout` will soon be deprecated and moved to test config
pv_test_timeout = 5
pv_test_timeout = 30

pv_clean_folders_url = http://host.docker.internal:9000/io/cleanup-test
pv_clean_folders_read_timeout = 300
Expand Down

0 comments on commit 3664d27

Please sign in to comment.