2023-01-11 11:44:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-01-18 14:06:28 +00:00
|
|
|
dir=$(pwd)
|
|
|
|
|
2023-01-12 10:24:56 +00:00
|
|
|
# Parse arg if any
|
2023-01-18 14:06:28 +00:00
|
|
|
ARGS1=${1:-"wakurtosis"}
|
2023-01-21 20:08:48 +00:00
|
|
|
ARGS2=${2:-"config.json"}
|
2023-01-12 10:24:56 +00:00
|
|
|
|
2023-01-11 11:44:03 +00:00
|
|
|
# Main .json configuration file
|
2023-01-18 14:06:28 +00:00
|
|
|
enclave_name=$ARGS1
|
2023-01-21 20:08:48 +00:00
|
|
|
wakurtosis_config_file=$ARGS2
|
2023-01-17 17:21:58 +00:00
|
|
|
|
2023-01-22 18:47:16 +00:00
|
|
|
echo "- Enclave name: " $enclave_name
|
|
|
|
echo "- Configuration file: " $wakurtosis_config_file
|
2023-01-17 17:21:58 +00:00
|
|
|
|
2023-01-21 16:34:54 +00:00
|
|
|
# Create and run Gennet docker container
|
2023-01-21 20:08:48 +00:00
|
|
|
echo -e "\nRunning topology generation"
|
2023-01-17 17:21:58 +00:00
|
|
|
cd gennet-module
|
2023-01-21 20:08:48 +00:00
|
|
|
docker run --name gennet-container -v ${dir}/config/:/config gennet --config-file /config/${wakurtosis_config_file} --output-dir /config/topology_generated
|
2023-01-17 17:21:58 +00:00
|
|
|
cd ..
|
|
|
|
|
2023-01-18 14:06:28 +00:00
|
|
|
docker rm gennet-container > /dev/null 2>&1
|
2023-01-11 11:44:03 +00:00
|
|
|
|
2023-01-18 14:06:28 +00:00
|
|
|
# Delete the enclave just in case
|
2023-02-10 10:25:59 +00:00
|
|
|
echo -e "\nCleaning up Kurtosis environment "$enclave_name
|
2023-01-18 14:06:28 +00:00
|
|
|
kurtosis enclave rm -f $enclave_name > /dev/null 2>&1
|
2023-02-10 10:39:36 +00:00
|
|
|
kurtosis clean -a > /dev/null 2>&1
|
2023-02-10 10:25:59 +00:00
|
|
|
|
|
|
|
# Delete previous logs
|
|
|
|
echo -e "\Deleting previous logs in ${enclave_name}_logs"
|
2023-02-10 10:39:36 +00:00
|
|
|
rm -rf ./${enclave_name}_logs > /dev/null 2>&1
|
|
|
|
rm ./kurtosisrun_log.txt > /dev/null 2>&1
|
2023-01-11 11:44:03 +00:00
|
|
|
|
|
|
|
# Create the new enclave and run the simulation
|
2023-01-21 20:08:48 +00:00
|
|
|
echo -e "\nInitiating enclave "$enclave_name
|
2023-01-22 18:50:06 +00:00
|
|
|
kurtosis_cmd="kurtosis run --enclave-id ${enclave_name} . '{\"wakurtosis_config_file\" : \"config/${wakurtosis_config_file}\"}' > kurtosisrun_log.txt 2>&1"
|
2023-01-12 10:24:56 +00:00
|
|
|
eval $kurtosis_cmd
|
2023-01-18 14:06:28 +00:00
|
|
|
echo -e "Enclave " $enclave_name " is up and running"
|
2023-01-11 11:44:03 +00:00
|
|
|
|
|
|
|
# Fetch the WSL service id and display the log of the simulation
|
2023-02-10 10:25:59 +00:00
|
|
|
wsl_service_id=$(kurtosis enclave inspect $enclave_name 2>/dev/null | grep wsl- | awk '{print $1}')
|
2023-01-18 14:06:28 +00:00
|
|
|
# kurtosis service logs wakurtosis $wsl_service_id
|
2023-02-10 10:25:59 +00:00
|
|
|
echo -e "\n--> To see simulation logs run: kurtosis service logs $enclave_name $wsl_service_id <--"
|
2023-01-11 11:44:03 +00:00
|
|
|
|
|
|
|
# Fetch the Grafana address & port
|
2023-02-10 10:25:59 +00:00
|
|
|
grafana_host=$(kurtosis enclave inspect $enclave_name 2>/dev/null | grep grafana- | awk '{print $6}')
|
2023-01-22 18:50:06 +00:00
|
|
|
echo -e "\n--> Statistics in Grafana server at http://$grafana_host/ <--"
|
|
|
|
|
2023-02-10 10:25:59 +00:00
|
|
|
echo "Output of kurtosis run command written in kurtosisrun_log.txt"
|
2023-01-30 13:05:08 +00:00
|
|
|
|
|
|
|
### Wait for WSL to finish
|
|
|
|
|
|
|
|
# Get the container suffix for the running service
|
|
|
|
cid_suffix="$(kurtosis enclave inspect $enclave_name | grep $wsl_service_id | cut -f 1 -d ' ')"
|
|
|
|
|
|
|
|
# Construct the fully qualified container name that kurtosis created
|
|
|
|
cid="$enclave_name--user-service--$cid_suffix"
|
|
|
|
|
|
|
|
# Wait for the container to halt; this will block
|
2023-02-10 10:39:36 +00:00
|
|
|
echo -e "Waiting for simulation to finish ..."
|
2023-01-30 13:05:08 +00:00
|
|
|
status_code="$(docker container wait $cid)"
|
|
|
|
|
2023-02-10 10:25:59 +00:00
|
|
|
### Logs
|
|
|
|
rm -rf ./$enclave_name_logs > /dev/null 2>&1
|
|
|
|
kurtosis enclave dump ${enclave_name} ${enclave_name}_logs > /dev/null 2>&1
|
2023-02-10 10:39:36 +00:00
|
|
|
echo -e "Simulation ended with code $status_code Results in ./${enclave_name}_logs"
|
2023-02-10 10:25:59 +00:00
|
|
|
|
2023-01-30 13:05:08 +00:00
|
|
|
# Copy simulation results
|
2023-02-10 10:39:36 +00:00
|
|
|
# docker cp "$cid:/wsl/summary.json" "./${enclave_name}_logs" > /dev/null 2>&1
|
|
|
|
docker cp "$cid:/wsl/messages.json" "./${enclave_name}_logs" > /dev/null 2>&1
|
2023-01-30 13:16:05 +00:00
|
|
|
|
|
|
|
# Stop and delete the enclave
|
2023-02-10 10:25:59 +00:00
|
|
|
# kurtosis enclave stop $enclave_name > /dev/null 2>&1
|
|
|
|
# kurtosis enclave rm -f $enclave_name > /dev/null 2>&1
|
|
|
|
# echo "Enclave $enclave_name stopped and deleted."
|
2023-01-30 13:05:08 +00:00
|
|
|
|
|
|
|
echo "Done."
|