Skip to content

Commit

Permalink
artipie#18 - make docker benchmark reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Aug 10, 2020
1 parent 00daced commit 2e171ae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
7 changes: 6 additions & 1 deletion aws-infrastructure/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ terraform apply -input=false -auto-approve
source set-env.sh

# Prepare env file for aws instances
rm -f instance-env.sh
cat <<EOT >> instance-env.sh
export PRIVATE_CLIENT_IP_ADDR=$PRIVATE_CLIENT_IP_ADDR
export PRIVATE_SERVER_IP_ADDR=$PRIVATE_SERVER_IP_ADDR
Expand All @@ -35,10 +36,11 @@ done
# Install required software on each VM
for IP in $PUBLIC_SERVER_IP_ADDR $PUBLIC_CLIENT_IP_ADDR
do
scp -i aws_ssh_key -oStrictHostKeyChecking=no ./instance-env.sh ubuntu@$PUBLIC_CLIENT_IP_ADDR:/home/ubuntu
scp -i aws_ssh_key -oStrictHostKeyChecking=no ./instance-env.sh ubuntu@$IP:/home/ubuntu
ssh -i aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$IP <<'ENDSSH'
set -x
echo "source /home/ubuntu/instance-env.sh" >> /home/ubuntu/.bashrc
source /home/ubuntu/instance-env.sh
sudo apt-get update
sudo apt-get install -y \
python3 \
Expand All @@ -58,6 +60,9 @@ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
echo "{\"insecure-registries\" : [\"$PUBLIC_SERVER_IP_ADDR:5000\",\"$PUBLIC_SERVER_IP_ADDR:8080\"]}" > daemon.json
sudo mv daemon.json /etc/docker/daemon.json
sudo service docker restart
docker run hello-world
ENDSSH
done
14 changes: 7 additions & 7 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ scp -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ./upload.py
scp -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ./upload.py ubuntu@$PUBLIC_SERVER_IP_ADDR:/home/ubuntu/upload.py

# Pull images and tag them on client VM
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR bash -c "/home/ubuntu/upload.py pull"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py pull"

# Benchmark artipie
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR bash -c "/home/ubuntu/upload.py start_artipie"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR bash -c "/home/ubuntu/upload.py benchmark_artipie"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR bash -c "/home/ubuntu/upload.py stop_artipie"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py start_artipie"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py benchmark_artipie"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py stop_artipie"

# Benchmark registry
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR bash -c "/home/ubuntu/upload.py start_registry"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR bash -c "/home/ubuntu/upload.py benchmark_registry"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR bash -c "/home/ubuntu/upload.py stop_registry"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py start_registry"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_CLIENT_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py benchmark_registry"
ssh -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR "source instance-env.sh; /home/ubuntu/upload.py stop_registry"

# Download results
scp -i ../aws-infrastructure/aws_ssh_key -oStrictHostKeyChecking=no ubuntu@$PUBLIC_SERVER_IP_ADDR:/home/ubuntu/*.json ./
Expand Down
7 changes: 4 additions & 3 deletions docker/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def run(args):
:return: nothing
"""
command = " ".join(args)
print(f"+ {command}")
print(f"Py3: {command}")
subprocess.run(args, check=True)


Expand Down Expand Up @@ -80,6 +80,7 @@ def measure(func):
tock = time.time()
return tock - tick


def pull_and_tag(images, host="localhost"):
"""
Pull images form docker hub and tag them for subsequent pushes
Expand All @@ -94,12 +95,12 @@ def pull_and_tag(images, host="localhost"):


def benchmark_artipie():
host = os.getenv("PUBLIC_SERVER_IP_ADDR", "localhost")
host = os.getenv("PUBLIC_SERVER_IP_ADDR")
upload_benchmark(images, f"{host}:8080/my-docker", "artipie")


def benchmark_registry():
host = os.getenv("PUBLIC_SERVER_IP_ADDR", "localhost")
host = os.getenv("PUBLIC_SERVER_IP_ADDR")
upload_benchmark(images, f"{host}:5000", "docker-registry")


Expand Down

0 comments on commit 2e171ae

Please sign in to comment.