Skip to content

Commit

Permalink
artipie#18 - docker benchmarks on a dedicated machine
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Aug 3, 2020
1 parent 2dfd5d1 commit 09eedf3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
5 changes: 4 additions & 1 deletion aws-infrastructure/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ cd "$( dirname "${BASH_SOURCE[0]}" )"
export PRIVATE_CLIENT_IP_ADDR=$(terraform output private_client_ip_addr)
export PRIVATE_SERVER_IP_ADDR=$(terraform output private_server_ip_addr)
export PUBLIC_CLIENT_IP_ADDR=$(terraform output public_client_ip_addr)
export PUBLIC_SERVER_IP_ADDR=$(terraform output public_server_ip_addr)
export PUBLIC_SERVER_IP_ADDR=$(terraform output public_server_ip_addr)

# Get back to the caller directory
cd -
21 changes: 21 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -x

# Enter script-located dir, whaterver the script is called from
cd "$( dirname "${BASH_SOURCE[0]}" )"

# Start AWS infrastructure
../aws-infrastructure/start.sh

# Setup env variables with VMm's ip
source ../aws-infrastructure/set-env.sh

# Pull images and tag them on client VM
scp -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ./upload.py ubuntu@$PUBLIC_CLIENT_IP_ADDR:/home/ubuntu/upload.py
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR <<'ENDSSH'
set -x
/home/ubuntu/upload.py
ENDSSH

# Stop AWS infrastructure
../aws-infrastructure/stop.sh
38 changes: 27 additions & 11 deletions docker/upload.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/python3
import subprocess
import sys
import os
import time
import json

images = ["ubuntu", "graphiteapp/graphite-statsd", "g4s8/artipie-base"]

# Start artipie with preconfigured docker repo
def start_artipie():
Expand Down Expand Up @@ -92,19 +94,33 @@ def perform_benchmarks(images):


# Pull images form docker hub and tag them for subsequent pushes
def pull_and_tag(images):
def pull_and_tag(images, host = "localhost"):
for image in images:
subprocess.run(["docker", "pull", image])
subprocess.run(["docker", "tag", image, f"localhost:5000/{image}"])
subprocess.run(["docker", "tag", image, f"localhost:8080/my-docker/{image}"])

subprocess.run(["docker", "tag", image, f"{host}:5000/{image}"])
subprocess.run(["docker", "tag", image, f"{host}:8080/my-docker/{image}"])

# Entry point
if __name__ == '__main__':
images = ["ubuntu", "graphiteapp/graphite-statsd", "g4s8/artipie-base"]
pull_and_tag(images)
start_registry()
start_artipie()
perform_benchmarks(images)
subprocess.run(["docker", "stop", "registry"])
subprocess.run(["docker", "stop", "artipie"])
arguments = len(sys.argv) - 1
# Run benchmark locally
if arguments == 0:
pull_and_tag(images)
start_registry()
start_artipie()
perform_benchmarks(images)
subprocess.run(["docker", "stop", "registry"])
subprocess.run(["docker", "stop", "artipie"])
# Run only pulling and tagging
elif sys.argv[1] == "pull":
pull_and_tag(images, host = os.getenv("PUBLIC_SERVER_IP_ADDR", "localhost"))
# Start only registry
elif sys.argv[1] == "start_registry":
start_registry()
elif sys.argv[1] == "start_artipie":
start_artipie()
elif sys.argv[1] == "stop_registry":
subprocess.run(["docker", "stop", "registry"])
elif sys.argv[1] == "stop_artipie":
subprocess.run(["docker", "stop", "artipie"])

0 comments on commit 09eedf3

Please sign in to comment.