Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Compare Batches Script

This directory contains the `compare_batches.sh` script for comparing batch data between two domains.

## Usage

To use the `compare_batches.sh` script:

1. Make the script executable:
```bash
chmod +x compare_batches.sh
```

2. Run it with two domain names:
```bash
./compare_batches.sh localhost:1633 other_domain
```

## What the script does

The `compare_batches.sh` script:

- Checks for correct number of arguments (requires exactly 2 domain names)
- Uses `curl -s` for silent mode to fetch `/batches` endpoint from both domains
- Pipes output through `jq` to format JSON
- Saves results to `1.txt` and `2.txt`
- Uses `diff --side-by-side --suppress-common-lines` to show only differing lines in a side-by-side format
- `--side-by-side` displays the differing lines from both files next to each other
- `--suppress-common-lines` ensures only differing lines are shown
- Reports if differences were found or not

## Output

The script will display differences between the two batch endpoints side by side, or report "No differences found" if the responses are identical.
42 changes: 42 additions & 0 deletions scripts/compare_batches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Check if two domain arguments are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <domain1> <domain2>"
exit 1
fi

DOMAIN1=$1
DOMAIN2=$2
FILE1="1.txt"
FILE2="2.txt"

# Perform curl requests in parallel
curl -s "http://${DOMAIN1}/batches" | jq > "$FILE1" &
PID1=$!
curl -s "http://${DOMAIN2}/batches" | jq > "$FILE2" &
PID2=$!

# Wait for both curl commands to complete
wait $PID1
if [ $? -ne 0 ]; then
echo "Error fetching data from ${DOMAIN1}"
exit 1
fi

wait $PID2
if [ $? -ne 0 ]; then
echo "Error fetching data from ${DOMAIN2}"
exit 1
fi

# Compare the files and show differences side by side
echo "Differences between ${FILE1} and ${FILE2} (side by side):"
diff --side-by-side --suppress-common-lines "$FILE1" "$FILE2"

# Check if there were any differences
if [ $? -eq 0 ]; then
echo "No differences found."
else
echo "Differences found (see above)."
fi