You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logging and Monitoring The script uses cargo run to start instances but lacks proper logging and monitoring for these operations. Consider adding structured tracing to monitor the instances' lifecycle and operations.
Tokio Task Spawning The script does not use spawn_named or spawn_blocking_named for spawning tasks. Ensure to use these functions for better task management and monitoring.
Leader Election Timeout The leader election process has a fixed timeout of 120 seconds. Consider making this configurable to allow flexibility during different test scenarios.
Dynamic Field Logging The script logs dynamic fields directly in the messages. Use structured tracing fields instead to log these dynamic fields.
Add a check to ensure the jq command is available before using it
Consider adding a check to ensure that the jq command is available on the system before using it in the check_liveness and check_leader functions. This will prevent the script from failing unexpectedly if jq is not installed.
check_liveness() {
local port=$1
+ if ! command -v jq &> /dev/null; then+ echo "jq command not found. Please install jq to proceed."+ exit 1+ fi
curl -s http://0.0.0.0:$port \
--header "content-type: application/json" \
--data '{"jsonrpc":"2.0","method":"stratus_health","params":[],"id":1}' | jq '.result'
}
Suggestion importance[1-10]: 9
Why: This suggestion is crucial as it prevents the script from failing unexpectedly if jq is not installed, ensuring robustness.
9
Add a check to ensure the killport command is available before using it
Add a check to ensure that the killport command is available on the system before using it in the cleanup and run_test functions. This will prevent the script from failing unexpectedly if killport is not installed.
cleanup() {
exit_code=$?
echo "Cleaning up..."
+ if ! command -v killport &> /dev/null; then+ echo "killport command not found. Please install killport to proceed."+ exit 1+ fi
for port in "${ports[@]}"; do
killport --quiet $port || true
done
Suggestion importance[1-10]: 9
Why: This check is important to prevent the script from failing if killport is not installed, ensuring the cleanup process runs smoothly.
9
Add a check to ensure the cargo command is available before using it
Add a check to ensure that the cargo command is available on the system before using it in the start_instance function. This will prevent the script from failing unexpectedly if cargo is not installed.
start_instance() {
local address=$1
local grpc_address=$2
local rocks_path_prefix=$3
local log_file=$4
local candidate_peers=$5
local tokio_console_address=$6
local metrics_exporter_address=$7
+ if ! command -v cargo &> /dev/null; then+ echo "cargo command not found. Please install cargo to proceed."+ exit 1+ fi
Suggestion importance[1-10]: 9
Why: Ensuring cargo is available before using it is critical to avoid unexpected script failures, thus improving script reliability.
9
Best practice
Initialize the leader_port variable to an empty string at the beginning of the function
To avoid potential issues with uninitialized variables, consider initializing the leader_port variable to an empty string at the beginning of the run_test function.
run_test() {
local instances=()
local all_addresses=()
+ local leader_port=""
Suggestion importance[1-10]: 7
Why: Initializing leader_port to an empty string is a good practice to avoid potential issues with uninitialized variables, enhancing code reliability.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Tests
Description
main.sh
and enhanced it with additional functionalities.main.sh
.Changes walkthrough 📝
main.sh
Rename and enhance leader election script
chaos/experiments/main.sh
leader-election.sh
tomain.sh
.and leader restart.
leader election.
e2e-generic.yml
Update workflow to use renamed script
.github/workflows/e2e-generic.yml
main.sh
.