Skip to content

Commit

Permalink
Test script for test LVV-T192
Browse files Browse the repository at this point in the history
  • Loading branch information
leannep committed Oct 11, 2024
1 parent 22c9fd3 commit d64a533
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
26 changes: 26 additions & 0 deletions inspection/test_LVV-T192/test_LVV-T192.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Check local IP address
local_ip="ipconfig getifaddr en0"
localip=$(eval "$local_ip")
echo "The output is: $localip"

# Check connection to a site
wget -q --spider http://google.com
if [ $? -ne 0 ]; then
echo "connection to site failed"
fi

# Download a document
url="https://dmtn-226.lsst.io/DMTN-226.pdf"
wget "$url"
if [ $? -ne 0 ]; then
echo "Command failed with exit status $?"
fi

# Check file exists locally
file_path=$(basename $url)
if [ ! -f "$file_path" ]; then
echo "File does not exist: $file_path"
fi
rm $file_path
69 changes: 69 additions & 0 deletions scripts/test_LVV-T192.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# Check local IP address
local_ip="ipconfig getifaddr en0"
localip=$(eval "$local_ip")
echo "The output is: $localip"

# Check connection to a site
wget -q --spider http://google.com
if [ $? -ne 0 ]; then
echo "connection to site failed"
fi

# Download a document
url="https://dmtn-226.lsst.io/DMTN-226.pdf"
wget "$url"
if [ $? -ne 0 ]; then
echo "Command failed with exit status $?"
fi

# Check file exists locally
file_path=$(basename $url)
if [ ! -f "$file_path" ]; then
echo "File does not exist: $file_path"
fi
rm $file_path

# Run a speed test
VENV_NAME="LVV-T192_env"

echo "Creating virtual environment '$VENV_NAME'..."
python3 -m venv "$VENV_NAME"

source "$VENV_NAME/bin/activate"
if [ $? -eq 0 ]; then
echo "Virtual environment '$VENV_NAME' activated."

# Install speedtest package in venv
package="speedtest-cli"
echo "Installing $package..."
pip install "$package"

# Check if the installation was successful
if [ $? -eq 0 ]; then
echo "$PACKAGE installed successfully."
else
echo "Failed to install $PACKAGE."
exit 1
fi

# Run speed test
echo "Checking internet speed..."
output=$(speedtest-cli --simple)

download_speed=$(echo "$output" | grep 'Download:' | awk '{print $2, $3}')
upload_speed=$(echo "$output" | grep 'Upload:' | awk '{print $2, $3}')
ping_time=$(echo "$output" | grep 'Ping:' | awk '{print $2, $3}')

echo "Parsed Speed Test Results:"
echo "Download Speed: $download_speed"
echo "Upload Speed: $upload_speed"
echo "Ping Time: $ping_time"
fi

# Deactivate and remove the venv
echo "Deactivating the virtual environment '$VENV_NAME'..."
deactivate
echo "Removing the virtual environment directory '$VENV_NAME'..."
rm -rf "$VENV_NAME"

0 comments on commit d64a533

Please sign in to comment.