-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - [AAP-38819] - Setting up pytest + S3 (Minio) + example test #57
Draft
msmagnanijr
wants to merge
2
commits into
ansible:devel
Choose a base branch
from
msmagnanijr:AAP-38819
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,111 @@ | ||
version: '3.8' | ||
|
||
services: | ||
minio: | ||
image: minio/minio:latest | ||
container_name: minio | ||
ports: | ||
- "9000:9000" | ||
- "9001:9001" | ||
environment: | ||
MINIO_ROOT_USER: minioaccess | ||
MINIO_ROOT_PASSWORD: miniosecret | ||
volumes: | ||
- minio_data:/data | ||
command: server /data --console-address ":9001" | ||
|
||
minio-setup: | ||
image: minio/mc:latest | ||
depends_on: | ||
- minio | ||
volumes: | ||
- minio_config:/tmp | ||
entrypoint: | | ||
sh -c ' | ||
echo "Waiting for MinIO to be ready..."; | ||
sleep 5; | ||
until /usr/bin/mc alias set local http://minio:9000 minioaccess miniosecret; do | ||
echo "MinIO is not ready yet... waiting..."; | ||
sleep 2; | ||
done; | ||
|
||
echo "MinIO is ready! Creating bucket and user..."; | ||
/usr/bin/mc mb --ignore-existing local/metricsutilitys3 || exit 1; | ||
/usr/bin/mc admin user add local mynewuser mysecretpassword || exit 1; | ||
/usr/bin/mc admin policy attach local readwrite --user=mynewuser || exit 1; | ||
/usr/bin/mc admin user svcacct add local mynewuser > /tmp/minio_keys.txt; | ||
|
||
echo "Extracting credentials..."; | ||
ACCESS_KEY="" | ||
SECRET_KEY="" | ||
|
||
while IFS= read -r line; do | ||
case "$$line" in | ||
"Access Key:"*) ACCESS_KEY="$${line#Access Key: }" ;; | ||
"Secret Key:"*) SECRET_KEY="$${line#Secret Key: }" ;; | ||
esac | ||
done < /tmp/minio_keys.txt | ||
|
||
if [ -z "$${ACCESS_KEY}" ] || [ -z "$${SECRET_KEY}" ]; then | ||
echo "ERROR: Failed to extract credentials!" | ||
exit 1 | ||
fi | ||
|
||
echo "ACCESS_KEY=$${ACCESS_KEY}" > /tmp/minio_env.sh | ||
echo "SECRET_KEY=$${SECRET_KEY}" >> /tmp/minio_env.sh | ||
chmod +x /tmp/minio_env.sh | ||
echo "Setup complete."; | ||
' | ||
|
||
metrics-utility: | ||
image: python:3.11-slim | ||
container_name: metrics-utility | ||
depends_on: | ||
- minio-setup | ||
volumes: | ||
- .:/app | ||
- minio_config:/tmp | ||
working_dir: /app | ||
environment: | ||
UV_VENV: /app/.venv | ||
METRICS_UTILITY_SHIP_TARGET: s3 | ||
METRICS_UTILITY_SHIP_PATH: metrics-utility/shipped_data | ||
METRICS_UTILITY_BUCKET_NAME: metricsutilitys3 | ||
METRICS_UTILITY_BUCKET_ENDPOINT: "http://minio:9000" | ||
METRICS_UTILITY_BUCKET_REGION: "us-east-1" | ||
METRICS_UTILITY_REPORT_TYPE: CCSPv2 | ||
METRICS_UTILITY_OPTIONAL_CCSP_REPORT_SHEETS: "jobs,managed_nodes,usage_by_organizations,managed_nodes_by_organizations" | ||
entrypoint: | | ||
bash -c ' | ||
echo "Waiting for MinIO credentials..."; | ||
while [ ! -s /tmp/minio_env.sh ]; do | ||
sleep 2; | ||
done; | ||
|
||
source /tmp/minio_env.sh; | ||
|
||
if [ -z "$$ACCESS_KEY" ] || [ -z "$$SECRET_KEY" ]; then | ||
echo "ERROR: Loaded credentials are empty!" | ||
exit 1 | ||
fi | ||
|
||
export METRICS_UTILITY_BUCKET_ACCESS_KEY=$$ACCESS_KEY; | ||
export METRICS_UTILITY_BUCKET_SECRET_KEY=$$SECRET_KEY; | ||
|
||
echo "Listing all environment variables:"; | ||
printenv | sort; | ||
|
||
echo "Installing dependencies..."; | ||
pip install uv || exit 1; | ||
uv venv || exit 1; | ||
uv pip install . || exit 1; | ||
. .venv/bin/activate || exit 1; | ||
|
||
echo "Running automation billing data collection..."; | ||
python manage.py gather_automation_controller_billing_data --ship --since=20d || exit 1; | ||
echo "Execution complete."; | ||
' | ||
|
||
volumes: | ||
minio_data: | ||
minio_config: |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is going to work outside of the awx container. Martin's PR #51 is about
./manage.py build_report
and notgather_automation_controller_billing_data
😢There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 That's what #52 is for :)
It connects to a custom postgres instance, so this would just need a compose entry for that instance too.
Will test when #52 gets in :)