This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webapp oci):initial version of webapp image
feat(github-actions): build webapp image feat(github-actions): build webapp image update docs, include a script to run tests based on env vars fixup! feat(github-actions): build webapp image use an entrypoint script that starts a cronjob to run every minute ci: attempt to have 2 tags for the webapp image, one with the sha fixup! feat(webapp oci):initial version of webapp image fixup! use an entrypoint script that starts a cronjob to run every minute fixup! use an entrypoint script that starts a cronjob to run every minute fixup! ci: attempt to have 2 tags for the webapp image, one with the sha tasks to run webapp image locally ci: fix gh actions invalid workflow file error debug logs on the entrypoint shell script fixup! ci: fix gh actions invalid workflow file error run the test delete-objects every 20 minutes change test frequency to every 3 minutes change timezone and add output of tests to the smile txt wip
- Loading branch information
Showing
11 changed files
with
236 additions
and
18 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
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 |
---|---|---|
|
@@ -2,3 +2,5 @@ config.yaml | |
results | ||
venv | ||
mgc | ||
nginx.conf | ||
!src/templates/nginx.conf |
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
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,50 @@ | ||
#!/bin/sh | ||
set +x | ||
|
||
# Check if CONFIG_YAML_CONTENT is present | ||
if [ -z "$CONFIG_YAML_CONTENT" ]; then | ||
echo "Error: CONFIG_YAML_CONTENT environment variable is not set." | ||
printf ":-(\n\nError: CONFIG_YAML_CONTENT environment variable is not set. $(date)" > /app/results/smile.txt | ||
exit 1 | ||
fi | ||
|
||
# create config.yaml file from env var | ||
echo "$CONFIG_YAML_CONTENT" > /app/config.yaml | ||
|
||
# create ~/.aws config files | ||
just _setup | ||
|
||
# space separated list of remote names | ||
remotes=$(dasel -f /app/config.yaml -r yaml -s '.remotes.all().key()' | grep -v '\-second$' | tr '\n' ' ') | ||
|
||
echo "Remotes: $remotes" | ||
date | ||
|
||
# Sync local_results_folder with remote_results_bucket as source | ||
remote_results_bucket=$(dasel -f ./config.yaml -r yaml -s '.results_bucket') | ||
local_results_folder="./results" | ||
rclone mkdir "$remote_results_bucket" # create remote bucket if it doesnt exist | ||
rclone sync "$remote_results_bucket" "$local_results_folder" # fetch previous results | ||
|
||
# Do a list-buckets on each remote | ||
for remote in $remotes; do | ||
echo "Executing AWS CLI command for profile $remote" | ||
echo "$remote" >> /app/results/smile.txt | ||
aws s3api list-buckets --cli-connect-timeout 2 --cli-read-timeout 2 --profile "$remote" >> /app/results/smile.txt | ||
done | ||
|
||
# asure that results folder is readable | ||
chmod -R 755 results | ||
|
||
# Schedule for TEST_SUITE=big | ||
echo "8 7,9,11,14,16,18,22,0 * * * TEST_SUITE=big /app/run_tests.sh" >> /etc/crontabs/root | ||
|
||
# Schedule for TEST_SUITE=small | ||
echo "*/5 * * * * TEST_SUITE=small /app/run_tests.sh" >> /etc/crontabs/root | ||
|
||
# Start cron | ||
crond -f & | ||
|
||
# Start Nginx | ||
exec nginx -g 'daemon off;' | ||
|
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
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,34 @@ | ||
#!/bin/sh | ||
set +x | ||
|
||
# cron job starts on /root and is run by user root | ||
cd /app | ||
|
||
touch results/debug_last_test_start | ||
|
||
# space separated list of remote names | ||
remotes=$(dasel -f ./config.yaml -r yaml -s '.remotes.all().key()' | grep -v '\-second$' | tr '\n' ' ') | ||
small_set_remotes=$(dasel -f ./config.yaml -r yaml -s '.small_set_remotes') | ||
|
||
# Check if TEST_SUITE is set and execute commands accordingly | ||
if [ "$TEST_SUITE" = "big" ]; then | ||
# Run tests for big suite | ||
just group-test index-s3 _big "$remotes" > results/debug_last_test.txt 2>&1 | ||
elif [ "$TEST_SUITE" = "small" ]; then | ||
# Run tests for small suite | ||
just group-test delete-objects _small "$small_set_remotes" > results/debug_last_test.txt 2>&1 | ||
else | ||
echo "Unknown TEST_SUITE value: $TEST_SUITE" > results/debug_last_test.txt 2>&1 | ||
exit 1 | ||
fi | ||
|
||
|
||
# asure that results folder is readable | ||
chmod -R 755 results | ||
|
||
printf ":-)\n\nLast test ended on $(date)" > results/smile.txt | ||
|
||
# Sync remote_results_bucket with local_results_folder as source (send results) | ||
remote_results_bucket=$(dasel -f ./config.yaml -r yaml -s '.results_bucket') | ||
local_results_folder="./results" | ||
rclone sync "$local_results_folder" "$remote_results_bucket" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Set number of worker processes automatically based on number of CPU cores. | ||
worker_processes auto; | ||
|
||
events { | ||
# The maximum number of simultaneous connections that can be opened by | ||
# a worker process. | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
charset utf-8; | ||
|
||
server { | ||
listen {{ .webapp.nginx.listen }}; | ||
server_name {{ .webapp.nginx.server_name }}; | ||
|
||
{{- range $location_name, $location := .webapp.nginx.locations}} | ||
location {{ $location_name }} { | ||
root {{ $location.root }}; | ||
index index.html; | ||
autoindex on; | ||
autoindex_localtime on; | ||
} | ||
{{- end}} | ||
} | ||
} |
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,47 @@ | ||
# Use main image as base | ||
FROM ghcr.io/marmotitude/object-storage-tests:main | ||
|
||
# Install Nginx and cron | ||
RUN apk update && \ | ||
apk add --no-cache nginx dcron tzdata | ||
|
||
# Set the timezone to America/Sao_Paulo | ||
RUN ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && \ | ||
echo "America/Sao_Paulo" > /etc/timezone | ||
|
||
# Keep a backup of alpine's default nginx config | ||
RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig | ||
|
||
# Copy our custom Nginx configuration | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Create the directory for the results | ||
RUN mkdir -p results | ||
|
||
# Set ownership and permissions for Nginx to read from /app/results | ||
RUN chown -R root:root results && \ | ||
chmod -R 755 results | ||
|
||
# Write dummy file to results directory with a smile and timestamp | ||
RUN printf ":-)\n\nBuilt on $(date) by:$(hostname)" > results/smile.txt | ||
|
||
# Copy the shell script that runs desired tests outputing to results folder | ||
# this script will be executed by an external scheduler periodically | ||
COPY run_tests.sh /app/run_tests.sh | ||
|
||
# Expose port 5000 | ||
EXPOSE 5000 | ||
|
||
COPY justfile /app/justfile | ||
|
||
# Copy the entrypoint script | ||
COPY entrypoint.sh /app/entrypoint.sh | ||
|
||
# Make the script executable | ||
RUN chmod +x /app/entrypoint.sh | ||
|
||
# Set the ENTRYPOINT to the script | ||
ENTRYPOINT ["/app/entrypoint.sh"] |