Commit 58ec49a3 authored by sveneh's avatar sveneh

added EC2 provisioning, optimised docker for EC2, added python and

cppjit client (python not yet working)
parent 52e174b1
venv/
*~
*.swp
*.swo
.vagrant/
client-tests.pem
---
- name: Provision EC2 instances
hosts: local
gather_facts: false
roles:
- ec2
tasks:
- include: roles/ec2/tasks/setup.yml
---
- name: Terminate all ec2 instances
hosts: security_group_client-tests
remote_user: ubuntu # private key defined via ansible.cfg
gather_facts: false
roles:
- ec2
tasks:
- include: roles/ec2/tasks/terminate.yml
# Ansible EC2 external inventory script settings
#
[ec2]
# to talk to a private eucalyptus instance uncomment these lines
# and edit edit eucalyptus_host to be the host name of your cloud controller
#eucalyptus = True
#eucalyptus_host = clc.cloud.domain.org
# AWS regions to make calls to. Set this to 'all' to make request to all regions
# in AWS and merge the results together. Alternatively, set this to a comma
# separated list of regions. E.g. 'us-east-1,us-west-1,us-west-2'
regions = us-east-1
regions_exclude = us-gov-west-1,cn-north-1
# When generating inventory, Ansible needs to know how to address a server.
# Each EC2 instance has a lot of variables associated with it. Here is the list:
# http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance
# Below are 2 variables that are used as the address of a server:
# - destination_variable
# - vpc_destination_variable
# This is the normal destination variable to use. If you are running Ansible
# from outside EC2, then 'public_dns_name' makes the most sense. If you are
# running Ansible from within EC2, then perhaps you want to use the internal
# address, and should set this to 'private_dns_name'.
destination_variable = public_dns_name
# For server inside a VPC, using DNS names may not make sense. When an instance
# has 'subnet_id' set, this variable is used. If the subnet is public, setting
# this to 'ip_address' will return the public IP address. For instances in a
# private subnet, this should be set to 'private_ip_address', and Ansible must
# be run from with EC2.
vpc_destination_variable = ip_address
# To tag instances on EC2 with the resource records that point to them from
# Route53, uncomment and set 'route53' to True.
route53 = False
# To exclude RDS instances from the inventory, uncomment and set to False.
#rds = False
# Additionally, you can specify the list of zones to exclude looking up in
# 'route53_excluded_zones' as a comma-separated list.
# route53_excluded_zones = samplezone1.com, samplezone2.com
# By default, only EC2 instances in the 'running' state are returned. Set
# 'all_instances' to True to return all instances regardless of state.
all_instances = False
# By default, only RDS instances in the 'available' state are returned. Set
# 'all_rds_instances' to True return all RDS instances regardless of state.
all_rds_instances = False
# API calls to EC2 are slow. For this reason, we cache the results of an API
# call. Set this to the path you want cache files to be written to. Two files
# will be written to this directory:
# - ansible-ec2.cache
# - ansible-ec2.index
cache_path = ~/.ansible/tmp
# The number of seconds a cache file is considered valid. After this many
# seconds, a new API call will be made, and the cache file will be updated.
# To disable the cache, set this value to 0
cache_max_age = 300
# Organize groups into a nested/hierarchy instead of a flat namespace.
nested_groups = False
# If you only want to include hosts that match a certain regular expression
# pattern_include = stage-*
# If you want to exclude any hosts that match a certain regular expression
# pattern_exclude = stage-*
# Instance filters can be used to control which instances are retrieved for
# inventory. For the full list of possible filters, please read the EC2 API
# docs: http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeInstances.html#query-DescribeInstances-filters
# Filters are key/value pairs separated by '=', to list multiple filters use
# a list separated by commas. See examples below.
# Retrieve only instances with (key=value) env=stage tag
# instance_filters = tag:env=stage
# Retrieve only instances with role=webservers OR role=dbservers tag
# instance_filters = tag:role=webservers,tag:role=dbservers
# Retrieve only t1.micro instances OR instances with tag env=stage
# instance_filters = instance-type=t1.micro,tag:env=stage
# You can use wildcards in filter values also. Below will list instances which
# tag Name value matches webservers1*
# (ex. webservers15, webservers1a, webservers123 etc)
# instance_filters = tag:Name=webservers1*
This diff is collapsed.
---
- name: Provision the operation system for tests
# testing
hosts: all
# hosts: all
# live
# hosts: TDB
hosts: tag_Name_test_runner
remote_user: ubuntu
roles:
- docker
- common
---
- name: restart sshd
sudo: true
service: name=ssh state=restarted
---
- name: install docker
sudo: true
# install script from https://docs.docker.com/installation/ubuntulinux/
shell: curl -sSL https://get.docker.com/ubuntu/ | sudo sh
- name: install package dependencies
sudo: true
apt: name={{ item }}
with_items:
- python-pip
- parallel
- htop
- name: install python dependencies
sudo: true
pip: name=docker-py
- name: enable docker for standard user
sudo: true
# todo: how to logout after this command, otherwise won't be effective in this play
user: name=vagrant groups=docker append=yes
- name: checkout test repo
git:
repo: https://github.com/sveneh/tests.git
repo: https://github.com/ethereum/tests.git
version: develop
dest: git
---
- name: restart sshd
sudo: true
service: name=ssh state=restarted
---
- name: update package list
sudo: true
apt: update_cache=true
- name: install docker dependencies
sudo: true
apt: name={{ item }} install_recommends=false
with_items:
# Docker has serious problems on EC2: http://www.danstutzman.com/2014/07/speed-up-docker-on-ec2
# and https://github.com/docker/docker/issues/4036
- linux-generic
- python-pip
- name: Kernel update needs a restart
sudo: true
command: shutdown -r now
async: 0
poll: 0
ignore_errors: true
- name: waiting for server to come back
local_action: wait_for host={{ inventory_hostname }} port=22
state=started
sudo: false
- name: install docker
sudo: true
# install script from https://docs.docker.com/installation/ubuntulinux/
# TODO this is not idempotent
shell: curl -sSL https://get.docker.com/ubuntu/ | sudo sh
- name: install docker python API
sudo: true
pip: name=docker-py
- name: enable docker for standard user
sudo: true
user: name={{ ansible_ssh_user }} groups=docker append=yes
notify: restart sshd
---
- name: create default security group
ec2_group:
name: "{{ security_group }}"
region: "{{ region }}"
description: "{{ project_description }}"
rules:
# ssh
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: "{{ ip_access_range }}"
rules_egress:
- proto: all
cidr_ip: "{{ ip_access_range }}"
- name: start ec2 instances
ec2:
group: "{{ security_group }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
wait: true
region: "{{ region }}"
key_name: "{{ keypair }}"
instance_tags:
Name: test_runner
count_tag:
Name: test_runner
exact_count: "{{ total_no_instances }}"
# volumes:
# - device_name: /dev/xvda
# volume_size: "{{ volume_size_gb }}"
---
- name: Terminate ec2 instances
local_action: ec2
state=absent
instance_ids={{ ec2_id }}
region={{ region }}
wait=true
---
# default config for ec2 instances
instance_type: c4.xlarge
security_group: client-tests
# image: ami-d6e7c084
image: ami-9eaa1cf6
# region: ap-southeast-1
region: us-east-1
keypair: christoph
# keypair: client-tests
volume_size_gb: 50
# limit access to AWS to these clients in CDIR notation
ip_access_range: 0.0.0.0/0
project_description: https://github.com/ethereum/tests
total_no_instances: 1
---
- name: update C++ client
sudo: true
docker_image:
path: git/ansible/test-files/docker-cpp
name: cpp
path: /home/{{ ansible_ssh_user }}/git/ansible/test-files/docker-cppjit
name: cppjit
state: build
# command: docker build -t cpp /home/{{ ansible_ssh_user }}/git/ansible/test-files/docker-cpp
async: 3600
poll: 5
- name: update Go client
sudo: true
docker_image:
path: git/ansible/test-files/docker-go
path: /home/{{ ansible_ssh_user }}/git/ansible/test-files/docker-go
name: go
state: build
# command: docker build -t go /home/{{ ansible_ssh_user }}/git/ansible/test-files/docker-go
async: 3600
poll: 5
- name: Run infinite tests (press ^C to stop)
sudo: true
shell: git/ansible/test-files/testrunner.sh
- name: update Python client
docker_image:
path: /home/{{ ansible_ssh_user }}/git/ansible/test-files/docker-python
name: python
state: build
async: 3600
poll: 5
- name: Run infinite tests
shell: seq {{ ansible_processor_vcpus }} | parallel --max-args=0 /home/{{ ansible_ssh_user }}/git/ansible/test-files/testrunner.sh
async: "{{ 3600 * 2 }}"
poll: 0
register: log_runner
- name: verify previous task
async_status: jid={{ log_runner.ansible_job_id }}
# adjusted from https://github.com/ethereum/cpp-ethereum/blob/develop/docker/Dockerfile
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get upgrade -y
# Ethereum dependencies
RUN apt-get install -qy build-essential g++-4.8 git cmake libboost-all-dev libcurl4-openssl-dev wget
RUN apt-get install -qy automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons
RUN apt-get install -qy libjsoncpp-dev libargtable2-dev
# NCurses based GUI (not optional though for a succesful compilation, see https://github.com/ethereum/cpp-ethereum/issues/452 )
RUN apt-get install -qy libncurses5-dev
# Qt-based GUI
# RUN apt-get install -qy qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev
RUN sudo apt-get -y install software-properties-common
# LLVM-3.5
RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
RUN echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main\ndeb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main" > /etc/apt/sources.list.d/llvm-trusty.list
RUN apt-get update
RUN apt-get install -qy llvm-3.5 libedit-dev
# Fix llvm-3.5 cmake paths
RUN mkdir -p /usr/lib/llvm-3.5/share/llvm && ln -s /usr/share/llvm-3.5/cmake /usr/lib/llvm-3.5/share/llvm/cmake
# Ethereum PPA
RUN apt-get install -qy software-properties-common
RUN add-apt-repository ppa:ethereum/ethereum
RUN apt-get update
RUN apt-get install -qy libcryptopp-dev libjson-rpc-cpp-dev
# Build Ethereum (HEADLESS)
RUN git clone --depth=1 --branch develop https://github.com/ethereum/cpp-ethereum
RUN mkdir -p cpp-ethereum/build
RUN cd cpp-ethereum/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DHEADLESS=1 -DEVMJIT=1 && make -j $(cat /proc/cpuinfo | grep processor | wc -l) && make install
RUN ldconfig
ENTRYPOINT ["/cpp-ethereum/build/test/checkRandomTest"]
FROM sveneh/pyethereum-base
RUN git clone --branch master https://github.com/ethereum/pyethereum.git
RUN cd pyethereum && curl https://bootstrap.pypa.io/bootstrap-buildout.py | python
RUN cd pyethereum && bin/buildout
#default port for incoming requests
EXPOSE 30303
WORKDIR /pyethereum/bin
ENTRYPOINT ["./python", "../tests/test_vm.py"]
......@@ -4,11 +4,10 @@
#cd ~/software/Ethereum/pyethereum (python has local dependencies so only works from within the directory)
while [ 1 ]
do
TEST="$(docker run --rm cpp)"
TEST="$(docker run --rm --entrypoint="/cpp-ethereum/build/test/createRandomTest" cppjit)"
# echo "$TEST"
# test pyethereum
#OUTPUT_PYTHON="$(python ./tests/test_vm.py "$TEST")"
#RESULT_PYTHON=$?
......@@ -17,11 +16,11 @@ do
RESULT_GO=$?
# test cpp-jit
#OUTPUT_CPPJIT="$(~/software/Ethereum/cpp-ethereum/build/test/checkRandomTest "$TEST")"
#RESULT_CPPJIT=$?
OUTPUT_CPPJIT="$(docker run --rm cppjit "$TEST")"
RESULT_CPPJIT=$?
# go fails
if [ "$RESULT_GO" -ne 0 ]; then
# go fails
if [ "$RESULT_GO" -ne 0 ]; then
echo Failed:
echo Output_GO:
echo $OUTPUT_GO
......@@ -29,28 +28,29 @@ if [ "$RESULT_GO" -ne 0 ]; then
echo "$TEST"
echo "$TEST" > FailedTest.json
mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")GO.json # replace with scp to central server
fi
# python fails
#if [ "$RESULT_PYTHON" -ne 0 ]; then
# echo Failed:
# echo Output_PYTHON:
# echo $OUTPUT_PYTHON
# echo Test:
# echo "$TEST"
# echo "$TEST" > FailedTest.json
# mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")PYTHON.json
#fi
# cppjit fails
#if [ "$RESULT_CPPJIT" -ne 0 ]; then
# echo Failed:
# echo Output_CPPJIT:
# echo $OUTPUT_CPPJIT
# echo Test:
# echo "$TEST"
# echo "$TEST" > FailedTest.json
# mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")CPPJIT.json
#fi
fi
# python fails
#if [ "$RESULT_PYTHON" -ne 0 ]; then
# echo Failed:
# echo Output_PYTHON:
# echo $OUTPUT_PYTHON
# echo Test:
# echo "$TEST"
# echo "$TEST" > FailedTest.json
# mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")PYTHON.json
#fi
# cppjit fails
if [ "$RESULT_CPPJIT" -ne 0 ]; then
echo Failed:
echo Output_CPPJIT:
echo $OUTPUT_CPPJIT
echo Test:
echo "$TEST"
echo "$TEST" > FailedTest.json
mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")CPPJIT.json
fi
exit
done
---
- name: preparing and running tests
# testing
hosts: all
# hosts: all
# live
# hosts: TBD
hosts: tag_Name_test_runner
# TODO use the right user for configuring, until credentials set, stay with default vagrant user
# remote_user: ubuntu
remote_user: ubuntu
roles:
- testrunner
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment