-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ci/cd_upgrade_validation_test' of https://github.com/an…
…t-media/Scripts.git into ci/cd_upgrade_validation_test
- Loading branch information
Showing
9 changed files
with
303 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Python 24x7 script | ||
|
||
on: | ||
schedule: | ||
- cron: '*/5 * * * *' | ||
|
||
jobs: | ||
run-selenium: | ||
runs-on: ubuntu-latest | ||
env: | ||
WEBHOOK_URL: ${{ secrets.WEBHOOK }} | ||
SERVER_IP: ${{ secrets.SERVER_IP }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
PASSWORD: ${{ secrets.PASSWORD }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python 3 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install requests | ||
pip install paramiko | ||
- name: Run staging script | ||
run: | | ||
python 24x7-testing/24x7-test1.py |
80 changes: 80 additions & 0 deletions
80
.github/workflows/ant-media-server-docker-multi-platform.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: CI/CD for Docker Images - Ant Media Server (Ubuntu & Rocky Linux) | ||
|
||
on: [push] | ||
|
||
jobs: | ||
ams_ubuntu_docker_test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download the latest version of Ant Media Server | ||
run: curl -L -o ant-media-server-community.zip $(curl -s https://api.github.com/repos/ant-media/Ant-Media-Server/releases/latest | grep "browser_download_url" | cut -d '"' -f 4) | ||
|
||
- name: Download Dockerfile | ||
run: wget --quiet https://raw.githubusercontent.com/ant-media/Scripts/master/docker/Dockerfile_Process -O Dockerfile | ||
|
||
- name: Build Docker image | ||
run: docker build --network=host -t antmediaserver:latest --build-arg AntMediaServer=ant-media-server-community.zip . | ||
|
||
- name: Run the image | ||
run: docker run -d -p 5080:5080 --name antmediaserver antmediaserver | ||
|
||
- name: Check Ant Media Server health with a timeout | ||
run: | | ||
timeout=120 | ||
start_time=$(date +%s) | ||
until wget http://localhost:5080 -O index.html; do | ||
current_time=$(date +%s) | ||
elapsed_time=$((current_time - start_time)) | ||
if [ $elapsed_time -gt $timeout ]; then | ||
echo "Timeout reached. Ant Media Server did not start within $timeout seconds." | ||
exit 1 | ||
fi | ||
echo "Waiting for Ant Media Server to start..." | ||
sleep 10 | ||
done | ||
- name: Stop and remove the container | ||
run: docker stop antmediaserver && docker rm antmediaserver | ||
|
||
ams_rockylinux_docker_test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download the latest version of Ant Media Server | ||
run: curl -L -o ant-media-server-community.zip $(curl -s https://api.github.com/repos/ant-media/Ant-Media-Server/releases/latest | grep "browser_download_url" | cut -d '"' -f 4) | ||
|
||
- name: Download Dockerfile | ||
run: wget --quiet https://raw.githubusercontent.com/ant-media/Scripts/master/docker/Dockerfile_RockyLinux -O Dockerfile | ||
|
||
- name: Build Docker image | ||
run: docker build --network=host -t antmediaserver:latest --build-arg AntMediaServer=ant-media-server-community.zip . | ||
|
||
- name: Run the image | ||
run: docker run -d -p 5080:5080 --name antmediaserver antmediaserver | ||
|
||
- name: Check Ant Media Server health with a timeout | ||
run: | | ||
timeout=120 | ||
start_time=$(date +%s) | ||
until wget http://localhost:5080 -O index.html; do | ||
current_time=$(date +%s) | ||
elapsed_time=$((current_time - start_time)) | ||
if [ $elapsed_time -gt $timeout ]; then | ||
echo "Timeout reached. Ant Media Server did not start within $timeout seconds." | ||
exit 1 | ||
fi | ||
echo "Waiting for Ant Media Server to start..." | ||
sleep 10 | ||
done | ||
- name: Stop and remove the container | ||
run: docker stop antmediaserver && docker rm antmediaserver |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Marketplace SSL Test | ||
|
||
#run tests on schedule because we don't want to generate a subdomain everytime | ||
on: | ||
schedule: | ||
- cron: '0 0 * * 1' | ||
|
||
|
||
|
||
jobs: | ||
run_build: | ||
name: Marketplace SSL Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run enable_ssl.sh for marketplace | ||
uses: appleboy/ssh-action@master | ||
with: | ||
#OVH_REMOTE_HOST has marketplace version deployed | ||
host: ${{ secrets.OVH_REMOTE_HOST }} | ||
username: ${{ secrets.OVH_REMOTE_USERNAME }} | ||
key: ${{ secrets.OVH_SSH_PRIVATE_KEY }} | ||
port: ${{ secrets.OVH_REMOTE_PORT }} | ||
# If the version is not marketplace, following enable_ssl.sh script fails | ||
script: | | ||
SECRET_KEY=$(openssl rand -base64 32 | head -c 32) | ||
sudo sed -i "/^server.jwtServerControlEnabled=/s|.*|server.jwtServerControlEnabled=true|" /usr/local/antmedia/conf/red5.properties | ||
sudo sed -i "/^server.jwtServerSecretKey=/s|.*|server.jwtServerSecretKey=$SECRET_KEY|" /usr/local/antmedia/conf/red5.properties | ||
sudo service antmedia restart | ||
sleep 20 | ||
OUTPUT=$(sudo bash /usr/local/antmedia/enable_ssl.sh) | ||
echo "OUTPUT -> $OUTPUT"; | ||
HTTPS_URL=$(echo "$OUTPUT" | grep 'You can use this url: '| grep -o 'https://[^ ]*') | ||
echo "HTTPS_URL -> $HTTPS_URL" | ||
sleep 20 | ||
status_code=$(curl -o /dev/null -s -I -w "%{http_code}" "$HTTPS_URL") | ||
if [ "$status_code" -eq 200 ]; then | ||
echo "URL($HTTPS_URL) is working: $status_code" | ||
else | ||
echo "URL($HTTPS_URL) is not working: $status_code" | ||
exit 1; | ||
fi | ||
- name: Run enable_ssl.sh for existing domain | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.OVH_REMOTE_HOST }} | ||
username: ${{ secrets.OVH_REMOTE_USERNAME }} | ||
key: ${{ secrets.OVH_SSH_PRIVATE_KEY }} | ||
port: ${{ secrets.OVH_REMOTE_PORT }} | ||
#restore the old domain to not encounter any issue | ||
script: | | ||
sudo bash /usr/local/antmedia/enable_ssl.sh -d ${{ secrets.OVH_REMOTE_HOST }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import os | ||
import time | ||
import requests | ||
import paramiko | ||
import json | ||
|
||
webhook_url = os.environ['WEBHOOK_URL'] | ||
icon_emoji = ":ghost:" | ||
|
||
def send_slack_message(webhook_url, message, icon_emoji=":ghost:"): | ||
payload = { | ||
"text": message, | ||
"icon_emoji": icon_emoji | ||
} | ||
response = requests.post(webhook_url, data={"payload": json.dumps(payload)}) | ||
|
||
if response.status_code != 200: | ||
print("Error sending Slack message: ", response.text) | ||
else: | ||
print("Slack message sent successfully!") | ||
|
||
def check_stream_status(api_url): | ||
try: | ||
# Make the GET request to the API | ||
response = requests.get(api_url) | ||
response.raise_for_status() # Raise an HTTPError for bad status codes | ||
|
||
response_data = response.json() | ||
|
||
# Extract the required fields | ||
status = response_data.get("status") | ||
webRTCViewerCount = response_data.get("webRTCViewerCount") | ||
|
||
# Check if the status is "broadcasting" and webRTCViewerCount is 1 | ||
if status == "broadcasting" and webRTCViewerCount == 1: | ||
print("Stream is broadcasting with 1 WebRTC viewer.") | ||
else: | ||
message = "Stream is not broadcasting or there is no viewer" | ||
send_slack_message(webhook_url, message, icon_emoji) | ||
return False | ||
|
||
except requests.exceptions.RequestException as e: | ||
print(f"Error making the API call: {e}") | ||
message = "Error making the API call" | ||
send_slack_message(webhook_url, message, icon_emoji) | ||
return False | ||
|
||
except requests.exceptions.HTTPError as e: | ||
print(f"HTTP error: {e}") | ||
message = "HTTP error when making the API call" | ||
send_slack_message(webhook_url, message, icon_emoji) | ||
return False | ||
|
||
except ValueError as e: | ||
print(f"Error: {e}") | ||
return False | ||
|
||
except Exception as e: | ||
print(f"Unexpected error: {e}") | ||
return False | ||
|
||
return True | ||
|
||
def check_server_for_errors(server_ip, username, password): | ||
try: | ||
# SSH into the server | ||
client = paramiko.SSHClient() | ||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | ||
client.connect(server_ip, username=username, password=password) | ||
|
||
# Check for error files | ||
file_extensions = [".log", ".hprof"] | ||
error_files = [] | ||
|
||
for ext in file_extensions: | ||
stdin, stdout, stderr = client.exec_command(f"ls /usr/local/antmedia/*{ext}") | ||
error_files.extend(stdout.readlines()) | ||
|
||
if error_files: | ||
print("Error files found:") | ||
for file in error_files: | ||
print(file.strip()) | ||
message = "The crash log or dump file is found on the server in 24x7 staging enviornment. Please check the logs" | ||
send_slack_message(webhook_url, message, icon_emoji) | ||
else: | ||
print("No error files found") | ||
|
||
except paramiko.AuthenticationException as e: | ||
print(f"Authentication failed: {e}") | ||
except paramiko.SSHException as e: | ||
print(f"SSH error: {e}") | ||
except Exception as e: | ||
print(f"Unexpected error: {e}") | ||
finally: | ||
client.close() | ||
|
||
if __name__ == "__main__": | ||
api_url = "https://test.antmedia.io:5443/24x7test/rest/v2/broadcasts/24x7test" | ||
if check_stream_status(api_url): | ||
# Replace the following with server details | ||
server_ip = os.environ['SERVER_IP'] | ||
username = os.environ['USERNAME'] | ||
password = os.environ['PASSWORD'] | ||
|
||
check_server_for_errors(server_ip, username, password) |
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
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
Oops, something went wrong.